CPLEX 9.x support.
authorladanyi
Wed, 02 Aug 2006 20:15:59 +0000
changeset 21686474b8254f24
parent 2167 7e109b222053
child 2169 9f71586a3f74
CPLEX 9.x support.
lemon/lp_cplex.cc
     1.1 --- a/lemon/lp_cplex.cc	Wed Aug 02 20:15:22 2006 +0000
     1.2 +++ b/lemon/lp_cplex.cc	Wed Aug 02 20:15:59 2006 +0000
     1.3 @@ -269,6 +269,24 @@
     1.4      //CPX_PARAM_LPMETHOD 
     1.5      status = CPXlpopt(env, lp);
     1.6      //status = CPXprimopt(env, lp);
     1.7 +#if CPX_VERSION >= 900
     1.8 +    if (status)
     1.9 +    {
    1.10 +      return UNSOLVED;
    1.11 +    }
    1.12 +    else
    1.13 +    {
    1.14 +      switch (CPXgetstat(env, lp))
    1.15 +      {
    1.16 +        case CPX_STAT_OPTIMAL:
    1.17 +        case CPX_STAT_INFEASIBLE:
    1.18 +        case CPX_STAT_UNBOUNDED:
    1.19 +          return SOLVED;
    1.20 +        default:
    1.21 +          return UNSOLVED;
    1.22 +      }
    1.23 +    }
    1.24 +#else
    1.25      if (status == 0){
    1.26        //We want to exclude some cases
    1.27        switch (CPXgetstat(env, lp)){
    1.28 @@ -285,6 +303,7 @@
    1.29      else{
    1.30        return UNSOLVED;
    1.31      }
    1.32 +#endif
    1.33    }
    1.34  
    1.35    LpCplex::Value LpCplex::_getPrimal(int i)
    1.36 @@ -380,6 +399,7 @@
    1.37  // 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 
    1.38    //Hulye cplex
    1.39    void statusSwitch(CPXENVptr env,int& stat){
    1.40 +#if CPX_VERSION < 900
    1.41      int lpmethod;
    1.42      CPXgetintparam (env,CPX_PARAM_LPMETHOD,&lpmethod);
    1.43      if (lpmethod==2){
    1.44 @@ -391,12 +411,25 @@
    1.45  	  stat=CPX_UNBOUNDED;
    1.46        }
    1.47      }
    1.48 +#endif
    1.49    }
    1.50  
    1.51    LpCplex::SolutionStatus LpCplex::_getPrimalStatus()
    1.52    {
    1.53 -    
    1.54      int stat = CPXgetstat(env, lp);
    1.55 +#if CPX_VERSION >= 900
    1.56 +    switch (stat)
    1.57 +    {
    1.58 +      case CPX_STAT_OPTIMAL:
    1.59 +        return OPTIMAL;
    1.60 +      case CPX_STAT_UNBOUNDED:
    1.61 +        return INFINITE;
    1.62 +      case CPX_STAT_INFEASIBLE:
    1.63 +        return INFEASIBLE;
    1.64 +      default:
    1.65 +        return UNDEFINED;
    1.66 +    }
    1.67 +#else
    1.68      statusSwitch(env,stat);
    1.69      //CPXgetstat(env, lp);
    1.70      //printf("A primal status: %d, CPX_OPTIMAL=%d \n",stat,CPX_OPTIMAL);
    1.71 @@ -429,7 +462,7 @@
    1.72        return UNDEFINED; //Everything else comes here
    1.73        //FIXME error
    1.74      }
    1.75 -
    1.76 +#endif
    1.77    }
    1.78  
    1.79  //9.0-as cplex verzio statusai
    1.80 @@ -452,6 +485,17 @@
    1.81    LpCplex::SolutionStatus LpCplex::_getDualStatus()
    1.82    {
    1.83      int stat = CPXgetstat(env, lp);
    1.84 +#if CPX_VERSION >= 900
    1.85 +    switch (stat)
    1.86 +    {
    1.87 +      case CPX_STAT_OPTIMAL:
    1.88 +        return OPTIMAL;
    1.89 +      case CPX_STAT_UNBOUNDED:
    1.90 +        return INFEASIBLE;
    1.91 +      default:
    1.92 +        return UNDEFINED;
    1.93 +    }
    1.94 +#else
    1.95      statusSwitch(env,stat);
    1.96      switch (stat) {
    1.97      case 0:
    1.98 @@ -464,11 +508,23 @@
    1.99        return UNDEFINED; //Everything else comes here
   1.100        //FIXME error
   1.101      }
   1.102 +#endif
   1.103    }
   1.104  
   1.105    LpCplex::ProblemTypes LpCplex::_getProblemType()
   1.106    {
   1.107      int stat = CPXgetstat(env, lp);
   1.108 +#if CPX_VERSION >= 900
   1.109 +    switch (stat)
   1.110 +    {
   1.111 +      case CPX_STAT_OPTIMAL:
   1.112 +	return PRIMAL_DUAL_FEASIBLE;
   1.113 +      case CPX_STAT_UNBOUNDED:
   1.114 + 	return PRIMAL_FEASIBLE_DUAL_INFEASIBLE;
   1.115 +      default:
   1.116 +        return UNKNOWN;
   1.117 +    }
   1.118 +#else
   1.119      switch (stat) {
   1.120      case CPX_OPTIMAL://Optimal
   1.121  	return PRIMAL_DUAL_FEASIBLE;
   1.122 @@ -483,6 +539,7 @@
   1.123  	return UNKNOWN;
   1.124        //FIXME error
   1.125      }
   1.126 +#endif
   1.127    }
   1.128  
   1.129    void LpCplex::_setMax()