Changeset 2324:18fc834761d9 in lemon-0.x
- Timestamp:
- 12/04/06 17:48:13 (17 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3100
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/lp_base.h
r2312 r2324 704 704 virtual void _setColCoeffs(int i, LpColIterator b, LpColIterator e) = 0; 705 705 virtual void _setCoeff(int row, int col, Value value) = 0; 706 virtual Value _getCoeff(int row, int col) = 0; 707 706 708 virtual void _setColLowerBound(int i, Value value) = 0; 707 709 virtual void _setColUpperBound(int i, Value value) = 0; … … 710 712 virtual void _setRowBounds(int i, Value lower, Value upper) = 0; 711 713 virtual void _setObjCoeff(int i, Value obj_coef) = 0; 714 virtual Value _getObjCoeff(int i) = 0; 712 715 virtual void _clearObj()=0; 713 716 … … 726 729 virtual void _setMin() = 0; 727 730 731 732 virtual bool _isMax() = 0; 733 728 734 //Own protected stuff 729 735 … … 1001 1007 } 1002 1008 1009 /// Get an element of the coefficient matrix of the LP 1010 1011 ///\param r is the row of the element in question 1012 ///\param c is the coloumn of the element in question 1013 ///\return the corresponding coefficient 1014 1015 Value coeff(Row r, Col c){ 1016 return _getCoeff(_lpId(r),_lpId(c)); 1017 } 1018 1003 1019 /// Set the lower bound of a column (i.e a variable) 1004 1020 … … 1172 1188 ///Set an element of the objective function 1173 1189 void objCoeff(Col c, Value v) {_setObjCoeff(_lpId(c),v); }; 1190 1191 ///Get an element of the objective function 1192 Value objCoeff(Col c) {return _getObjCoeff(_lpId(c)); }; 1193 1174 1194 ///Set the objective function 1175 1195 1176 1196 ///\param e is a linear expression of type \ref Expr. 1177 1197 ///\bug Is should be called obj() … … 1188 1208 void min() { _setMin(); } 1189 1209 1210 ///Query function: is this a maximization problem? 1211 bool is_max() {return _isMax(); } 1212 1213 ///Query function: is this a minimization problem? 1214 bool is_min() {return !is_max(); } 1190 1215 1191 1216 ///@} -
lemon/lp_glpk.cc
r2321 r2324 214 214 } 215 215 216 LpGlpk::Value LpGlpk::_getCoeff(int row, int col) 217 { 218 ///\todo This is not yet implemented!!! 219 return 0; 220 } 221 222 216 223 void LpGlpk::_setColLowerBound(int i, Value lo) 217 224 { … … 423 430 //i=0 means the constant term (shift) 424 431 lpx_set_obj_coef(lp, i, obj_coef); 432 } 433 434 LpGlpk::Value LpGlpk::_getObjCoeff(int i){ 435 //i=0 means the constant term (shift) 436 return lpx_get_obj_coef(lp, i); 425 437 } 426 438 … … 552 564 } 553 565 566 bool LpGlpk::_isMax() 567 { 568 return (lpx_get_obj_dir(lp)==LPX_MAX); 569 } 570 554 571 572 555 573 void LpGlpk::messageLevel(int m) 556 574 { -
lemon/lp_glpk.h
r2321 r2324 61 61 virtual void _setColCoeffs(int i, LpColIterator b, LpColIterator e); 62 62 virtual void _setCoeff(int row, int col, Value value); 63 virtual Value _getCoeff(int row, int col); 64 63 65 virtual void _setColLowerBound(int i, Value value); 64 66 virtual void _setColUpperBound(int i, Value value); … … 67 69 virtual void _setRowBounds(int i, Value lower, Value upper); 68 70 virtual void _setObjCoeff(int i, Value obj_coef); 71 virtual Value _getObjCoeff(int i); 69 72 virtual void _clearObj(); 70 73 // virtual void _setObj(int length, … … 91 94 virtual void _setMax(); 92 95 virtual void _setMin(); 96 97 virtual bool _isMax(); 93 98 94 99 public: -
lemon/lp_skeleton.cc
r2312 r2324 69 69 } 70 70 71 LpSkeleton::Value LpSkeleton::_getCoeff(int, int) 72 { 73 return 0; 74 } 75 71 76 72 77 void LpSkeleton::_setColLowerBound(int, Value) … … 94 99 } 95 100 101 LpSkeleton::Value LpSkeleton::_getObjCoeff(int i){ 102 return 0; 103 } 104 96 105 void LpSkeleton::_setMax() 97 106 { … … 101 110 { 102 111 } 112 113 bool LpSkeleton::_isMax() 114 { 115 return true; 116 } 117 103 118 104 119 void LpSkeleton::_clearObj() -
lemon/lp_skeleton.h
r2312 r2324 56 56 virtual void _setCoeff(int row, int col, Value value); 57 57 58 /// Get one element of the coefficient matrix 59 virtual Value _getCoeff(int row, int col); 60 58 61 /// The lower bound of a variable (column) have to be given by an 59 62 /// extended number of type Value, i.e. a finite number of type … … 91 94 /// \e 92 95 virtual void _setObjCoeff(int i, Value obj_coef); 96 97 /// \e 98 virtual Value _getObjCoeff(int i); 93 99 94 100 ///\e … … 135 141 136 142 ///\e 143 virtual bool _isMax(); 144 145 146 147 ///\e 137 148 virtual bool _isBasicCol(int i); 138 149 -
test/lp_test.cc
r2314 r2324 294 294 lp.max(); 295 295 296 297 //Testing the problem retrieving routines 298 check(lp.objCoeff(x1)==1,"First term should be 1 in the obj function!"); 299 check(lp.is_max(),"This is a maximization!"); 300 check(lp.coeff(upright,x1)==1,"The coefficient in question is 1!"); 301 302 296 303 //Maximization of x1+x2 297 304 //over the triangle with vertices (0,0) (0,1) (1,0)
Note: See TracChangeset
for help on using the changeset viewer.