source: branches/sandbox/Cbc/src/CbcCompareActual.hpp @ 1286

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

Changed formatting using AStyle -A4 -p

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 KB
Line 
1/* $Id: CbcCompareActual.hpp 1286 2009-11-09 23:33:07Z EdwinStraver $ */
2// Copyright (C) 2002, International Business Machines
3// Corporation and others.  All Rights Reserved.
4#ifndef CbcCompareActual_H
5#define CbcCompareActual_H
6
7
8//#############################################################################
9/*  These are alternative strategies for node traversal.
10    They can take data etc for fine tuning
11
12    At present the node list is stored as a heap and the "test"
13    comparison function returns true if node y is better than node x.
14
15*/
16#include "CbcNode.hpp"
17#include "CbcCompareBase.hpp"
18class CbcModel;
19// This is default before first solution
20class CbcCompareDepth : public CbcCompareBase {
21public:
22    // Default Constructor
23    CbcCompareDepth () ;
24
25    ~CbcCompareDepth();
26    // Copy constructor
27    CbcCompareDepth ( const CbcCompareDepth &rhs);
28
29    // Assignment operator
30    CbcCompareDepth & operator=( const CbcCompareDepth& rhs);
31
32    /// Clone
33    virtual CbcCompareBase * clone() const;
34    /// Create C++ lines to get to current state
35    virtual void generateCpp( FILE * fp);
36
37    // This returns true if the depth of node y is greater than depth of node x
38    virtual bool test (CbcNode * x, CbcNode * y);
39};
40class CbcCompareObjective  : public CbcCompareBase {
41public:
42    // Default Constructor
43    CbcCompareObjective ();
44
45    virtual ~CbcCompareObjective();
46    // Copy constructor
47    CbcCompareObjective ( const CbcCompareObjective &rhs);
48
49    // Assignment operator
50    CbcCompareObjective & operator=( const CbcCompareObjective& rhs);
51
52    /// Clone
53    virtual CbcCompareBase * clone() const;
54    /// Create C++ lines to get to current state
55    virtual void generateCpp( FILE * fp);
56
57    /* This returns true if objective value of node y is less than
58       objective value of node x */
59    virtual bool test (CbcNode * x, CbcNode * y);
60};
61/* This is an example of a more complex rule with data
62   It is default after first solution
63   If weight is 0.0 then it is computed to hit first solution
64   less 5%
65*/
66class CbcCompareDefault  : public CbcCompareBase {
67public:
68    // Default Constructor
69    CbcCompareDefault () ;
70    // Constructor with weight
71    CbcCompareDefault (double weight);
72
73    // Copy constructor
74    CbcCompareDefault ( const CbcCompareDefault &rhs);
75
76    // Assignment operator
77    CbcCompareDefault & operator=( const CbcCompareDefault& rhs);
78
79    /// Clone
80    virtual CbcCompareBase * clone() const;
81    /// Create C++ lines to get to current state
82    virtual void generateCpp( FILE * fp);
83
84    ~CbcCompareDefault() ;
85    /* This returns true if weighted value of node y is less than
86       weighted value of node x */
87    virtual bool test (CbcNode * x, CbcNode * y) ;
88
89    using CbcCompareBase::newSolution ;
90    // This allows method to change behavior as it is called
91    // after each solution
92    virtual void newSolution(CbcModel * model,
93                             double objectiveAtContinuous,
94                             int numberInfeasibilitiesAtContinuous) ;
95    // This allows method to change behavior
96    // Return true if want tree re-sorted
97    virtual bool every1000Nodes(CbcModel * model, int numberNodes);
98
99    /* if weight == -1.0 then fewest infeasibilities (before solution)
100       if -2.0 then do breadth first just for first 1000 nodes
101       if -3.0 then depth first before solution
102    */
103    inline double getWeight() const {
104        return weight_;
105    }
106    inline void setWeight(double weight) {
107        weight_ = weight;
108    }
109    /// Cutoff
110    inline double getCutoff() const {
111        return cutoff_;
112    }
113    inline void setCutoff(double cutoff) {
114        cutoff_ = cutoff;
115    }
116    /// Best possible solution
117    inline double getBestPossible() const {
118        return bestPossible_;
119    }
120    inline void setBestPossible(double bestPossible) {
121        bestPossible_ = bestPossible;
122    }
123    // Depth above which want to explore first
124    inline void setBreadthDepth(int value) {
125        breadthDepth_ = value;
126    }
127protected:
128    // Weight for each infeasibility
129    double weight_;
130    // Weight for each infeasibility - computed from solution
131    double saveWeight_;
132    /// Cutoff
133    double cutoff_;
134    /// Best possible solution
135    double bestPossible_;
136    // Number of solutions
137    int numberSolutions_;
138    // Tree size (at last check)
139    int treeSize_;
140    // Depth above which want to explore first
141    int breadthDepth_;
142};
143
144/* This is when rounding is being done
145*/
146class CbcCompareEstimate  : public CbcCompareBase {
147public:
148    // Default Constructor
149    CbcCompareEstimate () ;
150    ~CbcCompareEstimate() ;
151    // Copy constructor
152    CbcCompareEstimate ( const CbcCompareEstimate &rhs);
153
154    // Assignment operator
155    CbcCompareEstimate & operator=( const CbcCompareEstimate& rhs);
156
157    /// Clone
158    virtual CbcCompareBase * clone() const;
159    /// Create C++ lines to get to current state
160    virtual void generateCpp( FILE * fp);
161
162    virtual bool test (CbcNode * x, CbcNode * y) ;
163};
164
165#endif
Note: See TracBrowser for help on using the repository browser.