[Lemon-commits] [lemon_svn] ladanyi: r2883 - hugo/trunk/lemon

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 21:51:01 CET 2006


Author: ladanyi
Date: Wed Aug  2 22:15:59 2006
New Revision: 2883

Modified:
   hugo/trunk/lemon/lp_cplex.cc

Log:
CPLEX 9.x support.

Modified: hugo/trunk/lemon/lp_cplex.cc
==============================================================================
--- hugo/trunk/lemon/lp_cplex.cc	(original)
+++ hugo/trunk/lemon/lp_cplex.cc	Wed Aug  2 22:15:59 2006
@@ -269,6 +269,24 @@
     //CPX_PARAM_LPMETHOD 
     status = CPXlpopt(env, lp);
     //status = CPXprimopt(env, lp);
+#if CPX_VERSION >= 900
+    if (status)
+    {
+      return UNSOLVED;
+    }
+    else
+    {
+      switch (CPXgetstat(env, lp))
+      {
+        case CPX_STAT_OPTIMAL:
+        case CPX_STAT_INFEASIBLE:
+        case CPX_STAT_UNBOUNDED:
+          return SOLVED;
+        default:
+          return UNSOLVED;
+      }
+    }
+#else
     if (status == 0){
       //We want to exclude some cases
       switch (CPXgetstat(env, lp)){
@@ -285,6 +303,7 @@
     else{
       return UNSOLVED;
     }
+#endif
   }
 
   LpCplex::Value LpCplex::_getPrimal(int i)
@@ -380,6 +399,7 @@
 // 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 
   //Hulye cplex
   void statusSwitch(CPXENVptr env,int& stat){
+#if CPX_VERSION < 900
     int lpmethod;
     CPXgetintparam (env,CPX_PARAM_LPMETHOD,&lpmethod);
     if (lpmethod==2){
@@ -391,12 +411,25 @@
 	  stat=CPX_UNBOUNDED;
       }
     }
+#endif
   }
 
   LpCplex::SolutionStatus LpCplex::_getPrimalStatus()
   {
-    
     int stat = CPXgetstat(env, lp);
+#if CPX_VERSION >= 900
+    switch (stat)
+    {
+      case CPX_STAT_OPTIMAL:
+        return OPTIMAL;
+      case CPX_STAT_UNBOUNDED:
+        return INFINITE;
+      case CPX_STAT_INFEASIBLE:
+        return INFEASIBLE;
+      default:
+        return UNDEFINED;
+    }
+#else
     statusSwitch(env,stat);
     //CPXgetstat(env, lp);
     //printf("A primal status: %d, CPX_OPTIMAL=%d \n",stat,CPX_OPTIMAL);
@@ -429,7 +462,7 @@
       return UNDEFINED; //Everything else comes here
       //FIXME error
     }
-
+#endif
   }
 
 //9.0-as cplex verzio statusai
@@ -452,6 +485,17 @@
   LpCplex::SolutionStatus LpCplex::_getDualStatus()
   {
     int stat = CPXgetstat(env, lp);
+#if CPX_VERSION >= 900
+    switch (stat)
+    {
+      case CPX_STAT_OPTIMAL:
+        return OPTIMAL;
+      case CPX_STAT_UNBOUNDED:
+        return INFEASIBLE;
+      default:
+        return UNDEFINED;
+    }
+#else
     statusSwitch(env,stat);
     switch (stat) {
     case 0:
@@ -464,11 +508,23 @@
       return UNDEFINED; //Everything else comes here
       //FIXME error
     }
+#endif
   }
 
   LpCplex::ProblemTypes LpCplex::_getProblemType()
   {
     int stat = CPXgetstat(env, lp);
+#if CPX_VERSION >= 900
+    switch (stat)
+    {
+      case CPX_STAT_OPTIMAL:
+	return PRIMAL_DUAL_FEASIBLE;
+      case CPX_STAT_UNBOUNDED:
+ 	return PRIMAL_FEASIBLE_DUAL_INFEASIBLE;
+      default:
+        return UNKNOWN;
+    }
+#else
     switch (stat) {
     case CPX_OPTIMAL://Optimal
 	return PRIMAL_DUAL_FEASIBLE;
@@ -483,6 +539,7 @@
 	return UNKNOWN;
       //FIXME error
     }
+#endif
   }
 
   void LpCplex::_setMax()



More information about the Lemon-commits mailing list