equal
deleted
inserted
replaced
98 ///Common base class for LP solvers |
98 ///Common base class for LP solvers |
99 class LpSolverBase { |
99 class LpSolverBase { |
100 |
100 |
101 public: |
101 public: |
102 |
102 |
|
103 ///\e |
|
104 enum SolutionType { |
|
105 ///\e |
|
106 INFEASIBLE = 0, |
|
107 ///\e |
|
108 UNBOUNDED = 1, |
|
109 ///\e |
|
110 OPTIMAL = 2, |
|
111 ///\e |
|
112 FEASIBLE = 3, |
|
113 }; |
|
114 |
103 ///The floating point type used by the solver |
115 ///The floating point type used by the solver |
104 typedef double Value; |
116 typedef double Value; |
105 ///The infinity constant |
117 ///The infinity constant |
106 static const Value INF; |
118 static const Value INF; |
107 |
119 |
158 |
170 |
159 protected: |
171 protected: |
160 _FixId rows; |
172 _FixId rows; |
161 _FixId cols; |
173 _FixId cols; |
162 |
174 |
163 //MATRIX MANIPULATING FUNCTIONS |
|
164 |
|
165 /// \e |
175 /// \e |
166 virtual int _addCol() = 0; |
176 virtual int _addCol() = 0; |
167 /// \e |
177 /// \e |
168 virtual int _addRow() = 0; |
178 virtual int _addRow() = 0; |
169 /// \e |
179 /// \e |
210 |
220 |
211 /// \e |
221 /// \e |
212 virtual void _setObjCoeff(int i, Value obj_coef) = 0; |
222 virtual void _setObjCoeff(int i, Value obj_coef) = 0; |
213 |
223 |
214 ///\e |
224 ///\e |
|
225 |
|
226 ///\bug Wrong interface |
|
227 /// |
|
228 virtual SolutionType _solve() = 0; |
|
229 |
|
230 ///\e |
|
231 |
|
232 ///\bug Wrong interface |
|
233 /// |
|
234 virtual Value _getSolution(int i) = 0; |
|
235 ///\e |
215 |
236 |
216 ///\bug unimplemented!!!! |
237 ///\bug unimplemented!!!! |
217 void clearObj() {} |
238 void clearObj() {} |
218 public: |
239 public: |
219 |
240 |
220 |
241 |
221 ///\e |
242 ///\e |
222 virtual ~LpSolverBase() {} |
243 virtual ~LpSolverBase() {} |
223 |
244 |
|
245 ///\name Building up and modification of the LP |
|
246 |
|
247 ///@{ |
|
248 |
224 ///Add a new empty column (i.e a new variable) to the LP |
249 ///Add a new empty column (i.e a new variable) to the LP |
225 Col addCol() { Col c; c.id=cols.insert(_addCol()); return c;} |
250 Col addCol() { Col c; c.id=cols.insert(_addCol()); return c;} |
|
251 |
226 ///\brief Fill the elements of a container with newly created columns |
252 ///\brief Fill the elements of a container with newly created columns |
227 ///(i.e a new variables) |
253 ///(i.e a new variables) |
228 /// |
254 /// |
229 ///This magic function takes container as its argument |
255 ///This magic function takes container as its argument |
230 ///and fills its elements |
256 ///and fills its elements |
259 s++; |
285 s++; |
260 } |
286 } |
261 return s; |
287 return s; |
262 } |
288 } |
263 #endif |
289 #endif |
|
290 |
264 ///Add a new empty row (i.e a new constaint) to the LP |
291 ///Add a new empty row (i.e a new constaint) to the LP |
265 |
292 |
266 ///This function adds a new empty row (i.e a new constaint) to the LP. |
293 ///This function adds a new empty row (i.e a new constaint) to the LP. |
267 ///\return The created row |
294 ///\return The created row |
268 Row addRow() { Row r; r.id=rows.insert(_addRow()); return r;} |
295 Row addRow() { Row r; r.id=rows.insert(_addRow()); return r;} |
346 void setObj(Expr e) { |
373 void setObj(Expr e) { |
347 clearObj(); |
374 clearObj(); |
348 for (Expr::iterator i=e.begin(); i!=e.end(); ++i) |
375 for (Expr::iterator i=e.begin(); i!=e.end(); ++i) |
349 setObjCoeff((*i).first,(*i).second); |
376 setObjCoeff((*i).first,(*i).second); |
350 } |
377 } |
|
378 |
|
379 ///@} |
|
380 |
|
381 |
|
382 ///\name Solving the LP |
|
383 |
|
384 ///@{ |
|
385 |
|
386 ///\e |
|
387 SolutionType solve() { return _solve(); } |
|
388 |
|
389 ///@} |
|
390 |
|
391 ///\name Obtaining the solution LP |
|
392 |
|
393 ///@{ |
|
394 |
|
395 ///\e |
|
396 Value solution(Col c) { return _getSolution(cols.floatingId(c.id)); } |
|
397 |
|
398 ///@} |
351 |
399 |
352 }; |
400 }; |
353 |
401 |
354 } //namespace lemon |
402 } //namespace lemon |
355 |
403 |