/home/coin/SVN-release/Cbc-2.4.1/Cbc/src/CbcCutGenerator.hpp

Go to the documentation of this file.
00001 /* $Id: CbcCutGenerator.hpp 1271 2009-11-05 15:57:25Z forrest $ */
00002 // Copyright (C) 2003, International Business Machines
00003 // Corporation and others.  All Rights Reserved.
00004 #ifndef CbcCutGenerator_H
00005 #define CbcCutGenerator_H
00006 
00007 #include "OsiSolverInterface.hpp"
00008 #include "OsiCuts.hpp"
00009 #include "CglCutGenerator.hpp"
00010 
00011 class CbcModel;
00012 class OsiRowCut;
00013 class OsiRowCutDebugger;
00014 
00015 //#############################################################################
00016 
00046 class CbcCutGenerator  {
00047   
00048 public:
00049     
00068   bool generateCuts( OsiCuts &cs, int fullScan,OsiSolverInterface * solver,
00069                      CbcNode * node); 
00071 
00072     
00075 
00076   CbcCutGenerator (); 
00077 
00079   CbcCutGenerator(CbcModel * model,CglCutGenerator * generator,
00080                   int howOften=1, const char * name=NULL,
00081                   bool normal=true, bool atSolution=false, 
00082                   bool infeasible=false,int howOftenInsub=-100,
00083                   int whatDepth=-1, int whatDepthInSub=-1,int switchOffIfLessThan=0);
00084  
00086   CbcCutGenerator (const CbcCutGenerator &);
00087 
00089   CbcCutGenerator & operator=(const CbcCutGenerator& rhs);
00090 
00092   ~CbcCutGenerator ();
00094 
00102   void refreshModel(CbcModel * model);
00103 
00105   inline const char * cutGeneratorName() const
00106   { return generatorName_;}
00107 
00109   void generateTuning( FILE * fp);
00124   void setHowOften(int value) ;
00125 
00127   inline int howOften() const
00128   { return whenCutGenerator_;}
00130   inline int howOftenInSub() const
00131   { return whenCutGeneratorInSub_;}
00133   inline int inaccuracy() const
00134   { return inaccuracy_;}
00136   inline void setInaccuracy(int level)
00137   { inaccuracy_=level;}
00138 
00149   void setWhatDepth(int value) ;
00151   void setWhatDepthInSub(int value) ;
00153   inline int whatDepth() const
00154   { return depthCutGenerator_;}
00156   inline int whatDepthInSub() const
00157   { return depthCutGeneratorInSub_;}
00158 
00160   inline bool normal() const
00161   { return (switches_&1)!=0;}
00163   inline void setNormal(bool value) 
00164   { switches_&=~1;switches_ |= value ? 1 : 0;}
00166   inline bool atSolution() const
00167   { return (switches_&2)!=0;}
00169   inline void setAtSolution(bool value) 
00170   { switches_&=~2;switches_ |= value ? 2 : 0;}
00174   inline bool whenInfeasible() const
00175   { return (switches_&4)!=0;}
00179   inline void setWhenInfeasible(bool value) 
00180   { switches_&=~4;switches_ |= value ? 4 : 0;}
00182   inline bool timing() const
00183   { return (switches_&64)!=0;}
00185   inline void setTiming(bool value) 
00186   { switches_&=~64;switches_ |= value ? 64 : 0; timeInCutGenerator_=0.0;}
00188   inline double timeInCutGenerator() const
00189   { return timeInCutGenerator_;}
00190   inline void incrementTimeInCutGenerator(double value)
00191   { timeInCutGenerator_ += value;}
00193   inline CglCutGenerator * generator() const
00194   { return generator_;}
00196   inline int numberTimesEntered() const
00197   { return numberTimes_;}
00198   inline void setNumberTimesEntered(int value)
00199   { numberTimes_ = value;}
00200   inline void incrementNumberTimesEntered(int value=1)
00201   { numberTimes_ += value;}
00203   inline int numberCutsInTotal() const
00204   { return numberCuts_;}
00205   inline void setNumberCutsInTotal(int value)
00206   { numberCuts_ = value;}
00207   inline void incrementNumberCutsInTotal(int value=1)
00208   { numberCuts_ += value;}
00210   inline int numberElementsInTotal() const
00211   { return numberElements_;}
00212   inline void setNumberElementsInTotal(int value)
00213   { numberElements_ = value;}
00214   inline void incrementNumberElementsInTotal(int value=1)
00215   { numberElements_ += value;}
00217   inline int numberColumnCuts() const
00218   { return numberColumnCuts_;}
00219   inline void setNumberColumnCuts(int value)
00220   { numberColumnCuts_ = value;}
00221   inline void incrementNumberColumnCuts(int value=1)
00222   { numberColumnCuts_ += value;}
00224   inline int numberCutsActive() const
00225   { return numberCutsActive_;}
00226   inline void setNumberCutsActive(int value)
00227   { numberCutsActive_ = value;}
00228   inline void incrementNumberCutsActive(int value=1)
00229   { numberCutsActive_ += value;}
00230   inline void setSwitchOffIfLessThan(int value) 
00231   { switchOffIfLessThan_ = value;}
00232   inline int switchOffIfLessThan() const
00233   { return switchOffIfLessThan_;}
00235   inline bool needsOptimalBasis() const
00236   { return (switches_&128)!=0;}
00238   inline void setNeedsOptimalBasis(bool yesNo)
00239   { switches_&=~128;switches_ |= yesNo ? 128 : 0;}
00241   inline bool mustCallAgain() const
00242   { return (switches_&8)!=0;}
00244   inline void setMustCallAgain(bool yesNo)
00245   { switches_&=~8;switches_ |= yesNo ? 8 : 0;}
00247   inline bool switchedOff() const
00248   { return (switches_&16)!=0;}
00250   inline void setSwitchedOff(bool yesNo)
00251   { switches_&=~16;switches_ |= yesNo ? 16 : 0;}
00253   inline bool ineffectualCuts() const
00254   { return (switches_&512)!=0;}
00256   inline void setIneffectualCuts(bool yesNo)
00257   { switches_&=~512;switches_ |= yesNo ? 512 : 0;}
00259   inline bool whetherToUse() const
00260   { return (switches_&1024)!=0;}
00262   inline void setWhetherToUse(bool yesNo)
00263   { switches_&=~1024;switches_ |= yesNo ? 1024 : 0;}
00265   inline int numberCutsAtRoot() const
00266   { return numberCutsAtRoot_;}
00267   inline void setNumberCutsAtRoot(int value)
00268   { numberCutsAtRoot_ = value;}
00270   inline int numberActiveCutsAtRoot() const
00271   { return numberActiveCutsAtRoot_;}
00272   inline void setNumberActiveCutsAtRoot(int value)
00273   { numberActiveCutsAtRoot_ = value;}
00275   inline int numberShortCutsAtRoot() const
00276   { return numberShortCutsAtRoot_;}
00278   inline void setModel(CbcModel * model)
00279   { model_ = model;}
00281   
00282 private:
00285 
00286   inline bool globalCutsAtRoot() const
00287   { return (switches_&32)!=0;}
00289   inline void setGlobalCutsAtRoot(bool yesNo)
00290   { switches_&=~32;switches_ |= yesNo ? 32 : 0;}
00292   inline bool globalCuts() const
00293   { return (switches_&256)!=0;}
00295   inline void setGlobalCuts(bool yesNo)
00296   { switches_&=~256;switches_ |= yesNo ? 256 : 0;}
00298 
00299   OsiCuts savedCuts_;
00301   double timeInCutGenerator_;
00303   CbcModel *model_; 
00304 
00305   // The CglCutGenerator object
00306   CglCutGenerator * generator_;
00307 
00309   char * generatorName_;
00310 
00314   int whenCutGenerator_;
00318   int whenCutGeneratorInSub_;
00321   int switchOffIfLessThan_;
00322 
00326   int depthCutGenerator_;
00327 
00332   int depthCutGeneratorInSub_;
00333 
00335   int inaccuracy_;
00337   int numberTimes_;
00339   int numberCuts_;
00341   int numberElements_;
00343   int numberColumnCuts_;
00345   int numberCutsActive_;
00347   int numberCutsAtRoot_;
00349   int numberActiveCutsAtRoot_;
00351   int numberShortCutsAtRoot_;
00353   int switches_;
00354 };
00364 class CbcCutModifier {
00365 public:
00367   CbcCutModifier ();
00368 
00369   // Copy constructor 
00370   CbcCutModifier ( const CbcCutModifier &);
00371    
00373   virtual ~CbcCutModifier();
00374 
00376   CbcCutModifier & operator=(const CbcCutModifier& rhs);
00378   virtual CbcCutModifier * clone() const = 0;
00379 
00386   virtual int modify(const OsiSolverInterface * solver, OsiRowCut & cut) =0;
00388   virtual void generateCpp( FILE * ) {}
00389 protected:
00390   
00391 };
00392 
00405 class CbcCutSubsetModifier  : public CbcCutModifier {
00406 public:
00408   CbcCutSubsetModifier ();
00409 
00411   CbcCutSubsetModifier (int firstOdd);
00412 
00413   // Copy constructor 
00414   CbcCutSubsetModifier ( const CbcCutSubsetModifier &);
00415    
00417   virtual ~CbcCutSubsetModifier();
00418 
00420   CbcCutSubsetModifier & operator=(const CbcCutSubsetModifier& rhs);
00422   virtual CbcCutModifier * clone() const ;
00423 
00430   virtual int modify(const OsiSolverInterface * solver, OsiRowCut & cut) ;
00432   virtual void generateCpp( FILE * ) {}
00433 protected:
00436   int firstOdd_;
00437 };
00438 // How often to do if mostly switched off (A) 
00439 # define SCANCUTS 1000  
00440 // How often to do if mostly switched off (probing B)
00441 # define SCANCUTS_PROBING 1000  
00442 
00443 #endif

Generated on Thu Apr 8 03:02:02 2010 by  doxygen 1.4.7