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

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


Author: alpar
Date: Sun Apr 17 20:57:22 2005
New Revision: 1809

Modified:
   hugo/trunk/src/lemon/lp_base.cc
   hugo/trunk/src/lemon/lp_base.h
   hugo/trunk/src/lemon/lp_glpk.cc
   hugo/trunk/src/lemon/lp_glpk.h
   hugo/trunk/src/lemon/lp_skeleton.cc
   hugo/trunk/src/lemon/lp_skeleton.h

Log:
- compile failure fixed
- newLp(), copyLp() added
- more doc.

Modified: hugo/trunk/src/lemon/lp_base.cc
==============================================================================
--- hugo/trunk/src/lemon/lp_base.cc	(original)
+++ hugo/trunk/src/lemon/lp_base.cc	Sun Apr 17 20:57:22 2005
@@ -25,9 +25,9 @@
   const LpSolverBase::Value
   LpSolverBase::NaN = std::numeric_limits<Value>::quiet_NaN();
 
-  const LpSolverBase::Constr::Value
-  LpSolverBase::Constr::INF = std::numeric_limits<Value>::infinity();
-  const LpSolverBase::Constr::Value
-  LpSolverBase::Constr::NaN = std::numeric_limits<Value>::quiet_NaN();
+//   const LpSolverBase::Constr::Value
+//   LpSolverBase::Constr::INF = std::numeric_limits<Value>::infinity();
+//   const LpSolverBase::Constr::Value
+//   LpSolverBase::Constr::NaN = std::numeric_limits<Value>::quiet_NaN();
   
 } //namespace lemon

Modified: hugo/trunk/src/lemon/lp_base.h
==============================================================================
--- hugo/trunk/src/lemon/lp_base.h	(original)
+++ hugo/trunk/src/lemon/lp_base.h	Sun Apr 17 20:57:22 2005
@@ -198,7 +198,7 @@
     ///There are several ways to access and modify the contents of this
     ///container.
     ///- Its it fully compatible with \c std::map<Col,double>, so for expamle
-    ///if \c e is an Expr and \c v and \c w are of type \ref Col then you can
+    ///if \c e is an Expr and \c v and \c w are of type \ref Col, then you can
     ///read and modify the coefficients like
     ///these.
     ///\code
@@ -318,8 +318,29 @@
     
     ///Linear constraint
 
-    ///\todo document please
-    ///
+    ///This data stucture represents a linear constraint in the LP.
+    ///Basically it is a linear expression with a lower or an upper bound
+    ///(or both). These parts of the constraint can be obtained by the member
+    ///functions \ref expr(), \ref lowerBound() and \ref upperBound(),
+    ///respectively.
+    ///There are two ways to construct a constraint.
+    ///- You can set the linear expression and the bounds directly
+    ///  by the functions above.
+    ///- The operators <tt>\<=</tt>, <tt>==</tt> and  <tt>\>=</tt>
+    ///  are defined between expressions, or even between constraints whenever
+    ///  it makes sense. Therefore if \c e and \c f are linear expressions and
+    ///  \c s and \c t are numbers, then the followings are valid expressions
+    ///  and thus they can be used directly e.g. in \ref addRow() whenever
+    ///  it makes sense.
+    ///  \code
+    ///  e<=s
+    ///  e<=f
+    ///  s<=e<=t
+    ///  e>=t
+    ///  \endcode
+    ///\warning The validity of a constraint is checked only at run time, so
+    ///e.g. \ref addRow(<tt>x[1]\<=x[2]<=5</tt>) will compile, but will throw a
+    ///\ref LogicError exception.
     class Constr
     {
     public:
@@ -327,11 +348,9 @@
       typedef Expr::Key Key;
       typedef Expr::Value Value;
       
-      static const Value INF;
-      static const Value NaN;
-      //     static const Value INF=0;
-      //     static const Value NaN=1;
-      
+//       static const Value INF;
+//       static const Value NaN;
+
     protected:
       Expr _expr;
       Value _lb,_ub;
@@ -356,24 +375,35 @@
 	_expr.clear();
 	_lb=_ub=NaN;
       }
