source: branches/sandbox/Cbc/src/CbcCompareDefault.hpp @ 1314

Last change on this file since 1314 was 1314, checked in by EdwinStraver, 10 years ago

Broke up CbcCompareActual?.cpp into CbcCompareDepth?, CbcCompareDefault?, CbcCompareObjective? and CbcCompareEstimate?.
Carved CbcCutModifier? and CbcCutSubsetModifier? out of CbcCutGenerator?.
Updated spreadsheets.

File size: 3.1 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 void 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    }
86protected:
87    // Weight for each infeasibility
88    double weight_;
89    // Weight for each infeasibility - computed from solution
90    double saveWeight_;
91    /// Cutoff
92    double cutoff_;
93    /// Best possible solution
94    double bestPossible_;
95    // Number of solutions
96    int numberSolutions_;
97    // Tree size (at last check)
98    int treeSize_;
99    // Depth above which want to explore first
100    int breadthDepth_;
101};
102
103#endif //CbcCompareDefault_H
Note: See TracBrowser for help on using the repository browser.