Cbc trunk
|
00001 /* $Id$ */ 00002 // Copyright (C) 2003, International Business Machines 00003 // Corporation and others. All Rights Reserved. 00004 // This code is licensed under the terms of the Eclipse Public License (EPL). 00005 00006 #ifndef CbcCutGenerator_H 00007 #define CbcCutGenerator_H 00008 00009 #include "OsiSolverInterface.hpp" 00010 #include "OsiCuts.hpp" 00011 #include "CglCutGenerator.hpp" 00012 #include "CbcCutModifier.hpp" 00013 00014 class CbcModel; 00015 class OsiRowCut; 00016 class OsiRowCutDebugger; 00017 00018 //############################################################################# 00019 00049 class CbcCutGenerator { 00050 00051 public: 00052 00071 bool generateCuts( OsiCuts &cs, int fullScan, OsiSolverInterface * solver, 00072 CbcNode * node); 00074 00075 00078 00079 CbcCutGenerator (); 00080 00082 CbcCutGenerator(CbcModel * model, CglCutGenerator * generator, 00083 int howOften = 1, const char * name = NULL, 00084 bool normal = true, bool atSolution = false, 00085 bool infeasible = false, int howOftenInsub = -100, 00086 int whatDepth = -1, int whatDepthInSub = -1, int switchOffIfLessThan = 0); 00087 00089 CbcCutGenerator (const CbcCutGenerator &); 00090 00092 CbcCutGenerator & operator=(const CbcCutGenerator& rhs); 00093 00095 ~CbcCutGenerator (); 00097 00105 void refreshModel(CbcModel * model); 00106 00108 inline const char * cutGeneratorName() const { 00109 return generatorName_; 00110 } 00111 00113 void generateTuning( FILE * fp); 00128 void setHowOften(int value) ; 00129 00131 inline int howOften() const { 00132 return whenCutGenerator_; 00133 } 00135 inline int howOftenInSub() const { 00136 return whenCutGeneratorInSub_; 00137 } 00139 inline int inaccuracy() const { 00140 return inaccuracy_; 00141 } 00143 inline void setInaccuracy(int level) { 00144 inaccuracy_ = level; 00145 } 00146 00157 void setWhatDepth(int value) ; 00159 void setWhatDepthInSub(int value) ; 00161 inline int whatDepth() const { 00162 return depthCutGenerator_; 00163 } 00165 inline int whatDepthInSub() const { 00166 return depthCutGeneratorInSub_; 00167 } 00168 00170 inline bool normal() const { 00171 return (switches_&1) != 0; 00172 } 00174 inline void setNormal(bool value) { 00175 switches_ &= ~1; 00176 switches_ |= value ? 1 : 0; 00177 } 00179 inline bool atSolution() const { 00180 return (switches_&2) != 0; 00181 } 00183 inline void setAtSolution(bool value) { 00184 switches_ &= ~2; 00185 switches_ |= value ? 2 : 0; 00186 } 00190 inline bool whenInfeasible() const { 00191 return (switches_&4) != 0; 00192 } 00196 inline void setWhenInfeasible(bool value) { 00197 switches_ &= ~4; 00198 switches_ |= value ? 4 : 0; 00199 } 00201 inline bool timing() const { 00202 return (switches_&64) != 0; 00203 } 00205 inline void setTiming(bool value) { 00206 switches_ &= ~64; 00207 switches_ |= value ? 64 : 0; 00208 timeInCutGenerator_ = 0.0; 00209 } 00211 inline double timeInCutGenerator() const { 00212 return timeInCutGenerator_; 00213 } 00214 inline void incrementTimeInCutGenerator(double value) { 00215 timeInCutGenerator_ += value; 00216 } 00218 inline CglCutGenerator * generator() const { 00219 return generator_; 00220 } 00222 inline int numberTimesEntered() const { 00223 return numberTimes_; 00224 } 00225 inline void setNumberTimesEntered(int value) { 00226 numberTimes_ = value; 00227 } 00228 inline void incrementNumberTimesEntered(int value = 1) { 00229 numberTimes_ += value; 00230 } 00232 inline int numberCutsInTotal() const { 00233 return numberCuts_; 00234 } 00235 inline void setNumberCutsInTotal(int value) { 00236 numberCuts_ = value; 00237 } 00238 inline void incrementNumberCutsInTotal(int value = 1) { 00239 numberCuts_ += value; 00240 } 00242 inline int numberElementsInTotal() const { 00243 return numberElements_; 00244 } 00245 inline void setNumberElementsInTotal(int value) { 00246 numberElements_ = value; 00247 } 00248 inline void incrementNumberElementsInTotal(int value = 1) { 00249 numberElements_ += value; 00250 } 00252 inline int numberColumnCuts() const { 00253 return numberColumnCuts_; 00254 } 00255 inline void setNumberColumnCuts(int value) { 00256 numberColumnCuts_ = value; 00257 } 00258 inline void incrementNumberColumnCuts(int value = 1) { 00259 numberColumnCuts_ += value; 00260 } 00262 inline int numberCutsActive() const { 00263 return numberCutsActive_; 00264 } 00265 inline void setNumberCutsActive(int value) { 00266 numberCutsActive_ = value; 00267 } 00268 inline void incrementNumberCutsActive(int value = 1) { 00269 numberCutsActive_ += value; 00270 } 00271 inline void setSwitchOffIfLessThan(int value) { 00272 switchOffIfLessThan_ = value; 00273 } 00274 inline int switchOffIfLessThan() const { 00275 return switchOffIfLessThan_; 00276 } 00278 inline bool needsOptimalBasis() const { 00279 return (switches_&128) != 0; 00280 } 00282 inline void setNeedsOptimalBasis(bool yesNo) { 00283 switches_ &= ~128; 00284 switches_ |= yesNo ? 128 : 0; 00285 } 00287 inline bool mustCallAgain() const { 00288 return (switches_&8) != 0; 00289 } 00291 inline void setMustCallAgain(bool yesNo) { 00292 switches_ &= ~8; 00293 switches_ |= yesNo ? 8 : 0; 00294 } 00296 inline bool switchedOff() const { 00297 return (switches_&16) != 0; 00298 } 00300 inline void setSwitchedOff(bool yesNo) { 00301 switches_ &= ~16; 00302 switches_ |= yesNo ? 16 : 0; 00303 } 00305 inline bool ineffectualCuts() const { 00306 return (switches_&512) != 0; 00307 } 00309 inline void setIneffectualCuts(bool yesNo) { 00310 switches_ &= ~512; 00311 switches_ |= yesNo ? 512 : 0; 00312 } 00314 inline bool whetherToUse() const { 00315 return (switches_&1024) != 0; 00316 } 00318 inline void setWhetherToUse(bool yesNo) { 00319 switches_ &= ~1024; 00320 switches_ |= yesNo ? 1024 : 0; 00321 } 00323 inline int numberCutsAtRoot() const { 00324 return numberCutsAtRoot_; 00325 } 00326 inline void setNumberCutsAtRoot(int value) { 00327 numberCutsAtRoot_ = value; 00328 } 00330 inline int numberActiveCutsAtRoot() const { 00331 return numberActiveCutsAtRoot_; 00332 } 00333 inline void setNumberActiveCutsAtRoot(int value) { 00334 numberActiveCutsAtRoot_ = value; 00335 } 00337 inline int numberShortCutsAtRoot() const { 00338 return numberShortCutsAtRoot_; 00339 } 00341 inline void setModel(CbcModel * model) { 00342 model_ = model; 00343 } 00345 inline bool globalCutsAtRoot() const { 00346 return (switches_&32) != 0; 00347 } 00349 inline void setGlobalCutsAtRoot(bool yesNo) { 00350 switches_ &= ~32; 00351 switches_ |= yesNo ? 32 : 0; 00352 } 00354 inline bool globalCuts() const { 00355 return (switches_&256) != 0; 00356 } 00358 inline void setGlobalCuts(bool yesNo) { 00359 switches_ &= ~256; 00360 switches_ |= yesNo ? 256 : 0; 00361 } 00363 00364 private: 00367 00368 00369 OsiCuts savedCuts_; 00371 double timeInCutGenerator_; 00373 CbcModel *model_; 00374 00375 // The CglCutGenerator object 00376 CglCutGenerator * generator_; 00377 00379 char * generatorName_; 00380 00384 int whenCutGenerator_; 00388 int whenCutGeneratorInSub_; 00391 int switchOffIfLessThan_; 00392 00396 int depthCutGenerator_; 00397 00402 int depthCutGeneratorInSub_; 00403 00405 int inaccuracy_; 00407 int numberTimes_; 00409 int numberCuts_; 00411 int numberElements_; 00413 int numberColumnCuts_; 00415 int numberCutsActive_; 00417 int numberCutsAtRoot_; 00419 int numberActiveCutsAtRoot_; 00421 int numberShortCutsAtRoot_; 00423 int switches_; 00424 }; 00425 00426 // How often to do if mostly switched off (A) 00427 # define SCANCUTS 1000 00428 // How often to do if mostly switched off (probing B) 00429 # define SCANCUTS_PROBING 1000 00430 00431 #endif 00432