Changeset 1263:a490938ad0aa in lemon-0.x for src/work
- Timestamp:
- 03/25/05 17:19:03 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1690
- Location:
- src/work/athos/lp
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/work/athos/lp/Makefile
r1256 r1263 9 9 lp_solver_skeleton.o: lp_solver_skeleton.cc lp_solver_skeleton.h lp_base.h \ 10 10 lin_expr.h 11 lp_glpk.o: lp_glpk.cc lp_glpk.h lp_base.h \ 12 lin_expr.h 11 13 lp_test.o: lp_test.cc lp_base.h lin_expr.h lp_solver_skeleton.h lp_base.h \ 12 14 lin_expr.h 13 15 14 lp_test: lp_test.o lp_base.o lp_solver_skeleton.o 15 g++ -o $@ $^ 16 lp_test: lp_test.o lp_base.o lp_solver_skeleton.o lp_glpk.o 17 g++ -o $@ $^ -lglpk -
src/work/athos/lp/lp_base.h
r1259 r1263 101 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 115 ///The floating point type used by the solver 104 116 typedef double Value; … … 161 173 _FixId cols; 162 174 163 //MATRIX MANIPULATING FUNCTIONS164 165 175 /// \e 166 176 virtual int _addCol() = 0; … … 213 223 214 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 237 ///\bug unimplemented!!!! … … 222 243 virtual ~LpSolverBase() {} 223 244 245 ///\name Building up and modification of the LP 246 247 ///@{ 248 224 249 ///Add a new empty column (i.e a new variable) to the LP 225 250 Col addCol() { Col c; c.id=cols.insert(_addCol()); return c;} 251 226 252 ///\brief Fill the elements of a container with newly created columns 227 253 ///(i.e a new variables) … … 262 288 } 263 289 #endif 290 264 291 ///Add a new empty row (i.e a new constaint) to the LP 265 292 … … 349 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 }; -
src/work/athos/lp/lp_glpk.cc
r1261 r1263 42 42 void LpGlpk::_setRowCoeffs(int i, 43 43 int length, 44 int * indices, 45 Value * values ) 46 { 47 lpx_set_mat_row(lp, i, length, indices, values); 44 const int * indices, 45 const Value * values ) 46 { 47 lpx_set_mat_row(lp, i, length, 48 const_cast<int * >(indices) , 49 const_cast<Value * >(values)); 48 50 } 49 51 50 52 void LpGlpk::_setColCoeffs(int i, 51 53 int length, 52 int * indices, 53 Value * values) 54 { 55 lpx_set_mat_col(lp, i, length, indices, values); 54 const int * indices, 55 const Value * values) 56 { 57 lpx_set_mat_col(lp, i, length, 58 const_cast<int * >(indices), 59 const_cast<Value * >(values)); 56 60 } 57 61 … … 234 238 } 235 239 240 241 LpGlpk::SolutionType LpGlpk::_solve() 242 { 243 return OPTIMAL; 244 } 245 246 LpGlpk::Value LpGlpk::_getSolution(int i) 247 { 248 return 0; 249 } 250 251 252 236 253 } //END OF NAMESPACE LEMON 237 254 -
src/work/athos/lp/lp_glpk.h
r1261 r1263 56 56 virtual void _setRowCoeffs(int i, 57 57 int length, 58 int * indices,59 Value * values );58 const int * indices, 59 const Value * values ); 60 60 virtual void _setColCoeffs(int i, 61 61 int length, 62 int * indices,63 Value * values);62 const int * indices, 63 const Value * values); 64 64 virtual void _setColLowerBound(int i, Value value); 65 65 virtual void _setColUpperBound(int i, Value value); … … 67 67 virtual void _setRowUpperBound(int i, Value value); 68 68 virtual void _setObjCoeff(int i, Value obj_coef); 69 ///\e 70 71 ///\bug Unimplemented 72 /// 73 virtual SolutionType _solve(); 74 ///\e 75 76 ///\bug Unimplemented 77 /// 78 virtual Value _getSolution(int i); 69 79 70 80 }; -
src/work/athos/lp/lp_solver_skeleton.cc
r1254 r1263 65 65 { 66 66 } 67 68 LpSolverSkeleton::SolutionType LpSolverSkeleton::_solve() 69 { 70 return OPTIMAL; 71 } 72 73 LpSolverSkeleton::Value LpSolverSkeleton::_getSolution(int i) 74 { 75 return 0; 76 } 67 77 68 78 } //namespace lemon -
src/work/athos/lp/lp_solver_skeleton.h
r1254 r1263 44 44 virtual void _setRowUpperBound(int i, Value value); 45 45 virtual void _setObjCoeff(int i, Value obj_coef); 46 virtual SolutionType _solve(); 47 virtual Value _getSolution(int i); 48 46 49 }; 47 50 -
src/work/athos/lp/lp_test.cc
r1259 r1263 1 1 #include"lp_solver_skeleton.h" 2 #include"lp_glpk.h" 2 3 3 4 using namespace lemon; 4 5 5 int main()6 void lpTest(LpSolverBase & lp) 6 7 { 7 typedef LpSolverSkeleton LP; 8 LP lp; 8 typedef LpSolverBase LP; 9 9 10 10 std::vector<LP::Col> x; … … 38 38 lp.addRow(LP::INF,3.0*(x[1]+x[2]*2-5*x[3]+12-x[4]/3)+2*x[4]-4,23); 39 39 } 40 41 42 int main() 43 { 44 LpSolverSkeleton lp_skel; 45 LpGlpk lp_glpk; 46 47 lpTest(lp_skel); 48 lpTest(lp_glpk); 49 }
Note: See TracChangeset
for help on using the changeset viewer.