Go to the documentation of this file.
27 #ifndef AlpsSubTree_h_
28 #define AlpsSubTree_h_
33 #include "CoinError.hpp"
34 #include "CoinSort.hpp"
233 int & numNodesProcessed,
234 int & numNodesBranched,
235 int & numNodesDiscarded,
236 int & numNodesPartial,
248 int & numNodesProcessed,
249 int & numNodesBranched,
250 int & numNodesDiscarded,
251 int & numNodesPartial,
253 bool & betterSolution);
257 virtual int rampUp(
int minNumNodes,
258 int requiredNumNodes,
AlpsNodeStatus getStatus() const
AlpsNodePool * nodePool()
Access the node pool.
AlpsSubTree * splitSubTree(int &returnSize, int size=10)
The function split the subtree and return a subtree of the specified size or available size.
void replaceNode(AlpsTreeNode *oldNode, AlpsTreeNode *newNode)
This function replaces oldNode with newNode in the tree.
void setActiveNode(AlpsTreeNode *activeNode)
Set pointer to active node.
int getNextIndex() const
Get the index of the next generated node.
AlpsTreeNode * activeNode_
This is the node that is currently being processed.
virtual AlpsKnowledge * decode(AlpsEncoded &encoded) const
Decode the given AlpsEncoded object into a new AlpsKnowledge object and return a pointer to it.
void setNextIndex(int next)
Set the index of the next generated node.
void changeNodePool(AlpsNodePool *np)
Set node pool.
virtual int getNumKnowledges() const
Query the number of nodes in the node pool.
virtual void popKnowledge()
Remove the node with highest priority from the pool.
AlpsKnowledgeBroker * broker_
AlpsNodeStatus
The possible stati for the search nodes.
void clear()
Remove all the nodes in the pool (does not free memory).
int getDiveDepth()
Get dive depth.
void incDiveDepth(int num=1)
Increment dive depth.
AlpsSearchStrategy< AlpsTreeNode * > * diveNodeRule_
Diving node comparing rule.
void setRoot(AlpsTreeNode *r)
Set the root node of this subtree.
void clearNodePools()
Remove nodes in pools in the subtree.
void removeDeadNodes(AlpsTreeNode *&node)
The purpose of this method is to remove nodes that are not needed in the description of the subtree.
virtual std::pair< AlpsKnowledge *, double > getKnowledge() const
Get the node with highest priority. Doesn't remove it from the pool.
double getSolEstimate() const
Get the estimated quality of this subtree.
void setNodeSelection(AlpsSearchStrategy< AlpsTreeNode * > *nc)
Set the node comparision rule.
This class holds one node of the search tree.
virtual AlpsReturnStatus decodeToSelf(AlpsEncoded &encoded)
Decode the given AlpsEncoded object into this.
virtual int rampUp(int minNumNodes, int requiredNumNodes, int &depth, AlpsTreeNode *root=NULL)
Generate required number (specified by a parameter) of nodes.
double getQuality() const
Query/set the quality of the node.
void nullRootActiveNode()
Set root and active node to null.
double getQuality() const
Get the quality of this subtree.
AlpsTreeNode * getBestNode() const
Get the "best" node in the subtree.
double quality_
A quantity indicating how good this subtree is.
double calculateQuality()
Calcuate and return the quality of this subtree, which is measured by the quality of the specified nu...
This is an abstract base class for subproblem data to be stored in a tree node.
int getNumNodes() const
Return the number of nodes on this subtree.
bool doDive()
Check whether we should keep diving or not.
double getBestKnowledgeValue() const
Get the quality of the best node in the subtree.
virtual AlpsReturnStatus exploreSubTree(AlpsTreeNode *root, int nodeLimit, double timeLimit, int &numNodesProcessed, int &numNodesBranched, int &numNodesDiscarded, int &numNodesPartial, int &depth)
Explore the subtree from root as the root of the subtree for given number of nodes or time,...
The abstract base class of Alps knowledges generated during the search.
virtual ~AlpsSubTree()
Destructor.
The base class of knowledge broker class.
AlpsEncoded * encode() const
Encode the content of this into an AlpsEncoded object and return a pointer to it.
void setNodeSelection(AlpsSearchStrategy< AlpsTreeNode * > &compare)
Set strategy and resort heap.
AlpsNodePool is used to store the nodes to be processed.
void createChildren(AlpsTreeNode *parent, std::vector< CoinTriple< AlpsNodeDesc *, AlpsNodeStatus, double > > &children, AlpsNodePool *kidNodePool=NULL)
Create children nodes from the given parent node.
double getSolEstimate() const
Query/set the solution estimate of the node.
AlpsTreeNode * root_
The root of the sub tree.
AlpsTreeNode * activeNode()
Get pointer to active node.
int diveDepth_
Diving depth.
virtual bool hasKnowledge() const
Check whether there are still nodes in the node pool.
void setDiveDepth(int num)
Set dive depth.
virtual void addKnowledge(AlpsKnowledge *node, double priority)
Add a node to node pool.
AlpsNodePool * nodePool_
A node pool containing the leaf nodes awaiting processing.
This class contains the data pertaining to a particular subtree in the search tree.
AlpsReturnStatus exploreUnitWork(bool leaveAsIt, int unitWork, double unitTime, AlpsExitStatus &solStatus, int &numNodesProcessed, int &numNodesBranched, int &numNodesDiscarded, int &numNodesPartial, int &depth, bool &betterSolution)
Explore the subtree for certain amount of work/time.
virtual AlpsSubTree * newSubTree() const
Create a AlpsSubtree object dynamically.
AlpsNodePool * diveNodePool_
A node pool used when diving.
AlpsTreeNode * getRoot() const
Get the root node of this subtree.
void fathomAllNodes()
Fathom all nodes on this subtree.
void setNodePool(AlpsNodePool *np)
Set node pool.
void reset()
Move nodes in node pool, null active node.
AlpsNodePool * diveNodePool()
Access the node pool.
AlpsSubTree()
Default constructor.