# HG changeset patch # User alpar # Date 1112942772 0 # Node ID 3aaadfb7de3d58ec8b9f19c4288e5e2656a38461 # Parent cfc26d103bcf73d7d2536bb7b226dc0254b4a0f4 The case when the objective function contains a const component is handled correctly. diff -r cfc26d103bcf -r 3aaadfb7de3d src/lemon/lp_base.h --- a/src/lemon/lp_base.h Fri Apr 08 06:34:34 2005 +0000 +++ b/src/lemon/lp_base.h Fri Apr 08 06:46:12 2005 +0000 @@ -101,7 +101,7 @@ ///Common base class for LP solvers class LpSolverBase { - + public: ///\e @@ -375,6 +375,7 @@ _FixId rows; _FixId cols; + //Abstract virtual functions virtual int _addCol() = 0; virtual int _addRow() = 0; virtual void _setRowCoeffs(int i, @@ -397,10 +398,20 @@ virtual void _setMax() = 0; virtual void _setMin() = 0; - + //Own protected stuff + + //Constant component of the objective function + Value obj_const_comp; + + ///\e + + ///\bug Unimplemented void clearObj() {} + public: + ///\e + LpSolverBase() : obj_const_comp(0) {} ///\e virtual ~LpSolverBase() {} @@ -602,11 +613,12 @@ ///Set the objective function ///\param e is a linear expression of type \ref Expr. - ///\todo What to do with the constant component? + ///\bug The previous objective function is not cleared! void setObj(Expr e) { clearObj(); for (Expr::iterator i=e.begin(); i!=e.end(); ++i) objCoeff((*i).first,(*i).second); + obj_const_comp=e.constComp(); } ///Maximize @@ -646,7 +658,7 @@ /// of the primal problem, depending on whether we minimize or maximize. ///- \ref NAN if no primal solution is found. ///- The (finite) objective value if an optimal solution is found. - Value primalValue() { return _getPrimalValue();} + Value primalValue() { return _getPrimalValue()+obj_const_comp;} ///@} };