1.1 --- a/lemon/lp_skeleton.h Tue Dec 02 21:40:33 2008 +0100
1.2 +++ b/lemon/lp_skeleton.h Tue Dec 02 22:48:28 2008 +0100
1.3 @@ -26,15 +26,14 @@
1.4 namespace lemon {
1.5
1.6 ///A skeleton class to implement LP solver interfaces
1.7 - class LpSkeleton :public LpSolverBase {
1.8 + class SkeletonSolverBase : public virtual LpBase {
1.9 int col_num,row_num;
1.10
1.11 protected:
1.12
1.13 - ///\e
1.14 - virtual LpSolverBase* _newLp();
1.15 - ///\e
1.16 - virtual LpSolverBase* _copyLp();
1.17 + SkeletonSolverBase()
1.18 + : col_num(-1), row_num(-1) {}
1.19 +
1.20 /// \e
1.21 virtual int _addCol();
1.22 /// \e
1.23 @@ -43,21 +42,29 @@
1.24 virtual void _eraseCol(int i);
1.25 /// \e
1.26 virtual void _eraseRow(int i);
1.27 +
1.28 /// \e
1.29 - virtual void _getColName(int col, std::string & name) const;
1.30 + virtual void _getColName(int col, std::string& name) const;
1.31 /// \e
1.32 - virtual void _setColName(int col, const std::string & name);
1.33 + virtual void _setColName(int col, const std::string& name);
1.34 /// \e
1.35 virtual int _colByName(const std::string& name) const;
1.36
1.37 /// \e
1.38 - virtual void _setRowCoeffs(int i, ConstRowIterator b, ConstRowIterator e);
1.39 + virtual void _getRowName(int row, std::string& name) const;
1.40 /// \e
1.41 - virtual void _getRowCoeffs(int i, RowIterator b) const;
1.42 + virtual void _setRowName(int row, const std::string& name);
1.43 /// \e
1.44 - virtual void _setColCoeffs(int i, ConstColIterator b, ConstColIterator e);
1.45 + virtual int _rowByName(const std::string& name) const;
1.46 +
1.47 /// \e
1.48 - virtual void _getColCoeffs(int i, ColIterator b) const;
1.49 + virtual void _setRowCoeffs(int i, ExprIterator b, ExprIterator e);
1.50 + /// \e
1.51 + virtual void _getRowCoeffs(int i, InsertIterator b) const;
1.52 + /// \e
1.53 + virtual void _setColCoeffs(int i, ExprIterator b, ExprIterator e);
1.54 + /// \e
1.55 + virtual void _getColCoeffs(int i, InsertIterator b) const;
1.56
1.57 /// Set one element of the coefficient matrix
1.58 virtual void _setCoeff(int row, int col, Value value);
1.59 @@ -87,42 +94,103 @@
1.60 /// Value or \ref INF.
1.61 virtual Value _getColUpperBound(int i) const;
1.62
1.63 -// /// The lower bound of a linear expression (row) have to be given by an
1.64 -// /// extended number of type Value, i.e. a finite number of type
1.65 -// /// Value or -\ref INF.
1.66 -// virtual void _setRowLowerBound(int i, Value value);
1.67 -// /// \e
1.68 -
1.69 -// /// The upper bound of a linear expression (row) have to be given by an
1.70 -// /// extended number of type Value, i.e. a finite number of type
1.71 -// /// Value or \ref INF.
1.72 -// virtual void _setRowUpperBound(int i, Value value);
1.73 -
1.74 - /// The lower and upper bound of a linear expression (row) have to be
1.75 - /// given by an
1.76 + /// The lower bound of a constraint (row) have to be given by an
1.77 /// extended number of type Value, i.e. a finite number of type
1.78 - /// Value or +/-\ref INF.
1.79 - virtual void _setRowBounds(int i, Value lb, Value ub);
1.80 + /// Value or -\ref INF.
1.81 + virtual void _setRowLowerBound(int i, Value value);
1.82 /// \e
1.83
1.84 + /// The lower bound of a constraint (row) is an
1.85 + /// extended number of type Value, i.e. a finite number of type
1.86 + /// Value or -\ref INF.
1.87 + virtual Value _getRowLowerBound(int i) const;
1.88
1.89 - /// The lower and the upper bound of
1.90 - /// a constraint (row) are
1.91 - /// extended numbers of type Value, i.e. finite numbers of type
1.92 - /// Value, -\ref INF or \ref INF.
1.93 - virtual void _getRowBounds(int i, Value &lb, Value &ub) const;
1.94 + /// The upper bound of a constraint (row) have to be given by an
1.95 + /// extended number of type Value, i.e. a finite number of type
1.96 + /// Value or \ref INF.
1.97 + virtual void _setRowUpperBound(int i, Value value);
1.98 /// \e
1.99
1.100 + /// The upper bound of a constraint (row) is an
1.101 + /// extended number of type Value, i.e. a finite number of type
1.102 + /// Value or \ref INF.
1.103 + virtual Value _getRowUpperBound(int i) const;
1.104
1.105 /// \e
1.106 - virtual void _clearObj();
1.107 + virtual void _setObjCoeffs(ExprIterator b, ExprIterator e);
1.108 + /// \e
1.109 + virtual void _getObjCoeffs(InsertIterator b) const;
1.110 +
1.111 /// \e
1.112 virtual void _setObjCoeff(int i, Value obj_coef);
1.113 -
1.114 /// \e
1.115 virtual Value _getObjCoeff(int i) const;
1.116
1.117 ///\e
1.118 + virtual void _setSense(Sense);
1.119 + ///\e
1.120 + virtual Sense _getSense() const;
1.121 +
1.122 + ///\e
1.123 + virtual void _clear();
1.124 +
1.125 + };
1.126 +
1.127 + /// \brief Interface for a skeleton LP solver
1.128 + ///
1.129 + /// This class implements an interface for a skeleton LP solver.
1.130 + ///\ingroup lp_group
1.131 + class LpSkeleton : public SkeletonSolverBase, public LpSolver {
1.132 + public:
1.133 + LpSkeleton() : SkeletonSolverBase(), LpSolver() {}
1.134 +
1.135 + protected:
1.136 +
1.137 + ///\e
1.138 + virtual SolveExitStatus _solve();
1.139 +
1.140 + ///\e
1.141 + virtual Value _getPrimal(int i) const;
1.142 + ///\e
1.143 + virtual Value _getDual(int i) const;
1.144 +
1.145 + ///\e
1.146 + virtual Value _getPrimalValue() const;
1.147 +
1.148 + ///\e
1.149 + virtual Value _getPrimalRay(int i) const;
1.150 + ///\e
1.151 + virtual Value _getDualRay(int i) const;
1.152 +
1.153 + ///\e
1.154 + virtual ProblemType _getPrimalType() const;
1.155 + ///\e
1.156 + virtual ProblemType _getDualType() const;
1.157 +
1.158 + ///\e
1.159 + virtual VarStatus _getColStatus(int i) const;
1.160 + ///\e
1.161 + virtual VarStatus _getRowStatus(int i) const;
1.162 +
1.163 + ///\e
1.164 + virtual LpSkeleton* _newSolver() const;
1.165 + ///\e
1.166 + virtual LpSkeleton* _cloneSolver() const;
1.167 + ///\e
1.168 + virtual const char* _solverName() const;
1.169 +
1.170 + };
1.171 +
1.172 + /// \brief Interface for a skeleton MIP solver
1.173 + ///
1.174 + /// This class implements an interface for a skeleton MIP solver.
1.175 + ///\ingroup lp_group
1.176 + class MipSkeleton : public SkeletonSolverBase, public MipSolver {
1.177 + public:
1.178 + MipSkeleton() : SkeletonSolverBase(), MipSolver() {}
1.179 +
1.180 + protected:
1.181 + ///\e
1.182
1.183 ///\bug Wrong interface
1.184 ///
1.185 @@ -132,50 +200,28 @@
1.186
1.187 ///\bug Wrong interface
1.188 ///
1.189 - virtual Value _getPrimal(int i) const;
1.190 + virtual Value _getSol(int i) const;
1.191
1.192 ///\e
1.193
1.194 ///\bug Wrong interface
1.195 ///
1.196 - virtual Value _getDual(int i) const;
1.197 + virtual Value _getSolValue() const;
1.198
1.199 ///\e
1.200
1.201 ///\bug Wrong interface
1.202 ///
1.203 - virtual Value _getPrimalValue() const;
1.204 + virtual ProblemType _getType() const;
1.205
1.206 ///\e
1.207 -
1.208 - ///\bug Wrong interface
1.209 - ///
1.210 - virtual SolutionStatus _getPrimalStatus() const;
1.211 -
1.212 - ////e
1.213 - virtual SolutionStatus _getDualStatus() const;
1.214 -
1.215 + virtual MipSkeleton* _newSolver() const;
1.216
1.217 ///\e
1.218 - virtual ProblemTypes _getProblemType() const;
1.219 + virtual MipSkeleton* _cloneSolver() const;
1.220 + ///\e
1.221 + virtual const char* _solverName() const;
1.222
1.223 - ///\e
1.224 - virtual void _setMax();
1.225 - ///\e
1.226 - virtual void _setMin();
1.227 -
1.228 - ///\e
1.229 - virtual bool _isMax() const;
1.230 -
1.231 -
1.232 -
1.233 - ///\e
1.234 - virtual bool _isBasicCol(int i) const;
1.235 -
1.236 -
1.237 -
1.238 - public:
1.239 - LpSkeleton() : LpSolverBase(), col_num(0), row_num(0) {}
1.240 };
1.241
1.242 } //namespace lemon