# HG changeset patch # User athos # Date 1153137377 0 # Node ID ab368e0ab662e14e3eff2412193b9bfb2b2d0b10 # Parent 63d293ff1befd8d1d431d4b286c6a997fe0fa29d Modifications to the interface: colType() functions, though I left the old integer() functions, too. diff -r 63d293ff1bef -r ab368e0ab662 demo/mip_demo.cc --- a/demo/mip_demo.cc Mon Jul 17 09:31:41 2006 +0000 +++ b/demo/mip_demo.cc Mon Jul 17 11:56:17 2006 +0000 @@ -9,7 +9,7 @@ Mip ilp; - + typedef Mip::Row Row; typedef Mip::Col Col; diff -r 63d293ff1bef -r ab368e0ab662 lemon/lp_base.h --- a/lemon/lp_base.h Mon Jul 17 09:31:41 2006 +0000 +++ b/lemon/lp_base.h Mon Jul 17 11:56:17 2006 +0000 @@ -1158,31 +1158,58 @@ }; - ///Common base class for ILP solvers + ///Common base class for MIP solvers ///\todo Much more docs ///\ingroup gen_opt_group class MipSolverBase : virtual public LpSolverBase{ public: - ///Set the type of the given Col to integer or remove that property. + ///Possible variable (coloumn) types (e.g. real, integer, binary etc.) + enum ColTypes { + ///Continuous variable + REAL = 0, + ///Integer variable + INTEGER = 1 + ///\todo No support for other types yet. + }; + + ///Sets the type of the given coloumn to the given type /// - ///Set the type of the given Col to integer or remove that property. - void integer(Col c, bool enable) { - _integer(cols.floatingId(c.id),enable); + ///Sets the type of the given coloumn to the given type. + void colType(Col c, ColTypes col_type) { + _colType(cols.floatingId(c.id),col_type); } ///Gives back the type of the column. /// ///Gives back the type of the column. + ColTypes colType(Col c){ + return _colType(cols.floatingId(c.id)); + } + + ///Sets the type of the given Col to integer or remove that property. + /// + ///Sets the type of the given Col to integer or remove that property. + void integer(Col c, bool enable) { + if (enable) + colType(c,INTEGER); + else + colType(c,REAL); + } + + ///Gives back whether the type of the column is integer or not. + /// + ///Gives back the type of the column. ///\return true if the column has integer type and false if not. bool integer(Col c){ - return _integer(cols.floatingId(c.id)); + return (colType(c)==INTEGER); } protected: - virtual bool _integer(int col) = 0; - virtual void _integer(int col, bool enable) = 0; + virtual ColTypes _colType(int col) = 0; + virtual void _colType(int col, ColTypes col_type) = 0; + }; ///\relates LpSolverBase::Expr diff -r 63d293ff1bef -r ab368e0ab662 lemon/mip_glpk.cc --- a/lemon/mip_glpk.cc Mon Jul 17 09:31:41 2006 +0000 +++ b/lemon/mip_glpk.cc Mon Jul 17 11:56:17 2006 +0000 @@ -29,20 +29,30 @@ MipGlpk::MipGlpk() { lpx_set_class(lp,LPX_MIP); } - - void MipGlpk::_integer(int i, bool enable){ - if(enable){ - lpx_set_col_kind(lp,i,LPX_IV); - }else{ - lpx_set_col_kind(lp,i,LPX_CV); + + void MipGlpk::_colType(int i, ColTypes col_type){ + switch (col_type){ + case INTEGER: + lpx_set_col_kind(lp,i,LPX_IV); + break; + case REAL: + lpx_set_col_kind(lp,i,LPX_CV); + break; + default: + //FIXME problem } } - bool MipGlpk::_integer(int i){ - if(LPX_IV == lpx_get_col_kind(lp,i)){ - return true; + ColTypes MipGlpk::_colType(int i){ + switch (lpx_get_col_kind(lp,i)){ + case LPX_IV: + return INTEGER;//Or binary + case LPX_CV: + return REAL; + default: + return REAL;//Error! } - return false; + } LpGlpk::SolveExitStatus MipGlpk::_solve(){ diff -r 63d293ff1bef -r ab368e0ab662 lemon/mip_glpk.h --- a/lemon/mip_glpk.h Mon Jul 17 09:31:41 2006 +0000 +++ b/lemon/mip_glpk.h Mon Jul 17 11:56:17 2006 +0000 @@ -45,8 +45,8 @@ protected: - virtual void _integer(int c, bool enable); - virtual bool _integer(int c); + virtual ColTypes _colType(int col); + virtual void _colType(int col, ColTypes col_type); virtual LpGlpk::SolveExitStatus _solve(); virtual ParentLp::Value _getPrimal(int i);