_setObj function
authorathos
Wed, 20 Apr 2005 14:29:23 +0000
changeset 13768de0c1aeeb32
parent 1375 ebdce4f68ac4
child 1377 bfbb5b30c5b8
_setObj function
src/lemon/lp_base.h
src/lemon/lp_glpk.cc
src/lemon/lp_glpk.h
     1.1 --- a/src/lemon/lp_base.h	Tue Apr 19 14:15:01 2005 +0000
     1.2 +++ b/src/lemon/lp_base.h	Wed Apr 20 14:29:23 2005 +0000
     1.3 @@ -434,6 +434,9 @@
     1.4      virtual void _setRowLowerBound(int i, Value value) = 0;
     1.5      virtual void _setRowUpperBound(int i, Value value) = 0;
     1.6      virtual void _setObjCoeff(int i, Value obj_coef) = 0;
     1.7 +    virtual void _setObj(int length,
     1.8 +                         int  const * indices, 
     1.9 +                         Value  const * values ) = 0;
    1.10      virtual SolveExitStatus _solve() = 0;
    1.11      virtual Value _getPrimal(int i) = 0;
    1.12      virtual Value _getPrimalValue() = 0;
     2.1 --- a/src/lemon/lp_glpk.cc	Tue Apr 19 14:15:01 2005 +0000
     2.2 +++ b/src/lemon/lp_glpk.cc	Wed Apr 20 14:29:23 2005 +0000
     2.3 @@ -263,9 +263,26 @@
     2.4    
     2.5    void LpGlpk::_setObjCoeff(int i, Value obj_coef)
     2.6    {
     2.7 +    //i=0 means the constant term (shift)
     2.8      lpx_set_obj_coef(lp, i, obj_coef);
     2.9    }
    2.10  
    2.11 +  void LpGlpk::_setObj(int length,
    2.12 +		       int  const * indices, 
    2.13 +		       Value  const * values )
    2.14 +  {
    2.15 +    Value new_values[1+lpx_num_cols()];
    2.16 +    for (i=0;i<=lpx_num_cols();++i){
    2.17 +      new_values[i]=0;
    2.18 +    }
    2.19 +    for (i=1;i<=length;++i){
    2.20 +      new_values[indices[i]]=values[i];
    2.21 +    }
    2.22 +    
    2.23 +    for (i=0;i<=lpx_num_cols();++i){
    2.24 +      lpx_set_obj_coef(lp, i, new_values[i]);
    2.25 +    }
    2.26 +  }
    2.27  
    2.28    LpGlpk::SolveExitStatus LpGlpk::_solve()
    2.29    {
     3.1 --- a/src/lemon/lp_glpk.h	Tue Apr 19 14:15:01 2005 +0000
     3.2 +++ b/src/lemon/lp_glpk.h	Wed Apr 20 14:29:23 2005 +0000
     3.3 @@ -63,6 +63,10 @@
     3.4      virtual void _setRowLowerBound(int i, Value value);
     3.5      virtual void _setRowUpperBound(int i, Value value);
     3.6      virtual void _setObjCoeff(int i, Value obj_coef);
     3.7 +    virtual void _setObj(int length,
     3.8 +                         int  const * indices, 
     3.9 +                         Value  const * values ) = 0;
    3.10 +
    3.11      ///\e
    3.12      
    3.13      ///\todo It should be clarified