Changeset 2148:ab368e0ab662 in lemon-0.x
- Timestamp:
- 07/17/06 13:56:17 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2862
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
demo/mip_demo.cc
r2146 r2148 10 10 Mip ilp; 11 11 12 12 13 13 typedef Mip::Row Row; 14 14 typedef Mip::Col Col; -
lemon/lp_base.h
r2144 r2148 1159 1159 1160 1160 1161 ///Common base class for ILP solvers1161 ///Common base class for MIP solvers 1162 1162 ///\todo Much more docs 1163 1163 ///\ingroup gen_opt_group … … 1165 1165 public: 1166 1166 1167 ///Set the type of the given Col to integer or remove that property. 1168 /// 1169 ///Set the type of the given Col to integer or remove that property. 1167 ///Possible variable (coloumn) types (e.g. real, integer, binary etc.) 1168 enum ColTypes { 1169 ///Continuous variable 1170 REAL = 0, 1171 ///Integer variable 1172 INTEGER = 1 1173 ///\todo No support for other types yet. 1174 }; 1175 1176 ///Sets the type of the given coloumn to the given type 1177 /// 1178 ///Sets the type of the given coloumn to the given type. 1179 void colType(Col c, ColTypes col_type) { 1180 _colType(cols.floatingId(c.id),col_type); 1181 } 1182 1183 ///Gives back the type of the column. 1184 /// 1185 ///Gives back the type of the column. 1186 ColTypes colType(Col c){ 1187 return _colType(cols.floatingId(c.id)); 1188 } 1189 1190 ///Sets the type of the given Col to integer or remove that property. 1191 /// 1192 ///Sets the type of the given Col to integer or remove that property. 1170 1193 void integer(Col c, bool enable) { 1171 _integer(cols.floatingId(c.id),enable); 1172 } 1173 1174 ///Gives back the type of the column. 1194 if (enable) 1195 colType(c,INTEGER); 1196 else 1197 colType(c,REAL); 1198 } 1199 1200 ///Gives back whether the type of the column is integer or not. 1175 1201 /// 1176 1202 ///Gives back the type of the column. 1177 1203 ///\return true if the column has integer type and false if not. 1178 1204 bool integer(Col c){ 1179 return _integer(cols.floatingId(c.id));1205 return (colType(c)==INTEGER); 1180 1206 } 1181 1207 1182 1208 protected: 1183 1209 1184 virtual bool _integer(int col) = 0; 1185 virtual void _integer(int col, bool enable) = 0; 1210 virtual ColTypes _colType(int col) = 0; 1211 virtual void _colType(int col, ColTypes col_type) = 0; 1212 1186 1213 }; 1187 1214 -
lemon/mip_glpk.cc
r2144 r2148 30 30 lpx_set_class(lp,LPX_MIP); 31 31 } 32 33 void MipGlpk::_integer(int i, bool enable){ 34 if(enable){ 35 lpx_set_col_kind(lp,i,LPX_IV); 36 }else{ 37 lpx_set_col_kind(lp,i,LPX_CV); 32 33 void MipGlpk::_colType(int i, ColTypes col_type){ 34 switch (col_type){ 35 case INTEGER: 36 lpx_set_col_kind(lp,i,LPX_IV); 37 break; 38 case REAL: 39 lpx_set_col_kind(lp,i,LPX_CV); 40 break; 41 default: 42 //FIXME problem 38 43 } 39 44 } 40 45 41 bool MipGlpk::_integer(int i){ 42 if(LPX_IV == lpx_get_col_kind(lp,i)){ 43 return true; 46 ColTypes MipGlpk::_colType(int i){ 47 switch (lpx_get_col_kind(lp,i)){ 48 case LPX_IV: 49 return INTEGER;//Or binary 50 case LPX_CV: 51 return REAL; 52 default: 53 return REAL;//Error! 44 54 } 45 return false;55 46 56 } 47 57 -
lemon/mip_glpk.h
r2144 r2148 46 46 protected: 47 47 48 virtual void _integer(int c, bool enable);49 virtual bool _integer(int c);48 virtual ColTypes _colType(int col); 49 virtual void _colType(int col, ColTypes col_type); 50 50 51 51 virtual LpGlpk::SolveExitStatus _solve();
Note: See TracChangeset
for help on using the changeset viewer.