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

 1 edited
Legend:
 Unmodified
 Added
 Removed

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)
Note: See TracChangeset
for help on using the changeset viewer.