lemon/lp_cplex.cc
changeset 2173 b4de9aed7709
parent 1956 a055123339d5
child 2218 50f1a780a5ff
equal deleted inserted replaced
14:8daad837554f 15:ff2a30852e3e
   267   LpCplex::SolveExitStatus LpCplex::_solve()
   267   LpCplex::SolveExitStatus LpCplex::_solve()
   268   {
   268   {
   269     //CPX_PARAM_LPMETHOD 
   269     //CPX_PARAM_LPMETHOD 
   270     status = CPXlpopt(env, lp);
   270     status = CPXlpopt(env, lp);
   271     //status = CPXprimopt(env, lp);
   271     //status = CPXprimopt(env, lp);
       
   272 #if CPX_VERSION >= 900
       
   273     if (status)
       
   274     {
       
   275       return UNSOLVED;
       
   276     }
       
   277     else
       
   278     {
       
   279       switch (CPXgetstat(env, lp))
       
   280       {
       
   281         case CPX_STAT_OPTIMAL:
       
   282         case CPX_STAT_INFEASIBLE:
       
   283         case CPX_STAT_UNBOUNDED:
       
   284           return SOLVED;
       
   285         default:
       
   286           return UNSOLVED;
       
   287       }
       
   288     }
       
   289 #else
   272     if (status == 0){
   290     if (status == 0){
   273       //We want to exclude some cases
   291       //We want to exclude some cases
   274       switch (CPXgetstat(env, lp)){
   292       switch (CPXgetstat(env, lp)){
   275       case CPX_OBJ_LIM:
   293       case CPX_OBJ_LIM:
   276       case CPX_IT_LIM_FEAS:
   294       case CPX_IT_LIM_FEAS:
   283       }
   301       }
   284     }
   302     }
   285     else{
   303     else{
   286       return UNSOLVED;
   304       return UNSOLVED;
   287     }
   305     }
       
   306 #endif
   288   }
   307   }
   289 
   308 
   290   LpCplex::Value LpCplex::_getPrimal(int i)
   309   LpCplex::Value LpCplex::_getPrimal(int i)
   291   {
   310   {
   292     Value x;
   311     Value x;
   378 // Default: 0 
   397 // Default: 0 
   379 // Description: Method for linear optimization. 
   398 // Description: Method for linear optimization. 
   380 // 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 
   399 // 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 
   381   //Hulye cplex
   400   //Hulye cplex
   382   void statusSwitch(CPXENVptr env,int& stat){
   401   void statusSwitch(CPXENVptr env,int& stat){
       
   402 #if CPX_VERSION < 900
   383     int lpmethod;
   403     int lpmethod;
   384     CPXgetintparam (env,CPX_PARAM_LPMETHOD,&lpmethod);
   404     CPXgetintparam (env,CPX_PARAM_LPMETHOD,&lpmethod);
   385     if (lpmethod==2){
   405     if (lpmethod==2){
   386       if (stat==CPX_UNBOUNDED){
   406       if (stat==CPX_UNBOUNDED){
   387 	stat=CPX_INFEASIBLE;
   407 	stat=CPX_INFEASIBLE;
   389       else{
   409       else{
   390 	if (stat==CPX_INFEASIBLE)
   410 	if (stat==CPX_INFEASIBLE)
   391 	  stat=CPX_UNBOUNDED;
   411 	  stat=CPX_UNBOUNDED;
   392       }
   412       }
   393     }
   413     }
       
   414 #endif
   394   }
   415   }
   395 
   416 
   396   LpCplex::SolutionStatus LpCplex::_getPrimalStatus()
   417   LpCplex::SolutionStatus LpCplex::_getPrimalStatus()
   397   {
   418   {
   398     
       
   399     int stat = CPXgetstat(env, lp);
   419     int stat = CPXgetstat(env, lp);
       
   420 #if CPX_VERSION >= 900
       
   421     switch (stat)
       
   422     {
       
   423       case CPX_STAT_OPTIMAL:
       
   424         return OPTIMAL;
       
   425       case CPX_STAT_UNBOUNDED:
       
   426         return INFINITE;
       
   427       case CPX_STAT_INFEASIBLE:
       
   428         return INFEASIBLE;
       
   429       default:
       
   430         return UNDEFINED;
       
   431     }
       
   432 #else
   400     statusSwitch(env,stat);
   433     statusSwitch(env,stat);
   401     //CPXgetstat(env, lp);
   434     //CPXgetstat(env, lp);
   402     //printf("A primal status: %d, CPX_OPTIMAL=%d \n",stat,CPX_OPTIMAL);
   435     //printf("A primal status: %d, CPX_OPTIMAL=%d \n",stat,CPX_OPTIMAL);
   403     switch (stat) {
   436     switch (stat) {
   404     case 0:
   437     case 0:
   427 //       return FEASIBLE;
   460 //       return FEASIBLE;
   428     default:
   461     default:
   429       return UNDEFINED; //Everything else comes here
   462       return UNDEFINED; //Everything else comes here
   430       //FIXME error
   463       //FIXME error
   431     }
   464     }
   432 
   465 #endif
   433   }
   466   }
   434 
   467 
   435 //9.0-as cplex verzio statusai
   468 //9.0-as cplex verzio statusai
   436 // CPX_STAT_ABORT_DUAL_OBJ_LIM
   469 // CPX_STAT_ABORT_DUAL_OBJ_LIM
   437 // CPX_STAT_ABORT_IT_LIM
   470 // CPX_STAT_ABORT_IT_LIM
   450 // CPX_STAT_UNBOUNDED
   483 // CPX_STAT_UNBOUNDED
   451 
   484 
   452   LpCplex::SolutionStatus LpCplex::_getDualStatus()
   485   LpCplex::SolutionStatus LpCplex::_getDualStatus()
   453   {
   486   {
   454     int stat = CPXgetstat(env, lp);
   487     int stat = CPXgetstat(env, lp);
       
   488 #if CPX_VERSION >= 900
       
   489     switch (stat)
       
   490     {
       
   491       case CPX_STAT_OPTIMAL:
       
   492         return OPTIMAL;
       
   493       case CPX_STAT_UNBOUNDED:
       
   494         return INFEASIBLE;
       
   495       default:
       
   496         return UNDEFINED;
       
   497     }
       
   498 #else
   455     statusSwitch(env,stat);
   499     statusSwitch(env,stat);
   456     switch (stat) {
   500     switch (stat) {
   457     case 0:
   501     case 0:
   458       return UNDEFINED; //Undefined
   502       return UNDEFINED; //Undefined
   459     case CPX_OPTIMAL://Optimal
   503     case CPX_OPTIMAL://Optimal
   462      return INFEASIBLE;
   506      return INFEASIBLE;
   463     default:
   507     default:
   464       return UNDEFINED; //Everything else comes here
   508       return UNDEFINED; //Everything else comes here
   465       //FIXME error
   509       //FIXME error
   466     }
   510     }
       
   511 #endif
   467   }
   512   }
   468 
   513 
   469   LpCplex::ProblemTypes LpCplex::_getProblemType()
   514   LpCplex::ProblemTypes LpCplex::_getProblemType()
   470   {
   515   {
   471     int stat = CPXgetstat(env, lp);
   516     int stat = CPXgetstat(env, lp);
       
   517 #if CPX_VERSION >= 900
       
   518     switch (stat)
       
   519     {
       
   520       case CPX_STAT_OPTIMAL:
       
   521 	return PRIMAL_DUAL_FEASIBLE;
       
   522       case CPX_STAT_UNBOUNDED:
       
   523  	return PRIMAL_FEASIBLE_DUAL_INFEASIBLE;
       
   524       default:
       
   525         return UNKNOWN;
       
   526     }
       
   527 #else
   472     switch (stat) {
   528     switch (stat) {
   473     case CPX_OPTIMAL://Optimal
   529     case CPX_OPTIMAL://Optimal
   474 	return PRIMAL_DUAL_FEASIBLE;
   530 	return PRIMAL_DUAL_FEASIBLE;
   475     case CPX_UNBOUNDED:
   531     case CPX_UNBOUNDED:
   476  	return PRIMAL_FEASIBLE_DUAL_INFEASIBLE;
   532  	return PRIMAL_FEASIBLE_DUAL_INFEASIBLE;
   481     default:
   537     default:
   482 	//In all other cases
   538 	//In all other cases
   483 	return UNKNOWN;
   539 	return UNKNOWN;
   484       //FIXME error
   540       //FIXME error
   485     }
   541     }
       
   542 #endif
   486   }
   543   }
   487 
   544 
   488   void LpCplex::_setMax()
   545   void LpCplex::_setMax()
   489   {
   546   {
   490     CPXchgobjsen(env, lp, CPX_MAX);
   547     CPXchgobjsen(env, lp, CPX_MAX);