lemon/lp_cplex.cc
changeset 1574 697ed4dd309a
parent 1508 389a94a1d9eb
child 1787 932b8490caf0
equal deleted inserted replaced
5:4d3e4f0595e2 6:1bfcb0d0031b
   240   // further information about the status of the optimization.
   240   // further information about the status of the optimization.
   241   LpCplex::SolveExitStatus LpCplex::_solve()
   241   LpCplex::SolveExitStatus LpCplex::_solve()
   242   {
   242   {
   243     //CPX_PARAM_LPMETHOD 
   243     //CPX_PARAM_LPMETHOD 
   244     status = CPXlpopt(env, lp);
   244     status = CPXlpopt(env, lp);
       
   245     //status = CPXprimopt(env, lp);
   245     if (status == 0){
   246     if (status == 0){
   246       //We want to exclude some cases
   247       //We want to exclude some cases
   247       switch (CPXgetstat(env, lp)){
   248       switch (CPXgetstat(env, lp)){
   248       case CPX_OBJ_LIM:
   249       case CPX_OBJ_LIM:
   249       case CPX_IT_LIM_FEAS:
   250       case CPX_IT_LIM_FEAS:
   325 //
   326 //
   326 //     Ezeket hova tegyem:
   327 //     Ezeket hova tegyem:
   327 // ??case CPX_ABORT_DUAL_INFEAS           
   328 // ??case CPX_ABORT_DUAL_INFEAS           
   328 // ??case CPX_ABORT_CROSSOVER             
   329 // ??case CPX_ABORT_CROSSOVER             
   329 // ??case CPX_INForUNBD                   
   330 // ??case CPX_INForUNBD                   
   330 // ??case CPX_PIVOT                       
   331 // ??case CPX_PIVOT              
       
   332          
       
   333 //Some more interesting stuff:
       
   334 
       
   335 // CPX_PARAM_LPMETHOD  1062  int  LPMETHOD
       
   336 // 0 Automatic 
       
   337 // 1 Primal Simplex 
       
   338 // 2 Dual Simplex 
       
   339 // 3 Network Simplex 
       
   340 // 4 Standard Barrier 
       
   341 // Default: 0 
       
   342 // Description: Method for linear optimization. 
       
   343 // Determines which algorithm is used when CPXlpopt() (or "optimize" in the Interactive Optimizer) is called. Currently the behavior of the "Automatic" setting is that CPLEX simply invokes the dual simplex method, but this capability may be expanded in the future so that CPLEX chooses the method based on problem characteristics 
       
   344   //Hulye cplex
       
   345   void statusSwitch(CPXENVptr env,int& stat){
       
   346     int lpmethod;
       
   347     CPXgetintparam (env,CPX_PARAM_LPMETHOD,&lpmethod);
       
   348     if (lpmethod==2){
       
   349       if (stat==CPX_UNBOUNDED){
       
   350 	stat=CPX_INFEASIBLE;
       
   351       }
       
   352       else{
       
   353 	if (stat==CPX_INFEASIBLE)
       
   354 	  stat=CPX_UNBOUNDED;
       
   355       }
       
   356     }
       
   357   }
   331 
   358 
   332   LpCplex::SolutionStatus LpCplex::_getPrimalStatus()
   359   LpCplex::SolutionStatus LpCplex::_getPrimalStatus()
   333   {
   360   {
       
   361     
   334     int stat = CPXgetstat(env, lp);
   362     int stat = CPXgetstat(env, lp);
       
   363     statusSwitch(env,stat);
       
   364     //CPXgetstat(env, lp);
   335     //printf("A primal status: %d, CPX_OPTIMAL=%d \n",stat,CPX_OPTIMAL);
   365     //printf("A primal status: %d, CPX_OPTIMAL=%d \n",stat,CPX_OPTIMAL);
   336     switch (stat) {
   366     switch (stat) {
   337     case 0:
   367     case 0:
   338       return UNDEFINED; //Undefined
   368       return UNDEFINED; //Undefined
   339     case CPX_OPTIMAL://Optimal
   369     case CPX_OPTIMAL://Optimal
   340       return OPTIMAL;
   370       return OPTIMAL;
   341     case CPX_UNBOUNDED://Unbounded
   371     case CPX_UNBOUNDED://Unbounded
   342       return INFINITE;
   372       return INFEASIBLE;//In case of dual simplex
       
   373       //return INFINITE;
   343     case CPX_INFEASIBLE://Infeasible 
   374     case CPX_INFEASIBLE://Infeasible 
   344  //    case CPX_IT_LIM_INFEAS:
   375  //    case CPX_IT_LIM_INFEAS:
   345 //     case CPX_TIME_LIM_INFEAS:
   376 //     case CPX_TIME_LIM_INFEAS:
   346 //     case CPX_NUM_BEST_INFEAS:             
   377 //     case CPX_NUM_BEST_INFEAS:             
   347 //     case CPX_OPTIMAL_INFEAS:              
   378 //     case CPX_OPTIMAL_INFEAS:              
   348 //     case CPX_ABORT_INFEAS:                
   379 //     case CPX_ABORT_INFEAS:                
   349 //     case CPX_ABORT_PRIM_INFEAS:           
   380 //     case CPX_ABORT_PRIM_INFEAS:           
   350 //     case CPX_ABORT_PRIM_DUAL_INFEAS:      
   381 //     case CPX_ABORT_PRIM_DUAL_INFEAS:      
   351       return INFEASIBLE;
   382       return INFINITE;//In case of dual simplex
       
   383       //return INFEASIBLE;
   352 //     case CPX_OBJ_LIM:                    
   384 //     case CPX_OBJ_LIM:                    
   353 //     case CPX_IT_LIM_FEAS:             
   385 //     case CPX_IT_LIM_FEAS:             
   354 //     case CPX_TIME_LIM_FEAS:                
   386 //     case CPX_TIME_LIM_FEAS:                
   355 //     case CPX_NUM_BEST_FEAS:                
   387 //     case CPX_NUM_BEST_FEAS:                
   356 //     case CPX_ABORT_FEAS:                  
   388 //     case CPX_ABORT_FEAS:                  
   381 // CPX_STAT_UNBOUNDED
   413 // CPX_STAT_UNBOUNDED
   382 
   414 
   383   LpCplex::SolutionStatus LpCplex::_getDualStatus()
   415   LpCplex::SolutionStatus LpCplex::_getDualStatus()
   384   {
   416   {
   385     int stat = CPXgetstat(env, lp);
   417     int stat = CPXgetstat(env, lp);
       
   418     statusSwitch(env,stat);
   386     switch (stat) {
   419     switch (stat) {
   387     case 0:
   420     case 0:
   388       return UNDEFINED; //Undefined
   421       return UNDEFINED; //Undefined
   389     case CPX_OPTIMAL://Optimal
   422     case CPX_OPTIMAL://Optimal
   390       return OPTIMAL;
   423       return OPTIMAL;