Fixed the mip error (mipstatus was incorrect).
authorathos
Wed, 30 Aug 2006 16:08:03 +0000
changeset 2185e2bf51eab7f7
parent 2184 05a5e48010ab
child 2186 284a9ad118dd
Fixed the mip error (mipstatus was incorrect).
lemon/lp_base.h
lemon/mip_glpk.cc
lemon/mip_glpk.h
     1.1 --- a/lemon/lp_base.h	Mon Aug 28 16:11:02 2006 +0000
     1.2 +++ b/lemon/lp_base.h	Wed Aug 30 16:08:03 2006 +0000
     1.3 @@ -121,7 +121,7 @@
     1.4        
     1.5        ///\e
     1.6      enum SolutionStatus {
     1.7 -      ///Feasible solution has'n been found (but may exist).
     1.8 +      ///Feasible solution hasn't been found (but may exist).
     1.9  
    1.10        ///\todo NOTFOUND might be a better name.
    1.11        ///
    1.12 @@ -1205,10 +1205,16 @@
    1.13        return (colType(c)==INTEGER);
    1.14      }
    1.15  
    1.16 +    /// The status of the MIP problem
    1.17 +    SolutionStatus mipStatus() {
    1.18 +      return _getMipStatus();
    1.19 +    }
    1.20 +
    1.21    protected:
    1.22  
    1.23      virtual ColTypes _colType(int col) = 0;
    1.24      virtual void _colType(int col, ColTypes col_type) = 0;
    1.25 +    virtual SolutionStatus _getMipStatus()=0;
    1.26  
    1.27    };
    1.28    
     2.1 --- a/lemon/mip_glpk.cc	Mon Aug 28 16:11:02 2006 +0000
     2.2 +++ b/lemon/mip_glpk.cc	Wed Aug 30 16:08:03 2006 +0000
     2.3 @@ -69,7 +69,30 @@
     2.4          return UNSOLVED;
     2.5      }
     2.6    }
     2.7 -  
     2.8 +
     2.9 +
    2.10 +  LpGlpk::SolutionStatus MipGlpk::_getMipStatus(){
    2.11 +
    2.12 +    //Meg kell nezni: ha az LP is infinite, akkor ez is, ha az is
    2.13 +    //infeasible, akkor ez is, de ez lehet maskepp is infeasible.
    2.14 +    int stat=  lpx_mip_status(lp);
    2.15 +    switch (stat) {
    2.16 +    case LPX_I_UNDEF://Undefined (no solve has been run yet)
    2.17 +      return UNDEFINED;
    2.18 +   case LPX_I_NOFEAS://There is no feasible integral solution (primal, I guess)
    2.19 +      return INFEASIBLE;
    2.20 +//     case LPX_UNBND://Unbounded
    2.21 +//       return INFINITE;
    2.22 +    case LPX_I_FEAS://Feasible
    2.23 +      return FEASIBLE;
    2.24 +    case LPX_I_OPT://Feasible
    2.25 +      return OPTIMAL;
    2.26 +    default:
    2.27 +      return UNDEFINED; //to avoid gcc warning
    2.28 +      //FIXME error
    2.29 +    }
    2.30 +  }  
    2.31 +
    2.32    MipGlpk::Value MipGlpk::_getPrimal(int i){
    2.33      return lpx_mip_col_val(lp,i);
    2.34    }
     3.1 --- a/lemon/mip_glpk.h	Mon Aug 28 16:11:02 2006 +0000
     3.2 +++ b/lemon/mip_glpk.h	Wed Aug 30 16:08:03 2006 +0000
     3.3 @@ -49,6 +49,7 @@
     3.4      virtual void _colType(int col, ColTypes col_type);
     3.5      
     3.6      virtual LpGlpk::SolveExitStatus _solve();
     3.7 +    virtual LpGlpk::SolutionStatus _getMipStatus();
     3.8      virtual ParentLp::Value _getPrimal(int i);
     3.9      virtual ParentLp::Value _getPrimalValue();
    3.10    };