CbcCompareDefault.hpp
Go to the documentation of this file.
1 //Edwin 11/25/09 carved out of CbcCompareActual
2 #ifndef CbcCompareDefault_H
3 #define CbcCompareDefault_H
4 
5 
6 //#############################################################################
7 /* These are alternative strategies for node traversal.
8  They can take data etc for fine tuning
9 
10  At present the node list is stored as a heap and the "test"
11  comparison function returns true if node y is better than node x.
12 
13 */
14 #include "CbcNode.hpp"
15 #include "CbcCompareBase.hpp"
16 #include "CbcCompare.hpp"
17 
18 class CbcModel;
19 
20 /* This is an example of a more complex rule with data
21  It is default after first solution
22  If weight is 0.0 then it is computed to hit first solution
23  less 5%
24 */
26 public:
30  CbcCompareDefault (double weight);
31 
34 
37 
39  virtual CbcCompareBase * clone() const;
41  virtual void generateCpp( FILE * fp);
42 
44  /* This returns true if weighted value of node y is less than
45  weighted value of node x */
46  virtual bool test (CbcNode * x, CbcNode * y) ;
47 
51  virtual void newSolution(CbcModel * model,
52  double objectiveAtContinuous,
53  int numberInfeasibilitiesAtContinuous) ;
56  virtual bool every1000Nodes(CbcModel * model, int numberNodes);
57 
58  /* if weight == -1.0 then fewest infeasibilities (before solution)
59  if -2.0 then do breadth first just for first 1000 nodes
60  if -3.0 then depth first before solution
61  */
62  inline double getWeight() const {
63  return weight_;
64  }
65  inline void setWeight(double weight) {
66  weight_ = weight;
67  }
69  inline double getCutoff() const {
70  return cutoff_;
71  }
72  inline void setCutoff(double cutoff) {
73  cutoff_ = cutoff;
74  }
76  inline double getBestPossible() const {
77  return bestPossible_;
78  }
79  inline void setBestPossible(double bestPossible) {
80  bestPossible_ = bestPossible;
81  }
83  inline void setBreadthDepth(int value) {
84  breadthDepth_ = value;
85  }
87  void startDive(CbcModel * model);
89  void cleanDive();
90 protected:
92  double weight_;
94  double saveWeight_;
96  double cutoff_;
98  double bestPossible_;
109 };
110 
111 #endif //CbcCompareDefault_H
112 
virtual void newSolution(CbcModel *model, double objectiveAtContinuous, int numberInfeasibilitiesAtContinuous)
This allows method to change behavior as it is called after each solution.
int breadthDepth_
Depth above which want to explore first.
virtual bool every1000Nodes(CbcModel *model, int numberNodes)
This allows method to change behavior Return true if want tree re-sorted.
int treeSize_
Tree size (at last check)
void setBreadthDepth(int value)
Depth above which want to explore first.
double bestPossible_
Best possible solution.
void setBestPossible(double bestPossible)
double cutoff_
Cutoff.
double getBestPossible() const
Best possible solution.
CbcCompareDefault & operator=(const CbcCompareDefault &rhs)
Assignment operator.
virtual CbcCompareBase * clone() const
Clone.
virtual bool test(CbcNode *x, CbcNode *y)
This is test function.
double saveWeight_
Weight for each infeasibility - computed from solution.
void cleanDive()
Clean up diving (i.e. switch off or prepare)
virtual void newSolution(CbcModel *)
void setWeight(double weight)
int numberSolutions_
Number of solutions.
double getWeight() const
double weight_
Weight for each infeasibility.
double getCutoff() const
Cutoff.
int afterNodeNumber_
Node number when dive started.
virtual void generateCpp(FILE *fp)
Create C++ lines to get to current state.
CbcCompareDefault()
Default Constructor.
Information required while the node is live.
Definition: CbcNode.hpp:47
int startNodeNumber_
Chosen node from estimated (-1 is off)
void setCutoff(double cutoff)
void startDive(CbcModel *model)
Start dive.
Simple Branch and bound class.
Definition: CbcModel.hpp:98