# HG changeset patch # User athos # Date 1118329438 0 # Node ID 7c58aabb9eea1be59b2dd2948b700e78b1da8ef7 # Parent 2ee881cf30a8392581b9b0f6f66e23a2846a13b7 I could not check, because: aclocal-1.7: command not found diff -r 2ee881cf30a8 -r 7c58aabb9eea lemon/lp_base.h --- a/lemon/lp_base.h Thu Jun 09 09:49:56 2005 +0000 +++ b/lemon/lp_base.h Thu Jun 09 15:03:58 2005 +0000 @@ -118,7 +118,7 @@ UNSOLVED = 1 }; - ///\e + ///\e enum SolutionStatus { ///Feasible solution has'n been found (but may exist). @@ -137,6 +137,20 @@ ///corresponding bases) INFINITE = 4 }; + + ///\e The type of the investigated LP problem + enum Problemtypes { + ///Primal-dual feasible + PRIMAL_DUAL_FEASIBLE = 0, + ///Primal feasible dual infeasible + PRIMAL_FEASIBLE_DUAL_INFEASIBLE = 1, + ///Primal infeasible dual feasible + PRIMAL_INFEASIBLE_DUAL_FEASIBLE = 2, + ///Primal-dual infeasible + PRIMAL_DUAL_INFEASIBLE = 3, + ///Could not determine so far + UNKNOWN = 4 + }; ///The floating point type used by the solver typedef double Value; @@ -563,6 +577,11 @@ virtual Value _getPrimal(int i) = 0; virtual Value _getPrimalValue() = 0; virtual SolutionStatus _getPrimalStatus() = 0; + virtual SolutionStatus _getDualStatus() = 0; + ///\todo This could be implemented here, too, using _getPrimalStatus() and + ///_getDualStatus() + virtual ProblemTypes _getProblemType() = 0; + virtual void _setMax() = 0; virtual void _setMin() = 0; @@ -930,11 +949,21 @@ ///@{ - ///\e + /// The status of the primal problem (the original LP problem) SolutionStatus primalStatus() { return _getPrimalStatus(); } + /// The status of the dual (of the original LP) problem + SolutionStatus dualStatus() { + return _getDualStatus(); + } + + ///The type of the original LP problem + Problemtypes problemType() { + return _getProblemType(); + } + ///\e Value primal(Col c) { return _getPrimal(cols.floatingId(c.id)); } diff -r 2ee881cf30a8 -r 7c58aabb9eea lemon/lp_cplex.cc --- a/lemon/lp_cplex.cc Thu Jun 09 09:49:56 2005 +0000 +++ b/lemon/lp_cplex.cc Thu Jun 09 15:03:58 2005 +0000 @@ -260,6 +260,21 @@ } } + LpCplex::Value LpCplex::_getPrimal(int i) + { + Value x; + CPXgetx (env, lp, &x, i, i); + return x; + } + + LpCplex::Value LpCplex::_getPrimalValue() + { + Value objval; + //method = CPXgetmethod (env, lp); + status = CPXgetobjval (env, lp, &objval); + return objval; + } + //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. @@ -377,22 +392,24 @@ //FIXME error } - LpCplex::Value LpCplex::_getPrimal(int i) + + LpCplex::ProblemTypes LpCplex::_getProblemType() { - Value x; - CPXgetx (env, lp, &x, i, i); - return x; - } - - LpCplex::Value LpCplex::_getPrimalValue() - { - Value objval; - //method = CPXgetmethod (env, lp); - status = CPXgetobjval (env, lp, &objval); - return objval; - } - - + int stat = CPXgetstat (env, lp); + switch (stat) { + case CPX_OPTIMAL://Optimal + return PRIMAL_DUAL_FEASIBLE; + case CPX_UNBOUNDED: + return PRIMAL_FEASIBLE_DUAL_INFEASIBLE; +// return PRIMAL_INFEASIBLE_DUAL_FEASIBLE; +// return PRIMAL_DUAL_INFEASIBLE; + +//Seems to be that this is all we can say for sure + default: + //In all other cases + return UNKNOWN; + //FIXME error + } void LpCplex::_setMax() diff -r 2ee881cf30a8 -r 7c58aabb9eea lemon/lp_cplex.h --- a/lemon/lp_cplex.h Thu Jun 09 09:49:56 2005 +0000 +++ b/lemon/lp_cplex.h Thu Jun 09 15:03:58 2005 +0000 @@ -75,34 +75,19 @@ virtual void _clearObj(); ///\e - ///\bug Unimplemented - /// virtual SolveExitStatus _solve(); - ///\e - ///\bug Unimplemented - /// virtual Value _getPrimal(int i); - ///\e + - ///\bug Unimplemented - /// virtual Value _getPrimalValue(); - ///\e - ///\bug Unimplemented - /// virtual SolutionStatus _getPrimalStatus(); + virtual SolutionStatus _getDualStatus(); + virtual ProblemTypes _getProblemType(); - ///\e - ///\bug Unimplemented - /// virtual void _setMax(); - ///\e - - ///\bug Unimplemented - /// virtual void _setMin(); }; diff -r 2ee881cf30a8 -r 7c58aabb9eea lemon/lp_glpk.cc --- a/lemon/lp_glpk.cc Thu Jun 09 09:49:56 2005 +0000 +++ b/lemon/lp_glpk.cc Thu Jun 09 15:03:58 2005 +0000 @@ -444,7 +444,7 @@ case LPX_D_UNDEF://Undefined (no solve has been run yet) return UNDEFINED; case LPX_D_NOFEAS://There is no feasible solution (primal, I guess) - case LPX_D_INFEAS://Infeasible +// case LPX_D_INFEAS://Infeasible return INFEASIBLE; case LPX_FEAS://Feasible int stat2= lpx_get_prim_stat(lp); @@ -464,30 +464,19 @@ LpGlpk::ProblemTypes LpGlpk::_problemType() { - int stat= lpx_get_status(lp); + //int stat= lpx_get_status(lp); int statp= lpx_get_prim_stat(lp); int statd= lpx_get_dual_stat(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 - } + if (statp==LP_P_FEAS && statd==LP_D_FEAS) + return PRIMAL_DUAL_FEASIBLE; + if (statp==LP_P_FEAS && statd==LP_D_NOFEAS) + return PRIMAL_FEASIBLE_DUAL_INFEASIBLE; + if (statp==LP_P_NOFEAS && statd==LP_D_FEAS) + return PRIMAL_INFEASIBLE_DUAL_FEASIBLE; + if (statp==LP_P_NOFEAS && statd==LP_D_NOFEAS) + return PRIMAL_DUAL_INFEASIBLE; + //In all other cases + return UNKNOWN; } void LpGlpk::_setMax() diff -r 2ee881cf30a8 -r 7c58aabb9eea lemon/lp_glpk.h --- a/lemon/lp_glpk.h Thu Jun 09 09:49:56 2005 +0000 +++ b/lemon/lp_glpk.h Thu Jun 09 15:03:58 2005 +0000 @@ -85,6 +85,9 @@ ///\todo It should be clarified /// virtual SolutionStatus _getPrimalStatus(); + virtual SolutionStatus _getDualStatus(); + virtual ProblemTypes _getProblemType(); + virtual void _setMax(); virtual void _setMin(); diff -r 2ee881cf30a8 -r 7c58aabb9eea lemon/lp_skeleton.cc --- a/lemon/lp_skeleton.cc Thu Jun 09 09:49:56 2005 +0000 +++ b/lemon/lp_skeleton.cc Thu Jun 09 15:03:58 2005 +0000 @@ -120,7 +120,17 @@ LpSkeleton::SolutionStatus LpSkeleton::_getPrimalStatus() { - return OPTIMAL; + return UNDEFINED; + } + + LpSkeleton::SolutionStatus LpSkeleton::_getDualStatus() + { + return UNDEFINED; + } + + LpSkeleton::ProblemTypes LpSkeleton::_getProblemType() + { + return UNKNOWN; } } //namespace lemon diff -r 2ee881cf30a8 -r 7c58aabb9eea lemon/lp_skeleton.h --- a/lemon/lp_skeleton.h Thu Jun 09 09:49:56 2005 +0000 +++ b/lemon/lp_skeleton.h Thu Jun 09 15:03:58 2005 +0000 @@ -118,6 +118,13 @@ /// virtual SolutionStatus _getPrimalStatus(); + ////e + virtual SolutionStatus _getDualStatus(); + + + ///\e + virtual ProblemTypes _getProblemType(); + ///\e virtual void _setMax(); ///\e