23 #ifndef AlpsSubTree_h_
24 #define AlpsSubTree_h_
243 int & numNodesProcessed,
244 int & numNodesBranched,
245 int & numNodesDiscarded,
246 int & numNodesPartial,
258 int & numNodesProcessed,
259 int & numNodesBranched,
260 int & numNodesDiscarded,
261 int & numNodesPartial,
263 bool & betterSolution);
267 virtual int rampUp(
int minNumNodes,
268 int requiredNumNodes,
The base class of knowledge broker class.
double getBestKnowledgeValue() const
Get the quality of the best node in the subtree.
void fathomAllNodes()
Fathom all nodes on this subtree.
int getNumKnowledges() const
Query the number of nodes in the node pool.
int getNextIndex() const
Get the index of the next generated node.
double getSolEstimate() const
Query/set the solution estimate of the node.
void reset()
Move nodes in node pool, null active node.
AlpsKnowledgeBroker * broker_
A pointer to the knowledge broker of the process where this subtree is processed. ...
void createChildren(AlpsTreeNode *parent, std::vector< CoinTriple< AlpsNodeDesc *, AlpsNodeStatus, double > > &children, AlpsNodePool *kidNodePool=NULL)
Create children nodes from the given parent node.
void setNodeSelection(AlpsSearchStrategy< AlpsTreeNode * > &compare)
Set strategy and resort heap.
void setNodeSelection(AlpsSearchStrategy< AlpsTreeNode * > *nc)
Set the node comparision rule.
std::pair< AlpsKnowledge *, double > getKnowledge() const
Get the node with highest priority.
AlpsKnowledgeBroker * getKnowledgeBroker() const
Get the knowledge broker.
AlpsNodeStatus
The possible stati for the search nodes.
virtual int rampUp(int minNumNodes, int requiredNumNodes, int &depth, AlpsTreeNode *root=NULL)
Generate required number (specified by a parameter) of nodes.
void nullRootActiveNode()
Set root and active node to null.
virtual ~AlpsSubTree()
Destructor.
This class contains the data pertaining to a particular subtree in the search tree.
AlpsTreeNode * activeNode_
The next index to be assigned to a new search tree node.
void replaceNode(AlpsTreeNode *oldNode, AlpsTreeNode *newNode)
This function replaces oldNode with newNode in the tree.
void clear()
Remove all the nodes in the pool (does not free memory).
void clearNodePools()
Remove nodes in pools in the subtree.
int nextIndex()
Get the root node of this subtree.
void removeDeadNodes(AlpsTreeNode *&node)
The purpose of this method is to remove nodes that are not needed in the description of the subtree...
This data structure is to contain the packed form of an encodable knowledge.
double getSolEstimate() const
Get the emtimated quality of this 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...
virtual AlpsEncoded * encode() const
This method should encode the content of the subtree and return a pointer to the encoded form...
AlpsNodePool * nodePool_
A node pool containing the leaf nodes awaiting processing.
AlpsNodePool * diveNodePool_
A node pool used when diving.
void addKnowledge(AlpsKnowledge *node, double priority)
Remove the node with highest priority from the pool and the elite list.
This class holds one node of the search tree.
double getQuality() const
Get the quality of this subtree.
int getDiveDepth()
Get dive depth.
void popKnowledge()
Remove the node with highest priority from the pool.
int diveDepth_
Diving depth.
AlpsTreeNode * getRoot() const
Get the root node of this subtree.
AlpsNodePool * diveNodePool()
Access the node pool.
void setNextIndex(int next)
Set the index of the next generated node.
AlpsNodePool * nodePool()
Access the node pool.
The abstract base class of any user-defined class that Alps has to know about in order to encode/deco...
int getNumNodes() const
Return the number of nodes on this subtree.
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.
AlpsNodeStatus getStatus() const
Query/set the current status.
void setActiveNode(AlpsTreeNode *activeNode)
Set pointer to active node.
void setRoot(AlpsTreeNode *r)
Set the root node of this subtree.
AlpsTreeNode * root_
The root of the sub tree.
Node pool is used to store the nodes to be processed.
bool hasKnowledge() const
Check whether there are still nodes in 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...
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 ...
void setKnowledgeBroker(AlpsKnowledgeBroker *kb)
Set a pointer to the knowledge broker.
virtual AlpsSubTree * newSubTree() const
Create a AlpsSubtree object dynamically.
double quality_
A quantity indicating how good this subtree is.
void incDiveDepth(int num=1)
Increment dive depth.
AlpsTreeNode * activeNode()
Get pointer to active node.
AlpsSubTree()
Default constructor.
void setDiveDepth(int num)
Set dive depth.
virtual AlpsEncoded * encode() const
This method should encode the content of the object and return a pointer to the encoded form...
double calculateQuality()
Calcuate and return the quality of this subtree, which is measured by the quality of the specified nu...
AlpsSearchStrategy< AlpsTreeNode * > * diveNodeRule_
Diving node comparing rule.
A class to refer to the description of a search tree node.
void changeNodePool(AlpsNodePool *np)
Set node pool.
AlpsTreeNode * getBestNode() const
Get the "best" node in the subtree.
void setNodePool(AlpsNodePool *np)
Set node pool.
double getQuality() const
Query/set the quality of the node.