257 } |
257 } |
258 return s; |
258 return s; |
259 } |
259 } |
260 #endif |
260 #endif |
261 ///Add a new empty row (i.e a new constaint) to the LP |
261 ///Add a new empty row (i.e a new constaint) to the LP |
|
262 |
|
263 ///This function adds a new empty row (i.e a new constaint) to the LP. |
|
264 ///\return The created row |
262 Row addRow() { Row r; r.id=rows.insert(_addRow()); return r;} |
265 Row addRow() { Row r; r.id=rows.insert(_addRow()); return r;} |
263 |
266 |
264 ///Add a new row (i.e a new constaint) to the LP |
267 ///Set a row (i.e a constaint) of the LP |
265 |
268 |
266 ///\param l lower bound (-INF means no bound) |
269 ///\param r is the row to be modified |
267 ///\param e a linear expression (see \ref Expr) |
270 ///\param l is lower bound (-INF means no bound) |
268 ///\param u upper bound (INF means no bound) |
271 ///\param e is a linear expression (see \ref Expr) |
|
272 ///\param u is the upper bound (INF means no bound) |
269 ///\bug This is a temportary function. The interface will change to |
273 ///\bug This is a temportary function. The interface will change to |
270 ///a better one. |
274 ///a better one. |
271 Row addRow(Value l,Expr e, Value u) { |
275 void setRow(Row r, Value l,const Expr &e, Value u) { |
272 Row r=addRow(); |
|
273 std::vector<int> indices; |
276 std::vector<int> indices; |
274 std::vector<Value> values; |
277 std::vector<Value> values; |
275 indices.push_back(0); |
278 indices.push_back(0); |
276 values.push_back(0); |
279 values.push_back(0); |
277 for(Expr::iterator i=e.begin(); i!=e.end(); ++i) |
280 for(Expr::const_iterator i=e.begin(); i!=e.end(); ++i) |
278 if((*i).second!=0) { ///\bug EPSILON would be necessary here!!! |
281 if((*i).second!=0) { ///\bug EPSILON would be necessary here!!! |
279 indices.push_back(cols.floatingId((*i).first.id)); |
282 indices.push_back(cols.floatingId((*i).first.id)); |
280 values.push_back((*i).second); |
283 values.push_back((*i).second); |
281 } |
284 } |
282 _setRowCoeffs(rows.floatingId(r.id),indices.size()-1, |
285 _setRowCoeffs(rows.floatingId(r.id),indices.size()-1, |
283 &indices[0],&values[0]); |
286 &indices[0],&values[0]); |
284 _setRowLowerBound(rows.floatingId(r.id),l-e.constComp()); |
287 _setRowLowerBound(rows.floatingId(r.id),l-e.constComp()); |
285 _setRowUpperBound(rows.floatingId(r.id),u-e.constComp()); |
288 _setRowUpperBound(rows.floatingId(r.id),u-e.constComp()); |
|
289 } |
|
290 |
|
291 ///Add a new row (i.e a new constaint) to the LP |
|
292 |
|
293 ///\param l is the lower bound (-INF means no bound) |
|
294 ///\param e is a linear expression (see \ref Expr) |
|
295 ///\param u is the upper bound (INF means no bound) |
|
296 ///\return The created row. |
|
297 ///\bug This is a temportary function. The interface will change to |
|
298 ///a better one. |
|
299 Row addRow(Value l,const Expr &e, Value u) { |
|
300 Row r=addRow(); |
|
301 setRow(r,l,e,u); |
286 return r; |
302 return r; |
287 } |
303 } |
288 |
304 |
289 /// Set the lower bound of a column (i.e a variable) |
305 /// Set the lower bound of a column (i.e a variable) |
290 |
306 |