23 #ifndef AlpsSubTree_h_
24 #define AlpsSubTree_h_
231 int & numNodesProcessed,
232 int & numNodesBranched,
233 int & numNodesDiscarded,
234 int & numNodesPartial,
246 int & numNodesProcessed,
247 int & numNodesBranched,
248 int & numNodesDiscarded,
249 int & numNodesPartial,
251 bool & betterSolution);
256 int requiredNumNodes,
AlpsNodeStatus
The possible stati for the search nodes.
This data structure is to contain the packed form of an encodable knowledge.
The base class of knowledge broker class.
The abstract base class of any user-defined class that Alps has to know about in order to encode/deco...
virtual AlpsEncoded * encode() const
This method should encode the content of the object and return a pointer to the encoded form.
A class to refer to the description of a search tree node.
Node pool is used to store the nodes to be processed.
void setNodeSelection(AlpsSearchStrategy< AlpsTreeNode * > &compare)
Set strategy and resort heap.
void popKnowledge()
Remove the node with highest priority from the pool.
int getNumKnowledges() const
Query the number of nodes in the node pool.
void addKnowledge(AlpsKnowledge *node, double priority)
Remove the node with highest priority from the pool and the elite list.
std::pair< AlpsKnowledge *, double > getKnowledge() const
Get the node with highest priority.
void clear()
Remove all the nodes in the pool (does not free memory).
bool hasKnowledge() const
Check whether there are still nodes in the node pool.
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.
void createChildren(AlpsTreeNode *parent, std::vector< CoinTriple< AlpsNodeDesc *, AlpsNodeStatus, double > > &children, AlpsNodePool *kidNodePool=NULL)
Create children nodes from the given parent node.
AlpsNodePool * nodePool_
A node pool containing the leaf nodes awaiting processing.
AlpsSubTree(AlpsKnowledgeBroker *kb)
Useful constructor.
virtual AlpsSubTree * newSubTree() const
Create a AlpsSubtree object dynamically.
int getNextIndex() const
Get the index of the next generated node.
void clearNodePools()
Remove nodes in pools in the subtree.
AlpsTreeNode * activeNode_
This is the node that is currently being processed.
AlpsTreeNode * getBestNode() const
Get the "best" node 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.
void changeNodePool(AlpsNodePool *np)
Set node pool.
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...
AlpsSubTree()
Default constructor.
virtual AlpsKnowledge * decode(AlpsEncoded &encoded) const
This method should decode and return a pointer to a brand new object, i.e., the method must create a ...
AlpsNodePool * diveNodePool()
Access the node pool.
void setKnowledgeBroker(AlpsKnowledgeBroker *kb)
Set a pointer to the knowledge broker.
AlpsKnowledgeBroker * getKnowledgeBroker() const
Get the knowledge broker.
void setActiveNode(AlpsTreeNode *activeNode)
Set pointer to active node.
AlpsTreeNode * getRoot() const
Get the root node of this subtree.
virtual AlpsEncoded * encode() const
This method should encode the content of the subtree and return a pointer to the encoded form.
double getSolEstimate() const
Get the emtimated quality of this subtree.
bool doDive()
Check whether we should keep diving or not.
AlpsKnowledgeBroker * broker_
A pointer to the knowledge broker of the process where this subtree is processed.
AlpsTreeNode * root_
The root of the sub tree.
void fathomAllNodes()
Fathom all nodes on this subtree.
AlpsSearchStrategy< AlpsTreeNode * > * diveNodeRule_
Diving node comparing rule.
AlpsTreeNode * activeNode()
Get pointer to active node.
AlpsNodePool * nodePool()
Access the node pool.
AlpsNodePool * diveNodePool_
A node pool used when diving.
void setNextIndex(int next)
Set the index of the next generated node.
void setRoot(AlpsTreeNode *r)
Set the root node of this subtree.
virtual ~AlpsSubTree()
Destructor.
void setNodeSelection(AlpsSearchStrategy< AlpsTreeNode * > *nc)
Set the node comparision rule.
int getNumNodes() const
Return the number of nodes on this subtree.
void reset()
Move nodes in node pool, null active node.
AlpsSubTree * splitSubTree(int &returnSize, int size=10)
The function split the subtree and return a subtree of the specified size or available size.
virtual int rampUp(int minNumNodes, int requiredNumNodes, int &depth, AlpsTreeNode *root=NULL)
Generate required number (specified by a parameter) of nodes.
double getQuality() const
Get the quality of this subtree.
double getBestKnowledgeValue() const
Get the quality of the best node in the subtree.
void nullRootActiveNode()
Set root and active node to null.
void replaceNode(AlpsTreeNode *oldNode, AlpsTreeNode *newNode)
This function replaces oldNode with newNode in the tree.
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,...
void setNodePool(AlpsNodePool *np)
Set node pool.
This class holds one node of the search tree.
AlpsNodeStatus getStatus() const
Query/set the current status.
double getQuality() const
Query/set the quality of the node.
double getSolEstimate() const
Query/set the solution estimate of the node.