1.1 --- a/src/lemon/lp_base.cc Fri Apr 15 22:12:51 2005 +0000
1.2 +++ b/src/lemon/lp_base.cc Sun Apr 17 18:57:22 2005 +0000
1.3 @@ -25,9 +25,9 @@
1.4 const LpSolverBase::Value
1.5 LpSolverBase::NaN = std::numeric_limits<Value>::quiet_NaN();
1.6
1.7 - const LpSolverBase::Constr::Value
1.8 - LpSolverBase::Constr::INF = std::numeric_limits<Value>::infinity();
1.9 - const LpSolverBase::Constr::Value
1.10 - LpSolverBase::Constr::NaN = std::numeric_limits<Value>::quiet_NaN();
1.11 +// const LpSolverBase::Constr::Value
1.12 +// LpSolverBase::Constr::INF = std::numeric_limits<Value>::infinity();
1.13 +// const LpSolverBase::Constr::Value
1.14 +// LpSolverBase::Constr::NaN = std::numeric_limits<Value>::quiet_NaN();
1.15
1.16 } //namespace lemon
2.1 --- a/src/lemon/lp_base.h Fri Apr 15 22:12:51 2005 +0000
2.2 +++ b/src/lemon/lp_base.h Sun Apr 17 18:57:22 2005 +0000
2.3 @@ -198,7 +198,7 @@
2.4 ///There are several ways to access and modify the contents of this
2.5 ///container.
2.6 ///- Its it fully compatible with \c std::map<Col,double>, so for expamle
2.7 - ///if \c e is an Expr and \c v and \c w are of type \ref Col then you can
2.8 + ///if \c e is an Expr and \c v and \c w are of type \ref Col, then you can
2.9 ///read and modify the coefficients like
2.10 ///these.
2.11 ///\code
2.12 @@ -318,8 +318,29 @@
2.13
2.14 ///Linear constraint
2.15
2.16 - ///\todo document please
2.17 - ///
2.18 + ///This data stucture represents a linear constraint in the LP.
2.19 + ///Basically it is a linear expression with a lower or an upper bound
2.20 + ///(or both). These parts of the constraint can be obtained by the member
2.21 + ///functions \ref expr(), \ref lowerBound() and \ref upperBound(),
2.22 + ///respectively.
2.23 + ///There are two ways to construct a constraint.
2.24 + ///- You can set the linear expression and the bounds directly
2.25 + /// by the functions above.
2.26 + ///- The operators <tt>\<=</tt>, <tt>==</tt> and <tt>\>=</tt>
2.27 + /// are defined between expressions, or even between constraints whenever
2.28 + /// it makes sense. Therefore if \c e and \c f are linear expressions and
2.29 + /// \c s and \c t are numbers, then the followings are valid expressions
2.30 + /// and thus they can be used directly e.g. in \ref addRow() whenever
2.31 + /// it makes sense.
2.32 + /// \code
2.33 + /// e<=s
2.34 + /// e<=f
2.35 + /// s<=e<=t
2.36 + /// e>=t
2.37 + /// \endcode
2.38 + ///\warning The validity of a constraint is checked only at run time, so
2.39 + ///e.g. \ref addRow(<tt>x[1]\<=x[2]<=5</tt>) will compile, but will throw a
2.40 + ///\ref LogicError exception.
2.41 class Constr
2.42 {
2.43 public:
2.44 @@ -327,11 +348,9 @@
2.45 typedef Expr::Key Key;
2.46 typedef Expr::Value Value;
2.47
2.48 - static const Value INF;
2.49 - static const Value NaN;
2.50 - // static const Value INF=0;
2.51 - // static const Value NaN=1;
2.52 -
2.53 +// static const Value INF;
2.54 +// static const Value NaN;
2.55 +
2.56 protected:
2.57 Expr _expr;
2.58 Value _lb,_ub;
2.59 @@ -356,24 +375,35 @@
2.60 _expr.clear();
2.61 _lb=_ub=NaN;
2.62 }
2.63 - ///\e
2.64 +
2.65 + ///Reference to the linear expression
2.66 Expr &expr() { return _expr; }
2.67 - ///\e
2.68 + ///Cont reference to the linear expression
2.69 const Expr &expr() const { return _expr; }
2.70 - ///\e
2.71 + ///Reference to the lower bound.
2.72 +
2.73 + ///\return
2.74 + ///- -\ref INF: the constraint is lower unbounded.
2.75 + ///- -\ref NaN: lower bound has not been set.
2.76 + ///- finite number: the lower bound
2.77 Value &lowerBound() { return _lb; }
2.78 - ///\e
2.79 + ///The const version of \ref lowerBound()
2.80 const Value &lowerBound() const { return _lb; }
2.81 - ///\e
2.82 + ///Reference to the upper bound.
2.83 +
2.84 + ///\return
2.85 + ///- -\ref INF: the constraint is upper unbounded.
2.86 + ///- -\ref NaN: upper bound has not been set.
2.87 + ///- finite number: the upper bound
2.88 Value &upperBound() { return _ub; }
2.89 - ///\e
2.90 + ///The const version of \ref upperBound()
2.91 const Value &upperBound() const { return _ub; }
2.92 - ///\e
2.93 + ///Is the constraint lower bounded?
2.94 bool lowerBounded() const {
2.95 using namespace std;
2.96 return isfinite(_lb);
2.97 }
2.98 - ///\e
2.99 + ///Is the constraint upper bounded?
2.100 bool upperBounded() const {
2.101 using namespace std;
2.102 return isfinite(_ub);
2.103 @@ -386,6 +416,9 @@
2.104 _FixId cols;
2.105
2.106 //Abstract virtual functions
2.107 + virtual LpSolverBase &_newLp() = 0;
2.108 + virtual LpSolverBase &_copyLp() = 0;
2.109 +
2.110 virtual int _addCol() = 0;
2.111 virtual int _addRow() = 0;
2.112 virtual void _setRowCoeffs(int i,
2.113 @@ -426,6 +459,11 @@
2.114 ///\e
2.115 virtual ~LpSolverBase() {}
2.116
2.117 + ///Creates a new LP problem
2.118 + LpSolverBase &newLp() {return _newLp();}
2.119 + ///Make a copy of the LP problem
2.120 + LpSolverBase ©Lp() {return _copyLp();}
2.121 +
2.122 ///\name Build up and modify of the LP
2.123
2.124 ///@{
2.125 @@ -451,7 +489,7 @@
2.126 ///\ref Col as its \c mapped_type
2.127 ///like
2.128 ///\code
2.129 - ///std::map<AnyStatus,LpSolverBase::Col>
2.130 + ///std::map<AnyType,LpSolverBase::Col>
2.131 ///\endcode
2.132 ///- an iterable lemon \ref concept::WriteMap "write map" like
2.133 ///\code
2.134 @@ -459,7 +497,6 @@
2.135 ///ListGraph::EdgeMap<LpSolverBase::Col>
2.136 ///\endcode
2.137 ///\return The number of the created column.
2.138 - ///\bug Iterable nodemap hasn't been implemented yet.
2.139 #ifdef DOXYGEN
2.140 template<class T>
2.141 int addColSet(T &t) { return 0;}
2.142 @@ -668,7 +705,7 @@
2.143 ///\return
2.144 ///- \ref INF or -\ref INF means either infeasibility or unboundedness
2.145 /// of the primal problem, depending on whether we minimize or maximize.
2.146 - ///- \ref NAN if no primal solution is found.
2.147 + ///- \ref NaN if no primal solution is found.
2.148 ///- The (finite) objective value if an optimal solution is found.
2.149 Value primalValue() { return _getPrimalValue()+obj_const_comp;}
2.150 ///@}
2.151 @@ -683,7 +720,7 @@
2.152 const LpSolverBase::Expr &b)
2.153 {
2.154 LpSolverBase::Expr tmp(a);
2.155 - tmp+=b; ///\todo Don't STL have some special 'merge' algorithm?
2.156 + tmp+=b; ///\todo Doesn't STL have some special 'merge' algorithm?
2.157 return tmp;
2.158 }
2.159 ///\e
2.160 @@ -694,7 +731,7 @@
2.161 const LpSolverBase::Expr &b)
2.162 {
2.163 LpSolverBase::Expr tmp(a);
2.164 - tmp-=b; ///\todo Don't STL have some special 'merge' algorithm?
2.165 + tmp-=b; ///\todo Doesn't STL have some special 'merge' algorithm?
2.166 return tmp;
2.167 }
2.168 ///\e
2.169 @@ -705,7 +742,7 @@
2.170 const LpSolverBase::Value &b)
2.171 {
2.172 LpSolverBase::Expr tmp(a);
2.173 - tmp*=b; ///\todo Don't STL have some special 'merge' algorithm?
2.174 + tmp*=b; ///\todo Doesn't STL have some special 'merge' algorithm?
2.175 return tmp;
2.176 }
2.177
2.178 @@ -717,7 +754,7 @@
2.179 const LpSolverBase::Expr &b)
2.180 {
2.181 LpSolverBase::Expr tmp(b);
2.182 - tmp*=a; ///\todo Don't STL have some special 'merge' algorithm?
2.183 + tmp*=a; ///\todo Doesn't STL have some special 'merge' algorithm?
2.184 return tmp;
2.185 }
2.186 ///\e
2.187 @@ -728,7 +765,7 @@
2.188 const LpSolverBase::Value &b)
2.189 {
2.190 LpSolverBase::Expr tmp(a);
2.191 - tmp/=b; ///\todo Don't STL have some special 'merge' algorithm?
2.192 + tmp/=b; ///\todo Doesn't STL have some special 'merge' algorithm?
2.193 return tmp;
2.194 }
2.195
3.1 --- a/src/lemon/lp_glpk.cc Fri Apr 15 22:12:51 2005 +0000
3.2 +++ b/src/lemon/lp_glpk.cc Sun Apr 17 18:57:22 2005 +0000
3.3 @@ -24,6 +24,24 @@
3.4
3.5 namespace lemon {
3.6
3.7 + ///\e
3.8 +
3.9 + ///\bug Unimplemented!
3.10 + ///
3.11 + LpSolverBase &LpGlpk::_newLp()
3.12 + {
3.13 + return *((LpSolverBase *)0);
3.14 + }
3.15 +
3.16 + ///\e
3.17 +
3.18 + ///\bug Unimplemented!
3.19 + ///
3.20 + LpSolverBase &LpGlpk::_copyLp()
3.21 + {
3.22 + return *((LpSolverBase *)0);
3.23 + }
3.24 +
3.25 LpGlpk::LpGlpk() : Parent(),
3.26 lp(lpx_create_prob()) {
3.27 ///\todo constrol function for this:
4.1 --- a/src/lemon/lp_glpk.h Fri Apr 15 22:12:51 2005 +0000
4.2 +++ b/src/lemon/lp_glpk.h Sun Apr 17 18:57:22 2005 +0000
4.3 @@ -31,7 +31,7 @@
4.4
4.5 /// \brief Wrapper for GLPK solver
4.6 ///
4.7 - /// This class implements a lemon wrapper for GLPK.
4.8 + /// This class implements an interface for GLPK.
4.9 ///\ingroup gen_opt_group
4.10 class LpGlpk : public LpSolverBase {
4.11 protected:
4.12 @@ -45,6 +45,9 @@
4.13 ~LpGlpk();
4.14
4.15 protected:
4.16 + virtual LpSolverBase &_newLp();
4.17 + virtual LpSolverBase &_copyLp();
4.18 +
4.19 virtual int _addCol();
4.20 virtual int _addRow();
4.21 virtual void _setRowCoeffs(int i,
5.1 --- a/src/lemon/lp_skeleton.cc Fri Apr 15 22:12:51 2005 +0000
5.2 +++ b/src/lemon/lp_skeleton.cc Sun Apr 17 18:57:22 2005 +0000
5.3 @@ -21,6 +21,16 @@
5.4 ///\brief A skeleton file to implement LP solver interfaces
5.5 namespace lemon {
5.6
5.7 + LpSolverBase &LpSkeleton::_newLp()
5.8 + {
5.9 + return *((LpSolverBase *)0);
5.10 + }
5.11 +
5.12 + LpSolverBase &LpSkeleton::_copyLp()
5.13 + {
5.14 + return *((LpSolverBase *)0);
5.15 + }
5.16 +
5.17 int LpSkeleton::_addCol()
5.18 {
5.19 return ++col_num;
6.1 --- a/src/lemon/lp_skeleton.h Fri Apr 15 22:12:51 2005 +0000
6.2 +++ b/src/lemon/lp_skeleton.h Sun Apr 17 18:57:22 2005 +0000
6.3 @@ -29,6 +29,10 @@
6.4 int col_num,row_num;
6.5
6.6 protected:
6.7 + ///\e
6.8 + virtual LpSolverBase &_newLp();
6.9 + ///\e
6.10 + virtual LpSolverBase &_copyLp();
6.11 /// \e
6.12 virtual int _addCol();
6.13 /// \e