CbcStrategy.hpp
Go to the documentation of this file.
1 /* $Id: CbcStrategy.hpp 1432 2010-02-07 19:33:53Z bjarni $ */
2 // Copyright (C) 2005, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 #ifndef CbcStrategy_H
5 #define CbcStrategy_H
6 
7 #include "CbcModel.hpp"
8 class CglPreProcess;
9 class CbcNodeInfo;
10 class CbcNode;
11 class CoinWarmStartDiff;
12 
13 //#############################################################################
16 class CbcStrategy {
17 public:
18  // Default Constructor
19  CbcStrategy ();
20 
21  virtual ~CbcStrategy();
22 
24  virtual CbcStrategy * clone() const = 0;
25 
27  virtual void setupCutGenerators(CbcModel & model) = 0;
29  virtual void setupHeuristics(CbcModel & model) = 0;
31  virtual void setupPrinting(CbcModel & model, int modelLogLevel) = 0;
33  virtual void setupOther(CbcModel & model) = 0;
35  inline void setNested(int depth) {
36  depth_ = depth;
37  }
39  inline int getNested() const {
40  return depth_;
41  }
43  inline void setPreProcessState(int state) {
44  preProcessState_ = state;
45  }
47  inline int preProcessState() const {
48  return preProcessState_;
49  }
51  inline CglPreProcess * process() const {
52  return process_;
53  }
55  void deletePreProcess();
57  virtual CbcNodeInfo * fullNodeInfo(CbcModel * model, int numberRowsAtContinuous) const;
59  virtual CbcNodeInfo * partialNodeInfo(CbcModel * model, CbcNodeInfo * parent, CbcNode * owner,
60  int numberChangedBounds, const int * variables,
61  const double * boundChanges,
62  const CoinWarmStartDiff *basisDiff) const;
64  virtual void generateCpp( FILE * ) {}
71  virtual int status(CbcModel * model, CbcNodeInfo * parent, int whereFrom);
72 private:
73 
75  CbcStrategy & operator=(const CbcStrategy& rhs);
76 protected:
77  // Data
79  int depth_;
87  CglPreProcess * process_;
88 };
89 
93 class CbcStrategyNull : public CbcStrategy {
94 public:
95 
96  // Default Constructor
98 
99  // Copy constructor
100  CbcStrategyNull ( const CbcStrategyNull & rhs) : CbcStrategy(rhs) {}
101 
102  // Destructor
104 
106  virtual CbcStrategy * clone() const {
107  return new CbcStrategyNull(*this);
108  }
109 
111  virtual void setupCutGenerators(CbcModel & ) {}
113  virtual void setupHeuristics(CbcModel & ) {}
115  virtual void setupPrinting(CbcModel & , int ) {}
117  virtual void setupOther(CbcModel & ) {}
118 
119 protected:
120  // Data
121 private:
124 };
125 
130 public:
131 
132  // Default Constructor
133  CbcStrategyDefault (int cutsOnlyAtRoot = 1,
134  int numberStrong = 5,
135  int numberBeforeTrust = 0,
136  int printLevel = 0);
137 
138  // Copy constructor
140 
141  // Destructor
143 
145  virtual CbcStrategy * clone() const;
146 
148  virtual void setupCutGenerators(CbcModel & model);
150  virtual void setupHeuristics(CbcModel & model);
152  virtual void setupPrinting(CbcModel & model, int modelLogLevel) ;
154  virtual void setupOther(CbcModel & model);
156  inline void setupPreProcessing(int desired = 1, int passes = 10) {
157  desiredPreProcess_ = desired;
158  preProcessPasses_ = passes;
159  }
161  inline int desiredPreProcess() const {
162  return desiredPreProcess_;
163  }
165  inline int preProcessPasses() const {
166  return preProcessPasses_;
167  }
169  virtual void generateCpp( FILE * fp) ;
170 
171 protected:
172  // Data
173 
174  // Whether to do cuts only at root (-1 -> switch off totally)
176 
177  // How much strong branching to do
179 
180  // Number branches needed to trust with dynamic pseudo costs
182 
183  // Print level 0 little, 1 medium
185 
197 
198 private:
201 };
202 
203 
208 public:
209 
210  // Default Constructor
211  CbcStrategyDefaultSubTree (CbcModel * parent = NULL, int cutsOnlyAtRoot = 1,
212  int numberStrong = 5,
213  int numberBeforeTrust = 0,
214  int printLevel = 0);
215 
216  // Copy constructor
218 
219  // Destructor
221 
223  virtual CbcStrategy * clone() const;
224 
226  virtual void setupCutGenerators(CbcModel & model);
228  virtual void setupHeuristics(CbcModel & model);
230  virtual void setupPrinting(CbcModel & model, int modelLogLevel) ;
232  virtual void setupOther(CbcModel & model);
233 protected:
234  // Data
235  // Parent model
237  // Whether to do cuts only at root (-1 -> switch off totally)
239 
240  // How much strong branching to do
242 
243  // Number branches needed to trust with dynamic pseudo costs
245 
246  // Print level 0 little, 1 medium
248 
249 private:
252 };
253 
254 
255 #endif
256