Changeset 2328:b4931ae52069 in lemon-0.x
- Timestamp:
- 12/07/06 17:10:54 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3104
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/lp_base.h
r2324 r2328 707 707 708 708 virtual void _setColLowerBound(int i, Value value) = 0; 709 virtual Value _getColLowerBound(int i) = 0; 709 710 virtual void _setColUpperBound(int i, Value value) = 0; 711 virtual Value _getColUpperBound(int i) = 0; 710 712 // virtual void _setRowLowerBound(int i, Value value) = 0; 711 713 // virtual void _setRowUpperBound(int i, Value value) = 0; 712 714 virtual void _setRowBounds(int i, Value lower, Value upper) = 0; 715 virtual void _getRowBounds(int i, Value &lower, Value &upper)=0; 716 713 717 virtual void _setObjCoeff(int i, Value obj_coef) = 0; 714 718 virtual Value _getObjCoeff(int i) = 0; … … 1025 1029 _setColLowerBound(_lpId(c),value); 1026 1030 } 1031 1032 /// Get the lower bound of a column (i.e a variable) 1033 1034 /// This function returns the lower bound for column (variable) \t c 1035 /// (this might be -\ref INF as well). 1036 ///\return The lower bound for coloumn \t c 1037 Value colLowerBound(Col c) { 1038 return _getColLowerBound(_lpId(c)); 1039 } 1027 1040 1028 1041 ///\brief Set the lower bound of several columns … … 1072 1085 }; 1073 1086 1074 ///\brief Set the lower bound of several columns 1087 /// Get the upper bound of a column (i.e a variable) 1088 1089 /// This function returns the upper bound for column (variable) \t c 1090 /// (this might be \ref INF as well). 1091 ///\return The upper bound for coloumn \t c 1092 Value colUpperBound(Col c) { 1093 return _getColUpperBound(_lpId(c)); 1094 } 1095 1096 ///\brief Set the upper bound of several columns 1075 1097 ///(i.e a variables) at once 1076 1098 /// … … 1177 1199 /// Set the lower and the upper bounds of a row (i.e a constraint) 1178 1200 1179 /// The lower and the upper bound sof1201 /// The lower and the upper bound of 1180 1202 /// a constraint (row) have to be given by an 1181 1203 /// extended number of type Value, i.e. a finite number of type 1182 /// Value, -\ref INF or \ref INF. 1204 /// Value, -\ref INF or \ref INF. There is no separate function for the 1205 /// lower and the upper bound because that would have been hard to implement 1206 /// for CPLEX. 1183 1207 void rowBounds(Row c, Value lower, Value upper) { 1184 1208 _setRowBounds(_lpId(c),lower, upper); 1185 // _setRowUpperBound(_lpId(c),upper); 1186 } 1187 1209 } 1210 1211 /// Get the lower and the upper bounds of a row (i.e a constraint) 1212 1213 /// The lower and the upper bound of 1214 /// a constraint (row) are 1215 /// extended numbers of type Value, i.e. finite numbers of type 1216 /// Value, -\ref INF or \ref INF. 1217 /// \todo There is no separate function for the 1218 /// lower and the upper bound because we had problems with the 1219 /// implementation of the setting functions for CPLEX: 1220 /// check out whether this can be done for these functions. 1221 void getRowBounds(Row c, Value &lower, Value &upper) { 1222 _getRowBounds(_lpId(c),lower, upper); 1223 } 1224 1188 1225 ///Set an element of the objective function 1189 1226 void objCoeff(Col c, Value v) {_setObjCoeff(_lpId(c),v); }; -
lemon/lp_cplex.cc
r2312 r2328 44 44 45 45 LpSolverBase &LpCplex::_copyLp() { 46 ///\bug FixID data is not copied! 46 47 //The first approach opens a new environment 47 48 LpCplex* newlp=new LpCplex(); -
lemon/lp_glpk.cc
r2326 r2328 214 214 } 215 215 216 LpGlpk::Value LpGlpk::_getCoeff(int, int) 217 { 218 ///\todo This is not yet implemented!!! 216 LpGlpk::Value LpGlpk::_getCoeff(int row, int col) 217 { 218 219 int length=lpx_get_mat_row(lp, row, 0, 0); 220 221 std::vector<int> indices(length + 2); 222 std::vector<Value> values(length + 2); 223 224 lpx_get_mat_row(lp, row, &indices[0], &values[0]); 225 226 //The following code does not suppose that the elements of the 227 //array indices are sorted 228 for (int i = 1; i <= length; ++i) { 229 if (indices[i]==col){ 230 return values[i]; 231 } 232 } 219 233 return 0; 234 220 235 } 221 236 … … 263 278 264 279 } 280 281 LpGlpk::Value LpGlpk::_getColLowerBound(int i) 282 { 283 int b=lpx_get_col_type(lp, i); 284 switch (b) { 285 case LPX_LO: 286 case LPX_DB: 287 case LPX_FX: 288 return lpx_get_col_lb(lp, i); 289 default: ; 290 return -INF; 291 } 292 } 265 293 266 294 void LpGlpk::_setColUpperBound(int i, Value up) … … 306 334 } 307 335 } 336 } 337 338 LpGlpk::Value LpGlpk::_getColUpperBound(int i) 339 { 340 int b=lpx_get_col_type(lp, i); 341 switch (b) { 342 case LPX_UP: 343 case LPX_DB: 344 case LPX_FX: 345 return lpx_get_col_ub(lp, i); 346 default: ; 347 return INF; 348 } 308 349 } 309 350 … … 424 465 } 425 466 467 } 468 469 void LpGlpk::_getRowBounds(int i, Value &lb, Value &ub) 470 { 471 472 int b=lpx_get_row_type(lp, i); 473 switch (b) { 474 case LPX_FR: 475 case LPX_UP: 476 lb = -INF; 477 break; 478 default: 479 lb=lpx_get_row_lb(lp, i); 480 } 481 482 switch (b) { 483 case LPX_FR: 484 case LPX_LO: 485 ub = INF; 486 break; 487 default: 488 ub=lpx_get_row_ub(lp, i); 489 } 490 426 491 } 427 492 -
lemon/lp_glpk.h
r2324 r2328 64 64 65 65 virtual void _setColLowerBound(int i, Value value); 66 virtual Value _getColLowerBound(int i); 66 67 virtual void _setColUpperBound(int i, Value value); 68 virtual Value _getColUpperBound(int i); 69 67 70 // virtual void _setRowLowerBound(int i, Value value); 68 71 // virtual void _setRowUpperBound(int i, Value value); 69 72 virtual void _setRowBounds(int i, Value lower, Value upper); 73 virtual void _getRowBounds(int i, Value &lb, Value &ub); 70 74 virtual void _setObjCoeff(int i, Value obj_coef); 71 75 virtual Value _getObjCoeff(int i); -
lemon/lp_skeleton.cc
r2326 r2328 79 79 } 80 80 81 LpSkeleton::Value LpSkeleton::_getColLowerBound(int) 82 { 83 return 0; 84 } 85 81 86 void LpSkeleton::_setColUpperBound(int, Value) 82 87 { 88 } 89 90 LpSkeleton::Value LpSkeleton::_getColUpperBound(int) 91 { 92 return 0; 83 93 } 84 94 … … 92 102 93 103 void LpSkeleton::_setRowBounds(int, Value, Value) 104 { 105 } 106 107 void LpSkeleton::_getRowBounds(int, Value&, Value&) 94 108 { 95 109 } -
lemon/lp_skeleton.h
r2324 r2328 65 65 /// \e 66 66 67 /// The lower bound of a variable (column) is an 68 /// extended number of type Value, i.e. a finite number of type 69 /// Value or -\ref INF. 70 virtual Value _getColLowerBound(int i); 71 67 72 /// The upper bound of a variable (column) have to be given by an 68 73 /// extended number of type Value, i.e. a finite number of type … … 70 75 virtual void _setColUpperBound(int i, Value value); 71 76 /// \e 77 78 /// The upper bound of a variable (column) is an 79 /// extended number of type Value, i.e. a finite number of type 80 /// Value or \ref INF. 81 virtual Value _getColUpperBound(int i); 72 82 73 83 // /// The lower bound of a linear expression (row) have to be given by an … … 87 97 /// Value or +/-\ref INF. 88 98 virtual void _setRowBounds(int i, Value lb, Value ub); 99 /// \e 100 101 102 /// The lower and the upper bound of 103 /// a constraint (row) are 104 /// extended numbers of type Value, i.e. finite numbers of type 105 /// Value, -\ref INF or \ref INF. 106 virtual void _getRowBounds(int i, Value &lb, Value &ub); 89 107 /// \e 90 108 -
test/lp_test.cc
r2325 r2328 298 298 check(lp.objCoeff(x1)==1,"First term should be 1 in the obj function!"); 299 299 check(lp.is_max(),"This is a maximization!"); 300 check(lp.coeff(upright,x1)==0,"The coefficient in question is 1!"); 300 check(lp.coeff(upright,x1)==1,"The coefficient in question is 1!"); 301 // std::cout<<lp.colLowerBound(x1)<<std::endl; 302 check( lp.colLowerBound(x1)==0,"The lower bound for variable x1 should be 0."); 303 check( lp.colUpperBound(x1)==LpSolverBase::INF,"The upper bound for variable x1 should be infty."); 304 LpSolverBase::Value lb,ub; 305 lp.getRowBounds(upright,lb,ub); 306 check( lb==-LpSolverBase::INF,"The lower bound for the first row should be -infty."); 307 check( ub==1,"The upper bound for the first row should be 1."); 301 308 302 309
Note: See TracChangeset
for help on using the changeset viewer.