1 // Copyright (C) 2000, International Business Machines 2 // Corporation and others. All Rights Reserved. 3 // This code is licensed under the terms of the Eclipse Public License (EPL). 4 5 #ifndef CglCutGenerator_H 6 #define CglCutGenerator_H 7 8 #include "OsiCuts.hpp" 9 #include "OsiSolverInterface.hpp" 10 #include "CglTreeInfo.hpp" 11 12 //------------------------------------------------------------------- 13 // 14 // Abstract base class for generating cuts. 15 // 16 //------------------------------------------------------------------- 17 /// 18 /** Cut Generator Base Class 19 20 This is an abstract base class for generating cuts. A specific cut 21 generator will inherit from this class. 22 */ 23 class CglCutGenerator { 24 25 public: 26 /**@name Generate Cuts */ 27 //@{ 28 /** Generate cuts for the model data contained in si. 29 The generated cuts are inserted into and returned in the 30 collection of cuts cs. 31 */ 32 virtual void generateCuts(const OsiSolverInterface &si, OsiCuts &cs, 33 const CglTreeInfo info = CglTreeInfo()) 34 = 0; 35 //@} 36 37 /**@name Constructors and destructors */ 38 //@{ 39 /// Default constructor 40 CglCutGenerator(); 41 42 /// Copy constructor 43 CglCutGenerator(const CglCutGenerator &); 44 45 /// Clone 46 virtual CglCutGenerator *clone() const = 0; 47 48 /// Assignment operator 49 CglCutGenerator &operator=(const CglCutGenerator &rhs); 50 51 /// Destructor 52 virtual ~CglCutGenerator(); 53 54 /** Create C++ lines to set the generator in the current state. 55 The output must be parsed by the calling code, as each line 56 starts with a key indicating the following:<BR> 57 0: must be kept (for #includes etc)<BR> 58 3: Set to changed (not default) values<BR> 59 4: Set to default values (redundant)<BR> 60 61 Keys 1, 2, 5, 6, 7, 8 are defined, but not applicable to 62 cut generators. 63 */ generateCpp(FILE *)64 virtual std::string generateCpp(FILE *) { return ""; } 65 66 /// This can be used to refresh any information refreshSolver(OsiSolverInterface *)67 virtual void refreshSolver(OsiSolverInterface *) {} 68 //@} 69 70 /**@name Gets and Sets */ 71 //@{ 72 /** 73 Get Aggressiveness - 0 = neutral, 100 is normal root node. 74 Really just a hint to cut generator 75 */ getAggressiveness() const76 inline int getAggressiveness() const 77 { 78 return aggressive_; 79 } 80 81 /** 82 Set Aggressiveness - 0 = neutral, 100 is normal root node. 83 Really just a hint to cut generator 84 */ setAggressiveness(int value)85 inline void setAggressiveness(int value) 86 { 87 aggressive_ = value; 88 } 89 /// Set whether can do global cuts setGlobalCuts(bool trueOrFalse)90 inline void setGlobalCuts(bool trueOrFalse) 91 { 92 canDoGlobalCuts_ = trueOrFalse; 93 } 94 /// Say whether can do global cuts canDoGlobalCuts() const95 inline bool canDoGlobalCuts() const 96 { 97 return canDoGlobalCuts_; 98 } 99 /** 100 Returns true if may generate Row cuts in tree (rather than root node). 101 Used so know if matrix will change in tree. Really 102 meant so column cut generators can still be active 103 without worrying code. 104 Default is true 105 */ 106 virtual bool mayGenerateRowCutsInTree() const; 107 /// Return true if needs optimal basis to do cuts 108 virtual bool needsOptimalBasis() const; 109 /// Return maximum length of cut in tree maximumLengthOfCutInTree() const110 virtual int maximumLengthOfCutInTree() const 111 { 112 return COIN_INT_MAX; 113 } 114 //@} 115 116 // test this class 117 //static void unitTest(); 118 119 // private: 120 121 /** 122 Aggressiveness - 0 = neutral, 100 is normal root node. 123 Really just a hint to cut generator 124 */ 125 int aggressive_; 126 /// True if can do global cuts i.e. no general integers 127 bool canDoGlobalCuts_; 128 }; 129 130 #endif 131 132 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2 133 */ 134