diff -r be025fc1b13d -r 7a483c1d38b5 lemon/lp_cplex.cc --- a/lemon/lp_cplex.cc Thu Jun 09 09:47:51 2005 +0000 +++ b/lemon/lp_cplex.cc Thu Jun 09 09:49:48 2005 +0000 @@ -25,7 +25,6 @@ // env = CPXopenCPLEXdevelop(&status); env = CPXopenCPLEX(&status); lp = CPXcreateprob(env, &status, "LP problem"); - //CPXmsg (cpxresults, "Hello-bello\n"); } LpCplex::~LpCplex() { @@ -230,93 +229,123 @@ } } - + // The routine returns zero unless an error occurred during the + // optimization. Examples of errors include exhausting available + // memory (CPXERR_NO_MEMORY) or encountering invalid data in the + // CPLEX problem object (CPXERR_NO_PROBLEM). Exceeding a + // user-specified CPLEX limit, or proving the model infeasible or + // unbounded, are not considered errors. Note that a zero return + // value does not necessarily mean that a solution exists. Use query + // routines CPXsolninfo, CPXgetstat, and CPXsolution to obtain + // further information about the status of the optimization. LpCplex::SolveExitStatus LpCplex::_solve() { - + //CPX_PARAM_LPMETHOD status = CPXlpopt (env, lp); if (status == 0){ - return SOLVED; + //We want to exclude some cases + switch (CPXgetstat (env, lp)){ + case CPX_OBJ_LIM: + case CPX_IT_LIM_FEAS: + case CPX_IT_LIM_INFEAS: + case CPX_TIME_LIM_FEAS: + case CPX_TIME_LIM_INFEAS: + return UNSOLVED; + default: + return SOLVED; + } } else{ return UNSOLVED; } -// int i= lpx_simplex(lp); -// switch (i) { -// case LPX_E_OK: -// return SOLVED; -// break; -// default: -// return UNSOLVED; -// } } - LpCplex::SolutionStatus LpCplex::_getPrimalStatus() - { -//7.5-os cplex statusai -// #define CPX_OPTIMAL 1 -// #define CPX_INFEASIBLE 2 -// #define CPX_UNBOUNDED 3 -// #define CPX_OBJ_LIM 4 -// #define CPX_IT_LIM_FEAS 5 -// #define CPX_IT_LIM_INFEAS 6 -// #define CPX_TIME_LIM_FEAS 7 -// #define CPX_TIME_LIM_INFEAS 8 -// #define CPX_NUM_BEST_FEAS 9 -// #define CPX_NUM_BEST_INFEAS 10 -// #define CPX_OPTIMAL_INFEAS 11 -// #define CPX_ABORT_FEAS 12 -// #define CPX_ABORT_INFEAS 13 -// #define CPX_ABORT_DUAL_INFEAS 14 -// #define CPX_ABORT_PRIM_INFEAS 15 -// #define CPX_ABORT_PRIM_DUAL_INFEAS 16 -// #define CPX_ABORT_PRIM_DUAL_FEAS 17 -// #define CPX_ABORT_CROSSOVER 18 -// #define CPX_INForUNBD 19 -// #define CPX_PIVOT 20 +//7.5-os cplex statusai (Vigyazat: a 9.0-asei masok!) +// This table lists the statuses, returned by the CPXgetstat() routine, for solutions to LP problems or mixed integer problems. If no solution exists, the return value is zero. + +// For Simplex, Barrier +// 1 CPX_OPTIMAL +// Optimal solution found +// 2 CPX_INFEASIBLE +// Problem infeasible +// 3 CPX_UNBOUNDED +// Problem unbounded +// 4 CPX_OBJ_LIM +// Objective limit exceeded in Phase II +// 5 CPX_IT_LIM_FEAS +// Iteration limit exceeded in Phase II +// 6 CPX_IT_LIM_INFEAS +// Iteration limit exceeded in Phase I +// 7 CPX_TIME_LIM_FEAS +// Time limit exceeded in Phase II +// 8 CPX_TIME_LIM_INFEAS +// Time limit exceeded in Phase I +// 9 CPX_NUM_BEST_FEAS +// Problem non-optimal, singularities in Phase II +// 10 CPX_NUM_BEST_INFEAS +// Problem non-optimal, singularities in Phase I +// 11 CPX_OPTIMAL_INFEAS +// Optimal solution found, unscaled infeasibilities +// 12 CPX_ABORT_FEAS +// Aborted in Phase II +// 13 CPX_ABORT_INFEAS +// Aborted in Phase I +// 14 CPX_ABORT_DUAL_INFEAS +// Aborted in barrier, dual infeasible +// 15 CPX_ABORT_PRIM_INFEAS +// Aborted in barrier, primal infeasible +// 16 CPX_ABORT_PRIM_DUAL_INFEAS +// Aborted in barrier, primal and dual infeasible +// 17 CPX_ABORT_PRIM_DUAL_FEAS +// Aborted in barrier, primal and dual feasible +// 18 CPX_ABORT_CROSSOVER +// Aborted in crossover +// 19 CPX_INForUNBD +// Infeasible or unbounded +// 20 CPX_PIVOT +// User pivot used +// // Ezeket hova tegyem: // ??case CPX_ABORT_DUAL_INFEAS // ??case CPX_ABORT_CROSSOVER // ??case CPX_INForUNBD // ??case CPX_PIVOT + LpCplex::SolutionStatus LpCplex::_getPrimalStatus() + { int stat = CPXgetstat (env, lp); switch (stat) { case 0: return UNDEFINED; //Undefined - break; case CPX_OPTIMAL://Optimal return OPTIMAL; - break; case CPX_UNBOUNDED://Unbounded return INFINITE; - break; case CPX_INFEASIBLE://Infeasible - case CPX_IT_LIM_INFEAS: - case CPX_TIME_LIM_INFEAS: - case CPX_NUM_BEST_INFEAS: - case CPX_OPTIMAL_INFEAS: - case CPX_ABORT_INFEAS: - case CPX_ABORT_PRIM_INFEAS: - case CPX_ABORT_PRIM_DUAL_INFEAS: + // case CPX_IT_LIM_INFEAS: +// case CPX_TIME_LIM_INFEAS: +// case CPX_NUM_BEST_INFEAS: +// case CPX_OPTIMAL_INFEAS: +// case CPX_ABORT_INFEAS: +// case CPX_ABORT_PRIM_INFEAS: +// case CPX_ABORT_PRIM_DUAL_INFEAS: return INFEASIBLE; - break; - case CPX_OBJ_LIM: - case CPX_IT_LIM_FEAS: - case CPX_TIME_LIM_FEAS: - case CPX_NUM_BEST_FEAS: - case CPX_ABORT_FEAS: - case CPX_ABORT_PRIM_DUAL_FEAS: - return FEASIBLE; - break; +// case CPX_OBJ_LIM: +// case CPX_IT_LIM_FEAS: +// case CPX_TIME_LIM_FEAS: +// case CPX_NUM_BEST_FEAS: +// case CPX_ABORT_FEAS: +// case CPX_ABORT_PRIM_DUAL_FEAS: +// return FEASIBLE; default: return UNDEFINED; //Everything else comes here //FIXME error } + } - //Nem tudom, hanyas cplex verzio statusai +//9.0-as cplex verzio statusai // CPX_STAT_ABORT_DUAL_OBJ_LIM // CPX_STAT_ABORT_IT_LIM // CPX_STAT_ABORT_OBJ_LIM @@ -333,26 +362,20 @@ // CPX_STAT_OPTIMAL_RELAXED // CPX_STAT_UNBOUNDED -// 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::SolutionStatus LpCplex::_getDualStatus() + { + int stat = CPXgetstat (env, lp); + switch (stat) { + case 0: + return UNDEFINED; //Undefined + case CPX_OPTIMAL://Optimal + return OPTIMAL; + case CPX_UNBOUNDED: + return INFEASIBLE; + default: + return UNDEFINED; //Everything else comes here + //FIXME error + } LpCplex::Value LpCplex::_getPrimal(int i) {