source: trunk/include/CbcCompareActual.hpp @ 97

Last change on this file since 97 was 97, checked in by forrest, 15 years ago

for OsiCbc?

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