source: stable/2.6/Cbc/src/CbcStrategy.hpp @ 2122

Last change on this file since 2122 was 1432, checked in by bjarni, 10 years ago

Added extra return at end of each source file where needed, to remove possible linefeed conflicts (NightlyBuild? errors)

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