Changeset 2213:2c094dfa176d in lemon-0.x
- Timestamp:
- 09/08/06 17:51:32 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2941
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/mip_glpk.cc
r2185 r2213 58 58 LpGlpk::SolveExitStatus MipGlpk::_solve(){ 59 59 int result = lpx_simplex(lp); 60 result = lpx_integer(lp);61 switch (result){62 case LPX_E_OBJLL:63 case LPX_E_OBJUL:64 case LPX_E_ITLIM:65 case LPX_E_TMLIM:60 // 61 if (lpx_get_status(lp)==LPX_OPT){ 62 //Maybe we could try the routine lpx_intopt(lp), a revised 63 //version of lpx_integer 64 result = lpx_integer(lp); 65 switch (result){ 66 66 case LPX_E_OK: 67 67 return SOLVED; 68 68 default: 69 return UNSOLVED; 69 return UNSOLVED; 70 } 71 70 72 } 73 return UNSOLVED; 71 74 } 72 75 … … 74 77 LpGlpk::SolutionStatus MipGlpk::_getMipStatus(){ 75 78 76 //Meg kell nezni: ha az LP is infinite, akkor ez is, ha az is 77 //infeasible, akkor ez is, de ez lehet maskepp is infeasible. 78 int stat= lpx_mip_status(lp); 79 switch (stat) { 80 case LPX_I_UNDEF://Undefined (no solve has been run yet) 81 return UNDEFINED; 82 case LPX_I_NOFEAS://There is no feasible integral solution (primal, I guess) 83 return INFEASIBLE; 84 // case LPX_UNBND://Unbounded 85 // return INFINITE; 86 case LPX_I_FEAS://Feasible 87 return FEASIBLE; 88 case LPX_I_OPT://Feasible 89 return OPTIMAL; 90 default: 79 if (lpx_get_status(lp)==LPX_OPT){ 80 //Meg kell nezni: ha az LP is infinite, akkor ez is, ha az is 81 //infeasible, akkor ez is, de ez lehet maskepp is infeasible. 82 int stat= lpx_mip_status(lp); 83 84 switch (stat) { 85 case LPX_I_UNDEF://Undefined (no solve has been run yet) 86 return UNDEFINED; 87 case LPX_I_NOFEAS://There is no feasible integral solution 88 return INFEASIBLE; 89 // case LPX_UNBND://Unbounded 90 // return INFINITE; 91 case LPX_I_FEAS://Feasible 92 return FEASIBLE; 93 case LPX_I_OPT://Feasible 94 return OPTIMAL; 95 default: 91 96 return UNDEFINED; //to avoid gcc warning 92 97 //FIXME error 98 } 93 99 } 100 else 101 return UNDEFINED; //Maybe we could refine this: what does the LP 102 //relaxation look like 103 94 104 } 95 105 -
test/mip_test.cc
r2149 r2213 13 13 14 14 // itoa(stat,buf1, 10); 15 check(lp. primalStatus()==stat, buf.str());15 check(lp.mipStatus()==stat, buf.str()); 16 16 17 17 if (stat == LpSolverBase::OPTIMAL) { … … 36 36 37 37 38 39 40 41 //Objective function 42 mip.setObj(x1); 43 44 mip.max(); 45 46 47 //Unconstrained optimization 48 mip.solve(); 49 //Check it out! 50 38 51 //Constraints 39 52 mip.addRow(2*x1+x2 <=2); … … 45 58 46 59 47 //Objective function48 mip.setObj(x1);49 50 mip.max();51 52 53 60 //Maximization of x1 54 //over the triangle with vertices 61 //over the triangle with vertices 55 62 double expected_opt=4.0/5.0; 56 63 solveAndCheck(mip, Mip::OPTIMAL, expected_opt);
Note: See TracChangeset
for help on using the changeset viewer.