-      ///\e
+
+      ///Reference to the linear expression 
       Expr &expr() { return _expr; }
-      ///\e
+      ///Cont reference to the linear expression 
       const Expr &expr() const { return _expr; }
-      ///\e
+      ///Reference to the lower bound.
+
+      ///\return
+      ///- -\ref INF: the constraint is lower unbounded.
+      ///- -\ref NaN: lower bound has not been set.
+      ///- finite number: the lower bound
       Value &lowerBound() { return _lb; }
-      ///\e
+      ///The const version of \ref lowerBound()
       const Value &lowerBound() const { return _lb; }
-      ///\e
+      ///Reference to the upper bound.
+
+      ///\return
+      ///- -\ref INF: the constraint is upper unbounded.
+      ///- -\ref NaN: upper bound has not been set.
+      ///- finite number: the upper bound
       Value &upperBound() { return _ub; }
-      ///\e
+      ///The const version of \ref upperBound()
       const Value &upperBound() const { return _ub; }
-      ///\e
+      ///Is the constraint lower bounded?
       bool lowerBounded() const { 
 	using namespace std;
 	return isfinite(_lb);
       }
-      ///\e
+      ///Is the constraint upper bounded?
       bool upperBounded() const {
 	using namespace std;
 	return isfinite(_ub);
@@ -386,6 +416,9 @@
     _FixId cols;
 
     //Abstract virtual functions
+    virtual LpSolverBase &_newLp() = 0;
+    virtual LpSolverBase &_copyLp() = 0;
+
     virtual int _addCol() = 0;
     virtual int _addRow() = 0;
     virtual void _setRowCoeffs(int i, 
@@ -426,6 +459,11 @@
     ///\e
     virtual ~LpSolverBase() {}
 
+    ///Creates a new LP problem
+    LpSolverBase &newLp() {return _newLp();}
+    ///Make a copy of the LP problem
+    LpSolverBase &copyLp() {return _copyLp();}
+    
     ///\name Build up and modify of the LP
 
     ///@{
@@ -451,7 +489,7 @@
     ///\ref Col as its \c mapped_type
     ///like
     ///\code
-    ///std::map<AnyStatus,LpSolverBase::Col>
+    ///std::map<AnyType,LpSolverBase::Col>
     ///\endcode
     ///- an iterable lemon \ref concept::WriteMap "write map" like 
     ///\code
@@ -459,7 +497,6 @@
     ///ListGraph::EdgeMap<LpSolverBase::Col>
     ///\endcode
     ///\return The number of the created column.
-    ///\bug Iterable nodemap hasn't been implemented yet.
 #ifdef DOXYGEN
     template<class T>
     int addColSet(T &t) { return 0;} 
@@ -668,7 +705,7 @@
     ///\return
     ///- \ref INF or -\ref INF means either infeasibility or unboundedness
     /// of the primal problem, depending on whether we minimize or maximize.
-    ///- \ref NAN if no primal solution is found.
+    ///- \ref NaN if no primal solution is found.
     ///- The (finite) objective value if an optimal solution is found.
     Value primalValue() { return _getPrimalValue()+obj_const_comp;}
     ///@}
@@ -683,7 +720,7 @@
 				      const LpSolverBase::Expr &b) 
   {
     LpSolverBase::Expr tmp(a);
-    tmp+=b; ///\todo Don't STL have some special 'merge' algorithm?
+    tmp+=b; ///\todo Doesn't STL have some special 'merge' algorithm?
     return tmp;
   }
   ///\e
@@ -694,7 +731,7 @@
 				      const LpSolverBase::Expr &b) 
   {
     LpSolverBase::Expr tmp(a);
-    tmp-=b; ///\todo Don't STL have some special 'merge' algorithm?
+    tmp-=b; ///\todo Doesn't STL have some special 'merge' algorithm?
     return tmp;
   }
   ///\e
