1.1 --- a/src/lemon/lp_base.h Fri Apr 15 22:12:51 2005 +0000
1.2 +++ b/src/lemon/lp_base.h Sun Apr 17 18:57:22 2005 +0000
1.3 @@ -198,7 +198,7 @@
1.4 ///There are several ways to access and modify the contents of this
1.5 ///container.
1.6 ///- Its it fully compatible with \c std::map<Col,double>, so for expamle
1.7 - ///if \c e is an Expr and \c v and \c w are of type \ref Col then you can
1.8 + ///if \c e is an Expr and \c v and \c w are of type \ref Col, then you can
1.9 ///read and modify the coefficients like
1.10 ///these.
1.11 ///\code
1.12 @@ -318,8 +318,29 @@
1.13
1.14 ///Linear constraint
1.15
1.16 - ///\todo document please
1.17 - ///
1.18 + ///This data stucture represents a linear constraint in the LP.
1.19 + ///Basically it is a linear expression with a lower or an upper bound
1.20 + ///(or both). These parts of the constraint can be obtained by the member
1.21 + ///functions \ref expr(), \ref lowerBound() and \ref upperBound(),
1.22 + ///respectively.
1.23 + ///There are two ways to construct a constraint.
1.24 + ///- You can set the linear expression and the bounds directly
1.25 + /// by the functions above.
1.26 + ///- The operators <tt>\<=</tt>, <tt>==</tt> and <tt>\>=</tt>
1.27 + /// are defined between expressions, or even between constraints whenever
1.28 + /// it makes sense. Therefore if \c e and \c f are linear expressions and
1.29 + /// \c s and \c t are numbers, then the followings are valid expressions
1.30 + /// and thus they can be used directly e.g. in \ref addRow() whenever
1.31 + /// it makes sense.
1.32 + /// \code
1.33 + /// e<=s
1.34 + /// e<=f
1.35 + /// s<=e<=t
1.36 + /// e>=t
1.37 + /// \endcode
1.38 + ///\warning The validity of a constraint is checked only at run time, so
1.39 + ///e.g. \ref addRow(<tt>x[1]\<=x[2]<=5</tt>) will compile, but will throw a
1.40 + ///\ref LogicError exception.
1.41 class Constr
1.42 {
1.43 public:
1.44 @@ -327,11 +348,9 @@
1.45 typedef Expr::Key Key;
1.46 typedef Expr::Value Value;
1.47
1.48 - static const Value INF;
1.49 - static const Value NaN;
1.50 - // static const Value INF=0;
1.51 - // static const Value NaN=1;
1.52 -
1.53 +// static const Value INF;
1.54 +// static const Value NaN;
1.55 +
1.56 protected:
1.57 Expr _expr;
1.58 Value _lb,_ub;
1.59 @@ -356,24 +375,35 @@
1.60 _expr.clear();
1.61 _lb=_ub=NaN;
1.62 }
1.63 - ///\e
1.64 +
1.65 + ///Reference to the linear expression
1.66 Expr &expr() { return _expr; }
1.67 - ///\e
1.68 + ///Cont reference to the linear expression
1.69 const Expr &expr() const { return _expr; }
1.70 - ///\e
1.71 + ///Reference to the lower bound.
1.72 +
1.73 + ///\return
1.74 + ///- -\ref INF: the constraint is lower unbounded.
1.75 + ///- -\ref NaN: lower bound has not been set.
1.76 + ///- finite number: the lower bound
1.77 Value &lowerBound() { return _lb; }
1.78 - ///\e
1.79 + ///The const version of \ref lowerBound()
1.80 const Value &lowerBound() const { return _lb; }
1.81 - ///\e
1.82 + ///Reference to the upper bound.
1.83 +
1.84 + ///\return
1.85 + ///- -\ref INF: the constraint is upper unbounded.
1.86 + ///- -\ref NaN: upper bound has not been set.
1.87 + ///- finite number: the upper bound
1.88 Value &upperBound() { return _ub; }
1.89 - ///\e
1.90 + ///The const version of \ref upperBound()
1.91 const Value &upperBound() const { return _ub; }
1.92 - ///\e
1.93 + ///Is the constraint lower bounded?
1.94 bool lowerBounded() const {
1.95 using namespace std;
1.96 return isfinite(_lb);
1.97 }
1.98 - ///\e
1.99 + ///Is the constraint upper bounded?
1.100 bool upperBounded() const {
1.101 using namespace std;
1.102 return isfinite(_ub);
1.103 @@ -386,6 +416,9 @@
1.104 _FixId cols;
1.105
1.106 //Abstract virtual functions
1.107 + virtual LpSolverBase &_newLp() = 0;
1.108 + virtual LpSolverBase &_copyLp() = 0;
1.109 +
1.110 virtual int _addCol() = 0;
1.111 virtual int _addRow() = 0;
1.112 virtual void _setRowCoeffs(int i,
1.113 @@ -426,6 +459,11 @@
1.114 ///\e
1.115 virtual ~LpSolverBase() {}
1.116
1.117 + ///Creates a new LP problem
1.118 + LpSolverBase &newLp() {return _newLp();}
1.119 + ///Make a copy of the LP problem
1.120 + LpSolverBase ©Lp() {return _copyLp();}
1.121 +
1.122 ///\name Build up and modify of the LP
1.123
1.124 ///@{
1.125 @@ -451,7 +489,7 @@
1.126 ///\ref Col as its \c mapped_type
1.127 ///like
1.128 ///\code
1.129 - ///std::map<AnyStatus,LpSolverBase::Col>
1.130 + ///std::map<AnyType,LpSolverBase::Col>
1.131 ///\endcode
1.132 ///- an iterable lemon \ref concept::WriteMap "write map" like
1.133 ///\code
1.134 @@ -459,7 +497,6 @@
1.135 ///ListGraph::EdgeMap<LpSolverBase::Col>
1.136 ///\endcode
1.137 ///\return The number of the created column.
1.138 - ///\bug Iterable nodemap hasn't been implemented yet.
1.139 #ifdef DOXYGEN
1.140 template<class T>
1.141 int addColSet(T &t) { return 0;}
1.142 @@ -668,7 +705,7 @@
1.143 ///\return
1.144 ///- \ref INF or -\ref INF means either infeasibility or unboundedness
1.145 /// of the primal problem, depending on whether we minimize or maximize.
1.146 - ///- \ref NAN if no primal solution is found.
1.147 + ///- \ref NaN if no primal solution is found.
1.148 ///- The (finite) objective value if an optimal solution is found.
1.149 Value primalValue() { return _getPrimalValue()+obj_const_comp;}
1.150 ///@}
1.151 @@ -683,7 +720,7 @@
1.152 const LpSolverBase::Expr &b)
1.153 {
1.154 LpSolverBase::Expr tmp(a);
1.155 - tmp+=b; ///\todo Don't STL have some special 'merge' algorithm?
1.156 + tmp+=b; ///\todo Doesn't STL have some special 'merge' algorithm?
1.157 return tmp;
1.158 }
1.159 ///\e
1.160 @@ -694,7 +731,7 @@
1.161 const LpSolverBase::Expr &b)
1.162 {
1.163 LpSolverBase::Expr tmp(a);
1.164 - tmp-=b; ///\todo Don't STL have some special 'merge' algorithm?
1.165 + tmp-=b; ///\todo Doesn't STL have some special 'merge' algorithm?
1.166 return tmp;
1.167 }
1.168 ///\e
1.169 @@ -705,7 +742,7 @@
1.170 const LpSolverBase::Value &b)
1.171 {
1.172 LpSolverBase::Expr tmp(a);
1.173 - tmp*=b; ///\todo Don't STL have some special 'merge' algorithm?
1.174 + tmp*=b; ///\todo Doesn't STL have some special 'merge' algorithm?
1.175 return tmp;
1.176 }
1.177
1.178 @@ -717,7 +754,7 @@
1.179 const LpSolverBase::Expr &b)
1.180 {
1.181 LpSolverBase::Expr tmp(b);
1.182 - tmp*=a; ///\todo Don't STL have some special 'merge' algorithm?
1.183 + tmp*=a; ///\todo Doesn't STL have some special 'merge' algorithm?
1.184 return tmp;
1.185 }
1.186 ///\e
1.187 @@ -728,7 +765,7 @@
1.188 const LpSolverBase::Value &b)
1.189 {
1.190 LpSolverBase::Expr tmp(a);
1.191 - tmp/=b; ///\todo Don't STL have some special 'merge' algorithm?
1.192 + tmp/=b; ///\todo Doesn't STL have some special 'merge' algorithm?
1.193 return tmp;
1.194 }
1.195