# HG changeset patch
# User Alpar Juttner <alpar@cs.elte.hu>
# Date 1232526238 0
# Node ID c8a0d6a69a47604cc9642aab23a4773dcbc6d754
# Parent 2eb5c8ca2c919205c0674b905a1e8c3edfaa48ed
Smarter _addRow() API function (#203)
diff --git a/lemon/clp.h b/lemon/clp.h
|
a
|
b
|
|
| 72 | 72 | virtual const char* _solverName() const; |
| 73 | 73 | |
| 74 | 74 | virtual int _addCol(); |
| | 75 | using LpBase::_addRow; |
| 75 | 76 | virtual int _addRow(); |
| 76 | 77 | |
| 77 | 78 | virtual void _eraseCol(int i); |
diff --git a/lemon/glpk.h b/lemon/glpk.h
|
a
|
b
|
|
| 52 | 52 | protected: |
| 53 | 53 | |
| 54 | 54 | virtual int _addCol(); |
| | 55 | using LpBase::_addRow; |
| 55 | 56 | virtual int _addRow(); |
| 56 | 57 | |
| 57 | 58 | virtual void _eraseCol(int i); |
diff --git a/lemon/lp_base.h b/lemon/lp_base.h
|
a
|
b
|
|
| 941 | 941 | virtual void _setRowName(int row, const std::string& name) = 0; |
| 942 | 942 | virtual int _rowByName(const std::string& name) const = 0; |
| 943 | 943 | |
| | 944 | virtual int _addRow(ExprIterator b, ExprIterator e){ |
| | 945 | int i=_addRow();_setRowCoeffs(i, b, e); return i; |
| | 946 | }; |
| 944 | 947 | virtual void _setRowCoeffs(int i, ExprIterator b, ExprIterator e) = 0; |
| 945 | 948 | virtual void _getRowCoeffs(int i, InsertIterator b) const = 0; |
| 946 | 949 | |
| … |
… |
|
| 1197 | 1200 | ///\param u is the upper bound (\ref INF means no bound) |
| 1198 | 1201 | ///\return The created row. |
| 1199 | 1202 | Row addRow(Value l,const Expr &e, Value u) { |
| 1200 | | Row r=addRow(); |
| 1201 | | row(r,l,e,u); |
| | 1203 | Row r; |
| | 1204 | e.simplify(); |
| | 1205 | int id=_addRow(ExprIterator(e.comps.begin(), cols), |
| | 1206 | ExprIterator(e.comps.end(), cols)); |
| | 1207 | r._id=_addRowId(id); |
| | 1208 | _setRowLowerBound(r._id,l - *e); |
| | 1209 | _setRowUpperBound(r._id,u - *e); |
| 1202 | 1210 | return r; |
| 1203 | 1211 | } |
| 1204 | 1212 | |
| … |
… |
|
| 1207 | 1215 | ///\param c is a linear expression (see \ref Constr) |
| 1208 | 1216 | ///\return The created row. |
| 1209 | 1217 | Row addRow(const Constr &c) { |
| 1210 | | Row r=addRow(); |
| 1211 | | row(r,c); |
| | 1218 | Row r=addRow(c.lowerBounded()?c.lowerBound():-INF, |
| | 1219 | c.expr(), c.upperBounded()?c.upperBound():INF); |
| 1212 | 1220 | return r; |
| 1213 | 1221 | } |
| 1214 | 1222 | ///Erase a column (i.e a variable) from the LP |
diff --git a/lemon/lp_skeleton.cc b/lemon/lp_skeleton.cc
|
a
|
b
|
|
| 43 | 43 | void SkeletonSolverBase::_setRowName(int, const std::string &) {} |
| 44 | 44 | int SkeletonSolverBase::_rowByName(const std::string&) const { return -1; } |
| 45 | 45 | |
| | 46 | int SkeletonSolverBase::_addRow(ExprIterator, ExprIterator) { return ++row_num; } |
| 46 | 47 | void SkeletonSolverBase::_setRowCoeffs(int, ExprIterator, ExprIterator) {} |
| 47 | 48 | void SkeletonSolverBase::_getRowCoeffs(int, InsertIterator) const {} |
| 48 | 49 | |
diff --git a/lemon/lp_skeleton.h b/lemon/lp_skeleton.h
|
a
|
b
|
|
| 58 | 58 | virtual int _rowByName(const std::string& name) const; |
| 59 | 59 | |
| 60 | 60 | /// \e |
| | 61 | virtual int _addRow(ExprIterator b, ExprIterator e); |
| | 62 | /// \e |
| 61 | 63 | virtual void _setRowCoeffs(int i, ExprIterator b, ExprIterator e); |
| 62 | 64 | /// \e |
| 63 | 65 | virtual void _getRowCoeffs(int i, InsertIterator b) const; |