Changeset 2441:d8d6ab871608 in lemon0.x for lemon/lp_glpk.cc
 Timestamp:
 05/07/07 20:19:55 (13 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@3278
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

lemon/lp_glpk.cc
r2391 r2441 22 22 #include <lemon/lp_glpk.h> 23 23 //#include <iostream> 24 25 #if GLP_MAJOR_VERSION > 4  (GLP_MAJOR_VERSION == 4 && GLP_MINOR_VERSION > 15) 26 #define LEMON_glp(func) (glp_##func) 27 #define LEMON_lpx(func) (lpx_##func) 28 29 #define LEMON_GLP(def) (GLP_##def) 30 #define LEMON_LPX(def) (LPX_##def) 31 32 #else 33 34 #define LEMON_glp(func) (lpx_##func) 35 #define LEMON_lpx(func) (lpx_##func) 36 37 #define LEMON_GLP(def) (LPX_##def) 38 #define LEMON_LPX(def) (LPX_##def) 39 40 #endif 41 24 42 namespace lemon { 25 43 26 27 44 LpGlpk::LpGlpk() : Parent() { 45 solved = false; 28 46 rows = _lp_bits::LpId(1); 29 47 cols = _lp_bits::LpId(1); 30 lp = lpx_create_prob(); 31 lpx_create_index(lp); 32 ///\todo control function for this: 33 lpx_set_int_parm(lp, LPX_K_DUAL, 1); 48 lp = LEMON_glp(create_prob)(); 49 LEMON_glp(create_index)(lp); 50 LEMON_lpx(set_int_parm)(lp, LEMON_LPX(K_DUAL), 1); 34 51 messageLevel(0); 35 52 } 36 53 37 54 LpGlpk::LpGlpk(const LpGlpk &glp) : Parent() { 55 solved = false; 38 56 rows = _lp_bits::LpId(1); 39 57 cols = _lp_bits::LpId(1); 40 lp = lpx_create_prob();41 lpx_create_index(lp);58 lp = LEMON_glp(create_prob)(); 59 LEMON_glp(create_index)(lp); 42 60 ///\todo control function for this: 43 lpx_set_int_parm(lp, LPX_K_DUAL, 1);61 LEMON_lpx(set_int_parm)(lp, LEMON_LPX(K_DUAL), 1); 44 62 messageLevel(0); 45 63 //Coefficient matrix, row bounds 46 lpx_add_rows(lp, lpx_get_num_rows(glp.lp));47 lpx_add_cols(lp, lpx_get_num_cols(glp.lp));64 LEMON_glp(add_rows)(lp, LEMON_glp(get_num_rows)(glp.lp)); 65 LEMON_glp(add_cols)(lp, LEMON_glp(get_num_cols)(glp.lp)); 48 66 int len; 49 int ind[1+ lpx_get_num_cols(glp.lp)];50 Value val[1+ lpx_get_num_cols(glp.lp)];51 for (int i=1;i<= lpx_get_num_rows(glp.lp);++i)67 int ind[1+LEMON_glp(get_num_cols)(glp.lp)]; 68 Value val[1+LEMON_glp(get_num_cols)(glp.lp)]; 69 for (int i=1;i<=LEMON_glp(get_num_rows)(glp.lp);++i) 52 70 { 53 len=lpx_get_mat_row(glp.lp,i,ind,val); 54 lpx_set_mat_row(lp, i,len,ind,val); 55 lpx_set_row_bnds(lp,i,lpx_get_row_type(glp.lp,i), 56 lpx_get_row_lb(glp.lp,i),lpx_get_row_ub(glp.lp,i)); 71 len=LEMON_glp(get_mat_row)(glp.lp,i,ind,val); 72 LEMON_glp(set_mat_row)(lp, i,len,ind,val); 73 LEMON_glp(set_row_bnds)(lp,i, 74 LEMON_glp(get_row_type)(glp.lp,i), 75 LEMON_glp(get_row_lb)(glp.lp,i), 76 LEMON_glp(get_row_ub)(glp.lp,i)); 57 77 } 58 78 59 79 //Objective function, coloumn bounds 60 lpx_set_obj_dir(lp, lpx_get_obj_dir(glp.lp));80 LEMON_glp(set_obj_dir)(lp, LEMON_glp(get_obj_dir)(glp.lp)); 61 81 //Objectif function's constant term treated separately 62 lpx_set_obj_coef(lp,0,lpx_get_obj_coef(glp.lp,0));63 for (int i=1;i<= lpx_get_num_cols(glp.lp);++i)82 LEMON_glp(set_obj_coef)(lp,0,LEMON_glp(get_obj_coef)(glp.lp,0)); 83 for (int i=1;i<=LEMON_glp(get_num_cols)(glp.lp);++i) 64 84 { 65 lpx_set_obj_coef(lp,i,lpx_get_obj_coef(glp.lp,i)); 66 lpx_set_col_bnds(lp,i,lpx_get_col_type(glp.lp,i), 67 lpx_get_col_lb(glp.lp,i),lpx_get_col_ub(glp.lp,i)); 85 LEMON_glp(set_obj_coef)(lp,i, 86 LEMON_glp(get_obj_coef)(glp.lp,i)); 87 LEMON_glp(set_col_bnds)(lp,i, 88 LEMON_glp(get_col_type)(glp.lp,i), 89 LEMON_glp(get_col_lb)(glp.lp,i), 90 LEMON_glp(get_col_ub)(glp.lp,i)); 68 91 } 69 92 } 70 93 71 94 LpGlpk::~LpGlpk() { 72 lpx_delete_prob(lp);95 LEMON_glp(delete_prob)(lp); 73 96 } 74 97 75 98 int LpGlpk::_addCol() { 76 int i= lpx_add_cols(lp, 1);77 _setColLowerBound(i, INF);78 _setColUpperBound(i, INF);99 int i=LEMON_glp(add_cols)(lp, 1); 100 LEMON_glp(set_col_bnds)(lp, i, LEMON_GLP(FR), 0.0, 0.0); 101 solved = false; 79 102 return i; 80 103 } … … 98 121 99 122 int LpGlpk::_addRow() { 100 int i=lpx_add_rows(lp, 1); 123 int i=LEMON_glp(add_rows)(lp, 1); 124 solved = false; 101 125 return i; 102 126 } … … 106 130 int ca[2]; 107 131 ca[1]=i; 108 lpx_del_cols(lp, 1, ca); 132 LEMON_glp(del_cols)(lp, 1, ca); 133 solved = false; 109 134 } 110 135 … … 112 137 int ra[2]; 113 138 ra[1]=i; 114 lpx_del_rows(lp, 1, ra); 139 LEMON_glp(del_rows)(lp, 1, ra); 140 solved = false; 115 141 } 116 142 … … 118 144 { 119 145 120 c har *n = lpx_get_col_name(lp,c);146 const char *n = LEMON_glp(get_col_name)(lp,c); 121 147 name = n?n:""; 122 148 } … … 125 151 void LpGlpk::_setColName(int c, const std::string & name) 126 152 { 127 lpx_set_col_name(lp,c,const_cast<char*>(name.c_str()));153 LEMON_glp(set_col_name)(lp,c,const_cast<char*>(name.c_str())); 128 154 129 155 } … … 131 157 int LpGlpk::_colByName(const std::string& name) const 132 158 { 133 int k = lpx_find_col(lp, const_cast<char*>(name.c_str()));159 int k = LEMON_glp(find_col)(lp, const_cast<char*>(name.c_str())); 134 160 return k > 0 ? k : 1; 135 161 } … … 149 175 } 150 176 151 lpx_set_mat_row(lp, i, values.size()  1, &indices[0], &values[0]); 177 LEMON_glp(set_mat_row)(lp, i, values.size()  1, 178 &indices[0], &values[0]); 179 180 solved = false; 152 181 } 153 182 154 183 void LpGlpk::_getRowCoeffs(int ix, RowIterator b) const 155 184 { 156 int length = lpx_get_mat_row(lp, ix, 0, 0);185 int length = LEMON_glp(get_mat_row)(lp, ix, 0, 0); 157 186 158 187 std::vector<int> indices(length + 1); 159 188 std::vector<Value> values(length + 1); 160 189 161 lpx_get_mat_row(lp, ix, &indices[0], &values[0]);190 LEMON_glp(get_mat_row)(lp, ix, &indices[0], &values[0]); 162 191 163 192 for (int i = 1; i <= length; ++i) { … … 180 209 } 181 210 182 lpx_set_mat_col(lp, ix, values.size()  1, &indices[0], &values[0]); 211 LEMON_glp(set_mat_col)(lp, ix, values.size()  1, 212 &indices[0], &values[0]); 213 214 solved = false; 183 215 } 184 216 185 217 void LpGlpk::_getColCoeffs(int ix, ColIterator b) const 186 218 { 187 int length = lpx_get_mat_col(lp, ix, 0, 0);219 int length = LEMON_glp(get_mat_col)(lp, ix, 0, 0); 188 220 189 221 std::vector<int> indices(length + 1); 190 222 std::vector<Value> values(length + 1); 191 223 192 lpx_get_mat_col(lp, ix, &indices[0], &values[0]);224 LEMON_glp(get_mat_col)(lp, ix, &indices[0], &values[0]); 193 225 194 226 for (int i = 1; i <= length; ++i) { … … 201 233 { 202 234 203 if ( lpx_get_num_cols(lp) < lpx_get_num_rows(lp)) {204 205 int length= lpx_get_mat_row(lp, ix, 0, 0);235 if (LEMON_glp(get_num_cols)(lp) < LEMON_glp(get_num_rows)(lp)) { 236 237 int length=LEMON_glp(get_mat_row)(lp, ix, 0, 0); 206 238 207 239 std::vector<int> indices(length + 2); 208 240 std::vector<Value> values(length + 2); 209 241 210 lpx_get_mat_row(lp, ix, &indices[0], &values[0]);242 LEMON_glp(get_mat_row)(lp, ix, &indices[0], &values[0]); 211 243 212 244 //The following code does not suppose that the elements of the … … 226 258 } 227 259 228 lpx_set_mat_row(lp, ix, length, &indices[0], &values[0]);260 LEMON_glp(set_mat_row)(lp, ix, length, &indices[0], &values[0]); 229 261 230 262 } else { 231 263 232 int length= lpx_get_mat_col(lp, jx, 0, 0);264 int length=LEMON_glp(get_mat_col)(lp, jx, 0, 0); 233 265 234 266 std::vector<int> indices(length + 2); 235 267 std::vector<Value> values(length + 2); 236 268 237 lpx_get_mat_col(lp, jx, &indices[0], &values[0]);269 LEMON_glp(get_mat_col)(lp, jx, &indices[0], &values[0]); 238 270 239 271 //The following code does not suppose that the elements of the … … 253 285 } 254 286 255 lpx_set_mat_col(lp, jx, length, &indices[0], &values[0]); 256 } 287 LEMON_glp(set_mat_col)(lp, jx, length, &indices[0], &values[0]); 288 } 289 290 solved = false; 257 291 } 258 292 … … 260 294 { 261 295 262 int length= lpx_get_mat_row(lp, ix, 0, 0);296 int length=LEMON_glp(get_mat_row)(lp, ix, 0, 0); 263 297 264 298 std::vector<int> indices(length + 1); 265 299 std::vector<Value> values(length + 1); 266 300 267 lpx_get_mat_row(lp, ix, &indices[0], &values[0]);301 LEMON_glp(get_mat_row)(lp, ix, &indices[0], &values[0]); 268 302 269 303 //The following code does not suppose that the elements of the … … 284 318 //FIXME error 285 319 } 286 int b= lpx_get_col_type(lp, i);287 double up= lpx_get_col_ub(lp, i);320 int b=LEMON_glp(get_col_type)(lp, i); 321 double up=LEMON_glp(get_col_ub)(lp, i); 288 322 if (lo==INF) { 289 323 switch (b) { 290 case L PX_FR:291 case L PX_LO:292 lpx_set_col_bnds(lp, i, LPX_FR, lo, up);293 break; 294 case L PX_UP:295 break; 296 case L PX_DB:297 case L PX_FX:298 lpx_set_col_bnds(lp, i, LPX_UP, lo, up);324 case LEMON_GLP(FR): 325 case LEMON_GLP(LO): 326 LEMON_glp(set_col_bnds)(lp, i, LEMON_GLP(FR), lo, up); 327 break; 328 case LEMON_GLP(UP): 329 break; 330 case LEMON_GLP(DB): 331 case LEMON_GLP(FX): 332 LEMON_glp(set_col_bnds)(lp, i, LEMON_GLP(UP), lo, up); 299 333 break; 300 334 default: ; … … 303 337 } else { 304 338 switch (b) { 305 case L PX_FR:306 case L PX_LO:307 lpx_set_col_bnds(lp, i, LPX_LO, lo, up);308 break; 309 case L PX_UP:310 case L PX_DB:311 case L PX_FX:339 case LEMON_GLP(FR): 340 case LEMON_GLP(LO): 341 LEMON_glp(set_col_bnds)(lp, i, LEMON_GLP(LO), lo, up); 342 break; 343 case LEMON_GLP(UP): 344 case LEMON_GLP(DB): 345 case LEMON_GLP(FX): 312 346 if (lo==up) 313 lpx_set_col_bnds(lp, i, LPX_FX, lo, up);347 LEMON_glp(set_col_bnds)(lp, i, LEMON_GLP(FX), lo, up); 314 348 else 315 lpx_set_col_bnds(lp, i, LPX_DB, lo, up);349 LEMON_glp(set_col_bnds)(lp, i, LEMON_GLP(DB), lo, up); 316 350 break; 317 351 default: ; … … 320 354 } 321 355 356 solved = false; 322 357 } 323 358 324 359 LpGlpk::Value LpGlpk::_getColLowerBound(int i) const 325 360 { 326 int b= lpx_get_col_type(lp, i);361 int b=LEMON_glp(get_col_type)(lp, i); 327 362 switch (b) { 328 case L PX_LO:329 case L PX_DB:330 case L PX_FX:331 return lpx_get_col_lb(lp, i);363 case LEMON_GLP(LO): 364 case LEMON_GLP(DB): 365 case LEMON_GLP(FX): 366 return LEMON_glp(get_col_lb)(lp, i); 332 367 default: ; 333 368 return INF; … … 340 375 //FIXME error 341 376 } 342 int b= lpx_get_col_type(lp, i);343 double lo= lpx_get_col_lb(lp, i);377 int b=LEMON_glp(get_col_type)(lp, i); 378 double lo=LEMON_glp(get_col_lb)(lp, i); 344 379 if (up==INF) { 345 380 switch (b) { 346 case L PX_FR:347 case L PX_LO:348 break; 349 case L PX_UP:350 lpx_set_col_bnds(lp, i, LPX_FR, lo, up);351 break; 352 case L PX_DB:353 case L PX_FX:354 lpx_set_col_bnds(lp, i, LPX_LO, lo, up);381 case LEMON_GLP(FR): 382 case LEMON_GLP(LO): 383 break; 384 case LEMON_GLP(UP): 385 LEMON_glp(set_col_bnds)(lp, i, LEMON_GLP(FR), lo, up); 386 break; 387 case LEMON_GLP(DB): 388 case LEMON_GLP(FX): 389 LEMON_glp(set_col_bnds)(lp, i, LEMON_GLP(LO), lo, up); 355 390 break; 356 391 default: ; … … 359 394 } else { 360 395 switch (b) { 361 case L PX_FR:362 lpx_set_col_bnds(lp, i, LPX_UP, lo, up);363 break; 364 case L PX_UP:365 lpx_set_col_bnds(lp, i, LPX_UP, lo, up);366 break; 367 case L PX_LO:368 case L PX_DB:369 case L PX_FX:396 case LEMON_GLP(FR): 397 LEMON_glp(set_col_bnds)(lp, i, LEMON_GLP(UP), lo, up); 398 break; 399 case LEMON_GLP(UP): 400 LEMON_glp(set_col_bnds)(lp, i, LEMON_GLP(UP), lo, up); 401 break; 402 case LEMON_GLP(LO): 403 case LEMON_GLP(DB): 404 case LEMON_GLP(FX): 370 405 if (lo==up) 371 lpx_set_col_bnds(lp, i, LPX_FX, lo, up);406 LEMON_glp(set_col_bnds)(lp, i, LEMON_GLP(FX), lo, up); 372 407 else 373 lpx_set_col_bnds(lp, i, LPX_DB, lo, up);408 LEMON_glp(set_col_bnds)(lp, i, LEMON_GLP(DB), lo, up); 374 409 break; 375 410 default: ; … … 377 412 } 378 413 } 414 415 solved = false; 379 416 } 380 417 381 418 LpGlpk::Value LpGlpk::_getColUpperBound(int i) const 382 419 { 383 int b= lpx_get_col_type(lp, i);420 int b=LEMON_glp(get_col_type)(lp, i); 384 421 switch (b) { 385 case L PX_UP:386 case L PX_DB:387 case L PX_FX:388 return lpx_get_col_ub(lp, i);422 case LEMON_GLP(UP): 423 case LEMON_GLP(DB): 424 case LEMON_GLP(FX): 425 return LEMON_glp(get_col_ub)(lp, i); 389 426 default: ; 390 427 return INF; … … 401 438 if (lb == INF){ 402 439 if (ub == INF){ 403 lpx_set_row_bnds(lp, i, LPX_FR, lb, ub);440 LEMON_glp(set_row_bnds)(lp, i, LEMON_GLP(FR), lb, ub); 404 441 } 405 442 else{ 406 lpx_set_row_bnds(lp, i, LPX_UP, lb, ub);443 LEMON_glp(set_row_bnds)(lp, i, LEMON_GLP(UP), lb, ub); 407 444 } 408 445 } 409 446 else{ 410 447 if (ub==INF){ 411 lpx_set_row_bnds(lp, i, LPX_LO, lb, ub);448 LEMON_glp(set_row_bnds)(lp, i, LEMON_GLP(LO), lb, ub); 412 449 413 450 } 414 451 else{ 415 452 if (lb == ub){ 416 lpx_set_row_bnds(lp, i, LPX_FX, lb, ub);453 LEMON_glp(set_row_bnds)(lp, i, LEMON_GLP(FX), lb, ub); 417 454 } 418 455 else{ 419 lpx_set_row_bnds(lp, i, LPX_DB, lb, ub);456 LEMON_glp(set_row_bnds)(lp, i, LEMON_GLP(DB), lb, ub); 420 457 } 421 458 } 422 459 } 423 460 461 solved = false; 424 462 } 425 463 … … 427 465 { 428 466 429 int b= lpx_get_row_type(lp, i);467 int b=LEMON_glp(get_row_type)(lp, i); 430 468 switch (b) { 431 case L PX_FR:432 case L PX_UP:469 case LEMON_GLP(FR): 470 case LEMON_GLP(UP): 433 471 lb = INF; 434 472 break; 435 473 default: 436 lb= lpx_get_row_lb(lp, i);474 lb=LEMON_glp(get_row_lb)(lp, i); 437 475 } 438 476 439 477 switch (b) { 440 case L PX_FR:441 case L PX_LO:478 case LEMON_GLP(FR): 479 case LEMON_GLP(LO): 442 480 ub = INF; 443 481 break; 444 482 default: 445 ub= lpx_get_row_ub(lp, i);483 ub=LEMON_glp(get_row_ub)(lp, i); 446 484 } 447 485 … … 451 489 { 452 490 //i=0 means the constant term (shift) 453 lpx_set_obj_coef(lp, i, obj_coef); 491 LEMON_glp(set_obj_coef)(lp, i, obj_coef); 492 493 solved = false; 454 494 } 455 495 456 496 LpGlpk::Value LpGlpk::_getObjCoeff(int i) const { 457 497 //i=0 means the constant term (shift) 458 return lpx_get_obj_coef(lp, i);498 return LEMON_glp(get_obj_coef)(lp, i); 459 499 } 460 500 461 501 void LpGlpk::_clearObj() 462 502 { 463 for (int i=0;i<=lpx_get_num_cols(lp);++i){ 464 lpx_set_obj_coef(lp, i, 0); 465 } 503 for (int i=0;i<=LEMON_glp(get_num_cols)(lp);++i){ 504 LEMON_glp(set_obj_coef)(lp, i, 0); 505 } 506 507 solved = false; 466 508 } 467 509 … … 469 511 { 470 512 // A way to check the problem to be solved 471 // lpx_write_cpxlp(lp,"naittvan.cpx");472 473 lpx_std_basis(lp);474 int i = lpx_simplex(lp);513 //LEMON_glp(write_cpxlp(lp,"naittvan.cpx"); 514 515 LEMON_lpx(std_basis)(lp); 516 int i = LEMON_lpx(simplex)(lp); 475 517 476 518 switch (i) { 477 case LPX_E_OK: 519 case LEMON_LPX(E_OK): 520 solved = true; 478 521 return SOLVED; 479 522 default: … … 484 527 LpGlpk::Value LpGlpk::_getPrimal(int i) const 485 528 { 486 return lpx_get_col_prim(lp,i);529 return LEMON_glp(get_col_prim)(lp,i); 487 530 } 488 531 489 532 LpGlpk::Value LpGlpk::_getDual(int i) const 490 533 { 491 return lpx_get_row_dual(lp,i);534 return LEMON_glp(get_row_dual)(lp,i); 492 535 } 493 536 494 537 LpGlpk::Value LpGlpk::_getPrimalValue() const 495 538 { 496 return lpx_get_obj_val(lp);539 return LEMON_glp(get_obj_val)(lp); 497 540 } 498 541 bool LpGlpk::_isBasicCol(int i) const 499 542 { 500 return ( lpx_get_col_stat(lp, i)==LPX_BS);543 return (LEMON_glp(get_col_stat)(lp, i)==LEMON_GLP(BS)); 501 544 } 502 545 … … 504 547 LpGlpk::SolutionStatus LpGlpk::_getPrimalStatus() const 505 548 { 506 int stat= lpx_get_status(lp); 549 if (!solved) return UNDEFINED; 550 int stat= LEMON_lpx(get_status)(lp); 507 551 switch (stat) { 508 case L PX_UNDEF://Undefined (no solve has been run yet)552 case LEMON_LPX(UNDEF)://Undefined (no solve has been run yet) 509 553 return UNDEFINED; 510 case L PX_NOFEAS://There is no feasible solution (primal, I guess)511 case L PX_INFEAS://Infeasible554 case LEMON_LPX(NOFEAS)://There is no feasible solution (primal, I guess) 555 case LEMON_LPX(INFEAS)://Infeasible 512 556 return INFEASIBLE; 513 case L PX_UNBND://Unbounded557 case LEMON_LPX(UNBND)://Unbounded 514 558 return INFINITE; 515 case L PX_FEAS://Feasible559 case LEMON_LPX(FEAS)://Feasible 516 560 return FEASIBLE; 517 case L PX_OPT://Feasible561 case LEMON_LPX(OPT)://Feasible 518 562 return OPTIMAL; 519 563 default: … … 525 569 LpGlpk::SolutionStatus LpGlpk::_getDualStatus() const 526 570 { 527 switch (lpx_get_dual_stat(lp)) { 528 case LPX_D_UNDEF://Undefined (no solve has been run yet) 571 if (!solved) return UNDEFINED; 572 switch (LEMON_lpx(get_dual_stat)(lp)) { 573 case LEMON_LPX(D_UNDEF)://Undefined (no solve has been run yet) 529 574 return UNDEFINED; 530 case L PX_D_NOFEAS://There is no dual feasible solution531 // case L PX_D_INFEAS://Infeasible575 case LEMON_LPX(D_NOFEAS)://There is no dual feasible solution 576 // case LEMON_LPX(D_INFEAS://Infeasible 532 577 return INFEASIBLE; 533 case L PX_D_FEAS://Feasible534 switch ( lpx_get_status(lp)) {535 case L PX_NOFEAS:578 case LEMON_LPX(D_FEAS)://Feasible 579 switch (LEMON_lpx(get_status)(lp)) { 580 case LEMON_LPX(NOFEAS): 536 581 return INFINITE; 537 case L PX_OPT:582 case LEMON_LPX(OPT): 538 583 return OPTIMAL; 539 584 default: … … 548 593 LpGlpk::ProblemTypes LpGlpk::_getProblemType() const 549 594 { 550 //int stat= lpx_get_status(lp); 551 int statp= lpx_get_prim_stat(lp); 552 int statd= lpx_get_dual_stat(lp); 553 if (statp==LPX_P_FEAS && statd==LPX_D_FEAS) 595 if (!solved) return UNKNOWN; 596 //int stat= LEMON_glp(get_status(lp); 597 int statp= LEMON_lpx(get_prim_stat)(lp); 598 int statd= LEMON_lpx(get_dual_stat)(lp); 599 if (statp==LEMON_LPX(P_FEAS) && statd==LEMON_LPX(D_FEAS)) 554 600 return PRIMAL_DUAL_FEASIBLE; 555 if (statp==L PX_P_FEAS && statd==LPX_D_NOFEAS)601 if (statp==LEMON_LPX(P_FEAS) && statd==LEMON_LPX(D_NOFEAS)) 556 602 return PRIMAL_FEASIBLE_DUAL_INFEASIBLE; 557 if (statp==L PX_P_NOFEAS && statd==LPX_D_FEAS)603 if (statp==LEMON_LPX(P_NOFEAS) && statd==LEMON_LPX(D_FEAS)) 558 604 return PRIMAL_INFEASIBLE_DUAL_FEASIBLE; 559 if (statp==L PX_P_NOFEAS && statd==LPX_D_NOFEAS)605 if (statp==LEMON_LPX(P_NOFEAS) && statd==LEMON_LPX(D_NOFEAS)) 560 606 return PRIMAL_DUAL_INFEASIBLE; 561 607 //In all other cases … … 565 611 void LpGlpk::_setMax() 566 612 { 567 lpx_set_obj_dir(lp, LPX_MAX); 613 solved = false; 614 LEMON_glp(set_obj_dir)(lp, LEMON_GLP(MAX)); 568 615 } 569 616 570 617 void LpGlpk::_setMin() 571 618 { 572 lpx_set_obj_dir(lp, LPX_MIN); 619 solved = false; 620 LEMON_glp(set_obj_dir)(lp, LEMON_GLP(MIN)); 573 621 } 574 622 575 623 bool LpGlpk::_isMax() const 576 624 { 577 return ( lpx_get_obj_dir(lp)==LPX_MAX);625 return (LEMON_glp(get_obj_dir)(lp)==LEMON_GLP(MAX)); 578 626 } 579 627 … … 582 630 void LpGlpk::messageLevel(int m) 583 631 { 584 lpx_set_int_parm(lp, LPX_K_MSGLEV, m);632 LEMON_lpx(set_int_parm)(lp, LEMON_LPX(K_MSGLEV), m); 585 633 } 586 634 587 635 void LpGlpk::presolver(bool b) 588 636 { 589 lpx_set_int_parm(lp, LPX_K_PRESOL, b);637 LEMON_lpx(set_int_parm)(lp, LEMON_LPX(K_PRESOL), b); 590 638 } 591 639
Note: See TracChangeset
for help on using the changeset viewer.