The case when the objective function contains a const component is handled
authoralpar
Fri, 08 Apr 2005 06:46:12 +0000
changeset 13233aaadfb7de3d
parent 1322 cfc26d103bcf
child 1324 eca073533990
The case when the objective function contains a const component is handled
correctly.
src/lemon/lp_base.h
     1.1 --- a/src/lemon/lp_base.h	Fri Apr 08 06:34:34 2005 +0000
     1.2 +++ b/src/lemon/lp_base.h	Fri Apr 08 06:46:12 2005 +0000
     1.3 @@ -101,7 +101,7 @@
     1.4      
     1.5    ///Common base class for LP solvers
     1.6    class LpSolverBase {
     1.7 -    
     1.8 +
     1.9    public:
    1.10  
    1.11      ///\e
    1.12 @@ -375,6 +375,7 @@
    1.13      _FixId rows;
    1.14      _FixId cols;
    1.15  
    1.16 +    //Abstract virtual functions
    1.17      virtual int _addCol() = 0;
    1.18      virtual int _addRow() = 0;
    1.19      virtual void _setRowCoeffs(int i, 
    1.20 @@ -397,10 +398,20 @@
    1.21      virtual void _setMax() = 0;
    1.22      virtual void _setMin() = 0;
    1.23      
    1.24 -
    1.25 +    //Own protected stuff
    1.26 +    
    1.27 +    //Constant component of the objective function
    1.28 +    Value obj_const_comp;
    1.29 +    
    1.30 +    ///\e
    1.31 +    
    1.32 +    ///\bug Unimplemented
    1.33      void clearObj() {}
    1.34 +    
    1.35    public:
    1.36  
    1.37 +    ///\e
    1.38 +    LpSolverBase() : obj_const_comp(0) {}
    1.39  
    1.40      ///\e
    1.41      virtual ~LpSolverBase() {}
    1.42 @@ -602,11 +613,12 @@
    1.43      ///Set the objective function
    1.44      
    1.45      ///\param e is a linear expression of type \ref Expr.
    1.46 -    ///\todo What to do with the constant component?
    1.47 +    ///\bug The previous objective function is not cleared!
    1.48      void setObj(Expr e) {
    1.49        clearObj();
    1.50        for (Expr::iterator i=e.begin(); i!=e.end(); ++i)
    1.51  	objCoeff((*i).first,(*i).second);
    1.52 +      obj_const_comp=e.constComp();
    1.53      }
    1.54  
    1.55      ///Maximize
    1.56 @@ -646,7 +658,7 @@
    1.57      /// of the primal problem, depending on whether we minimize or maximize.
    1.58      ///- \ref NAN if no primal solution is found.
    1.59      ///- The (finite) objective value if an optimal solution is found.
    1.60 -    Value primalValue() { return _getPrimalValue();}
    1.61 +    Value primalValue() { return _getPrimalValue()+obj_const_comp;}
    1.62      ///@}
    1.63      
    1.64    };