bugfix in setCol, getting dual values
authormarci
Sun, 13 Nov 2005 20:01:17 +0000
changeset 1787932b8490caf0
parent 1786 a263c131e999
child 1788 614ce2dd3cba
bugfix in setCol, getting dual values
lemon/lp_base.h
lemon/lp_cplex.cc
lemon/lp_cplex.h
lemon/lp_glpk.cc
lemon/lp_glpk.h
     1.1 --- a/lemon/lp_base.h	Thu Nov 10 12:41:33 2005 +0000
     1.2 +++ b/lemon/lp_base.h	Sun Nov 13 20:01:17 2005 +0000
     1.3 @@ -36,6 +36,7 @@
     1.4    ///\todo This might be implemented to be also usable in other places.
     1.5    class _FixId 
     1.6    {
     1.7 +  protected:
     1.8      std::vector<int> index;
     1.9      std::vector<int> cross;
    1.10      int first_free;
    1.11 @@ -592,6 +593,7 @@
    1.12  //                          Value  const * values ) = 0;
    1.13      virtual SolveExitStatus _solve() = 0;
    1.14      virtual Value _getPrimal(int i) = 0;
    1.15 +    virtual Value _getDual(int i) = 0;
    1.16      virtual Value _getPrimalValue() = 0;
    1.17      virtual SolutionStatus _getPrimalStatus() = 0;
    1.18      virtual SolutionStatus _getDualStatus() = 0;
    1.19 @@ -708,7 +710,7 @@
    1.20        values.push_back(0);
    1.21        for(DualExpr::const_iterator i=e.begin(); i!=e.end(); ++i)
    1.22  	if((*i).second!=0) { ///\bug EPSILON would be necessary here!!!
    1.23 -	  indices.push_back(cols.floatingId((*i).first.id));
    1.24 +	  indices.push_back(rows.floatingId((*i).first.id));
    1.25  	  values.push_back((*i).second);
    1.26  	}
    1.27        _setColCoeffs(cols.floatingId(c.id),indices.size()-1,
    1.28 @@ -1001,6 +1003,9 @@
    1.29      Value primal(Col c) { return _getPrimal(cols.floatingId(c.id)); }
    1.30  
    1.31      ///\e
    1.32 +    Value dual(Row r) { return _getDual(rows.floatingId(r.id)); }
    1.33 +
    1.34 +    ///\e
    1.35  
    1.36      ///\return
    1.37      ///- \ref INF or -\ref INF means either infeasibility or unboundedness
     2.1 --- a/lemon/lp_cplex.cc	Thu Nov 10 12:41:33 2005 +0000
     2.2 +++ b/lemon/lp_cplex.cc	Sun Nov 13 20:01:17 2005 +0000
     2.3 @@ -267,6 +267,13 @@
     2.4      CPXgetx(env, lp, &x, i, i);
     2.5      return x;
     2.6    }
     2.7 +
     2.8 +  LpCplex::Value LpCplex::_getDual(int i)
     2.9 +  {
    2.10 +    Value y;
    2.11 +    CPXgety(env, lp, &y, i, i);
    2.12 +    return y;
    2.13 +  }
    2.14    
    2.15    LpCplex::Value LpCplex::_getPrimalValue()
    2.16    {
     3.1 --- a/lemon/lp_cplex.h	Thu Nov 10 12:41:33 2005 +0000
     3.2 +++ b/lemon/lp_cplex.h	Sun Nov 13 20:01:17 2005 +0000
     3.3 @@ -78,7 +78,7 @@
     3.4      virtual SolveExitStatus _solve();
     3.5  
     3.6      virtual Value _getPrimal(int i);
     3.7 -
     3.8 +    virtual Value _getDual(int i);
     3.9      
    3.10      virtual Value _getPrimalValue();
    3.11      
     4.1 --- a/lemon/lp_glpk.cc	Thu Nov 10 12:41:33 2005 +0000
     4.2 +++ b/lemon/lp_glpk.cc	Sun Nov 13 20:01:17 2005 +0000
     4.3 @@ -409,6 +409,11 @@
     4.4    {
     4.5      return lpx_get_col_prim(lp,i);
     4.6    }
     4.7 +
     4.8 +  LpGlpk::Value LpGlpk::_getDual(int i)
     4.9 +  {
    4.10 +    return lpx_get_row_dual(lp,i);
    4.11 +  }
    4.12    
    4.13    LpGlpk::Value LpGlpk::_getPrimalValue()
    4.14    {
     5.1 --- a/lemon/lp_glpk.h	Thu Nov 10 12:41:33 2005 +0000
     5.2 +++ b/lemon/lp_glpk.h	Sun Nov 13 20:01:17 2005 +0000
     5.3 @@ -79,6 +79,7 @@
     5.4      ///
     5.5      virtual SolveExitStatus _solve();
     5.6      virtual Value _getPrimal(int i);
     5.7 +    virtual Value _getDual(int i);
     5.8      virtual Value _getPrimalValue();
     5.9      ///\e
    5.10