14#include "CbcCompareBase.hpp"
18#include "CbcCompareActual.hpp"
42 virtual CbcTree *
clone()
const;
47 virtual CbcNode *
top()
const;
50 virtual void push(CbcNode * x);
64 return (
static_cast<int>(nodes_.size()) + (nextOnBranch_ != NULL) );
75 virtual void cleanTree(CbcModel * model,
double cutoff,
double & bestPossibleObjective);
97 CbcNode * nextOnBranch_;
100 bool stop_diving_on_cutoff_;
129 virtual CbcNode *
top()
const;
132 virtual void push(CbcNode * x);
146 return (
static_cast<int>(nodes_.size()) + (nextOnBranch_ != NULL) + (candidateChild_ != NULL) );
157 virtual void cleanTree(CbcModel * model,
double cutoff,
double & bestPossibleObjective);
166 nextOnBranch_ = NULL;
176 CbcNode * nextOnBranch_;
178 CbcNode * candidateChild_;
181 bool stop_diving_on_cutoff_;
225 virtual CbcNode *
top()
const;
228 virtual void push(CbcNode * x);
254 virtual void cleanTree(CbcModel * model,
double cutoff,
double & bestPossibleObjective);
305 void pushDiveOntoHeap(
double cutoff);
316 numberSolToStopDive_(5),
317 numberNodesToLimitTreeSize_(1000000),
318 comparisonDive_(NULL),
319 comparisonBound_(NULL)
325 delete comparisonDive_;
326 delete comparisonBound_;
333 numberSolToStopDive_(rhs.numberSolToStopDive_),
334 numberNodesToLimitTreeSize_(rhs.numberNodesToLimitTreeSize_),
335 comparisonDive_(rhs.comparisonDive_->
clone()),
336 comparisonBound_(rhs.comparisonBound_->
clone())
343 CbcCompareBase::operator=(rhs);
345 numberSolToStopDive_ = rhs.numberSolToStopDive_;
346 numberNodesToLimitTreeSize_ = rhs.numberNodesToLimitTreeSize_;
347 delete comparisonDive_;
348 delete comparisonBound_;
349 comparisonDive_ = NULL;
350 comparisonBound_ = NULL;
351 if (rhs.comparisonDive_) comparisonDive_ = rhs.comparisonDive_->clone();
352 if (rhs.comparisonBound_) comparisonBound_ = rhs.comparisonBound_->clone();
358 virtual CbcCompareBase *
clone()
const
364 virtual bool test (CbcNode * x, CbcNode * y);
371 double objectiveAtContinuous,
372 int numberInfeasibilitiesAtContinuous);
387 numberSolToStopDive_ = val;
393 numberNodesToLimitTreeSize_ = val;
399 comparisonDive_ = val.clone();
404 comparisonBound_ = val.clone();
410 int numberSolToStopDive_;
412 int numberNodesToLimitTreeSize_;
414 CbcCompareBase * comparisonDive_;
416 CbcCompareBase * comparisonBound_;
418 CbcCompareDepth comparisonDepth_;
A class to have all elements necessary to setup a branch-and-bound.
A more elaborate diving class.
virtual void push(CbcNode *x)
Add node to the heap.
void initialize(BabSetupBase &b)
Initialize the method (get options)
ComparisonModes getComparisonMode()
get the mode of comparison of the tree.
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Register the options of the method.
virtual int size()
Give size of the tree.
int maxDiveBacktracks_
Maximum number of backtrack in one dive.
virtual double getBestPossibleObjective()
Get best possible objective function in the tree.
void setComparisonMode(ComparisonModes newMode)
Changes the mode of comparison of the tree for "safety reasons" if the mode really changes we always ...
virtual ~CbcDfsDiver()
Destructor.
int maxDiveDepth_
Maximum depth to go from divingBoard.
int diveListSize_
Record dive list size for constant time access.
@ Enlarge
At the very beginning we might want to enlarge the tree just a bit.
virtual CbcNode * top() const
Return top node (next node to process.*/.
virtual void cleanTree(CbcModel *model, double cutoff, double &bestPossibleObjective)
Prune the tree using an objective function cutoff.
CbcDfsDiver & operator=(const CbcDfsDiver &rhs)
Assignment operator.
int maxDepthBFS_
Maximum depth until which we'll do a bredth-first-search.
virtual CbcNode * bestNode(double cutoff)
Remove the best node from the heap and return it.
int nBacktracks_
number of backtracks done in current dive.
int treeCleaning_
Flag to say that we are currently cleaning the tree and should work only on the heap.
virtual bool empty()
Test if empty.
ComparisonModes mode_
Current mode of the diving strategy.
CbcDfsDiver()
Default constructor.
std::list< CbcNode * > dive_
List of the nodes in the current dive.
CbcDfsDiver(const CbcDfsDiver &rhs)
Copy constructor.
double cutoff_
Last reported cutoff.
virtual void pop()
Remove the top node of the heap.
int divingBoardDepth_
Depth of the node from which diving was started (we call this node the diving board).
virtual CbcTree * clone() const
Virtual copy constructor.
virtual void endSearch()
Don't know what this is yet?
Class to do diving in the tree.
void initialize(BabSetupBase &b)
Initialize the method (get options)
virtual void cleanTree(CbcModel *model, double cutoff, double &bestPossibleObjective)
Prune the tree using an objective function cutoff.
virtual CbcTree * clone() const
Virtual copy constructor.
CbcDiver()
Default constructor.
virtual ~CbcDiver()
Destructor.
virtual int size()
Give size of the tree.
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Register the options of the method.
virtual CbcNode * bestNode(double cutoff)
Remove the best node from the heap and return it.
CbcDiver & operator=(const CbcDiver &rhs)
Assignment operator.
virtual CbcNode * top() const
Return top node (next node to process.*/.
virtual bool empty()
Test if empty.
virtual void pop()
Remove the top node of the heap.
virtual double getBestPossibleObjective()
Get best possible objective function in the tree.
CbcDiver(const CbcDiver &rhs)
Copy constructor.
virtual void push(CbcNode *x)
Add node to the heap.
virtual void endSearch()
Don't know what this is yet?
Class to do probed diving in the tree.
virtual ~CbcProbedDiver()
Destructor.
virtual int size()
Give size of the tree.
virtual void pop()
Remove the top node of the heap.
virtual CbcNode * bestNode(double cutoff)
Remove the best node from the heap and return it.
virtual void cleanTree(CbcModel *model, double cutoff, double &bestPossibleObjective)
Prune the tree using an objective function cutoff.
CbcProbedDiver(const CbcProbedDiver &rhs)
Copy constructor.
virtual void endSearch()
Don't know what this is yet?
virtual double getBestPossibleObjective()
Get best possible objective function in the tree.
void initialize(BabSetupBase &b)
Initialize the method (get options)
virtual bool empty()
Test if empty.
CbcProbedDiver & operator=(const CbcProbedDiver &rhs)
Assignment operator.
virtual CbcTree * clone() const
Virtual copy constructor.
CbcProbedDiver()
Default constructor.
virtual CbcNode * top() const
Return top node (next node to process.*/.
virtual void push(CbcNode *x)
Add node to the heap.
void setComparisonBound(const CbcCompareBase &val)
Set comparison method when closing bound.
virtual bool newSolution(CbcModel *model)
Called after each new solution.
DiverCompare(const DiverCompare &rhs)
void setDiver(CbcDfsDiver *diver)
Set the dfs diver to use.
void setNumberSolToStopDive(int val)
Set numberSolToStopDive_.
virtual bool newSolution(CbcModel *model, double objectiveAtContinuous, int numberInfeasibilitiesAtContinuous)
Called after each new solution.
DiverCompare & operator=(const DiverCompare &rhs)
virtual bool test(CbcNode *x, CbcNode *y)
This is test function.
void setComparisonDive(const CbcCompareBase &val)
Set comparison method when diving.
virtual bool every1000Nodes(CbcModel *model, int numberNodes)
Called 1000 nodes.
virtual CbcCompareBase * clone() const
Clone.
void setNumberNodesToLimitTreeSize(int val)
Set numberNodesToLimitTreeSize_.
(C) Copyright International Business Machines Corporation 2007