Cbc  2.10.3
CbcCompareDefault.hpp
Go to the documentation of this file.
1 // $Id: CbcCompareDefault.hpp 2465 2019-01-03 19:26:52Z unxusr $
2 // Copyright (C) 2002, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 // This code is licensed under the terms of the Eclipse Public License (EPL).
5 
6 //Edwin 11/25/09 carved out of CbcCompareActual
7 
8 #ifndef CbcCompareDefault_H
9 #define CbcCompareDefault_H
10 
11 //#############################################################################
12 /* These are alternative strategies for node traversal.
13  They can take data etc for fine tuning
14 
15  At present the node list is stored as a heap and the "test"
16  comparison function returns true if node y is better than node x.
17 
18 */
19 #include "CbcNode.hpp"
20 #include "CbcCompareBase.hpp"
21 #include "CbcCompare.hpp"
22 
23 class CbcModel;
24 
25 /* This is an example of a more complex rule with data
26  It is default after first solution
27  If weight is 0.0 then it is computed to hit first solution
28  less 5%
29 */
31 public:
35  CbcCompareDefault(double weight);
36 
39 
42 
44  virtual CbcCompareBase *clone() const;
46  virtual void generateCpp(FILE *fp);
47 
49  /* This returns true if weighted value of node y is less than
50  weighted value of node x */
51  virtual bool test(CbcNode *x, CbcNode *y);
52 
56  virtual bool newSolution(CbcModel *model,
57  double objectiveAtContinuous,
58  int numberInfeasibilitiesAtContinuous);
61  virtual bool every1000Nodes(CbcModel *model, int numberNodes);
62 
63  /* if weight == -1.0 then fewest infeasibilities (before solution)
64  if -2.0 then do breadth first just for first 1000 nodes
65  if -3.0 then depth first before solution
66  */
67  inline double getWeight() const
68  {
69  return weight_;
70  }
71  inline void setWeight(double weight)
72  {
73  weight_ = weight;
74  }
76  inline double getCutoff() const
77  {
78  return cutoff_;
79  }
80  inline void setCutoff(double cutoff)
81  {
82  cutoff_ = cutoff;
83  }
85  inline double getBestPossible() const
86  {
87  return bestPossible_;
88  }
89  inline void setBestPossible(double bestPossible)
90  {
91  bestPossible_ = bestPossible;
92  }
94  inline void setBreadthDepth(int value)
95  {
96  breadthDepth_ = value;
97  }
99  void startDive(CbcModel *model);
101  void cleanDive();
102 
103 protected:
105  double weight_;
107  double saveWeight_;
109  double cutoff_;
124 };
125 
126 #endif //CbcCompareDefault_H
127 
128 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
129 */
double getWeight() const
int startNodeNumber_
Chosen node from estimated (-1 is off)
int treeSize_
Tree size (at last check)
double weight_
Weight for each infeasibility.
double bestPossible_
Best possible solution.
void setWeight(double weight)
virtual bool newSolution(CbcModel *)
Reconsider behaviour after discovering a new solution.
int breadthDepth_
Depth above which want to explore first.
CbcCompareDefault()
Default Constructor.
int afterNodeNumber_
Node number when dive started.
virtual bool every1000Nodes(CbcModel *model, int numberNodes)
This allows method to change behavior Return true if want tree re-sorted.
void setBreadthDepth(int value)
Depth above which want to explore first.
virtual bool newSolution(CbcModel *model, double objectiveAtContinuous, int numberInfeasibilitiesAtContinuous)
This allows method to change behavior as it is called after each solution.
void setCutoff(double cutoff)
double getBestPossible() const
Best possible solution.
void cleanDive()
Clean up diving (i.e. switch off or prepare)
virtual void generateCpp(FILE *fp)
Create C++ lines to get to current state.
Information required while the node is live.
Definition: CbcNode.hpp:49
double saveWeight_
Weight for each infeasibility - computed from solution.
bool setupForDiving_
Indicates doing setup for diving.
void setBestPossible(double bestPossible)
int numberSolutions_
Number of solutions.
virtual CbcCompareBase * clone() const
Clone.
virtual bool test(CbcNode *x, CbcNode *y)
This is test function.
CbcCompareDefault & operator=(const CbcCompareDefault &rhs)
Assignment operator.
Simple Branch and bound class.
Definition: CbcModel.hpp:100
void startDive(CbcModel *model)
Start dive.
double getCutoff() const
Cutoff.