[Lemon-commits] [lemon_svn] alpar: r1762 - hugo/trunk/src/lemon

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:47:24 CET 2006


Author: alpar
Date: Fri Apr  8 08:46:12 2005
New Revision: 1762

Modified:
   hugo/trunk/src/lemon/lp_base.h

Log:
The case when the objective function contains a const component is handled
correctly.

Modified: hugo/trunk/src/lemon/lp_base.h
==============================================================================
--- hugo/trunk/src/lemon/lp_base.h	(original)
+++ hugo/trunk/src/lemon/lp_base.h	Fri Apr  8 08:46:12 2005
@@ -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;}
     ///@}
     
   };  



More information about the Lemon-commits mailing list