# HG changeset patch # User athos # Date 1157730692 0 # Node ID 2c094dfa176d2297b9aca14fdc375e0a092ff7f8 # Parent 0ad3835449f823fadfa32a469271a857e2f7d38c Some corrections. diff -r 0ad3835449f8 -r 2c094dfa176d lemon/mip_glpk.cc --- a/lemon/mip_glpk.cc Fri Sep 08 08:55:07 2006 +0000 +++ b/lemon/mip_glpk.cc Fri Sep 08 15:51:32 2006 +0000 @@ -57,40 +57,50 @@ LpGlpk::SolveExitStatus MipGlpk::_solve(){ int result = lpx_simplex(lp); - result = lpx_integer(lp); - switch (result){ - case LPX_E_OBJLL: - case LPX_E_OBJUL: - case LPX_E_ITLIM: - case LPX_E_TMLIM: + // + if (lpx_get_status(lp)==LPX_OPT){ + //Maybe we could try the routine lpx_intopt(lp), a revised + //version of lpx_integer + result = lpx_integer(lp); + switch (result){ case LPX_E_OK: - return SOLVED; + return SOLVED; default: - return UNSOLVED; + return UNSOLVED; + } + } + return UNSOLVED; } LpGlpk::SolutionStatus MipGlpk::_getMipStatus(){ - //Meg kell nezni: ha az LP is infinite, akkor ez is, ha az is - //infeasible, akkor ez is, de ez lehet maskepp is infeasible. - int stat= lpx_mip_status(lp); - switch (stat) { - case LPX_I_UNDEF://Undefined (no solve has been run yet) - return UNDEFINED; - case LPX_I_NOFEAS://There is no feasible integral solution (primal, I guess) - return INFEASIBLE; -// case LPX_UNBND://Unbounded -// return INFINITE; - case LPX_I_FEAS://Feasible - return FEASIBLE; - case LPX_I_OPT://Feasible - return OPTIMAL; - default: + if (lpx_get_status(lp)==LPX_OPT){ + //Meg kell nezni: ha az LP is infinite, akkor ez is, ha az is + //infeasible, akkor ez is, de ez lehet maskepp is infeasible. + int stat= lpx_mip_status(lp); + + switch (stat) { + case LPX_I_UNDEF://Undefined (no solve has been run yet) + return UNDEFINED; + case LPX_I_NOFEAS://There is no feasible integral solution + return INFEASIBLE; + // case LPX_UNBND://Unbounded + // return INFINITE; + case LPX_I_FEAS://Feasible + return FEASIBLE; + case LPX_I_OPT://Feasible + return OPTIMAL; + default: return UNDEFINED; //to avoid gcc warning //FIXME error + } } + else + return UNDEFINED; //Maybe we could refine this: what does the LP + //relaxation look like + } MipGlpk::Value MipGlpk::_getPrimal(int i){ diff -r 0ad3835449f8 -r 2c094dfa176d test/mip_test.cc --- a/test/mip_test.cc Fri Sep 08 08:55:07 2006 +0000 +++ b/test/mip_test.cc Fri Sep 08 15:51:32 2006 +0000 @@ -12,7 +12,7 @@ buf << "Primalstatus should be: " << int(stat)<<" and it is "<