source: trunk/Cbc/src/CbcStrategy.hpp @ 1995

Last change on this file since 1995 was 1573, checked in by lou, 8 years ago

Change to EPL license notice.

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