CbcCutGenerator.hpp

Go to the documentation of this file.
00001 /* $Id: CbcCutGenerator.hpp 1883 2013-04-06 13:33:15Z stefan $ */
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     }
00169     inline void setMaximumTries(int value)
00170     { maximumTries_ = value;}
00172     inline int maximumTries() const
00173     { return maximumTries_;}
00174 
00176     inline int switches() const {
00177         return switches_;
00178     }
00180     inline bool normal() const {
00181         return (switches_&1) != 0;
00182     }
00184     inline void setNormal(bool value) {
00185         switches_ &= ~1;
00186         switches_ |= value ? 1 : 0;
00187     }
00189     inline bool atSolution() const {
00190         return (switches_&2) != 0;
00191     }
00193     inline void setAtSolution(bool value) {
00194         switches_ &= ~2;
00195         switches_ |= value ? 2 : 0;
00196     }
00200     inline bool whenInfeasible() const {
00201         return (switches_&4) != 0;
00202     }
00206     inline void setWhenInfeasible(bool value) {
00207         switches_ &= ~4;
00208         switches_ |= value ? 4 : 0;
00209     }
00211     inline bool timing() const {
00212         return (switches_&64) != 0;
00213     }
00215     inline void setTiming(bool value) {
00216         switches_ &= ~64;
00217         switches_ |= value ? 64 : 0;
00218         timeInCutGenerator_ = 0.0;
00219     }
00221     inline double timeInCutGenerator() const {
00222         return timeInCutGenerator_;
00223     }
00224     inline void incrementTimeInCutGenerator(double value) {
00225         timeInCutGenerator_ += value;
00226     }
00228     inline CglCutGenerator * generator() const {
00229         return generator_;
00230     }
00232     inline int numberTimesEntered() const {
00233         return numberTimes_;
00234     }
00235     inline void setNumberTimesEntered(int value) {
00236         numberTimes_ = value;
00237     }
00238     inline void incrementNumberTimesEntered(int value = 1) {
00239         numberTimes_ += value;
00240     }
00242     inline int numberCutsInTotal() const {
00243         return numberCuts_;
00244     }
00245     inline void setNumberCutsInTotal(int value) {
00246         numberCuts_ = value;
00247     }
00248     inline void incrementNumberCutsInTotal(int value = 1) {
00249         numberCuts_ += value;
00250     }
00252     inline int numberElementsInTotal() const {
00253         return numberElements_;
00254     }
00255     inline void setNumberElementsInTotal(int value) {
00256         numberElements_ = value;
00257     }
00258     inline void incrementNumberElementsInTotal(int value = 1) {
00259         numberElements_ += value;
00260     }
00262     inline int numberColumnCuts() const {
00263         return numberColumnCuts_;
00264     }
00265     inline void setNumberColumnCuts(int value) {
00266         numberColumnCuts_ = value;
00267     }
00268     inline void incrementNumberColumnCuts(int value = 1) {
00269         numberColumnCuts_ += value;
00270     }
00272     inline int numberCutsActive() const {
00273         return numberCutsActive_;
00274     }
00275     inline void setNumberCutsActive(int value) {
00276         numberCutsActive_ = value;
00277     }
00278     inline void incrementNumberCutsActive(int value = 1) {
00279         numberCutsActive_ += value;
00280     }
00281     inline void setSwitchOffIfLessThan(int value) {
00282         switchOffIfLessThan_ = value;
00283     }
00284     inline int switchOffIfLessThan() const {
00285         return switchOffIfLessThan_;
00286     }
00288     inline bool needsOptimalBasis() const {
00289         return (switches_&128) != 0;
00290     }
00292     inline void setNeedsOptimalBasis(bool yesNo) {
00293         switches_ &= ~128;
00294         switches_ |= yesNo ? 128 : 0;
00295     }
00297     inline bool mustCallAgain() const {
00298         return (switches_&8) != 0;
00299     }
00301     inline void setMustCallAgain(bool yesNo) {
00302         switches_ &= ~8;
00303         switches_ |= yesNo ? 8 : 0;
00304     }
00306     inline bool switchedOff() const {
00307         return (switches_&16) != 0;
00308     }
00310     inline void setSwitchedOff(bool yesNo) {
00311         switches_ &= ~16;
00312         switches_ |= yesNo ? 16 : 0;
00313     }
00315     inline bool ineffectualCuts() const {
00316         return (switches_&512) != 0;
00317     }
00319     inline void setIneffectualCuts(bool yesNo) {
00320         switches_ &= ~512;
00321         switches_ |= yesNo ? 512 : 0;
00322     }
00324     inline bool whetherToUse() const {
00325         return (switches_&1024) != 0;
00326     }
00328     inline void setWhetherToUse(bool yesNo) {
00329         switches_ &= ~1024;
00330         switches_ |= yesNo ? 1024 : 0;
00331     }
00333     inline bool whetherInMustCallAgainMode() const {
00334         return (switches_&2048) != 0;
00335     }
00337     inline void setWhetherInMustCallAgainMode(bool yesNo) {
00338         switches_ &= ~2048;
00339         switches_ |= yesNo ? 2048 : 0;
00340     }
00342     inline bool whetherCallAtEnd() const {
00343         return (switches_&4096) != 0;
00344     }
00346     inline void setWhetherCallAtEnd(bool yesNo) {
00347         switches_ &= ~4096;
00348         switches_ |= yesNo ? 4096 : 0;
00349     }
00351     inline int numberCutsAtRoot() const {
00352         return numberCutsAtRoot_;
00353     }
00354     inline void setNumberCutsAtRoot(int value) {
00355         numberCutsAtRoot_ = value;
00356     }
00358     inline int numberActiveCutsAtRoot() const {
00359         return numberActiveCutsAtRoot_;
00360     }
00361     inline void setNumberActiveCutsAtRoot(int value) {
00362         numberActiveCutsAtRoot_ = value;
00363     }
00365     inline int numberShortCutsAtRoot() const {
00366         return numberShortCutsAtRoot_;
00367     }
00368     inline void setNumberShortCutsAtRoot(int value) {
00369         numberShortCutsAtRoot_ = value;
00370     }
00372     inline void setModel(CbcModel * model) {
00373         model_ = model;
00374     }
00376     inline bool globalCutsAtRoot() const {
00377         return (switches_&32) != 0;
00378     }
00380     inline void setGlobalCutsAtRoot(bool yesNo) {
00381         switches_ &= ~32;
00382         switches_ |= yesNo ? 32 : 0;
00383     }
00385     inline bool globalCuts() const {
00386         return (switches_&256) != 0;
00387     }
00389     inline void setGlobalCuts(bool yesNo) {
00390         switches_ &= ~256;
00391         switches_ |= yesNo ? 256 : 0;
00392     }
00394     void addStatistics(const CbcCutGenerator * other);
00396     void scaleBackStatistics(int factor);
00398 
00399 private:
00402 
00403 
00404     OsiCuts savedCuts_;
00406     double timeInCutGenerator_;
00408     CbcModel *model_;
00409 
00410     // The CglCutGenerator object
00411     CglCutGenerator * generator_;
00412 
00414     char * generatorName_;
00415 
00419     int whenCutGenerator_;
00423     int whenCutGeneratorInSub_;
00426     int switchOffIfLessThan_;
00427 
00431     int depthCutGenerator_;
00432 
00437     int depthCutGeneratorInSub_;
00438 
00440     int inaccuracy_;
00442     int numberTimes_;
00444     int numberCuts_;
00446     int numberElements_;
00448     int numberColumnCuts_;
00450     int numberCutsActive_;
00452     int numberCutsAtRoot_;
00454     int numberActiveCutsAtRoot_;
00456     int numberShortCutsAtRoot_;
00458     int switches_;
00460     int maximumTries_;
00461 };
00462 
00463 // How often to do if mostly switched off (A)
00464 # define SCANCUTS 1000
00465 // How often to do if mostly switched off (probing B)
00466 # define SCANCUTS_PROBING 1000
00467 
00468 #endif
00469 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 11 Apr 2013 for Cbc by  doxygen 1.6.1