Cbc  2.10.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbcStrategy.hpp
Go to the documentation of this file.
1 /* $Id: CbcStrategy.hpp 2465 2019-01-03 19:26:52Z unxusr $ */
2 // Copyright (C) 2005, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 // This code is licensed under the terms of the Eclipse Public License (EPL).
5 
6 #ifndef CbcStrategy_H
7 #define CbcStrategy_H
8 
9 #include "CbcModel.hpp"
10 class CglPreProcess;
11 class CbcNodeInfo;
12 class CbcNode;
13 class CoinWarmStartDiff;
14 
15 //#############################################################################
18 class CbcStrategy {
19 public:
20  // Default Constructor
21  CbcStrategy();
22 
23  virtual ~CbcStrategy();
24 
26  virtual CbcStrategy *clone() const = 0;
27 
29  virtual void setupCutGenerators(CbcModel &model) = 0;
31  virtual void setupHeuristics(CbcModel &model) = 0;
33  virtual void setupPrinting(CbcModel &model, int modelLogLevel) = 0;
35  virtual void setupOther(CbcModel &model) = 0;
37  inline void setNested(int depth)
38  {
39  depth_ = depth;
40  }
42  inline int getNested() const
43  {
44  return depth_;
45  }
47  inline void setPreProcessState(int state)
48  {
49  preProcessState_ = state;
50  }
52  inline int preProcessState() const
53  {
54  return preProcessState_;
55  }
57  inline CglPreProcess *process() const
58  {
59  return process_;
60  }
62  void deletePreProcess();
64  virtual CbcNodeInfo *fullNodeInfo(CbcModel *model, int numberRowsAtContinuous) const;
66  virtual CbcNodeInfo *partialNodeInfo(CbcModel *model, CbcNodeInfo *parent, CbcNode *owner,
67  int numberChangedBounds, const int *variables,
68  const double *boundChanges,
69  const CoinWarmStartDiff *basisDiff) const;
71  virtual void generateCpp(FILE *) {}
78  virtual int status(CbcModel *model, CbcNodeInfo *parent, int whereFrom);
79 
80 private:
82  CbcStrategy &operator=(const CbcStrategy &rhs);
83 
84 protected:
85  // Data
87  int depth_;
96 };
97 
101 class CbcStrategyNull : public CbcStrategy {
102 public:
103  // Default Constructor
105 
106  // Copy constructor
108  : CbcStrategy(rhs)
109  {
110  }
111 
112  // Destructor
114 
116  virtual CbcStrategy *clone() const
117  {
118  return new CbcStrategyNull(*this);
119  }
120 
122  virtual void setupCutGenerators(CbcModel &) {}
124  virtual void setupHeuristics(CbcModel &) {}
126  virtual void setupPrinting(CbcModel &, int) {}
128  virtual void setupOther(CbcModel &) {}
129 
130 protected:
131  // Data
132 private:
135 };
136 
141 public:
142  // Default Constructor
143  CbcStrategyDefault(int cutsOnlyAtRoot = 1,
144  int numberStrong = 5,
145  int numberBeforeTrust = 0,
146  int printLevel = 0);
147 
148  // Copy constructor
150 
151  // Destructor
153 
155  virtual CbcStrategy *clone() const;
156 
158  virtual void setupCutGenerators(CbcModel &model);
160  virtual void setupHeuristics(CbcModel &model);
162  virtual void setupPrinting(CbcModel &model, int modelLogLevel);
164  virtual void setupOther(CbcModel &model);
166  inline void setupPreProcessing(int desired = 1, int passes = 10)
167  {
168  desiredPreProcess_ = desired;
169  preProcessPasses_ = passes;
170  }
172  inline int desiredPreProcess() const
173  {
174  return desiredPreProcess_;
175  }
177  inline int preProcessPasses() const
178  {
179  return preProcessPasses_;
180  }
182  virtual void generateCpp(FILE *fp);
183 
184 protected:
185  // Data
186 
187  // Whether to do cuts only at root (-1 -> switch off totally)
189 
190  // How much strong branching to do
192 
193  // Number branches needed to trust with dynamic pseudo costs
195 
196  // Print level 0 little, 1 medium
198 
210 
211 private:
214 };
215 
220 public:
221  // Default Constructor
222  CbcStrategyDefaultSubTree(CbcModel *parent = NULL, int cutsOnlyAtRoot = 1,
223  int numberStrong = 5,
224  int numberBeforeTrust = 0,
225  int printLevel = 0);
226 
227  // Copy constructor
229 
230  // Destructor
232 
234  virtual CbcStrategy *clone() const;
235 
237  virtual void setupCutGenerators(CbcModel &model);
239  virtual void setupHeuristics(CbcModel &model);
241  virtual void setupPrinting(CbcModel &model, int modelLogLevel);
243  virtual void setupOther(CbcModel &model);
244 
245 protected:
246  // Data
247  // Parent model
249  // Whether to do cuts only at root (-1 -> switch off totally)
251 
252  // How much strong branching to do
254 
255  // Number branches needed to trust with dynamic pseudo costs
257 
258  // Print level 0 little, 1 medium
260 
261 private:
264 };
265 
266 #endif
267 
268 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
269 */
int preProcessPasses() const
See how many passes wanted.
int preProcessState_
PreProcessing state - -1 infeasible 0 off 1 was done (so need post-processing)
Definition: CbcStrategy.hpp:93
CbcStrategyDefault & operator=(const CbcStrategyDefault &rhs)
Illegal Assignment operator.
CglPreProcess * process() const
Pre-processing object.
Definition: CbcStrategy.hpp:57
CbcStrategy & operator=(const CbcStrategy &rhs)
Illegal Assignment operator.
virtual CbcNodeInfo * fullNodeInfo(CbcModel *model, int numberRowsAtContinuous) const
Return a new Full node information pointer (descendant of CbcFullNodeInfo)
virtual void setupCutGenerators(CbcModel &model)
Setup cut generators.
virtual void setupHeuristics(CbcModel &model)
Setup heuristics.
virtual CbcStrategy * clone() const
Clone.
Default class for sub trees.
virtual CbcStrategy * clone() const
Clone.
virtual void setupCutGenerators(CbcModel &model)=0
Setup cut generators.
virtual void setupOther(CbcModel &)
Other stuff e.g. strong branching.
void setPreProcessState(int state)
Say preProcessing done.
Definition: CbcStrategy.hpp:47
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 setupCutGenerators(CbcModel &)
Setup cut generators.
virtual void setupOther(CbcModel &model)
Other stuff e.g. strong branching.
int preProcessState() const
See what sort of preprocessing was done.
Definition: CbcStrategy.hpp:52
virtual void setupPrinting(CbcModel &model, int modelLogLevel)
Do printing stuff.
CbcStrategyDefaultSubTree(CbcModel *parent=NULL, int cutsOnlyAtRoot=1, int numberStrong=5, int numberBeforeTrust=0, int printLevel=0)
CbcStrategyDefaultSubTree & operator=(const CbcStrategyDefaultSubTree &rhs)
Illegal Assignment operator.
int desiredPreProcess_
Desired pre-processing 0 - none 1 - ordinary 2 - find sos 3 - find cliques 4 - more aggressive sos 5 ...
void setNested(int depth)
Set model depth (i.e. how nested)
Definition: CbcStrategy.hpp:37
virtual void setupOther(CbcModel &model)
Other stuff e.g. strong branching.
virtual void setupCutGenerators(CbcModel &model)
Setup cut generators.
void deletePreProcess()
Delete pre-processing object to save memory.
virtual ~CbcStrategy()
Information required while the node is live.
Definition: CbcNode.hpp:49
virtual void setupPrinting(CbcModel &, int)
Do printing stuff.
CbcStrategyDefault(int cutsOnlyAtRoot=1, int numberStrong=5, int numberBeforeTrust=0, int printLevel=0)
Null class.
virtual void setupHeuristics(CbcModel &model)=0
Setup heuristics.
virtual void generateCpp(FILE *fp)
Create C++ lines to get to current state.
virtual void setupPrinting(CbcModel &model, int modelLogLevel)
Do printing stuff.
virtual void setupHeuristics(CbcModel &model)
Setup heuristics.
int desiredPreProcess() const
See what sort of preprocessing wanted.
virtual void setupPrinting(CbcModel &model, int modelLogLevel)=0
Do printing stuff.
virtual CbcStrategy * clone() const =0
Clone.
CbcStrategyNull(const CbcStrategyNull &rhs)
Information required to recreate the subproblem at this node.
Definition: CbcNodeInfo.hpp:68
Abstract base class for warm start `diff' objects.
CbcStrategyNull & operator=(const CbcStrategyNull &rhs)
Illegal Assignment operator.
virtual void setupOther(CbcModel &model)=0
Other stuff e.g. strong branching and preprocessing.
int getNested() const
Get model depth (i.e. how nested)
Definition: CbcStrategy.hpp:42
virtual void setupHeuristics(CbcModel &)
Setup heuristics.
int depth_
Model depth.
Definition: CbcStrategy.hpp:87
virtual void generateCpp(FILE *)
Create C++ lines to get to current state.
Definition: CbcStrategy.hpp:71
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 ...
Class for preProcessing and postProcessing.
virtual CbcStrategy * clone() const
Clone.
int preProcessPasses_
Number of pre-processing passes.
Simple Branch and bound class.
Definition: CbcModel.hpp:100
void setupPreProcessing(int desired=1, int passes=10)
Set up preProcessing - see below.
CglPreProcess * process_
If preprocessing then this is object.
Definition: CbcStrategy.hpp:95
Strategy base class.
Definition: CbcStrategy.hpp:18
Default class.