source: stable/2.4/Cbc/src/CbcStrategy.hpp @ 1271

Last change on this file since 1271 was 1271, checked in by forrest, 10 years ago

Creating new stable branch 2.4 from trunk (rev 1270)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.7 KB
Line 
1/* $Id: CbcStrategy.hpp 1271 2009-11-05 15:57:25Z forrest $ */
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"
8class CglPreProcess;
9class CbcNodeInfo;
10class CbcNode;
11class CoinWarmStartDiff;
12
13//#############################################################################
14/** Strategy base class */
15
16class CbcStrategy {
17public:
18  // Default Constructor
19  CbcStrategy ();
20
21  virtual ~CbcStrategy();
22
23  /// Clone
24  virtual CbcStrategy * clone() const=0;
25
26  /// Setup cut generators
27  virtual void setupCutGenerators(CbcModel & model)=0;
28  /// Setup heuristics
29  virtual void setupHeuristics(CbcModel & model)=0;
30  /// Do printing stuff
31  virtual void setupPrinting(CbcModel & model,int modelLogLevel)=0;
32  /// Other stuff e.g. strong branching and preprocessing
33  virtual void setupOther(CbcModel & model)=0;
34  /// Set model depth (i.e. how nested)
35  inline void setNested(int depth)
36  { depth_=depth;}
37  /// Get model depth (i.e. how nested)
38  inline int getNested() const
39  { return depth_;}
40  /// Say preProcessing done
41  inline void setPreProcessState(int state)
42  { preProcessState_=state;}
43  /// See what sort of preprocessing was done
44  inline int preProcessState() const
45  { return preProcessState_;}
46  /// Pre-processing object
47  inline CglPreProcess * process() const
48  { return process_;}
49  /// Delete pre-processing object to save memory
50  void deletePreProcess();
51  /// Return a new Full node information pointer (descendant of CbcFullNodeInfo)
52  virtual CbcNodeInfo * fullNodeInfo(CbcModel * model,int numberRowsAtContinuous) const;
53  /// Return a new Partial node information pointer (descendant of CbcPartialNodeInfo)
54  virtual CbcNodeInfo * partialNodeInfo(CbcModel * model, CbcNodeInfo * parent, CbcNode * owner,
55                                        int numberChangedBounds,const int * variables,
56                                        const double * boundChanges,
57                                        const CoinWarmStartDiff *basisDiff) const;
58  /// Create C++ lines to get to current state
59  virtual void generateCpp( FILE * ) {}
60  /** After a CbcModel::resolve this can return a status
61      -1 no effect
62      0 treat as optimal
63      1 as 0 but do not do any more resolves (i.e. no more cuts)
64      2 treat as infeasible
65  */
66  virtual int status(CbcModel * model, CbcNodeInfo * parent, int whereFrom);
67private:
68 
69  /// Illegal Assignment operator
70  CbcStrategy & operator=(const CbcStrategy& rhs);
71protected:
72  // Data
73  /// Model depth
74  int depth_;
75  /** PreProcessing state -
76      -1 infeasible
77      0 off
78      1 was done (so need post-processing)
79  */
80  int preProcessState_;
81  /// If preprocessing then this is object
82  CglPreProcess * process_;
83};
84
85/** Null class
86 */
87
88class CbcStrategyNull : public CbcStrategy {
89public:
90
91  // Default Constructor
92  CbcStrategyNull () {}
93
94  // Copy constructor
95  CbcStrategyNull ( const CbcStrategyNull & rhs) : CbcStrategy(rhs) {}
96   
97  // Destructor
98  ~CbcStrategyNull () {}
99 
100  /// Clone
101  virtual CbcStrategy * clone() const { return new CbcStrategyNull(*this);}
102
103  /// Setup cut generators
104  virtual void setupCutGenerators(CbcModel & ) {}
105  /// Setup heuristics
106  virtual void setupHeuristics(CbcModel & ) {}
107  /// Do printing stuff
108  virtual void setupPrinting(CbcModel & ,int ) {}
109  /// Other stuff e.g. strong branching
110  virtual void setupOther(CbcModel & ) {}
111
112protected:
113  // Data
114private:
115  /// Illegal Assignment operator
116  CbcStrategyNull & operator=(const CbcStrategyNull& rhs);
117};
118
119/** Default class
120 */
121
122class CbcStrategyDefault : public CbcStrategy {
123public:
124
125  // Default Constructor
126  CbcStrategyDefault (int cutsOnlyAtRoot=1,
127                      int numberStrong=5,
128                      int numberBeforeTrust=0,
129                      int printLevel=0);
130
131  // Copy constructor
132  CbcStrategyDefault ( const CbcStrategyDefault &);
133   
134  // Destructor
135  ~CbcStrategyDefault ();
136 
137  /// Clone
138  virtual CbcStrategy * clone() const;
139
140  /// Setup cut generators
141  virtual void setupCutGenerators(CbcModel & model);
142  /// Setup heuristics
143  virtual void setupHeuristics(CbcModel & model);
144  /// Do printing stuff
145  virtual void setupPrinting(CbcModel & model,int modelLogLevel) ;
146  /// Other stuff e.g. strong branching
147  virtual void setupOther(CbcModel & model);
148  /// Set up preProcessing - see below
149  inline void setupPreProcessing(int desired=1, int passes=10)
150  { desiredPreProcess_=desired;preProcessPasses_=passes;}
151  /// See what sort of preprocessing wanted
152  inline int desiredPreProcess() const
153  { return desiredPreProcess_;}
154  /// See how many passes wanted
155  inline int preProcessPasses() const
156  { return preProcessPasses_;}
157  /// Create C++ lines to get to current state
158  virtual void generateCpp( FILE * fp) ;
159
160protected:
161  // Data
162
163  // Whether to do cuts only at root (-1 -> switch off totally)
164  int cutsOnlyAtRoot_;
165
166  // How much strong branching to do
167  int numberStrong_;
168
169  // Number branches needed to trust with dynamic pseudo costs
170  int numberBeforeTrust_;
171
172  // Print level 0 little, 1 medium
173  int printLevel_;
174
175  /** Desired pre-processing
176      0 - none
177      1 - ordinary
178      2 - find sos
179      3 - find cliques
180      4 - more aggressive sos
181      5 - add integer slacks
182  */
183  int desiredPreProcess_;
184  /// Number of pre-processing passes
185  int preProcessPasses_;
186
187private:
188  /// Illegal Assignment operator
189  CbcStrategyDefault & operator=(const CbcStrategyDefault& rhs);
190};
191
192
193/** Default class for sub trees
194 */
195
196class CbcStrategyDefaultSubTree : public CbcStrategy {
197public:
198
199  // Default Constructor
200  CbcStrategyDefaultSubTree (CbcModel * parent=NULL,int cutsOnlyAtRoot=1,
201                      int numberStrong=5,
202                      int numberBeforeTrust=0,
203                      int printLevel=0);
204
205  // Copy constructor
206  CbcStrategyDefaultSubTree ( const CbcStrategyDefaultSubTree &);
207   
208  // Destructor
209  ~CbcStrategyDefaultSubTree ();
210 
211  /// Clone
212  virtual CbcStrategy * clone() const;
213
214  /// Setup cut generators
215  virtual void setupCutGenerators(CbcModel & model);
216  /// Setup heuristics
217  virtual void setupHeuristics(CbcModel & model);
218  /// Do printing stuff
219  virtual void setupPrinting(CbcModel & model,int modelLogLevel) ;
220  /// Other stuff e.g. strong branching
221  virtual void setupOther(CbcModel & model);
222protected:
223  // Data
224  // Parent model
225  CbcModel * parentModel_;
226  // Whether to do cuts only at root (-1 -> switch off totally)
227  int cutsOnlyAtRoot_;
228
229  // How much strong branching to do
230  int numberStrong_;
231
232  // Number branches needed to trust with dynamic pseudo costs
233  int numberBeforeTrust_;
234
235  // Print level 0 little, 1 medium
236  int printLevel_;
237
238private:
239  /// Illegal Assignment operator
240  CbcStrategyDefaultSubTree & operator=(const CbcStrategyDefaultSubTree& rhs);
241};
242
243
244#endif
Note: See TracBrowser for help on using the repository browser.