source: trunk/Cbc/src/CbcCompareDefault.hpp @ 1557

Last change on this file since 1557 was 1506, checked in by lou, 9 years ago

Fix `Invalid heap' error in cl debug builds. Add validateHeap method to CbcTree? for future debugging.

File size: 3.4 KB
Line 
1//Edwin 11/25/09 carved out of CbcCompareActual
2#ifndef CbcCompareDefault_H
3#define CbcCompareDefault_H
4
5
6//#############################################################################
7/*  These are alternative strategies for node traversal.
8    They can take data etc for fine tuning
9
10    At present the node list is stored as a heap and the "test"
11    comparison function returns true if node y is better than node x.
12
13*/
14#include "CbcNode.hpp"
15#include "CbcCompareBase.hpp"
16#include "CbcCompare.hpp"
17
18class CbcModel;
19
20/* This is an example of a more complex rule with data
21   It is default after first solution
22   If weight is 0.0 then it is computed to hit first solution
23   less 5%
24*/
25class CbcCompareDefault  : public CbcCompareBase {
26public:
27    /// Default Constructor
28    CbcCompareDefault () ;
29    /// Constructor with weight
30    CbcCompareDefault (double weight);
31
32    /// Copy constructor
33    CbcCompareDefault ( const CbcCompareDefault &rhs);
34
35    /// Assignment operator
36    CbcCompareDefault & operator=( const CbcCompareDefault& rhs);
37
38    /// Clone
39    virtual CbcCompareBase * clone() const;
40    /// Create C++ lines to get to current state
41    virtual void generateCpp( FILE * fp);
42
43    ~CbcCompareDefault() ;
44    /* This returns true if weighted value of node y is less than
45       weighted value of node x */
46    virtual bool test (CbcNode * x, CbcNode * y) ;
47
48    using CbcCompareBase::newSolution ;
49    /// This allows method to change behavior as it is called
50    /// after each solution
51    virtual bool newSolution(CbcModel * model,
52                             double objectiveAtContinuous,
53                             int numberInfeasibilitiesAtContinuous) ;
54    /// This allows method to change behavior
55    /// Return true if want tree re-sorted
56    virtual bool every1000Nodes(CbcModel * model, int numberNodes);
57
58    /* if weight == -1.0 then fewest infeasibilities (before solution)
59       if -2.0 then do breadth first just for first 1000 nodes
60       if -3.0 then depth first before solution
61    */
62    inline double getWeight() const {
63        return weight_;
64    }
65    inline void setWeight(double weight) {
66        weight_ = weight;
67    }
68    /// Cutoff
69    inline double getCutoff() const {
70        return cutoff_;
71    }
72    inline void setCutoff(double cutoff) {
73        cutoff_ = cutoff;
74    }
75    /// Best possible solution
76    inline double getBestPossible() const {
77        return bestPossible_;
78    }
79    inline void setBestPossible(double bestPossible) {
80        bestPossible_ = bestPossible;
81    }
82    /// Depth above which want to explore first
83    inline void setBreadthDepth(int value) {
84        breadthDepth_ = value;
85    }
86    /// Start dive
87    void startDive(CbcModel * model);
88    /// Clean up diving (i.e. switch off or prepare)
89    void cleanDive();
90protected:
91    /// Weight for each infeasibility
92    double weight_;
93    /// Weight for each infeasibility - computed from solution
94    double saveWeight_;
95    /// Cutoff
96    double cutoff_;
97    /// Best possible solution
98    double bestPossible_;
99    /// Number of solutions
100    int numberSolutions_;
101    /// Tree size (at last check)
102    int treeSize_;
103    /// Depth above which want to explore first
104    int breadthDepth_;
105    /// Chosen node from estimated (-1 is off)
106    int startNodeNumber_;
107    /// Node number when dive started
108    int afterNodeNumber_;
109    /// Indicates doing setup for diving
110    bool setupForDiving_ ;
111};
112
113#endif //CbcCompareDefault_H
114
Note: See TracBrowser for help on using the repository browser.