diff -r 17c80cb3754b -r 3626c7f10f14 src/lemon/lp_cplex.cc --- a/src/lemon/lp_cplex.cc Thu May 05 15:34:43 2005 +0000 +++ b/src/lemon/lp_cplex.cc Thu May 05 15:43:43 2005 +0000 @@ -14,8 +14,8 @@ * purpose. * */ - -#include"lp_cplex.h" +#include +#include ///\file ///\brief Implementation of the LEMON-CPLEX lp solver interface. @@ -65,8 +65,14 @@ } - LpSolverBase &LpCplex::_newLp() {return *(LpSolverBase*)0;} - LpSolverBase &LpCplex::_copyLp() {return *(LpSolverBase*)0;} + LpSolverBase &LpCplex::_newLp() + { + return *(LpSolverBase*)0; + } + LpSolverBase &LpCplex::_copyLp() { + return *(LpSolverBase*)0; + //Ez lesz majd CPXcloneprob (env, lp, &status); + } int LpCplex::_addCol() { @@ -155,7 +161,7 @@ if (lb==INF || ub==-INF) { //FIXME error } - + int cnt=1; int indices[1]; indices[0]=i; @@ -165,6 +171,7 @@ sense[0]='L'; CPXchgsense (env, lp, cnt, indices, sense); CPXchgcoef (env, lp, i, -1, ub); + } else{ if (ub==INF){ @@ -188,36 +195,36 @@ } } - void LpCplex::_setRowLowerBound(int i, Value value) - { - //Not implemented, obsolete - } +// void LpCplex::_setRowLowerBound(int i, Value value) +// { +// //Not implemented, obsolete +// } - void LpCplex::_setRowUpperBound(int i, Value value) - { - //Not implemented, obsolete -// //TODO Ezt kell meg megirni -// //type of the problem -// char sense[1]; -// status = CPXgetsense (env, lp, sense, i, i); -// Value rhs[1]; -// status = CPXgetrhs (env, lp, rhs, i, i); +// void LpCplex::_setRowUpperBound(int i, Value value) +// { +// //Not implemented, obsolete +// // //TODO Ezt kell meg megirni +// // //type of the problem +// // char sense[1]; +// // status = CPXgetsense (env, lp, sense, i, i); +// // Value rhs[1]; +// // status = CPXgetrhs (env, lp, rhs, i, i); -// switch (sense[0]) { -// case 'L'://<= constraint -// break; -// case 'E'://= constraint -// break; -// case 'G'://>= constraint -// break; -// case 'R'://ranged constraint -// break; -// default: ; -// //FIXME error -// } +// // switch (sense[0]) { +// // case 'L'://<= constraint +// // break; +// // case 'E'://= constraint +// // break; +// // case 'G'://>= constraint +// // break; +// // case 'R'://ranged constraint +// // break; +// // default: ; +// // //FIXME error +// // } -// status = CPXchgcoef (env, lp, i, -2, value_rng); - } +// // status = CPXchgcoef (env, lp, i, -2, value_rng); +// } void LpCplex::_setObjCoeff(int i, Value obj_coef) { @@ -254,30 +261,41 @@ LpCplex::SolutionStatus LpCplex::_getPrimalStatus() { +// CPX_STAT_ABORT_DUAL_OBJ_LIM +// CPX_STAT_ABORT_IT_LIM +// CPX_STAT_ABORT_OBJ_LIM +// CPX_STAT_ABORT_PRIM_OBJ_LIM +// CPX_STAT_ABORT_TIME_LIM +// CPX_STAT_ABORT_USER +// CPX_STAT_FEASIBLE_RELAXED +// CPX_STAT_INFEASIBLE +// CPX_STAT_INForUNBD +// CPX_STAT_NUM_BEST +// CPX_STAT_OPTIMAL +// CPX_STAT_OPTIMAL_FACE_UNBOUNDED +// CPX_STAT_OPTIMAL_INFEAS +// CPX_STAT_OPTIMAL_RELAXED +// CPX_STAT_UNBOUNDED + //Unimplemented - return OPTIMAL; -// int stat= lpx_get_status(lp); -// switch (stat) { -// case LPX_UNDEF://Undefined (no solve has been run yet) -// return UNDEFINED; -// break; -// case LPX_NOFEAS://There is no feasible solution (primal, I guess) -// case LPX_INFEAS://Infeasible -// return INFEASIBLE; -// break; -// case LPX_UNBND://Unbounded -// return INFINITE; -// break; -// case LPX_FEAS://Feasible -// return FEASIBLE; -// break; -// case LPX_OPT://Feasible -// return OPTIMAL; -// break; -// default: -// return UNDEFINED; //to avoid gcc warning -// //FIXME error -// } + int stat = CPXgetstat (env, lp); + switch (stat) { + case CPX_STAT_OPTIMAL://Optimal + return OPTIMAL; + break; + case CPX_STAT_INFEASIBLE://Infeasible + return INFEASIBLE; + break; + case CPX_STAT_UNBOUNDED://Unbounded + return INFINITE; + break; + case CPX_STAT_NUM_BEST://Feasible + return FEASIBLE; + break; + default: + return UNDEFINED; //Everything else comes here + //FIXME error + } } LpCplex::Value LpCplex::_getPrimal(int i) @@ -289,8 +307,10 @@ LpCplex::Value LpCplex::_getPrimalValue() { - //Unimplemented - return 0; + Value objval; + //method = CPXgetmethod (env, lp); + status = CPXgetobjval (env, lp, &objval); + return objval; }