CbcCutGenerator.hpp

Go to the documentation of this file.
00001 /* $Id: CbcCutGenerator.hpp 2081 2014-09-25 11:31:17Z forrest $ */
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 void setSwitches(int value) {
00181         switches_ = value;
00182     }
00184     inline bool normal() const {
00185         return (switches_&1) != 0;
00186     }
00188     inline void setNormal(bool value) {
00189         switches_ &= ~1;
00190         switches_ |= value ? 1 : 0;
00191     }
00193     inline bool atSolution() const {
00194         return (switches_&2) != 0;
00195     }
00197     inline void setAtSolution(bool value) {
00198         switches_ &= ~2;
00199         switches_ |= value ? 2 : 0;
00200     }
00204     inline bool whenInfeasible() const {
00205         return (switches_&4) != 0;
00206     }
00210     inline void setWhenInfeasible(bool value) {
00211         switches_ &= ~4;
00212         switches_ |= value ? 4 : 0;
00213     }
00215     inline bool timing() const {
00216         return (switches_&64) != 0;
00217     }
00219     inline void setTiming(bool value) {
00220         switches_ &= ~64;
00221         switches_ |= value ? 64 : 0;
00222         timeInCutGenerator_ = 0.0;
00223     }
00225     inline double timeInCutGenerator() const {
00226         return timeInCutGenerator_;
00227     }
00228     inline void incrementTimeInCutGenerator(double value) {
00229         timeInCutGenerator_ += value;
00230     }
00232     inline CglCutGenerator * generator() const {
00233         return generator_;
00234     }
00236     inline int numberTimesEntered() const {
00237         return numberTimes_;
00238     }
00239     inline void setNumberTimesEntered(int value) {
00240         numberTimes_ = value;
00241     }
00242     inline void incrementNumberTimesEntered(int value = 1) {
00243         numberTimes_ += value;
00244     }
00246     inline int numberCutsInTotal() const {
00247         return numberCuts_;
00248     }
00249     inline void setNumberCutsInTotal(int value) {
00250         numberCuts_ = value;
00251     }
00252     inline void incrementNumberCutsInTotal(int value = 1) {
00253         numberCuts_ += value;
00254     }
00256     inline int numberElementsInTotal() const {
00257         return numberElements_;
00258     }
00259     inline void setNumberElementsInTotal(int value) {
00260         numberElements_ = value;
00261     }
00262     inline void incrementNumberElementsInTotal(int value = 1) {
00263         numberElements_ += value;
00264     }
00266     inline int numberColumnCuts() const {
00267         return numberColumnCuts_;
00268     }
00269     inline void setNumberColumnCuts(int value) {
00270         numberColumnCuts_ = value;
00271     }
00272     inline void incrementNumberColumnCuts(int value = 1) {
00273         numberColumnCuts_ += value;
00274     }
00276     inline int numberCutsActive() const {
00277         return numberCutsActive_;
00278     }
00279     inline void setNumberCutsActive(int value) {
00280         numberCutsActive_ = value;
00281     }
00282     inline void incrementNumberCutsActive(int value = 1) {
00283         numberCutsActive_ += value;
00284     }
00285     inline void setSwitchOffIfLessThan(int value) {
00286         switchOffIfLessThan_ = value;
00287     }
00288     inline int switchOffIfLessThan() const {
00289         return switchOffIfLessThan_;
00290     }
00292     inline bool needsOptimalBasis() const {
00293         return (switches_&128) != 0;
00294     }
00296     inline void setNeedsOptimalBasis(bool yesNo) {
00297         switches_ &= ~128;
00298         switches_ |= yesNo ? 128 : 0;
00299     }
00301     inline bool mustCallAgain() const {
00302         return (switches_&8) != 0;
00303     }
00305     inline void setMustCallAgain(bool yesNo) {
00306         switches_ &= ~8;
00307         switches_ |= yesNo ? 8 : 0;
00308     }
00310     inline bool switchedOff() const {
00311         return (switches_&16) != 0;
00312     }
00314     inline void setSwitchedOff(bool yesNo) {
00315         switches_ &= ~16;
00316         switches_ |= yesNo ? 16 : 0;
00317     }
00319     inline bool ineffectualCuts() const {
00320         return (switches_&512) != 0;
00321     }
00323     inline void setIneffectualCuts(bool yesNo) {
00324         switches_ &= ~512;
00325         switches_ |= yesNo ? 512 : 0;
00326     }
00328     inline bool whetherToUse() const {
00329         return (switches_&1024) != 0;
00330     }
00332     inline void setWhetherToUse(bool yesNo) {
00333         switches_ &= ~1024;
00334         switches_ |= yesNo ? 1024 : 0;
00335     }
00337     inline bool whetherInMustCallAgainMode() const {
00338         return (switches_&2048) != 0;
00339     }
00341     inline void setWhetherInMustCallAgainMode(bool yesNo) {
00342         switches_ &= ~2048;
00343         switches_ |= yesNo ? 2048 : 0;
00344     }
00346     inline bool whetherCallAtEnd() const {
00347         return (switches_&4096) != 0;
00348     }
00350     inline void setWhetherCallAtEnd(bool yesNo) {
00351         switches_ &= ~4096;
00352         switches_ |= yesNo ? 4096 : 0;
00353     }
00355     inline bool needsRefresh() const {
00356         return (switches_&8192) != 0;
00357     }
00359     inline void setNeedsRefresh(bool yesNo) {
00360         switches_ &= ~8192;
00361         switches_ |= yesNo ? 8192 : 0;
00362     }
00364     inline int numberCutsAtRoot() const {
00365         return numberCutsAtRoot_;
00366     }
00367     inline void setNumberCutsAtRoot(int value) {
00368         numberCutsAtRoot_ = value;
00369     }
00371     inline int numberActiveCutsAtRoot() const {
00372         return numberActiveCutsAtRoot_;
00373     }
00374     inline void setNumberActiveCutsAtRoot(int value) {
00375         numberActiveCutsAtRoot_ = value;
00376     }
00378     inline int numberShortCutsAtRoot() const {
00379         return numberShortCutsAtRoot_;
00380     }
00381     inline void setNumberShortCutsAtRoot(int value) {
00382         numberShortCutsAtRoot_ = value;
00383     }
00385     inline void setModel(CbcModel * model) {
00386         model_ = model;
00387     }
00389     inline bool globalCutsAtRoot() const {
00390         return (switches_&32) != 0;
00391     }
00393     inline void setGlobalCutsAtRoot(bool yesNo) {
00394         switches_ &= ~32;
00395         switches_ |= yesNo ? 32 : 0;
00396     }
00398     inline bool globalCuts() const {
00399         return (switches_&256) != 0;
00400     }
00402     inline void setGlobalCuts(bool yesNo) {
00403         switches_ &= ~256;
00404         switches_ |= yesNo ? 256 : 0;
00405     }
00407     void addStatistics(const CbcCutGenerator * other);
00409     void scaleBackStatistics(int factor);
00411 
00412 private:
00415 
00416 
00417     OsiCuts savedCuts_;
00419     double timeInCutGenerator_;
00421     CbcModel *model_;
00422 
00423     // The CglCutGenerator object
00424     CglCutGenerator * generator_;
00425 
00427     char * generatorName_;
00428 
00432     int whenCutGenerator_;
00436     int whenCutGeneratorInSub_;
00439     int switchOffIfLessThan_;
00440 
00444     int depthCutGenerator_;
00445 
00450     int depthCutGeneratorInSub_;
00451 
00453     int inaccuracy_;
00455     int numberTimes_;
00457     int numberCuts_;
00459     int numberElements_;
00461     int numberColumnCuts_;
00463     int numberCutsActive_;
00465     int numberCutsAtRoot_;
00467     int numberActiveCutsAtRoot_;
00469     int numberShortCutsAtRoot_;
00471     int switches_;
00473     int maximumTries_;
00474 };
00475 
00476 // How often to do if mostly switched off (A)
00477 # define SCANCUTS 1000
00478 // How often to do if mostly switched off (probing B)
00479 # define SCANCUTS_PROBING 1000
00480 
00481 #endif
00482 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 8 Mar 2015 for Cbc by  doxygen 1.6.1