@@ -705,7 +742,7 @@
 				      const LpSolverBase::Value &b) 
   {
     LpSolverBase::Expr tmp(a);
-    tmp*=b; ///\todo Don't STL have some special 'merge' algorithm?
+    tmp*=b; ///\todo Doesn't STL have some special 'merge' algorithm?
     return tmp;
   }
   
@@ -717,7 +754,7 @@
 				      const LpSolverBase::Expr &b) 
   {
     LpSolverBase::Expr tmp(b);
-    tmp*=a; ///\todo Don't STL have some special 'merge' algorithm?
+    tmp*=a; ///\todo Doesn't STL have some special 'merge' algorithm?
     return tmp;
   }
   ///\e
@@ -728,7 +765,7 @@
 				      const LpSolverBase::Value &b) 
   {
     LpSolverBase::Expr tmp(a);
-    tmp/=b; ///\todo Don't STL have some special 'merge' algorithm?
+    tmp/=b; ///\todo Doesn't STL have some special 'merge' algorithm?
     return tmp;
   }
   

Modified: hugo/trunk/src/lemon/lp_glpk.cc
==============================================================================
--- hugo/trunk/src/lemon/lp_glpk.cc	(original)
+++ hugo/trunk/src/lemon/lp_glpk.cc	Sun Apr 17 20:57:22 2005
@@ -24,6 +24,24 @@
 
 namespace lemon {
 
+  ///\e
+
+  ///\bug Unimplemented!
+  ///
+  LpSolverBase &LpGlpk::_newLp()
+  {
+    return *((LpSolverBase *)0);
+  }
+  
+  ///\e
+
+  ///\bug Unimplemented!
+  ///
+  LpSolverBase &LpGlpk::_copyLp()
+  {
+    return *((LpSolverBase *)0);
+  }
+
   LpGlpk::LpGlpk() : Parent(), 
 		     lp(lpx_create_prob()) {
     ///\todo constrol function for this:

Modified: hugo/trunk/src/lemon/lp_glpk.h
==============================================================================
--- hugo/trunk/src/lemon/lp_glpk.h	(original)
+++ hugo/trunk/src/lemon/lp_glpk.h	Sun Apr 17 20:57:22 2005
@@ -31,7 +31,7 @@
 
   /// \brief Wrapper for GLPK solver
   /// 
-  /// This class implements a lemon wrapper for GLPK.
+  /// This class implements an interface for GLPK.
   ///\ingroup gen_opt_group
   class LpGlpk : public LpSolverBase {
   protected:
@@ -45,6 +45,9 @@
     ~LpGlpk();
     
   protected:
+    virtual LpSolverBase &_newLp();
+    virtual LpSolverBase &_copyLp();
+
     virtual int _addCol();
     virtual int _addRow();
     virtual void _setRowCoeffs(int i, 

Modified: hugo/trunk/src/lemon/lp_skeleton.cc
==============================================================================
--- hugo/trunk/src/lemon/lp_skeleton.cc	(original)
+++ hugo/trunk/src/lemon/lp_skeleton.cc	Sun Apr 17 20:57:22 2005
@@ -21,6 +21,16 @@
 ///\brief A skeleton file to implement LP solver interfaces
 namespace lemon {
   
+  LpSolverBase &LpSkeleton::_newLp()
+  {
+    return *((LpSolverBase *)0);
+  }
+  
+  LpSolverBase &LpSkeleton::_copyLp()
+  {
+    return *((LpSolverBase *)0);
+  }
+
   int LpSkeleton::_addCol()
   {
     return ++col_num;

Modified: hugo/trunk/src/lemon/lp_skeleton.h
==============================================================================
--- hugo/trunk/src/lemon/lp_skeleton.h	(original)
+++ hugo/trunk/src/lemon/lp_skeleton.h	Sun Apr 17 20:57:22 2005
@@ -29,6 +29,10 @@
     int col_num,row_num;
     
   protected:
+    ///\e
+    virtual LpSolverBase &_newLp();
+    ///\e
+    virtual LpSolverBase &_copyLp();
     /// \e
     virtual int _addCol();
     /// \e



More information about the Lemon-commits mailing list