# HG changeset patch
# User Gabor Gevay <ggab90@gmail.com>
# Date 1390224652 -3600
# Mon Jan 20 14:30:52 2014 +0100
# Node ID df948ed5f35f60643b78d4d8340276063b0e1361
# Parent 2463647b2411f53666b2182090dcca27a32c7da8
STL style iterators in LpBase.
diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt
a
|
b
|
|
19 | 19 | |
20 | 20 | |
21 | 21 | ADD_EXECUTABLE(stlit_test stlit_test/stlit_test.cc) |
22 | | TARGET_LINK_LIBRARIES(stlit_test lemon) |
| 22 | TARGET_LINK_LIBRARIES(stlit_test lemon glpk) |
23 | 23 | |
diff --git a/contrib/stlit_test/stlit_test.cc b/contrib/stlit_test/stlit_test.cc
a
|
b
|
|
9 | 9 | #include <lemon/path.h> |
10 | 10 | #include <lemon/bfs.h> |
11 | 11 | #include <lemon/bellman_ford.h> |
12 | | #include <lemon/euler.h> |
| 12 | #include <lemon/concepts/digraph.h> |
| 13 | //#include <lemon/euler.h> |
13 | 14 | #include <lemon/maps.h> |
| 15 | //#include <lemon/matching.h> |
| 16 | #include <lemon/glpk.h> |
14 | 17 | |
15 | 18 | |
16 | 19 | using namespace std; |
… |
… |
|
189 | 192 | cout<<g.id(v)<<endl; |
190 | 193 | } |
191 | 194 | |
| 195 | // cout<<endl; |
| 196 | // |
| 197 | // { |
| 198 | // ListGraph g; |
| 199 | // auto u=g.addNode(), v=g.addNode(); |
| 200 | // g.addEdge(u,v); g.addEdge(v,u); |
| 201 | // ListGraph::EdgeMap<int> m(g); |
| 202 | // MaxWeightedMatching<ListGraph> alg(g, m); |
| 203 | // alg.run(); |
| 204 | // //for(auto u: alg.blossomNodes(0)) |
| 205 | // //cout<<g.id(u)<<endl; |
| 206 | // auto beg = alg.blossomNodes(0).begin(); |
| 207 | // auto end = alg.blossomNodes(0).end(); |
| 208 | // } |
| 209 | |
| 210 | cout<<endl; |
| 211 | |
| 212 | { |
| 213 | typedef GlpkLp Lp; |
| 214 | Lp lp; |
| 215 | lp.max(); |
| 216 | Lp::Col x1 = lp.addCol(), x2 = lp.addCol(); |
| 217 | lp.addRow(x1+x2 <= 100); |
| 218 | for(auto c: lp.cols()) |
| 219 | cout<<lp.id(c)<<endl; |
| 220 | for(auto r: lp.rows()) |
| 221 | cout<<lp.id(r)<<endl; |
| 222 | } |
| 223 | |
| 224 | |
192 | 225 | return 0; |
193 | 226 | } |
194 | 227 | |
diff --git a/lemon/cbc.cc b/lemon/cbc.cc
a
|
b
|
|
111 | 111 | } |
112 | 112 | |
113 | 113 | void CbcMip::_eraseColId(int i) { |
114 | | cols.eraseIndex(i); |
| 114 | _cols.eraseIndex(i); |
115 | 115 | } |
116 | 116 | |
117 | 117 | void CbcMip::_eraseRowId(int i) { |
118 | | rows.eraseIndex(i); |
| 118 | _rows.eraseIndex(i); |
119 | 119 | } |
120 | 120 | |
121 | 121 | void CbcMip::_getColName(int c, std::string& name) const { |
diff --git a/lemon/clp.cc b/lemon/clp.cc
a
|
b
|
|
29 | 29 | |
30 | 30 | ClpLp::ClpLp(const ClpLp& other) { |
31 | 31 | _prob = new ClpSimplex(*other._prob); |
32 | | rows = other.rows; |
33 | | cols = other.cols; |
| 32 | _rows = other._rows; |
| 33 | _cols = other._cols; |
34 | 34 | _init_temporals(); |
35 | 35 | messageLevel(MESSAGE_NOTHING); |
36 | 36 | } |
… |
… |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | void ClpLp::_eraseColId(int i) { |
106 | | cols.eraseIndex(i); |
107 | | cols.shiftIndices(i); |
| 106 | _cols.eraseIndex(i); |
| 107 | _cols.shiftIndices(i); |
108 | 108 | } |
109 | 109 | |
110 | 110 | void ClpLp::_eraseRowId(int i) { |
111 | | rows.eraseIndex(i); |
112 | | rows.shiftIndices(i); |
| 111 | _rows.eraseIndex(i); |
| 112 | _rows.shiftIndices(i); |
113 | 113 | } |
114 | 114 | |
115 | 115 | void ClpLp::_getColName(int c, std::string& name) const { |
diff --git a/lemon/clp.h b/lemon/clp.h
a
|
b
|
|
151 | 151 | SolveExitStatus solveBarrier(); |
152 | 152 | |
153 | 153 | ///Returns the constraint identifier understood by CLP. |
154 | | int clpRow(Row r) const { return rows(id(r)); } |
| 154 | int clpRow(Row r) const { return _rows(id(r)); } |
155 | 155 | |
156 | 156 | ///Returns the variable identifier understood by CLP. |
157 | | int clpCol(Col c) const { return cols(id(c)); } |
| 157 | int clpCol(Col c) const { return _cols(id(c)); } |
158 | 158 | |
159 | 159 | }; |
160 | 160 | |
diff --git a/lemon/cplex.cc b/lemon/cplex.cc
a
|
b
|
|
87 | 87 | : LpBase() { |
88 | 88 | int status; |
89 | 89 | _prob = CPXcloneprob(cplexEnv(), cplex._prob, &status); |
90 | | rows = cplex.rows; |
91 | | cols = cplex.cols; |
| 90 | _rows = cplex._rows; |
| 91 | _cols = cplex._cols; |
92 | 92 | messageLevel(MESSAGE_NOTHING); |
93 | 93 | } |
94 | 94 | |
… |
… |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | void CplexBase::_eraseColId(int i) { |
158 | | cols.eraseIndex(i); |
159 | | cols.shiftIndices(i); |
| 158 | _cols.eraseIndex(i); |
| 159 | _cols.shiftIndices(i); |
160 | 160 | } |
161 | 161 | void CplexBase::_eraseRowId(int i) { |
162 | | rows.eraseIndex(i); |
163 | | rows.shiftIndices(i); |
| 162 | _rows.eraseIndex(i); |
| 163 | _rows.shiftIndices(i); |
164 | 164 | } |
165 | 165 | |
166 | 166 | void CplexBase::_getColName(int col, std::string &name) const { |
diff --git a/lemon/glpk.cc b/lemon/glpk.cc
a
|
b
|
|
38 | 38 | lp = glp_create_prob(); |
39 | 39 | glp_copy_prob(lp, other.lp, GLP_ON); |
40 | 40 | glp_create_index(lp); |
41 | | rows = other.rows; |
42 | | cols = other.cols; |
| 41 | _rows = other._rows; |
| 42 | _cols = other._cols; |
43 | 43 | messageLevel(MESSAGE_NOTHING); |
44 | 44 | } |
45 | 45 | |
… |
… |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | void GlpkBase::_eraseColId(int i) { |
111 | | cols.eraseIndex(i); |
112 | | cols.shiftIndices(i); |
| 111 | _cols.eraseIndex(i); |
| 112 | _cols.shiftIndices(i); |
113 | 113 | } |
114 | 114 | |
115 | 115 | void GlpkBase::_eraseRowId(int i) { |
116 | | rows.eraseIndex(i); |
117 | | rows.shiftIndices(i); |
| 116 | _rows.eraseIndex(i); |
| 117 | _rows.shiftIndices(i); |
118 | 118 | } |
119 | 119 | |
120 | 120 | void GlpkBase::_getColName(int c, std::string& name) const { |
diff --git a/lemon/glpk.h b/lemon/glpk.h
a
|
b
|
|
141 | 141 | _solver_bits::VoidPtr lpx() const {return lp;} |
142 | 142 | |
143 | 143 | ///Returns the constraint identifier understood by GLPK. |
144 | | int lpxRow(Row r) const { return rows(id(r)); } |
| 144 | int lpxRow(Row r) const { return _rows(id(r)); } |
145 | 145 | |
146 | 146 | ///Returns the variable identifier understood by GLPK. |
147 | | int lpxCol(Col c) const { return cols(id(c)); } |
| 147 | int lpxCol(Col c) const { return _cols(id(c)); } |
148 | 148 | |
149 | 149 | #ifdef DOXYGEN |
150 | 150 | /// Write the problem or the solution to a file in the given format |
diff --git a/lemon/lp_base.h b/lemon/lp_base.h
a
|
b
|
|
31 | 31 | #include<lemon/core.h> |
32 | 32 | #include<lemon/bits/solver_bits.h> |
33 | 33 | |
| 34 | #include<lemon/bits/stl_iterators.h> |
| 35 | |
34 | 36 | ///\file |
35 | 37 | ///\brief The interface of the LP solver interface. |
36 | 38 | ///\ingroup lp_group |
… |
… |
|
45 | 47 | |
46 | 48 | protected: |
47 | 49 | |
48 | | _solver_bits::VarIndex rows; |
49 | | _solver_bits::VarIndex cols; |
| 50 | _solver_bits::VarIndex _rows; |
| 51 | _solver_bits::VarIndex _cols; |
50 | 52 | |
51 | 53 | public: |
52 | 54 | |
… |
… |
|
166 | 168 | /// |
167 | 169 | ColIt(const LpBase &solver) : _solver(&solver) |
168 | 170 | { |
169 | | _solver->cols.firstItem(_id); |
| 171 | _solver->_cols.firstItem(_id); |
170 | 172 | } |
171 | 173 | /// Invalid constructor \& conversion |
172 | 174 | |
… |
… |
|
179 | 181 | /// |
180 | 182 | ColIt &operator++() |
181 | 183 | { |
182 | | _solver->cols.nextItem(_id); |
| 184 | _solver->_cols.nextItem(_id); |
183 | 185 | return *this; |
184 | 186 | } |
185 | 187 | }; |
186 | 188 | |
| 189 | /// \brief Gets the collection of the columns of the LP problem. |
| 190 | /// |
| 191 | /// This function can be used for iterating on |
| 192 | /// the columns of the LP problem. It returns a wrapped ColIt, which looks |
| 193 | /// like an STL container (by having begin() and end()) |
| 194 | /// which you can use in range-based for loops, stl algorithms, etc. |
| 195 | /// For example you can write: |
| 196 | ///\code |
| 197 | /// for(auto c: lp.cols()) |
| 198 | /// doSomething(c); |
| 199 | LemonRangeWrapper1<ColIt, LpBase> cols() { |
| 200 | return LemonRangeWrapper1<ColIt, LpBase>(*this); |
| 201 | } |
| 202 | |
| 203 | |
187 | 204 | /// \brief Returns the ID of the column. |
188 | 205 | static int id(const Col& col) { return col._id; } |
189 | 206 | /// \brief Returns the column with the given ID. |
… |
… |
|
261 | 278 | /// |
262 | 279 | RowIt(const LpBase &solver) : _solver(&solver) |
263 | 280 | { |
264 | | _solver->rows.firstItem(_id); |
| 281 | _solver->_rows.firstItem(_id); |
265 | 282 | } |
266 | 283 | /// Invalid constructor \& conversion |
267 | 284 | |
… |
… |
|
274 | 291 | /// |
275 | 292 | RowIt &operator++() |
276 | 293 | { |
277 | | _solver->rows.nextItem(_id); |
| 294 | _solver->_rows.nextItem(_id); |
278 | 295 | return *this; |
279 | 296 | } |
280 | 297 | }; |
| 298 | |
| 299 | /// \brief Gets the collection of the rows of the LP problem. |
| 300 | /// |
| 301 | /// This function can be used for iterating on |
| 302 | /// the rows of the LP problem. It returns a wrapped RowIt, which looks |
| 303 | /// like an STL container (by having begin() and end()) |
| 304 | /// which you can use in range-based for loops, stl algorithms, etc. |
| 305 | /// For example you can write: |
| 306 | ///\code |
| 307 | /// for(auto c: lp.rows()) |
| 308 | /// doSomething(c); |
| 309 | LemonRangeWrapper1<RowIt, LpBase> rows() { |
| 310 | return LemonRangeWrapper1<RowIt, LpBase>(*this); |
| 311 | } |
| 312 | |
281 | 313 | |
282 | 314 | /// \brief Returns the ID of the row. |
283 | 315 | static int id(const Row& row) { return row._id; } |
… |
… |
|
934 | 966 | |
935 | 967 | //Abstract virtual functions |
936 | 968 | |
937 | | virtual int _addColId(int col) { return cols.addIndex(col); } |
938 | | virtual int _addRowId(int row) { return rows.addIndex(row); } |
| 969 | virtual int _addColId(int col) { return _cols.addIndex(col); } |
| 970 | virtual int _addRowId(int row) { return _rows.addIndex(row); } |
939 | 971 | |
940 | | virtual void _eraseColId(int col) { cols.eraseIndex(col); } |
941 | | virtual void _eraseRowId(int row) { rows.eraseIndex(row); } |
| 972 | virtual void _eraseColId(int col) { _cols.eraseIndex(col); } |
| 973 | virtual void _eraseRowId(int row) { _rows.eraseIndex(row); } |
942 | 974 | |
943 | 975 | virtual int _addCol() = 0; |
944 | 976 | virtual int _addRow() = 0; |
… |
… |
|
1003 | 1035 | //Constant component of the objective function |
1004 | 1036 | Value obj_const_comp; |
1005 | 1037 | |
1006 | | LpBase() : rows(), cols(), obj_const_comp(0) {} |
| 1038 | LpBase() : _rows(), _cols(), obj_const_comp(0) {} |
1007 | 1039 | |
1008 | 1040 | public: |
1009 | 1041 | |
… |
… |
|
1115 | 1147 | ///a better one. |
1116 | 1148 | void col(Col c, const DualExpr &e) { |
1117 | 1149 | e.simplify(); |
1118 | | _setColCoeffs(cols(id(c)), ExprIterator(e.comps.begin(), rows), |
1119 | | ExprIterator(e.comps.end(), rows)); |
| 1150 | _setColCoeffs(_cols(id(c)), ExprIterator(e.comps.begin(), _rows), |
| 1151 | ExprIterator(e.comps.end(), _rows)); |
1120 | 1152 | } |
1121 | 1153 | |
1122 | 1154 | ///Get a column (i.e a dual constraint) of the LP |
… |
… |
|
1125 | 1157 | ///\return the dual expression associated to the column |
1126 | 1158 | DualExpr col(Col c) const { |
1127 | 1159 | DualExpr e; |
1128 | | _getColCoeffs(cols(id(c)), InsertIterator(e.comps, rows)); |
| 1160 | _getColCoeffs(_cols(id(c)), InsertIterator(e.comps, _rows)); |
1129 | 1161 | return e; |
1130 | 1162 | } |
1131 | 1163 | |
… |
… |
|
1212 | 1244 | ///\param u is the upper bound (\ref INF means no bound) |
1213 | 1245 | void row(Row r, Value l, const Expr &e, Value u) { |
1214 | 1246 | e.simplify(); |
1215 | | _setRowCoeffs(rows(id(r)), ExprIterator(e.comps.begin(), cols), |
1216 | | ExprIterator(e.comps.end(), cols)); |
1217 | | _setRowLowerBound(rows(id(r)),l - *e); |
1218 | | _setRowUpperBound(rows(id(r)),u - *e); |
| 1247 | _setRowCoeffs(_rows(id(r)), ExprIterator(e.comps.begin(), _cols), |
| 1248 | ExprIterator(e.comps.end(), _cols)); |
| 1249 | _setRowLowerBound(_rows(id(r)),l - *e); |
| 1250 | _setRowUpperBound(_rows(id(r)),u - *e); |
1219 | 1251 | } |
1220 | 1252 | |
1221 | 1253 | ///Set a row (i.e a constraint) of the LP |
… |
… |
|
1234 | 1266 | ///\return the expression associated to the row |
1235 | 1267 | Expr row(Row r) const { |
1236 | 1268 | Expr e; |
1237 | | _getRowCoeffs(rows(id(r)), InsertIterator(e.comps, cols)); |
| 1269 | _getRowCoeffs(_rows(id(r)), InsertIterator(e.comps, _cols)); |
1238 | 1270 | return e; |
1239 | 1271 | } |
1240 | 1272 | |
… |
… |
|
1247 | 1279 | Row addRow(Value l,const Expr &e, Value u) { |
1248 | 1280 | Row r; |
1249 | 1281 | e.simplify(); |
1250 | | r._id = _addRowId(_addRow(l - *e, ExprIterator(e.comps.begin(), cols), |
1251 | | ExprIterator(e.comps.end(), cols), u - *e)); |
| 1282 | r._id = _addRowId(_addRow(l - *e, ExprIterator(e.comps.begin(), _cols), |
| 1283 | ExprIterator(e.comps.end(), _cols), u - *e)); |
1252 | 1284 | return r; |
1253 | 1285 | } |
1254 | 1286 | |
… |
… |
|
1260 | 1292 | Row r; |
1261 | 1293 | c.expr().simplify(); |
1262 | 1294 | r._id = _addRowId(_addRow(c.lowerBounded()?c.lowerBound()-*c.expr():-INF, |
1263 | | ExprIterator(c.expr().comps.begin(), cols), |
1264 | | ExprIterator(c.expr().comps.end(), cols), |
| 1295 | ExprIterator(c.expr().comps.begin(), _cols), |
| 1296 | ExprIterator(c.expr().comps.end(), _cols), |
1265 | 1297 | c.upperBounded()?c.upperBound()-*c.expr():INF)); |
1266 | 1298 | return r; |
1267 | 1299 | } |
… |
… |
|
1269 | 1301 | |
1270 | 1302 | ///\param c is the column to be deleted |
1271 | 1303 | void erase(Col c) { |
1272 | | _eraseCol(cols(id(c))); |
1273 | | _eraseColId(cols(id(c))); |
| 1304 | _eraseCol(_cols(id(c))); |
| 1305 | _eraseColId(_cols(id(c))); |
1274 | 1306 | } |
1275 | 1307 | ///Erase a row (i.e a constraint) from the LP |
1276 | 1308 | |
1277 | 1309 | ///\param r is the row to be deleted |
1278 | 1310 | void erase(Row r) { |
1279 | | _eraseRow(rows(id(r))); |
1280 | | _eraseRowId(rows(id(r))); |
| 1311 | _eraseRow(_rows(id(r))); |
| 1312 | _eraseRowId(_rows(id(r))); |
1281 | 1313 | } |
1282 | 1314 | |
1283 | 1315 | /// Get the name of a column |
… |
… |
|
1286 | 1318 | ///\return The name of the colunm |
1287 | 1319 | std::string colName(Col c) const { |
1288 | 1320 | std::string name; |
1289 | | _getColName(cols(id(c)), name); |
| 1321 | _getColName(_cols(id(c)), name); |
1290 | 1322 | return name; |
1291 | 1323 | } |
1292 | 1324 | |
… |
… |
|
1295 | 1327 | ///\param c is the coresponding column |
1296 | 1328 | ///\param name The name to be given |
1297 | 1329 | void colName(Col c, const std::string& name) { |
1298 | | _setColName(cols(id(c)), name); |
| 1330 | _setColName(_cols(id(c)), name); |
1299 | 1331 | } |
1300 | 1332 | |
1301 | 1333 | /// Get the column by its name |
… |
… |
|
1304 | 1336 | ///\return the proper column or \c INVALID |
1305 | 1337 | Col colByName(const std::string& name) const { |
1306 | 1338 | int k = _colByName(name); |
1307 | | return k != -1 ? Col(cols[k]) : Col(INVALID); |
| 1339 | return k != -1 ? Col(_cols[k]) : Col(INVALID); |
1308 | 1340 | } |
1309 | 1341 | |
1310 | 1342 | /// Get the name of a row |
… |
… |
|
1313 | 1345 | ///\return The name of the row |
1314 | 1346 | std::string rowName(Row r) const { |
1315 | 1347 | std::string name; |
1316 | | _getRowName(rows(id(r)), name); |
| 1348 | _getRowName(_rows(id(r)), name); |
1317 | 1349 | return name; |
1318 | 1350 | } |
1319 | 1351 | |
… |
… |
|
1322 | 1354 | ///\param r is the coresponding row |
1323 | 1355 | ///\param name The name to be given |
1324 | 1356 | void rowName(Row r, const std::string& name) { |
1325 | | _setRowName(rows(id(r)), name); |
| 1357 | _setRowName(_rows(id(r)), name); |
1326 | 1358 | } |
1327 | 1359 | |
1328 | 1360 | /// Get the row by its name |
… |
… |
|
1331 | 1363 | ///\return the proper row or \c INVALID |
1332 | 1364 | Row rowByName(const std::string& name) const { |
1333 | 1365 | int k = _rowByName(name); |
1334 | | return k != -1 ? Row(rows[k]) : Row(INVALID); |
| 1366 | return k != -1 ? Row(_rows[k]) : Row(INVALID); |
1335 | 1367 | } |
1336 | 1368 | |
1337 | 1369 | /// Set an element of the coefficient matrix of the LP |
… |
… |
|
1340 | 1372 | ///\param c is the column of the element to be modified |
1341 | 1373 | ///\param val is the new value of the coefficient |
1342 | 1374 | void coeff(Row r, Col c, Value val) { |
1343 | | _setCoeff(rows(id(r)),cols(id(c)), val); |
| 1375 | _setCoeff(_rows(id(r)),_cols(id(c)), val); |
1344 | 1376 | } |
1345 | 1377 | |
1346 | 1378 | /// Get an element of the coefficient matrix of the LP |
… |
… |
|
1349 | 1381 | ///\param c is the column of the element |
1350 | 1382 | ///\return the corresponding coefficient |
1351 | 1383 | Value coeff(Row r, Col c) const { |
1352 | | return _getCoeff(rows(id(r)),cols(id(c))); |
| 1384 | return _getCoeff(_rows(id(r)),_cols(id(c))); |
1353 | 1385 | } |
1354 | 1386 | |
1355 | 1387 | /// Set the lower bound of a column (i.e a variable) |
… |
… |
|
1358 | 1390 | /// extended number of type Value, i.e. a finite number of type |
1359 | 1391 | /// Value or -\ref INF. |
1360 | 1392 | void colLowerBound(Col c, Value value) { |
1361 | | _setColLowerBound(cols(id(c)),value); |
| 1393 | _setColLowerBound(_cols(id(c)),value); |
1362 | 1394 | } |
1363 | 1395 | |
1364 | 1396 | /// Get the lower bound of a column (i.e a variable) |
… |
… |
|
1367 | 1399 | /// (this might be -\ref INF as well). |
1368 | 1400 | ///\return The lower bound for column \c c |
1369 | 1401 | Value colLowerBound(Col c) const { |
1370 | | return _getColLowerBound(cols(id(c))); |
| 1402 | return _getColLowerBound(_cols(id(c))); |
1371 | 1403 | } |
1372 | 1404 | |
1373 | 1405 | ///\brief Set the lower bound of several columns |
… |
… |
|
1413 | 1445 | /// extended number of type Value, i.e. a finite number of type |
1414 | 1446 | /// Value or \ref INF. |
1415 | 1447 | void colUpperBound(Col c, Value value) { |
1416 | | _setColUpperBound(cols(id(c)),value); |
| 1448 | _setColUpperBound(_cols(id(c)),value); |
1417 | 1449 | }; |
1418 | 1450 | |
1419 | 1451 | /// Get the upper bound of a column (i.e a variable) |
… |
… |
|
1422 | 1454 | /// (this might be \ref INF as well). |
1423 | 1455 | /// \return The upper bound for column \c c |
1424 | 1456 | Value colUpperBound(Col c) const { |
1425 | | return _getColUpperBound(cols(id(c))); |
| 1457 | return _getColUpperBound(_cols(id(c))); |
1426 | 1458 | } |
1427 | 1459 | |
1428 | 1460 | ///\brief Set the upper bound of several columns |
… |
… |
|
1469 | 1501 | /// extended number of type Value, i.e. a finite number of type |
1470 | 1502 | /// Value, -\ref INF or \ref INF. |
1471 | 1503 | void colBounds(Col c, Value lower, Value upper) { |
1472 | | _setColLowerBound(cols(id(c)),lower); |
1473 | | _setColUpperBound(cols(id(c)),upper); |
| 1504 | _setColLowerBound(_cols(id(c)),lower); |
| 1505 | _setColUpperBound(_cols(id(c)),upper); |
1474 | 1506 | } |
1475 | 1507 | |
1476 | 1508 | ///\brief Set the lower and the upper bound of several columns |
… |
… |
|
1515 | 1547 | /// extended number of type Value, i.e. a finite number of type |
1516 | 1548 | /// Value or -\ref INF. |
1517 | 1549 | void rowLowerBound(Row r, Value value) { |
1518 | | _setRowLowerBound(rows(id(r)),value); |
| 1550 | _setRowLowerBound(_rows(id(r)),value); |
1519 | 1551 | } |
1520 | 1552 | |
1521 | 1553 | /// Get the lower bound of a row (i.e a constraint) |
… |
… |
|
1524 | 1556 | /// (this might be -\ref INF as well). |
1525 | 1557 | ///\return The lower bound for row \c r |
1526 | 1558 | Value rowLowerBound(Row r) const { |
1527 | | return _getRowLowerBound(rows(id(r))); |
| 1559 | return _getRowLowerBound(_rows(id(r))); |
1528 | 1560 | } |
1529 | 1561 | |
1530 | 1562 | /// Set the upper bound of a row (i.e a constraint) |
… |
… |
|
1533 | 1565 | /// extended number of type Value, i.e. a finite number of type |
1534 | 1566 | /// Value or -\ref INF. |
1535 | 1567 | void rowUpperBound(Row r, Value value) { |
1536 | | _setRowUpperBound(rows(id(r)),value); |
| 1568 | _setRowUpperBound(_rows(id(r)),value); |
1537 | 1569 | } |
1538 | 1570 | |
1539 | 1571 | /// Get the upper bound of a row (i.e a constraint) |
… |
… |
|
1542 | 1574 | /// (this might be -\ref INF as well). |
1543 | 1575 | ///\return The upper bound for row \c r |
1544 | 1576 | Value rowUpperBound(Row r) const { |
1545 | | return _getRowUpperBound(rows(id(r))); |
| 1577 | return _getRowUpperBound(_rows(id(r))); |
1546 | 1578 | } |
1547 | 1579 | |
1548 | 1580 | ///Set an element of the objective function |
1549 | | void objCoeff(Col c, Value v) {_setObjCoeff(cols(id(c)),v); }; |
| 1581 | void objCoeff(Col c, Value v) {_setObjCoeff(_cols(id(c)),v); }; |
1550 | 1582 | |
1551 | 1583 | ///Get an element of the objective function |
1552 | | Value objCoeff(Col c) const { return _getObjCoeff(cols(id(c))); }; |
| 1584 | Value objCoeff(Col c) const { return _getObjCoeff(_cols(id(c))); }; |
1553 | 1585 | |
1554 | 1586 | ///Set the objective function |
1555 | 1587 | |
1556 | 1588 | ///\param e is a linear expression of type \ref Expr. |
1557 | 1589 | /// |
1558 | 1590 | void obj(const Expr& e) { |
1559 | | _setObjCoeffs(ExprIterator(e.comps.begin(), cols), |
1560 | | ExprIterator(e.comps.end(), cols)); |
| 1591 | _setObjCoeffs(ExprIterator(e.comps.begin(), _cols), |
| 1592 | ExprIterator(e.comps.end(), _cols)); |
1561 | 1593 | obj_const_comp = *e; |
1562 | 1594 | } |
1563 | 1595 | |
… |
… |
|
1567 | 1599 | ///Expr. |
1568 | 1600 | Expr obj() const { |
1569 | 1601 | Expr e; |
1570 | | _getObjCoeffs(InsertIterator(e.comps, cols)); |
| 1602 | _getObjCoeffs(InsertIterator(e.comps, _cols)); |
1571 | 1603 | *e = obj_const_comp; |
1572 | 1604 | return e; |
1573 | 1605 | } |
… |
… |
|
1586 | 1618 | void min() { _setSense(MIN); } |
1587 | 1619 | |
1588 | 1620 | ///Clear the problem |
1589 | | void clear() { _clear(); rows.clear(); cols.clear(); } |
| 1621 | void clear() { _clear(); _rows.clear(); _cols.clear(); } |
1590 | 1622 | |
1591 | 1623 | /// Set the message level of the solver |
1592 | 1624 | void messageLevel(MessageLevel level) { _messageLevel(level); } |
… |
… |
|
1929 | 1961 | |
1930 | 1962 | /// Return the primal value of the column. |
1931 | 1963 | /// \pre The problem is solved. |
1932 | | Value primal(Col c) const { return _getPrimal(cols(id(c))); } |
| 1964 | Value primal(Col c) const { return _getPrimal(_cols(id(c))); } |
1933 | 1965 | |
1934 | 1966 | /// Return the primal value of the expression |
1935 | 1967 | |
… |
… |
|
1956 | 1988 | /// \pre The problem is solved and the dual problem is infeasible. |
1957 | 1989 | /// \note Some solvers does not provide primal ray calculation |
1958 | 1990 | /// functions. |
1959 | | Value primalRay(Col c) const { return _getPrimalRay(cols(id(c))); } |
| 1991 | Value primalRay(Col c) const { return _getPrimalRay(_cols(id(c))); } |
1960 | 1992 | |
1961 | 1993 | /// Return the dual value of the row |
1962 | 1994 | |
1963 | 1995 | /// Return the dual value of the row. |
1964 | 1996 | /// \pre The problem is solved. |
1965 | | Value dual(Row r) const { return _getDual(rows(id(r))); } |
| 1997 | Value dual(Row r) const { return _getDual(_rows(id(r))); } |
1966 | 1998 | |
1967 | 1999 | /// Return the dual value of the dual expression |
1968 | 2000 | |
… |
… |
|
1990 | 2022 | /// \pre The problem is solved and the primal problem is infeasible. |
1991 | 2023 | /// \note Some solvers does not provide dual ray calculation |
1992 | 2024 | /// functions. |
1993 | | Value dualRay(Row r) const { return _getDualRay(rows(id(r))); } |
| 2025 | Value dualRay(Row r) const { return _getDualRay(_rows(id(r))); } |
1994 | 2026 | |
1995 | 2027 | /// Return the basis status of the column |
1996 | 2028 | |
1997 | 2029 | /// \see VarStatus |
1998 | | VarStatus colStatus(Col c) const { return _getColStatus(cols(id(c))); } |
| 2030 | VarStatus colStatus(Col c) const { return _getColStatus(_cols(id(c))); } |
1999 | 2031 | |
2000 | 2032 | /// Return the basis status of the row |
2001 | 2033 | |
2002 | 2034 | /// \see VarStatus |
2003 | | VarStatus rowStatus(Row r) const { return _getRowStatus(rows(id(r))); } |
| 2035 | VarStatus rowStatus(Row r) const { return _getRowStatus(_rows(id(r))); } |
2004 | 2036 | |
2005 | 2037 | ///The value of the objective function |
2006 | 2038 | |
… |
… |
|
2080 | 2112 | ///Sets the type of the given column to the given type. |
2081 | 2113 | /// |
2082 | 2114 | void colType(Col c, ColTypes col_type) { |
2083 | | _setColType(cols(id(c)),col_type); |
| 2115 | _setColType(_cols(id(c)),col_type); |
2084 | 2116 | } |
2085 | 2117 | |
2086 | 2118 | ///Gives back the type of the column. |
… |
… |
|
2088 | 2120 | ///Gives back the type of the column. |
2089 | 2121 | /// |
2090 | 2122 | ColTypes colType(Col c) const { |
2091 | | return _getColType(cols(id(c))); |
| 2123 | return _getColType(_cols(id(c))); |
2092 | 2124 | } |
2093 | 2125 | ///@} |
2094 | 2126 | |
… |
… |
|
2105 | 2137 | |
2106 | 2138 | /// Return the value of the row in the solution. |
2107 | 2139 | /// \pre The problem is solved. |
2108 | | Value sol(Col c) const { return _getSol(cols(id(c))); } |
| 2140 | Value sol(Col c) const { return _getSol(_cols(id(c))); } |
2109 | 2141 | |
2110 | 2142 | /// Return the value of the expression in the solution |
2111 | 2143 | |
diff --git a/lemon/soplex.cc b/lemon/soplex.cc
a
|
b
|
|
37 | 37 | } |
38 | 38 | |
39 | 39 | SoplexLp::SoplexLp(const SoplexLp& lp) { |
40 | | rows = lp.rows; |
41 | | cols = lp.cols; |
| 40 | _rows = lp._rows; |
| 41 | _cols = lp._cols; |
42 | 42 | |
43 | 43 | soplex = new soplex::SoPlex; |
44 | 44 | (*static_cast<soplex::SPxLP*>(soplex)) = *(lp.soplex); |
… |
… |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | void SoplexLp::_eraseColId(int i) { |
125 | | cols.eraseIndex(i); |
126 | | cols.relocateIndex(i, cols.maxIndex()); |
| 125 | _cols.eraseIndex(i); |
| 126 | _cols.relocateIndex(i, _cols.maxIndex()); |
127 | 127 | } |
128 | 128 | void SoplexLp::_eraseRowId(int i) { |
129 | | rows.eraseIndex(i); |
130 | | rows.relocateIndex(i, rows.maxIndex()); |
| 129 | _rows.eraseIndex(i); |
| 130 | _rows.relocateIndex(i, _rows.maxIndex()); |
131 | 131 | } |
132 | 132 | |
133 | 133 | void SoplexLp::_getColName(int c, std::string &name) const { |
… |
… |
|
432 | 432 | _col_names_ref.clear(); |
433 | 433 | _row_names.clear(); |
434 | 434 | _row_names_ref.clear(); |
435 | | cols.clear(); |
436 | | rows.clear(); |
| 435 | _cols.clear(); |
| 436 | _rows.clear(); |
437 | 437 | _clear_temporals(); |
438 | 438 | } |
439 | 439 | |