# CbcCutGenerator.hpp

Go to the documentation of this file.

    00001 /* $Id: CbcCutGenerator.hpp 1675 2011-06-19 17:23:14Z 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     }
    00168
    00170     inline int switches() const {
    00171         return switches_;
    00172     }
    00174     inline bool normal() const {
    00175         return (switches_&1) != 0;
    00176     }
    00178     inline void setNormal(bool value) {
    00179         switches_ &= ~1;
    00180         switches_ |= value ? 1 : 0;
    00181     }
    00183     inline bool atSolution() const {
    00184         return (switches_&2) != 0;
    00185     }
    00187     inline void setAtSolution(bool value) {
    00188         switches_ &= ~2;
    00189         switches_ |= value ? 2 : 0;
    00190     }
    00194     inline bool whenInfeasible() const {
    00195         return (switches_&4) != 0;
    00196     }
    00200     inline void setWhenInfeasible(bool value) {
    00201         switches_ &= ~4;
    00202         switches_ |= value ? 4 : 0;
    00203     }
    00205     inline bool timing() const {
    00206         return (switches_&64) != 0;
    00207     }
    00209     inline void setTiming(bool value) {
    00210         switches_ &= ~64;
    00211         switches_ |= value ? 64 : 0;
    00212         timeInCutGenerator_ = 0.0;
    00213     }
    00215     inline double timeInCutGenerator() const {
    00216         return timeInCutGenerator_;
    00217     }
    00218     inline void incrementTimeInCutGenerator(double value) {
    00219         timeInCutGenerator_ += value;
    00220     }
    00222     inline CglCutGenerator * generator() const {
    00223         return generator_;
    00224     }
    00226     inline int numberTimesEntered() const {
    00227         return numberTimes_;
    00228     }
    00229     inline void setNumberTimesEntered(int value) {
    00230         numberTimes_ = value;
    00231     }
    00232     inline void incrementNumberTimesEntered(int value = 1) {
    00233         numberTimes_ += value;
    00234     }
    00236     inline int numberCutsInTotal() const {
    00237         return numberCuts_;
    00238     }
    00239     inline void setNumberCutsInTotal(int value) {
    00240         numberCuts_ = value;
    00241     }
    00242     inline void incrementNumberCutsInTotal(int value = 1) {
    00243         numberCuts_ += value;
    00244     }
    00246     inline int numberElementsInTotal() const {
    00247         return numberElements_;
    00248     }
    00249     inline void setNumberElementsInTotal(int value) {
    00250         numberElements_ = value;
    00251     }
    00252     inline void incrementNumberElementsInTotal(int value = 1) {
    00253         numberElements_ += value;
    00254     }
    00256     inline int numberColumnCuts() const {
    00257         return numberColumnCuts_;
    00258     }
    00259     inline void setNumberColumnCuts(int value) {
    00260         numberColumnCuts_ = value;
    00261     }
    00262     inline void incrementNumberColumnCuts(int value = 1) {
    00263         numberColumnCuts_ += value;
    00264     }
    00266     inline int numberCutsActive() const {
    00267         return numberCutsActive_;
    00268     }
    00269     inline void setNumberCutsActive(int value) {
    00270         numberCutsActive_ = value;
    00271     }
    00272     inline void incrementNumberCutsActive(int value = 1) {
    00273         numberCutsActive_ += value;
    00274     }
    00275     inline void setSwitchOffIfLessThan(int value) {
    00276         switchOffIfLessThan_ = value;
    00277     }
    00278     inline int switchOffIfLessThan() const {
    00279         return switchOffIfLessThan_;
    00280     }
    00282     inline bool needsOptimalBasis() const {
    00283         return (switches_&128) != 0;
    00284     }
    00286     inline void setNeedsOptimalBasis(bool yesNo) {
    00287         switches_ &= ~128;
    00288         switches_ |= yesNo ? 128 : 0;
    00289     }
    00291     inline bool mustCallAgain() const {
    00292         return (switches_&8) != 0;
    00293     }
    00295     inline void setMustCallAgain(bool yesNo) {
    00296         switches_ &= ~8;
    00297         switches_ |= yesNo ? 8 : 0;
    00298     }
    00300     inline bool switchedOff() const {
    00301         return (switches_&16) != 0;
    00302     }
    00304     inline void setSwitchedOff(bool yesNo) {
    00305         switches_ &= ~16;
    00306         switches_ |= yesNo ? 16 : 0;
    00307     }
    00309     inline bool ineffectualCuts() const {
    00310         return (switches_&512) != 0;
    00311     }
    00313     inline void setIneffectualCuts(bool yesNo) {
    00314         switches_ &= ~512;
    00315         switches_ |= yesNo ? 512 : 0;
    00316     }
    00318     inline bool whetherToUse() const {
    00319         return (switches_&1024) != 0;
    00320     }
    00322     inline void setWhetherToUse(bool yesNo) {
    00323         switches_ &= ~1024;
    00324         switches_ |= yesNo ? 1024 : 0;
    00325     }
    00327     inline bool whetherInMustCallAgainMode() const {
    00328         return (switches_&2048) != 0;
    00329     }
    00331     inline void setWhetherInMustCallAgainMode(bool yesNo) {
    00332         switches_ &= ~2048;
    00333         switches_ |= yesNo ? 2048 : 0;
    00334     }
    00336     inline bool whetherCallAtEnd() const {
    00337         return (switches_&4096) != 0;
    00338     }
    00340     inline void setWhetherCallAtEnd(bool yesNo) {
    00341         switches_ &= ~4096;
    00342         switches_ |= yesNo ? 4096 : 0;
    00343     }
    00345     inline int numberCutsAtRoot() const {
    00346         return numberCutsAtRoot_;
    00347     }
    00348     inline void setNumberCutsAtRoot(int value) {
    00349         numberCutsAtRoot_ = value;
    00350     }
    00352     inline int numberActiveCutsAtRoot() const {
    00353         return numberActiveCutsAtRoot_;
    00354     }
    00355     inline void setNumberActiveCutsAtRoot(int value) {
    00356         numberActiveCutsAtRoot_ = value;
    00357     }
    00359     inline int numberShortCutsAtRoot() const {
    00360         return numberShortCutsAtRoot_;
    00361     }
    00363     inline void setModel(CbcModel * model) {
    00364         model_ = model;
    00365     }
    00367     inline bool globalCutsAtRoot() const {
    00368         return (switches_&32) != 0;
    00369     }
    00371     inline void setGlobalCutsAtRoot(bool yesNo) {
    00372         switches_ &= ~32;
    00373         switches_ |= yesNo ? 32 : 0;
    00374     }
    00376     inline bool globalCuts() const {
    00377         return (switches_&256) != 0;
    00378     }
    00380     inline void setGlobalCuts(bool yesNo) {
    00381         switches_ &= ~256;
    00382         switches_ |= yesNo ? 256 : 0;
    00383     }
    00385
    00386 private:
    00389
    00390
    00391     OsiCuts savedCuts_;
    00393     double timeInCutGenerator_;
    00395     CbcModel *model_;
    00396
    00397     // The CglCutGenerator object
    00398     CglCutGenerator * generator_;
    00399
    00401     char * generatorName_;
    00402
    00406     int whenCutGenerator_;
    00410     int whenCutGeneratorInSub_;
    00413     int switchOffIfLessThan_;
    00414
    00418     int depthCutGenerator_;
    00419
    00424     int depthCutGeneratorInSub_;
    00425
    00427     int inaccuracy_;
    00429     int numberTimes_;
    00431     int numberCuts_;
    00433     int numberElements_;
    00435     int numberColumnCuts_;
    00437     int numberCutsActive_;
    00439     int numberCutsAtRoot_;
    00441     int numberActiveCutsAtRoot_;
    00443     int numberShortCutsAtRoot_;
    00445     int switches_;
    00446 };
    00447
    00448 // How often to do if mostly switched off (A)
    00449 # define SCANCUTS 1000
    00450 // How often to do if mostly switched off (probing B)
    00451 # define SCANCUTS_PROBING 1000
    00452
    00453 #endif
    00454

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines