lemon/mip_glpk.cc
changeset 2213 2c094dfa176d
parent 2185 e2bf51eab7f7
child 2218 50f1a780a5ff
     1.1 --- a/lemon/mip_glpk.cc	Fri Sep 08 08:55:07 2006 +0000
     1.2 +++ b/lemon/mip_glpk.cc	Fri Sep 08 15:51:32 2006 +0000
     1.3 @@ -57,40 +57,50 @@
     1.4    
     1.5    LpGlpk::SolveExitStatus MipGlpk::_solve(){
     1.6      int result = lpx_simplex(lp);
     1.7 -    result = lpx_integer(lp);
     1.8 -    switch (result){
     1.9 -      case LPX_E_OBJLL:
    1.10 -      case LPX_E_OBJUL:
    1.11 -      case LPX_E_ITLIM:
    1.12 -      case LPX_E_TMLIM:
    1.13 +    //
    1.14 +    if (lpx_get_status(lp)==LPX_OPT){
    1.15 +      //Maybe we could try the routine lpx_intopt(lp), a revised
    1.16 +      //version of lpx_integer
    1.17 +      result = lpx_integer(lp);
    1.18 +      switch (result){
    1.19        case LPX_E_OK:
    1.20 -        return SOLVED;
    1.21 +	return SOLVED;
    1.22        default:
    1.23 -        return UNSOLVED;
    1.24 +	return UNSOLVED;
    1.25 +      }
    1.26 +      
    1.27      }
    1.28 +    return UNSOLVED;
    1.29    }
    1.30  
    1.31  
    1.32    LpGlpk::SolutionStatus MipGlpk::_getMipStatus(){
    1.33  
    1.34 -    //Meg kell nezni: ha az LP is infinite, akkor ez is, ha az is
    1.35 -    //infeasible, akkor ez is, de ez lehet maskepp is infeasible.
    1.36 -    int stat=  lpx_mip_status(lp);
    1.37 -    switch (stat) {
    1.38 -    case LPX_I_UNDEF://Undefined (no solve has been run yet)
    1.39 -      return UNDEFINED;
    1.40 -   case LPX_I_NOFEAS://There is no feasible integral solution (primal, I guess)
    1.41 -      return INFEASIBLE;
    1.42 -//     case LPX_UNBND://Unbounded
    1.43 -//       return INFINITE;
    1.44 -    case LPX_I_FEAS://Feasible
    1.45 -      return FEASIBLE;
    1.46 -    case LPX_I_OPT://Feasible
    1.47 -      return OPTIMAL;
    1.48 -    default:
    1.49 +    if (lpx_get_status(lp)==LPX_OPT){
    1.50 +      //Meg kell nezni: ha az LP is infinite, akkor ez is, ha az is
    1.51 +      //infeasible, akkor ez is, de ez lehet maskepp is infeasible.
    1.52 +      int stat=  lpx_mip_status(lp);
    1.53 +      
    1.54 +      switch (stat) {
    1.55 +      case LPX_I_UNDEF://Undefined (no solve has been run yet)
    1.56 +	return UNDEFINED;
    1.57 +      case LPX_I_NOFEAS://There is no feasible integral solution
    1.58 +	return INFEASIBLE;
    1.59 +	//     case LPX_UNBND://Unbounded
    1.60 +	//       return INFINITE;
    1.61 +      case LPX_I_FEAS://Feasible
    1.62 +	return FEASIBLE;
    1.63 +      case LPX_I_OPT://Feasible
    1.64 +	return OPTIMAL;
    1.65 +      default:
    1.66        return UNDEFINED; //to avoid gcc warning
    1.67        //FIXME error
    1.68 +      }
    1.69      }
    1.70 +    else 
    1.71 +      return UNDEFINED; //Maybe we could refine this: what does the LP
    1.72 +			//relaxation look like
    1.73 +      
    1.74    }  
    1.75  
    1.76    MipGlpk::Value MipGlpk::_getPrimal(int i){