Some corrections.
1.1 --- a/lemon/mip_glpk.cc Fri Sep 08 08:55:07 2006 +0000
1.2 +++ b/lemon/mip_glpk.cc Fri Sep 08 15:51:32 2006 +0000
1.3 @@ -57,40 +57,50 @@
1.4
1.5 LpGlpk::SolveExitStatus MipGlpk::_solve(){
1.6 int result = lpx_simplex(lp);
1.7 - result = lpx_integer(lp);
1.8 - switch (result){
1.9 - case LPX_E_OBJLL:
1.10 - case LPX_E_OBJUL:
1.11 - case LPX_E_ITLIM:
1.12 - case LPX_E_TMLIM:
1.13 + //
1.14 + if (lpx_get_status(lp)==LPX_OPT){
1.15 + //Maybe we could try the routine lpx_intopt(lp), a revised
1.16 + //version of lpx_integer
1.17 + result = lpx_integer(lp);
1.18 + switch (result){
1.19 case LPX_E_OK:
1.20 - return SOLVED;
1.21 + return SOLVED;
1.22 default:
1.23 - return UNSOLVED;
1.24 + return UNSOLVED;
1.25 + }
1.26 +
1.27 }
1.28 + return UNSOLVED;
1.29 }
1.30
1.31
1.32 LpGlpk::SolutionStatus MipGlpk::_getMipStatus(){
1.33
1.34 - //Meg kell nezni: ha az LP is infinite, akkor ez is, ha az is
1.35 - //infeasible, akkor ez is, de ez lehet maskepp is infeasible.
1.36 - int stat= lpx_mip_status(lp);
1.37 - switch (stat) {
1.38 - case LPX_I_UNDEF://Undefined (no solve has been run yet)
1.39 - return UNDEFINED;
1.40 - case LPX_I_NOFEAS://There is no feasible integral solution (primal, I guess)
1.41 - return INFEASIBLE;
1.42 -// case LPX_UNBND://Unbounded
1.43 -// return INFINITE;
1.44 - case LPX_I_FEAS://Feasible
1.45 - return FEASIBLE;
1.46 - case LPX_I_OPT://Feasible
1.47 - return OPTIMAL;
1.48 - default:
1.49 + if (lpx_get_status(lp)==LPX_OPT){
1.50 + //Meg kell nezni: ha az LP is infinite, akkor ez is, ha az is
1.51 + //infeasible, akkor ez is, de ez lehet maskepp is infeasible.
1.52 + int stat= lpx_mip_status(lp);
1.53 +
1.54 + switch (stat) {
1.55 + case LPX_I_UNDEF://Undefined (no solve has been run yet)
1.56 + return UNDEFINED;
1.57 + case LPX_I_NOFEAS://There is no feasible integral solution
1.58 + return INFEASIBLE;
1.59 + // case LPX_UNBND://Unbounded
1.60 + // return INFINITE;
1.61 + case LPX_I_FEAS://Feasible
1.62 + return FEASIBLE;
1.63 + case LPX_I_OPT://Feasible
1.64 + return OPTIMAL;
1.65 + default:
1.66 return UNDEFINED; //to avoid gcc warning
1.67 //FIXME error
1.68 + }
1.69 }
1.70 + else
1.71 + return UNDEFINED; //Maybe we could refine this: what does the LP
1.72 + //relaxation look like
1.73 +
1.74 }
1.75
1.76 MipGlpk::Value MipGlpk::_getPrimal(int i){
2.1 --- a/test/mip_test.cc Fri Sep 08 08:55:07 2006 +0000
2.2 +++ b/test/mip_test.cc Fri Sep 08 15:51:32 2006 +0000
2.3 @@ -12,7 +12,7 @@
2.4 buf << "Primalstatus should be: " << int(stat)<<" and it is "<<int(lp.primalStatus());
2.5
2.6 // itoa(stat,buf1, 10);
2.7 - check(lp.primalStatus()==stat, buf.str());
2.8 + check(lp.mipStatus()==stat, buf.str());
2.9
2.10 if (stat == LpSolverBase::OPTIMAL) {
2.11 std::ostringstream buf;
2.12 @@ -35,6 +35,19 @@
2.13
2.14
2.15
2.16 +
2.17 +
2.18 +
2.19 + //Objective function
2.20 + mip.setObj(x1);
2.21 +
2.22 + mip.max();
2.23 +
2.24 +
2.25 + //Unconstrained optimization
2.26 + mip.solve();
2.27 + //Check it out!
2.28 +
2.29 //Constraints
2.30 mip.addRow(2*x1+x2 <=2);
2.31 mip.addRow(x1-2*x2 <=0);
2.32 @@ -44,14 +57,8 @@
2.33
2.34
2.35
2.36 - //Objective function
2.37 - mip.setObj(x1);
2.38 -
2.39 - mip.max();
2.40 -
2.41 -
2.42 //Maximization of x1
2.43 - //over the triangle with vertices
2.44 + //over the triangle with vertices
2.45 double expected_opt=4.0/5.0;
2.46 solveAndCheck(mip, Mip::OPTIMAL, expected_opt);
2.47