1.1 --- a/src/lemon/lp_cplex.cc Thu May 05 15:34:43 2005 +0000
1.2 +++ b/src/lemon/lp_cplex.cc Thu May 05 15:43:43 2005 +0000
1.3 @@ -14,8 +14,8 @@
1.4 * purpose.
1.5 *
1.6 */
1.7 -
1.8 -#include"lp_cplex.h"
1.9 +#include <iostream>
1.10 +#include<lemon/lp_cplex.h>
1.11
1.12 ///\file
1.13 ///\brief Implementation of the LEMON-CPLEX lp solver interface.
1.14 @@ -65,8 +65,14 @@
1.15
1.16 }
1.17
1.18 - LpSolverBase &LpCplex::_newLp() {return *(LpSolverBase*)0;}
1.19 - LpSolverBase &LpCplex::_copyLp() {return *(LpSolverBase*)0;}
1.20 + LpSolverBase &LpCplex::_newLp()
1.21 + {
1.22 + return *(LpSolverBase*)0;
1.23 + }
1.24 + LpSolverBase &LpCplex::_copyLp() {
1.25 + return *(LpSolverBase*)0;
1.26 + //Ez lesz majd CPXcloneprob (env, lp, &status);
1.27 + }
1.28
1.29 int LpCplex::_addCol()
1.30 {
1.31 @@ -155,7 +161,7 @@
1.32 if (lb==INF || ub==-INF) {
1.33 //FIXME error
1.34 }
1.35 -
1.36 +
1.37 int cnt=1;
1.38 int indices[1];
1.39 indices[0]=i;
1.40 @@ -165,6 +171,7 @@
1.41 sense[0]='L';
1.42 CPXchgsense (env, lp, cnt, indices, sense);
1.43 CPXchgcoef (env, lp, i, -1, ub);
1.44 +
1.45 }
1.46 else{
1.47 if (ub==INF){
1.48 @@ -188,36 +195,36 @@
1.49 }
1.50 }
1.51
1.52 - void LpCplex::_setRowLowerBound(int i, Value value)
1.53 - {
1.54 - //Not implemented, obsolete
1.55 - }
1.56 +// void LpCplex::_setRowLowerBound(int i, Value value)
1.57 +// {
1.58 +// //Not implemented, obsolete
1.59 +// }
1.60
1.61 - void LpCplex::_setRowUpperBound(int i, Value value)
1.62 - {
1.63 - //Not implemented, obsolete
1.64 -// //TODO Ezt kell meg megirni
1.65 -// //type of the problem
1.66 -// char sense[1];
1.67 -// status = CPXgetsense (env, lp, sense, i, i);
1.68 -// Value rhs[1];
1.69 -// status = CPXgetrhs (env, lp, rhs, i, i);
1.70 +// void LpCplex::_setRowUpperBound(int i, Value value)
1.71 +// {
1.72 +// //Not implemented, obsolete
1.73 +// // //TODO Ezt kell meg megirni
1.74 +// // //type of the problem
1.75 +// // char sense[1];
1.76 +// // status = CPXgetsense (env, lp, sense, i, i);
1.77 +// // Value rhs[1];
1.78 +// // status = CPXgetrhs (env, lp, rhs, i, i);
1.79
1.80 -// switch (sense[0]) {
1.81 -// case 'L'://<= constraint
1.82 -// break;
1.83 -// case 'E'://= constraint
1.84 -// break;
1.85 -// case 'G'://>= constraint
1.86 -// break;
1.87 -// case 'R'://ranged constraint
1.88 -// break;
1.89 -// default: ;
1.90 -// //FIXME error
1.91 -// }
1.92 +// // switch (sense[0]) {
1.93 +// // case 'L'://<= constraint
1.94 +// // break;
1.95 +// // case 'E'://= constraint
1.96 +// // break;
1.97 +// // case 'G'://>= constraint
1.98 +// // break;
1.99 +// // case 'R'://ranged constraint
1.100 +// // break;
1.101 +// // default: ;
1.102 +// // //FIXME error
1.103 +// // }
1.104
1.105 -// status = CPXchgcoef (env, lp, i, -2, value_rng);
1.106 - }
1.107 +// // status = CPXchgcoef (env, lp, i, -2, value_rng);
1.108 +// }
1.109
1.110 void LpCplex::_setObjCoeff(int i, Value obj_coef)
1.111 {
1.112 @@ -254,30 +261,41 @@
1.113
1.114 LpCplex::SolutionStatus LpCplex::_getPrimalStatus()
1.115 {
1.116 +// CPX_STAT_ABORT_DUAL_OBJ_LIM
1.117 +// CPX_STAT_ABORT_IT_LIM
1.118 +// CPX_STAT_ABORT_OBJ_LIM
1.119 +// CPX_STAT_ABORT_PRIM_OBJ_LIM
1.120 +// CPX_STAT_ABORT_TIME_LIM
1.121 +// CPX_STAT_ABORT_USER
1.122 +// CPX_STAT_FEASIBLE_RELAXED
1.123 +// CPX_STAT_INFEASIBLE
1.124 +// CPX_STAT_INForUNBD
1.125 +// CPX_STAT_NUM_BEST
1.126 +// CPX_STAT_OPTIMAL
1.127 +// CPX_STAT_OPTIMAL_FACE_UNBOUNDED
1.128 +// CPX_STAT_OPTIMAL_INFEAS
1.129 +// CPX_STAT_OPTIMAL_RELAXED
1.130 +// CPX_STAT_UNBOUNDED
1.131 +
1.132 //Unimplemented
1.133 - return OPTIMAL;
1.134 -// int stat= lpx_get_status(lp);
1.135 -// switch (stat) {
1.136 -// case LPX_UNDEF://Undefined (no solve has been run yet)
1.137 -// return UNDEFINED;
1.138 -// break;
1.139 -// case LPX_NOFEAS://There is no feasible solution (primal, I guess)
1.140 -// case LPX_INFEAS://Infeasible
1.141 -// return INFEASIBLE;
1.142 -// break;
1.143 -// case LPX_UNBND://Unbounded
1.144 -// return INFINITE;
1.145 -// break;
1.146 -// case LPX_FEAS://Feasible
1.147 -// return FEASIBLE;
1.148 -// break;
1.149 -// case LPX_OPT://Feasible
1.150 -// return OPTIMAL;
1.151 -// break;
1.152 -// default:
1.153 -// return UNDEFINED; //to avoid gcc warning
1.154 -// //FIXME error
1.155 -// }
1.156 + int stat = CPXgetstat (env, lp);
1.157 + switch (stat) {
1.158 + case CPX_STAT_OPTIMAL://Optimal
1.159 + return OPTIMAL;
1.160 + break;
1.161 + case CPX_STAT_INFEASIBLE://Infeasible
1.162 + return INFEASIBLE;
1.163 + break;
1.164 + case CPX_STAT_UNBOUNDED://Unbounded
1.165 + return INFINITE;
1.166 + break;
1.167 + case CPX_STAT_NUM_BEST://Feasible
1.168 + return FEASIBLE;
1.169 + break;
1.170 + default:
1.171 + return UNDEFINED; //Everything else comes here
1.172 + //FIXME error
1.173 + }
1.174 }
1.175
1.176 LpCplex::Value LpCplex::_getPrimal(int i)
1.177 @@ -289,8 +307,10 @@
1.178
1.179 LpCplex::Value LpCplex::_getPrimalValue()
1.180 {
1.181 - //Unimplemented
1.182 - return 0;
1.183 + Value objval;
1.184 + //method = CPXgetmethod (env, lp);
1.185 + status = CPXgetobjval (env, lp, &objval);
1.186 + return objval;
1.187 }
1.188
1.189