COIN-OR::LEMON - Graph Library

Changeset 2213:2c094dfa176d in lemon-0.x


Ignore:
Timestamp:
09/08/06 17:51:32 (18 years ago)
Author:
athos
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2941
Message:

Some corrections.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lemon/mip_glpk.cc

    r2185 r2213  
    5858  LpGlpk::SolveExitStatus MipGlpk::_solve(){
    5959    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){
    6666      case LPX_E_OK:
    67         return SOLVED;
     67        return SOLVED;
    6868      default:
    69         return UNSOLVED;
     69        return UNSOLVED;
     70      }
     71     
    7072    }
     73    return UNSOLVED;
    7174  }
    7275
     
    7477  LpGlpk::SolutionStatus MipGlpk::_getMipStatus(){
    7578
    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:
    9196      return UNDEFINED; //to avoid gcc warning
    9297      //FIXME error
     98      }
    9399    }
     100    else
     101      return UNDEFINED; //Maybe we could refine this: what does the LP
     102                        //relaxation look like
     103     
    94104  } 
    95105
  • test/mip_test.cc

    r2149 r2213  
    1313
    1414  //  itoa(stat,buf1, 10);
    15   check(lp.primalStatus()==stat, buf.str());
     15  check(lp.mipStatus()==stat, buf.str());
    1616
    1717  if (stat ==  LpSolverBase::OPTIMAL) {
     
    3636
    3737
     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
    3851  //Constraints
    3952  mip.addRow(2*x1+x2 <=2); 
     
    4558
    4659
    47   //Objective function
    48   mip.setObj(x1);
    49 
    50   mip.max();
    51 
    52 
    5360  //Maximization of x1
    54   //over the triangle with vertices
     61  //over the triangle with vertices 
    5562  double expected_opt=4.0/5.0;
    5663  solveAndCheck(mip, Mip::OPTIMAL, expected_opt);
Note: See TracChangeset for help on using the changeset viewer.