# HG changeset patch # User marci # Date 1131912077 0 # Node ID 932b8490caf009b3772a1a9285f273515ac5a158 # Parent a263c131e99991ae5dfb913659013a8de721ac22 bugfix in setCol, getting dual values diff -r a263c131e999 -r 932b8490caf0 lemon/lp_base.h --- a/lemon/lp_base.h Thu Nov 10 12:41:33 2005 +0000 +++ b/lemon/lp_base.h Sun Nov 13 20:01:17 2005 +0000 @@ -36,6 +36,7 @@ ///\todo This might be implemented to be also usable in other places. class _FixId { + protected: std::vector index; std::vector cross; int first_free; @@ -592,6 +593,7 @@ // Value const * values ) = 0; virtual SolveExitStatus _solve() = 0; virtual Value _getPrimal(int i) = 0; + virtual Value _getDual(int i) = 0; virtual Value _getPrimalValue() = 0; virtual SolutionStatus _getPrimalStatus() = 0; virtual SolutionStatus _getDualStatus() = 0; @@ -708,7 +710,7 @@ values.push_back(0); for(DualExpr::const_iterator i=e.begin(); i!=e.end(); ++i) if((*i).second!=0) { ///\bug EPSILON would be necessary here!!! - indices.push_back(cols.floatingId((*i).first.id)); + indices.push_back(rows.floatingId((*i).first.id)); values.push_back((*i).second); } _setColCoeffs(cols.floatingId(c.id),indices.size()-1, @@ -1001,6 +1003,9 @@ Value primal(Col c) { return _getPrimal(cols.floatingId(c.id)); } ///\e + Value dual(Row r) { return _getDual(rows.floatingId(r.id)); } + + ///\e ///\return ///- \ref INF or -\ref INF means either infeasibility or unboundedness diff -r a263c131e999 -r 932b8490caf0 lemon/lp_cplex.cc --- a/lemon/lp_cplex.cc Thu Nov 10 12:41:33 2005 +0000 +++ b/lemon/lp_cplex.cc Sun Nov 13 20:01:17 2005 +0000 @@ -267,6 +267,13 @@ CPXgetx(env, lp, &x, i, i); return x; } + + LpCplex::Value LpCplex::_getDual(int i) + { + Value y; + CPXgety(env, lp, &y, i, i); + return y; + } LpCplex::Value LpCplex::_getPrimalValue() { diff -r a263c131e999 -r 932b8490caf0 lemon/lp_cplex.h --- a/lemon/lp_cplex.h Thu Nov 10 12:41:33 2005 +0000 +++ b/lemon/lp_cplex.h Sun Nov 13 20:01:17 2005 +0000 @@ -78,7 +78,7 @@ virtual SolveExitStatus _solve(); virtual Value _getPrimal(int i); - + virtual Value _getDual(int i); virtual Value _getPrimalValue(); diff -r a263c131e999 -r 932b8490caf0 lemon/lp_glpk.cc --- a/lemon/lp_glpk.cc Thu Nov 10 12:41:33 2005 +0000 +++ b/lemon/lp_glpk.cc Sun Nov 13 20:01:17 2005 +0000 @@ -409,6 +409,11 @@ { return lpx_get_col_prim(lp,i); } + + LpGlpk::Value LpGlpk::_getDual(int i) + { + return lpx_get_row_dual(lp,i); + } LpGlpk::Value LpGlpk::_getPrimalValue() { diff -r a263c131e999 -r 932b8490caf0 lemon/lp_glpk.h --- a/lemon/lp_glpk.h Thu Nov 10 12:41:33 2005 +0000 +++ b/lemon/lp_glpk.h Sun Nov 13 20:01:17 2005 +0000 @@ -79,6 +79,7 @@ /// virtual SolveExitStatus _solve(); virtual Value _getPrimal(int i); + virtual Value _getDual(int i); virtual Value _getPrimalValue(); ///\e