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 
virtual void setupOther(CbcModel &model)=0
Other stuff e.g. strong branching and preprocessing.
CbcStrategyNull & operator=(const CbcStrategyNull &rhs)
Illegal Assignment operator.
CbcStrategyDefault & operator=(const CbcStrategyDefault &rhs)
Illegal Assignment operator.
virtual void setupHeuristics(CbcModel &model)=0
Setup heuristics.
CglPreProcess * process_
If preprocessing then this is object.
Definition: CbcStrategy.hpp:87
virtual void setupCutGenerators(CbcModel &model)
Setup cut generators.
virtual void setupOther(CbcModel &model)
Other stuff e.g. strong branching.
CglPreProcess * process() const
Pre-processing object.
Definition: CbcStrategy.hpp:51
virtual void setupPrinting(CbcModel &, int)
Do printing stuff.
CbcStrategyDefaultSubTree & operator=(const CbcStrategyDefaultSubTree &rhs)
Illegal Assignment operator.
int preProcessState() const
See what sort of preprocessing was done.
Definition: CbcStrategy.hpp:47
virtual void setupOther(CbcModel &model)
Other stuff e.g. strong branching.
int preProcessState_
PreProcessing state - -1 infeasible 0 off 1 was done (so need post-processing)
Definition: CbcStrategy.hpp:85
virtual int status(CbcModel *model, CbcNodeInfo *parent, int whereFrom)
After a CbcModel::resolve this can return a status -1 no effect 0 treat as optimal 1 as 0 but do not ...
void deletePreProcess()
Delete pre-processing object to save memory.
Information required to recreate the subproblem at this node.
Definition: CbcNodeInfo.hpp:62
virtual void setupCutGenerators(CbcModel &model)=0
Setup cut generators.
virtual void setupHeuristics(CbcModel &model)
Setup heuristics.
virtual CbcStrategy * clone() const
Clone.
virtual void setupCutGenerators(CbcModel &model)
Setup cut generators.
CbcStrategyDefault(int cutsOnlyAtRoot=1, int numberStrong=5, int numberBeforeTrust=0, int printLevel=0)
virtual void setupPrinting(CbcModel &model, int modelLogLevel)
Do printing stuff.
virtual CbcStrategy * clone() const
Clone.
Default class.
virtual void setupCutGenerators(CbcModel &)
Setup cut generators.
virtual void generateCpp(FILE *fp)
Create C++ lines to get to current state.
int getNested() const
Get model depth (i.e. how nested)
Definition: CbcStrategy.hpp:39
virtual void setupHeuristics(CbcModel &)
Setup heuristics.
int preProcessPasses() const
See how many passes wanted.
int desiredPreProcess() const
See what sort of preprocessing wanted.
virtual void generateCpp(FILE *)
Create C++ lines to get to current state.
Definition: CbcStrategy.hpp:64
virtual CbcNodeInfo * partialNodeInfo(CbcModel *model, CbcNodeInfo *parent, CbcNode *owner, int numberChangedBounds, const int *variables, const double *boundChanges, const CoinWarmStartDiff *basisDiff) const
Return a new Partial node information pointer (descendant of CbcPartialNodeInfo)
virtual void setupOther(CbcModel &)
Other stuff e.g. strong branching.
virtual void setupPrinting(CbcModel &model, int modelLogLevel)=0
Do printing stuff.
void setupPreProcessing(int desired=1, int passes=10)
Set up preProcessing - see below.
virtual void setupHeuristics(CbcModel &model)
Setup heuristics.
virtual void setupPrinting(CbcModel &model, int modelLogLevel)
Do printing stuff.
int preProcessPasses_
Number of pre-processing passes.
CbcStrategy & operator=(const CbcStrategy &rhs)
Illegal Assignment operator.
Strategy base class.
Definition: CbcStrategy.hpp:16
int desiredPreProcess_
Desired pre-processing 0 - none 1 - ordinary 2 - find sos 3 - find cliques 4 - more aggressive sos 5 ...
virtual CbcStrategy * clone() const
Clone.
CbcStrategyNull(const CbcStrategyNull &rhs)
CbcStrategyDefaultSubTree(CbcModel *parent=NULL, int cutsOnlyAtRoot=1, int numberStrong=5, int numberBeforeTrust=0, int printLevel=0)
Information required while the node is live.
Definition: CbcNode.hpp:47
virtual CbcNodeInfo * fullNodeInfo(CbcModel *model, int numberRowsAtContinuous) const
Return a new Full node information pointer (descendant of CbcFullNodeInfo)
Default class for sub trees.
void setNested(int depth)
Set model depth (i.e. how nested)
Definition: CbcStrategy.hpp:35
int depth_
Model depth.
Definition: CbcStrategy.hpp:79
Null class.
Definition: CbcStrategy.hpp:93
void setPreProcessState(int state)
Say preProcessing done.
Definition: CbcStrategy.hpp:43
virtual ~CbcStrategy()
Simple Branch and bound class.
Definition: CbcModel.hpp:98
virtual CbcStrategy * clone() const =0
Clone.