Changeset 1458:7a483c1d38b5 in lemon0.x
 Timestamp:
 06/09/05 11:49:48 (17 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@1938
 Location:
 lemon
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

lemon/lp_base.h
r1445 r1458 109 109 public: 110 110 111 /// \e111 ///Possible outcomes of an LP solving procedure 112 112 enum SolveExitStatus { 113 ///\e 113 ///This means that the problem has been successfully solved: either 114 ///an optimal solution has been found or infeasibility/unboundedness 115 ///has been proved. 114 116 SOLVED = 0, 115 /// \e117 ///Any other case (including the case when some user specified limit has been exceeded) 116 118 UNSOLVED = 1 117 119 }; … … 916 918 ///@{ 917 919 918 ///\e 920 ///\e Solve the LP problem at hand 921 /// 922 ///\return The result of the optimization procedure. Possible values and their meanings can be found in the documentation of \ref SolveExitStatus. 923 /// 924 ///\todo Which method is used to solve the problem 919 925 SolveExitStatus solve() { return _solve(); } 920 926 … … 925 931 ///@{ 926 932 927 ///\e 933 ///\e 928 934 SolutionStatus primalStatus() { 929 935 return _getPrimalStatus(); 
lemon/lp_cplex.cc
r1436 r1458 26 26 env = CPXopenCPLEX(&status); 27 27 lp = CPXcreateprob(env, &status, "LP problem"); 28 //CPXmsg (cpxresults, "Hellobello\n");29 28 } 30 29 … … 231 230 232 231 } 233 232 // The routine returns zero unless an error occurred during the 233 // optimization. Examples of errors include exhausting available 234 // memory (CPXERR_NO_MEMORY) or encountering invalid data in the 235 // CPLEX problem object (CPXERR_NO_PROBLEM). Exceeding a 236 // userspecified CPLEX limit, or proving the model infeasible or 237 // unbounded, are not considered errors. Note that a zero return 238 // value does not necessarily mean that a solution exists. Use query 239 // routines CPXsolninfo, CPXgetstat, and CPXsolution to obtain 240 // further information about the status of the optimization. 234 241 LpCplex::SolveExitStatus LpCplex::_solve() 235 242 { 236 243 //CPX_PARAM_LPMETHOD 237 244 status = CPXlpopt (env, lp); 238 245 if (status == 0){ 239 return SOLVED; 246 //We want to exclude some cases 247 switch (CPXgetstat (env, lp)){ 248 case CPX_OBJ_LIM: 249 case CPX_IT_LIM_FEAS: 250 case CPX_IT_LIM_INFEAS: 251 case CPX_TIME_LIM_FEAS: 252 case CPX_TIME_LIM_INFEAS: 253 return UNSOLVED; 254 default: 255 return SOLVED; 256 } 240 257 } 241 258 else{ 242 259 return UNSOLVED; 243 260 } 244 // int i= lpx_simplex(lp); 245 // switch (i) { 246 // case LPX_E_OK: 247 // return SOLVED; 248 // break; 249 // default: 250 // return UNSOLVED; 251 // } 252 } 253 254 LpCplex::SolutionStatus LpCplex::_getPrimalStatus() 255 { 256 //7.5os cplex statusai 257 // #define CPX_OPTIMAL 1 258 // #define CPX_INFEASIBLE 2 259 // #define CPX_UNBOUNDED 3 260 // #define CPX_OBJ_LIM 4 261 // #define CPX_IT_LIM_FEAS 5 262 // #define CPX_IT_LIM_INFEAS 6 263 // #define CPX_TIME_LIM_FEAS 7 264 // #define CPX_TIME_LIM_INFEAS 8 265 // #define CPX_NUM_BEST_FEAS 9 266 // #define CPX_NUM_BEST_INFEAS 10 267 // #define CPX_OPTIMAL_INFEAS 11 268 // #define CPX_ABORT_FEAS 12 269 // #define CPX_ABORT_INFEAS 13 270 // #define CPX_ABORT_DUAL_INFEAS 14 271 // #define CPX_ABORT_PRIM_INFEAS 15 272 // #define CPX_ABORT_PRIM_DUAL_INFEAS 16 273 // #define CPX_ABORT_PRIM_DUAL_FEAS 17 274 // #define CPX_ABORT_CROSSOVER 18 275 // #define CPX_INForUNBD 19 276 // #define CPX_PIVOT 20 277 261 } 262 263 264 //7.5os cplex statusai (Vigyazat: a 9.0asei masok!) 265 // This table lists the statuses, returned by the CPXgetstat() routine, for solutions to LP problems or mixed integer problems. If no solution exists, the return value is zero. 266 267 // For Simplex, Barrier 268 // 1 CPX_OPTIMAL 269 // Optimal solution found 270 // 2 CPX_INFEASIBLE 271 // Problem infeasible 272 // 3 CPX_UNBOUNDED 273 // Problem unbounded 274 // 4 CPX_OBJ_LIM 275 // Objective limit exceeded in Phase II 276 // 5 CPX_IT_LIM_FEAS 277 // Iteration limit exceeded in Phase II 278 // 6 CPX_IT_LIM_INFEAS 279 // Iteration limit exceeded in Phase I 280 // 7 CPX_TIME_LIM_FEAS 281 // Time limit exceeded in Phase II 282 // 8 CPX_TIME_LIM_INFEAS 283 // Time limit exceeded in Phase I 284 // 9 CPX_NUM_BEST_FEAS 285 // Problem nonoptimal, singularities in Phase II 286 // 10 CPX_NUM_BEST_INFEAS 287 // Problem nonoptimal, singularities in Phase I 288 // 11 CPX_OPTIMAL_INFEAS 289 // Optimal solution found, unscaled infeasibilities 290 // 12 CPX_ABORT_FEAS 291 // Aborted in Phase II 292 // 13 CPX_ABORT_INFEAS 293 // Aborted in Phase I 294 // 14 CPX_ABORT_DUAL_INFEAS 295 // Aborted in barrier, dual infeasible 296 // 15 CPX_ABORT_PRIM_INFEAS 297 // Aborted in barrier, primal infeasible 298 // 16 CPX_ABORT_PRIM_DUAL_INFEAS 299 // Aborted in barrier, primal and dual infeasible 300 // 17 CPX_ABORT_PRIM_DUAL_FEAS 301 // Aborted in barrier, primal and dual feasible 302 // 18 CPX_ABORT_CROSSOVER 303 // Aborted in crossover 304 // 19 CPX_INForUNBD 305 // Infeasible or unbounded 306 // 20 CPX_PIVOT 307 // User pivot used 308 // 278 309 // Ezeket hova tegyem: 279 310 // ??case CPX_ABORT_DUAL_INFEAS … … 282 313 // ??case CPX_PIVOT 283 314 315 LpCplex::SolutionStatus LpCplex::_getPrimalStatus() 316 { 284 317 int stat = CPXgetstat (env, lp); 285 318 switch (stat) { 286 319 case 0: 287 320 return UNDEFINED; //Undefined 288 break;289 321 case CPX_OPTIMAL://Optimal 290 322 return OPTIMAL; 291 break;292 323 case CPX_UNBOUNDED://Unbounded 293 324 return INFINITE; 294 break;295 325 case CPX_INFEASIBLE://Infeasible 296 case CPX_IT_LIM_INFEAS:297 case CPX_TIME_LIM_INFEAS:298 case CPX_NUM_BEST_INFEAS:299 case CPX_OPTIMAL_INFEAS:300 case CPX_ABORT_INFEAS:301 case CPX_ABORT_PRIM_INFEAS:302 case CPX_ABORT_PRIM_DUAL_INFEAS:326 // case CPX_IT_LIM_INFEAS: 327 // case CPX_TIME_LIM_INFEAS: 328 // case CPX_NUM_BEST_INFEAS: 329 // case CPX_OPTIMAL_INFEAS: 330 // case CPX_ABORT_INFEAS: 331 // case CPX_ABORT_PRIM_INFEAS: 332 // case CPX_ABORT_PRIM_DUAL_INFEAS: 303 333 return INFEASIBLE; 304 break; 305 case CPX_OBJ_LIM: 306 case CPX_IT_LIM_FEAS: 307 case CPX_TIME_LIM_FEAS: 308 case CPX_NUM_BEST_FEAS: 309 case CPX_ABORT_FEAS: 310 case CPX_ABORT_PRIM_DUAL_FEAS: 311 return FEASIBLE; 312 break; 334 // case CPX_OBJ_LIM: 335 // case CPX_IT_LIM_FEAS: 336 // case CPX_TIME_LIM_FEAS: 337 // case CPX_NUM_BEST_FEAS: 338 // case CPX_ABORT_FEAS: 339 // case CPX_ABORT_PRIM_DUAL_FEAS: 340 // return FEASIBLE; 313 341 default: 314 342 return UNDEFINED; //Everything else comes here … … 316 344 } 317 345 318 319 //Nem tudom, hanyas cplex verzio statusai 346 } 347 348 //9.0as cplex verzio statusai 320 349 // CPX_STAT_ABORT_DUAL_OBJ_LIM 321 350 // CPX_STAT_ABORT_IT_LIM … … 334 363 // CPX_STAT_UNBOUNDED 335 364 336 // int stat = CPXgetstat (env, lp); 337 // switch (stat) { 338 // case CPX_STAT_OPTIMAL://Optimal 339 // return OPTIMAL; 340 // break; 341 // case CPX_STAT_INFEASIBLE://Infeasible 342 // return INFEASIBLE; 343 // break; 344 // case CPX_STAT_UNBOUNDED://Unbounded 345 // return INFINITE; 346 // break; 347 // case CPX_STAT_NUM_BEST://Feasible 348 // return FEASIBLE; 349 // break; 350 // default: 351 // return UNDEFINED; //Everything else comes here 352 // //FIXME error 353 // } 354 355 } 365 LpCplex::SolutionStatus LpCplex::_getDualStatus() 366 { 367 int stat = CPXgetstat (env, lp); 368 switch (stat) { 369 case 0: 370 return UNDEFINED; //Undefined 371 case CPX_OPTIMAL://Optimal 372 return OPTIMAL; 373 case CPX_UNBOUNDED: 374 return INFEASIBLE; 375 default: 376 return UNDEFINED; //Everything else comes here 377 //FIXME error 378 } 356 379 357 380 LpCplex::Value LpCplex::_getPrimal(int i) 
lemon/lp_glpk.cc
r1436 r1458 397 397 LpGlpk::SolveExitStatus LpGlpk::_solve() 398 398 { 399 int i = lpx_simplex(lp);399 int i = lpx_simplex(lp); 400 400 switch (i) { 401 401 case LPX_E_OK: 402 402 return SOLVED; 403 break;404 403 default: 405 404 return UNSOLVED; … … 421 420 { 422 421 int stat= lpx_get_status(lp); 422 switch (stat) { 423 case LPX_UNDEF://Undefined (no solve has been run yet) 424 return UNDEFINED; 425 case LPX_NOFEAS://There is no feasible solution (primal, I guess) 426 case LPX_INFEAS://Infeasible 427 return INFEASIBLE; 428 case LPX_UNBND://Unbounded 429 return INFINITE; 430 case LPX_FEAS://Feasible 431 return FEASIBLE; 432 case LPX_OPT://Feasible 433 return OPTIMAL; 434 default: 435 return UNDEFINED; //to avoid gcc warning 436 //FIXME error 437 } 438 } 439 440 LpGlpk::SolutionStatus LpGlpk::_getDualStatus() 441 { 442 int stat= lpx_get_dual_stat(lp); 443 switch (stat) { 444 case LPX_D_UNDEF://Undefined (no solve has been run yet) 445 return UNDEFINED; 446 case LPX_D_NOFEAS://There is no feasible solution (primal, I guess) 447 case LPX_D_INFEAS://Infeasible 448 return INFEASIBLE; 449 case LPX_FEAS://Feasible 450 int stat2= lpx_get_prim_stat(lp); 451 switch (stat2){ 452 case LPX_P_NOFEAS: 453 return INFINITE; 454 case LPX_OPT: 455 return OPTIMAL; 456 default: 457 return FEASIBLE; 458 } 459 default: 460 return UNDEFINED; //to avoid gcc warning 461 //FIXME error 462 } 463 } 464 465 LpGlpk::ProblemTypes LpGlpk::_problemType() 466 { 467 int stat= lpx_get_status(lp); 468 int statp= lpx_get_prim_stat(lp); 469 int statd= lpx_get_dual_stat(lp); 423 470 switch (stat) { 424 471 case LPX_UNDEF://Undefined (no solve has been run yet) … … 444 491 } 445 492 446 447 493 void LpGlpk::_setMax() 448 494 {
Note: See TracChangeset
for help on using the changeset viewer.