source: stable/2.4/Cbc/src/CbcCompareActual.hpp @ 1271

Last change on this file since 1271 was 1271, checked in by forrest, 10 years ago

Creating new stable branch 2.4 from trunk (rev 1270)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
Line 
1/* $Id: CbcCompareActual.hpp 1271 2009-11-05 15:57:25Z forrest $ */
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  inline void setWeight(double weight)
106  { weight_ = weight;}
107  /// Cutoff
108  inline double getCutoff() const
109  { return cutoff_;}
110  inline void setCutoff(double cutoff)
111  { cutoff_ = cutoff;}
112  /// Best possible solution
113  inline double getBestPossible() const
114  { return bestPossible_;}
115  inline void setBestPossible(double bestPossible)
116  { bestPossible_ = bestPossible;}
117  // Depth above which want to explore first
118  inline void setBreadthDepth(int value)
119  {  breadthDepth_ = value;}
120protected:
121  // Weight for each infeasibility
122  double weight_;
123  // Weight for each infeasibility - computed from solution
124  double saveWeight_;
125  /// Cutoff
126  double cutoff_;
127  /// Best possible solution
128  double bestPossible_;
129  // Number of solutions
130  int numberSolutions_;
131  // Tree size (at last check)
132  int treeSize_;
133  // Depth above which want to explore first
134  int breadthDepth_;
135};
136
137/* This is when rounding is being done
138*/
139class CbcCompareEstimate  : public CbcCompareBase {
140public:
141  // Default Constructor
142  CbcCompareEstimate () ;
143  ~CbcCompareEstimate() ;
144  // Copy constructor
145  CbcCompareEstimate ( const CbcCompareEstimate &rhs);
146   
147  // Assignment operator
148  CbcCompareEstimate & operator=( const CbcCompareEstimate& rhs);
149
150  /// Clone
151  virtual CbcCompareBase * clone() const;
152  /// Create C++ lines to get to current state
153  virtual void generateCpp( FILE * fp);
154
155  virtual bool test (CbcNode * x, CbcNode * y) ;
156};
157
158#endif
Note: See TracBrowser for help on using the repository browser.