COIN-OR::LEMON - Graph Library

Changeset 1458:7a483c1d38b5 in lemon-0.x for lemon/lp_cplex.cc


Ignore:
Timestamp:
06/09/05 11:49:48 (19 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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)
Note: See TracChangeset for help on using the changeset viewer.