Cbc  2.9.8
CbcCompareDefault.hpp
Go to the documentation of this file.
1 // $Id: CbcCompareDefault.hpp 1899 2013-04-09 18:12:08Z stefan $
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 //#############################################################################
13 /* These are alternative strategies for node traversal.
14  They can take data etc for fine tuning
15 
16  At present the node list is stored as a heap and the "test"
17  comparison function returns true if node y is better than node x.
18 
19 */
20 #include "CbcNode.hpp"
21 #include "CbcCompareBase.hpp"
22 #include "CbcCompare.hpp"
23 
24 class CbcModel;
25 
26 /* This is an example of a more complex rule with data
27  It is default after first solution
28  If weight is 0.0 then it is computed to hit first solution
29  less 5%
30 */
32 public:
36  CbcCompareDefault (double weight);
37 
40 
43 
45  virtual CbcCompareBase * clone() const;
47  virtual void generateCpp( FILE * fp);
48 
50  /* This returns true if weighted value of node y is less than
51  weighted value of node x */
52  virtual bool test (CbcNode * x, CbcNode * y) ;
53 
57  virtual bool newSolution(CbcModel * model,
58  double objectiveAtContinuous,
59  int numberInfeasibilitiesAtContinuous) ;
62  virtual bool every1000Nodes(CbcModel * model, int numberNodes);
63 
64  /* if weight == -1.0 then fewest infeasibilities (before solution)
65  if -2.0 then do breadth first just for first 1000 nodes
66  if -3.0 then depth first before solution
67  */
68  inline double getWeight() const {
69  return weight_;
70  }
71  inline void setWeight(double weight) {
72  weight_ = weight;
73  }
75  inline double getCutoff() const {
76  return cutoff_;
77  }
78  inline void setCutoff(double cutoff) {
79  cutoff_ = cutoff;
80  }
82  inline double getBestPossible() const {
83  return bestPossible_;
84  }
85  inline void setBestPossible(double bestPossible) {
86  bestPossible_ = bestPossible;
87  }
89  inline void setBreadthDepth(int value) {
90  breadthDepth_ = value;
91  }
93  void startDive(CbcModel * model);
95  void cleanDive();
96 protected:
98  double weight_;
100  double saveWeight_;
102  double cutoff_;
117 };
118 
119 #endif //CbcCompareDefault_H
120 
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:101
void startDive(CbcModel *model)
Start dive.
double getCutoff() const
Cutoff.