COIN-OR::LEMON - Graph Library

Changeset 1458:7a483c1d38b5 in lemon-0.x


Ignore:
Timestamp:
06/09/05 11:49:48 (20 years ago)
Author:
athos
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1938
Message:

Not ready, but I commit it for simplicity.

Location:
lemon
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lemon/lp_base.h

    r1445 r1458  
    109109  public:
    110110
    111     ///\e
     111    ///Possible outcomes of an LP solving procedure
    112112    enum SolveExitStatus {
    113       ///\e
     113      ///This means that the problem has been successfully solved: either
     114      ///an optimal solution has been found or infeasibility/unboundedness
     115      ///has been proved.
    114116      SOLVED = 0,
    115       ///\e
     117      ///Any other case (including the case when some user specified limit has been exceeded)
    116118      UNSOLVED = 1
    117119    };
     
    916918    ///@{
    917919
    918     ///\e
     920    ///\e Solve the LP problem at hand
     921    ///
     922    ///\return The result of the optimization procedure. Possible values and their meanings can be found in the documentation of \ref SolveExitStatus.
     923    ///
     924    ///\todo Which method is used to solve the problem
    919925    SolveExitStatus solve() { return _solve(); }
    920926   
     
    925931    ///@{
    926932
    927     ///\e
     933    ///\e 
    928934    SolutionStatus primalStatus() {
    929935      return _getPrimalStatus();
  • lemon/lp_cplex.cc

    r1436 r1458  
    2626    env = CPXopenCPLEX(&status);     
    2727    lp = CPXcreateprob(env, &status, "LP problem");
    28     //CPXmsg (cpxresults, "Hello-bello\n");
    2928  }
    3029 
     
    231230   
    232231  }
    233 
     232  // The routine returns zero unless an error occurred during the
     233  // optimization. Examples of errors include exhausting available
     234  // memory (CPXERR_NO_MEMORY) or encountering invalid data in the
     235  // CPLEX problem object (CPXERR_NO_PROBLEM). Exceeding a
     236  // user-specified CPLEX limit, or proving the model infeasible or
     237  // unbounded, are not considered errors. Note that a zero return
     238  // value does not necessarily mean that a solution exists. Use query
     239  // routines CPXsolninfo, CPXgetstat, and CPXsolution to obtain
     240  // further information about the status of the optimization.
    234241  LpCplex::SolveExitStatus LpCplex::_solve()
    235242  {
    236    
     243    //CPX_PARAM_LPMETHOD
    237244    status = CPXlpopt (env, lp);
    238245    if (status == 0){
    239       return SOLVED;
     246      //We want to exclude some cases
     247      switch (CPXgetstat (env, lp)){
     248      case CPX_OBJ_LIM:
     249      case CPX_IT_LIM_FEAS:
     250      case CPX_IT_LIM_INFEAS:               
     251      case CPX_TIME_LIM_FEAS:
     252      case CPX_TIME_LIM_INFEAS:
     253        return UNSOLVED;
     254      default:
     255        return SOLVED;
     256      }
    240257    }
    241258    else{
    242259      return UNSOLVED;
    243260    }
    244 //     int i=  lpx_simplex(lp);
    245 //     switch (i) {
    246 //     case LPX_E_OK:
    247 //       return SOLVED;
    248 //       break;
    249 //     default:
    250 //       return UNSOLVED;
    251 //     }
    252   }
    253 
    254   LpCplex::SolutionStatus LpCplex::_getPrimalStatus()
    255   {
    256 //7.5-os cplex statusai
    257 // #define CPX_OPTIMAL                      1
    258 // #define CPX_INFEASIBLE                   2
    259 // #define CPX_UNBOUNDED                    3
    260 // #define CPX_OBJ_LIM                      4
    261 // #define CPX_IT_LIM_FEAS                  5
    262 // #define CPX_IT_LIM_INFEAS                6
    263 // #define CPX_TIME_LIM_FEAS                7
    264 // #define CPX_TIME_LIM_INFEAS              8
    265 // #define CPX_NUM_BEST_FEAS                9
    266 // #define CPX_NUM_BEST_INFEAS             10
    267 // #define CPX_OPTIMAL_INFEAS              11
    268 // #define CPX_ABORT_FEAS                  12
    269 // #define CPX_ABORT_INFEAS                13
    270 // #define CPX_ABORT_DUAL_INFEAS           14
    271 // #define CPX_ABORT_PRIM_INFEAS           15
    272 // #define CPX_ABORT_PRIM_DUAL_INFEAS      16
    273 // #define CPX_ABORT_PRIM_DUAL_FEAS        17
    274 // #define CPX_ABORT_CROSSOVER             18
    275 // #define CPX_INForUNBD                   19
    276 // #define CPX_PIVOT                       20
    277 
     261  }
     262
     263
     264//7.5-os cplex statusai (Vigyazat: a 9.0-asei masok!)
     265// This table lists the statuses, returned by the CPXgetstat() routine, for solutions to LP problems or mixed integer problems. If no solution exists, the return value is zero.
     266
     267// For Simplex, Barrier 
     268// 1    CPX_OPTIMAL 
     269//       Optimal solution found 
     270// 2    CPX_INFEASIBLE 
     271//       Problem infeasible 
     272// 3    CPX_UNBOUNDED 
     273//       Problem unbounded 
     274// 4    CPX_OBJ_LIM 
     275//       Objective limit exceeded in Phase II 
     276// 5    CPX_IT_LIM_FEAS 
     277//       Iteration limit exceeded in Phase II 
     278// 6    CPX_IT_LIM_INFEAS 
     279//       Iteration limit exceeded in Phase I 
     280// 7    CPX_TIME_LIM_FEAS 
     281//       Time limit exceeded in Phase II 
     282// 8    CPX_TIME_LIM_INFEAS 
     283//       Time limit exceeded in Phase I 
     284// 9    CPX_NUM_BEST_FEAS 
     285//       Problem non-optimal, singularities in Phase II 
     286// 10   CPX_NUM_BEST_INFEAS 
     287//       Problem non-optimal, singularities in Phase I 
     288// 11   CPX_OPTIMAL_INFEAS 
     289//       Optimal solution found, unscaled infeasibilities 
     290// 12   CPX_ABORT_FEAS 
     291//       Aborted in Phase II 
     292// 13   CPX_ABORT_INFEAS 
     293//       Aborted in Phase I 
     294// 14   CPX_ABORT_DUAL_INFEAS 
     295//       Aborted in barrier, dual infeasible 
     296// 15   CPX_ABORT_PRIM_INFEAS 
     297//       Aborted in barrier, primal infeasible 
     298// 16   CPX_ABORT_PRIM_DUAL_INFEAS 
     299//       Aborted in barrier, primal and dual infeasible 
     300// 17   CPX_ABORT_PRIM_DUAL_FEAS 
     301//       Aborted in barrier, primal and dual feasible 
     302// 18   CPX_ABORT_CROSSOVER 
     303//       Aborted in crossover 
     304// 19   CPX_INForUNBD 
     305//       Infeasible or unbounded 
     306// 20   CPX_PIVOT
     307//       User pivot used
     308//
    278309//     Ezeket hova tegyem:
    279310// ??case CPX_ABORT_DUAL_INFEAS           
     
    282313// ??case CPX_PIVOT                       
    283314
     315  LpCplex::SolutionStatus LpCplex::_getPrimalStatus()
     316  {
    284317    int stat = CPXgetstat (env, lp);
    285318    switch (stat) {
    286319    case 0:
    287320      return UNDEFINED; //Undefined
    288       break;     
    289321    case CPX_OPTIMAL://Optimal
    290322      return OPTIMAL;
    291       break;
    292323    case CPX_UNBOUNDED://Unbounded
    293324      return INFINITE;
    294       break;
    295325    case CPX_INFEASIBLE://Infeasible
    296     case CPX_IT_LIM_INFEAS:
    297     case CPX_TIME_LIM_INFEAS:
    298     case CPX_NUM_BEST_INFEAS:             
    299     case CPX_OPTIMAL_INFEAS:             
    300     case CPX_ABORT_INFEAS:               
    301     case CPX_ABORT_PRIM_INFEAS:           
    302     case CPX_ABORT_PRIM_DUAL_INFEAS:     
     326 //    case CPX_IT_LIM_INFEAS:
     327//     case CPX_TIME_LIM_INFEAS:
     328//     case CPX_NUM_BEST_INFEAS:             
     329//     case CPX_OPTIMAL_INFEAS:             
     330//     case CPX_ABORT_INFEAS:               
     331//     case CPX_ABORT_PRIM_INFEAS:           
     332//     case CPX_ABORT_PRIM_DUAL_INFEAS:     
    303333      return INFEASIBLE;
    304       break;
    305     case CPX_OBJ_LIM:                   
    306     case CPX_IT_LIM_FEAS:             
    307     case CPX_TIME_LIM_FEAS:               
    308     case CPX_NUM_BEST_FEAS:               
    309     case CPX_ABORT_FEAS:                 
    310     case CPX_ABORT_PRIM_DUAL_FEAS:       
    311       return FEASIBLE;
    312       break;
     334//     case CPX_OBJ_LIM:                   
     335//     case CPX_IT_LIM_FEAS:             
     336//     case CPX_TIME_LIM_FEAS:               
     337//     case CPX_NUM_BEST_FEAS:               
     338//     case CPX_ABORT_FEAS:                 
     339//     case CPX_ABORT_PRIM_DUAL_FEAS:       
     340//       return FEASIBLE;
    313341    default:
    314342      return UNDEFINED; //Everything else comes here
     
    316344    }
    317345
    318 
    319     //Nem tudom, hanyas cplex verzio statusai
     346  }
     347
     348//9.0-as cplex verzio statusai
    320349// CPX_STAT_ABORT_DUAL_OBJ_LIM
    321350// CPX_STAT_ABORT_IT_LIM
     
    334363// CPX_STAT_UNBOUNDED
    335364
    336 //     int stat = CPXgetstat (env, lp);
    337 //     switch (stat) {
    338 //     case CPX_STAT_OPTIMAL://Optimal
    339 //       return OPTIMAL;
    340 //       break;
    341 //     case CPX_STAT_INFEASIBLE://Infeasible
    342 //       return INFEASIBLE;
    343 //       break;
    344 //     case CPX_STAT_UNBOUNDED://Unbounded
    345 //       return INFINITE;
    346 //       break;
    347 //     case CPX_STAT_NUM_BEST://Feasible
    348 //       return FEASIBLE;
    349 //       break;
    350 //     default:
    351 //       return UNDEFINED; //Everything else comes here
    352 //       //FIXME error
    353 //     }
    354 
    355   }
     365  LpCplex::SolutionStatus LpCplex::_getDualStatus()
     366  {
     367    int stat = CPXgetstat (env, lp);
     368    switch (stat) {
     369    case 0:
     370      return UNDEFINED; //Undefined
     371    case CPX_OPTIMAL://Optimal
     372      return OPTIMAL;
     373    case CPX_UNBOUNDED:
     374     return INFEASIBLE;
     375    default:
     376      return UNDEFINED; //Everything else comes here
     377      //FIXME error
     378    }
    356379
    357380  LpCplex::Value LpCplex::_getPrimal(int i)
  • lemon/lp_glpk.cc

    r1436 r1458  
    397397  LpGlpk::SolveExitStatus LpGlpk::_solve()
    398398  {
    399     int i=  lpx_simplex(lp);
     399    int i =  lpx_simplex(lp);
    400400    switch (i) {
    401401    case LPX_E_OK:
    402402      return SOLVED;
    403       break;
    404403    default:
    405404      return UNSOLVED;
     
    421420  {
    422421    int stat=  lpx_get_status(lp);
     422    switch (stat) {
     423    case LPX_UNDEF://Undefined (no solve has been run yet)
     424      return UNDEFINED;
     425    case LPX_NOFEAS://There is no feasible solution (primal, I guess)
     426    case LPX_INFEAS://Infeasible
     427      return INFEASIBLE;
     428    case LPX_UNBND://Unbounded
     429      return INFINITE;
     430    case LPX_FEAS://Feasible
     431      return FEASIBLE;
     432    case LPX_OPT://Feasible
     433      return OPTIMAL;
     434    default:
     435      return UNDEFINED; //to avoid gcc warning
     436      //FIXME error
     437    }
     438  }
     439
     440  LpGlpk::SolutionStatus LpGlpk::_getDualStatus()
     441  {
     442    int stat=  lpx_get_dual_stat(lp);
     443    switch (stat) {
     444    case LPX_D_UNDEF://Undefined (no solve has been run yet)
     445      return UNDEFINED;
     446    case LPX_D_NOFEAS://There is no feasible solution (primal, I guess)
     447    case LPX_D_INFEAS://Infeasible
     448      return INFEASIBLE;
     449    case LPX_FEAS://Feasible   
     450      int stat2=  lpx_get_prim_stat(lp);
     451      switch (stat2){
     452      case LPX_P_NOFEAS:
     453        return INFINITE;
     454      case LPX_OPT:
     455        return OPTIMAL;
     456      default:
     457        return FEASIBLE;
     458      }
     459    default:
     460      return UNDEFINED; //to avoid gcc warning
     461      //FIXME error
     462    }
     463  }
     464
     465  LpGlpk::ProblemTypes LpGlpk::_problemType()
     466  {
     467    int stat=  lpx_get_status(lp);
     468    int statp=  lpx_get_prim_stat(lp);
     469    int statd=  lpx_get_dual_stat(lp);
    423470    switch (stat) {
    424471    case LPX_UNDEF://Undefined (no solve has been run yet)
     
    444491  }
    445492
    446 
    447493  void LpGlpk::_setMax()
    448494  {
Note: See TracChangeset for help on using the changeset viewer.