This class contains the data pertaining to a particular subtree in the search tree. More...
#include <AlpsSubTree.h>
Public Member Functions | |
AlpsSubTree () | |
Default constructor. More... | |
AlpsSubTree (AlpsKnowledgeBroker *kb) | |
Useful constructor. More... | |
virtual | ~AlpsSubTree () |
Destructor. More... | |
AlpsTreeNode * | activeNode () |
Get pointer to active node. More... | |
void | setActiveNode (AlpsTreeNode *activeNode) |
Set pointer to active node. More... | |
void | createChildren (AlpsTreeNode *parent, std::vector< CoinTriple< AlpsNodeDesc *, AlpsNodeStatus, double > > &children, AlpsNodePool *kidNodePool=NULL) |
Create children nodes from the given parent node. More... | |
AlpsSubTree * | splitSubTree (int &returnSize, int size=10) |
The function split the subtree and return a subtree of the specified size or available size. More... | |
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, depending on which one reach first. More... | |
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. More... | |
virtual int | rampUp (int minNumNodes, int requiredNumNodes, int &depth, AlpsTreeNode *root=NULL) |
Generate required number (specified by a parameter) of nodes. More... | |
virtual AlpsEncoded * | encode () const |
This method should encode the content of the subtree and return a pointer to the encoded form. More... | |
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 new object on the heap from the decoded data instead of filling up the object for which the method was invoked. More... | |
virtual AlpsSubTree * | newSubTree () const |
Create a AlpsSubtree object dynamically. More... | |
void | clearNodePools () |
Remove nodes in pools in the subtree. More... | |
void | nullRootActiveNode () |
Set root and active node to null. More... | |
bool | doDive () |
Check whether we should keep diving or not. More... | |
void | reset () |
Move nodes in node pool, null active node. More... | |
query and set member functions | |
AlpsTreeNode * | getRoot () const |
Get the root node of this subtree. More... | |
void | setRoot (AlpsTreeNode *r) |
Set the root node of this subtree. More... | |
AlpsNodePool * | nodePool () |
Access the node pool. More... | |
AlpsNodePool * | diveNodePool () |
Access the node pool. More... | |
void | setNodePool (AlpsNodePool *np) |
Set node pool. More... | |
void | changeNodePool (AlpsNodePool *np) |
Set node pool. More... | |
double | getBestKnowledgeValue () const |
Get the quality of the best node in the subtree. More... | |
AlpsTreeNode * | getBestNode () const |
Get the "best" node in the subtree. More... | |
AlpsKnowledgeBroker * | getKnowledgeBroker () const |
Get the knowledge broker. More... | |
void | setKnowledgeBroker (AlpsKnowledgeBroker *kb) |
Set a pointer to the knowledge broker. More... | |
double | getQuality () const |
Get the quality of this subtree. More... | |
double | getSolEstimate () const |
Get the emtimated quality of this subtree. More... | |
double | calculateQuality () |
Calcuate and return the quality of this subtree, which is measured by the quality of the specified number of nodes. More... | |
int | nextIndex () |
Get the root node of this subtree. More... | |
int | getNextIndex () const |
Get the index of the next generated node. More... | |
void | setNextIndex (int next) |
Set the index of the next generated node. More... | |
int | getNumNodes () const |
Return the number of nodes on this subtree. More... | |
void | setNodeSelection (AlpsSearchStrategy< AlpsTreeNode * > *nc) |
Set the node comparision rule. More... | |
Public Member Functions inherited from AlpsKnowledge | |
AlpsKnowledge () | |
virtual | ~AlpsKnowledge () |
KnowledgeType | getType () |
void | setType (KnowledgeType t) |
virtual AlpsReturnStatus | encode (AlpsEncoded *encoded) |
Pack into a encode object. More... | |
AlpsEncoded * | getEncoded () const |
Get/set encoded. More... | |
void | setEncoded (AlpsEncoded *e) |
Protected Member Functions | |
void | removeDeadNodes (AlpsTreeNode *&node) |
The purpose of this method is to remove nodes that are not needed in the description of the subtree. More... | |
void | replaceNode (AlpsTreeNode *oldNode, AlpsTreeNode *newNode) |
This function replaces oldNode with newNode in the tree. More... | |
void | fathomAllNodes () |
Fathom all nodes on this subtree. More... | |
Protected Attributes | |
AlpsTreeNode * | root_ |
The root of the sub tree. More... | |
AlpsNodePool * | nodePool_ |
A node pool containing the leaf nodes awaiting processing. More... | |
AlpsNodePool * | diveNodePool_ |
A node pool used when diving. More... | |
AlpsSearchStrategy < AlpsTreeNode * > * | diveNodeRule_ |
Diving node comparing rule. More... | |
AlpsTreeNode * | activeNode_ |
The next index to be assigned to a new search tree node. More... | |
double | quality_ |
A quantity indicating how good this subtree is. More... | |
AlpsKnowledgeBroker * | broker_ |
A pointer to the knowledge broker of the process where this subtree is processed. More... | |
Protected Attributes inherited from AlpsKnowledge | |
KnowledgeType | type_ |
This class contains the data pertaining to a particular subtree in the search tree.
In order to improve scalability, we will try to deal with entire subtrees as much as possible. They will be the basic unit of work that will be passed between processes.
Definition at line 47 of file AlpsSubTree.h.
AlpsSubTree::AlpsSubTree | ( | ) |
Default constructor.
AlpsSubTree::AlpsSubTree | ( | AlpsKnowledgeBroker * | kb | ) |
Useful constructor.
|
virtual |
Destructor.
|
protected |
The purpose of this method is to remove nodes that are not needed in the description of the subtree.
The argument node must have status fathomed
. First, the argument node is removed, and then the parent is examined to determine whether it has any children left. If it has none, then this function is called recursively on the parent. This removes all nodes that are no longer needed.
|
protected |
This function replaces oldNode
with newNode
in the tree.
|
protected |
Fathom all nodes on this subtree.
Set activeNode_ and root_ to NULL.
|
inline |
Get pointer to active node.
Definition at line 110 of file AlpsSubTree.h.
|
inline |
Set pointer to active node.
Definition at line 113 of file AlpsSubTree.h.
void AlpsSubTree::createChildren | ( | AlpsTreeNode * | parent, |
std::vector< CoinTriple< AlpsNodeDesc *, AlpsNodeStatus, double > > & | children, | ||
AlpsNodePool * | kidNodePool = NULL |
||
) |
Create children nodes from the given parent node.
|
inline |
Get the root node of this subtree.
Definition at line 126 of file AlpsSubTree.h.
|
inline |
Set the root node of this subtree.
Definition at line 129 of file AlpsSubTree.h.
|
inline |
Access the node pool.
Definition at line 132 of file AlpsSubTree.h.
|
inline |
Access the node pool.
Definition at line 135 of file AlpsSubTree.h.
|
inline |
Set node pool.
Delete previous node pool and nodes in pool if exit.
Definition at line 138 of file AlpsSubTree.h.
|
inline |
Set node pool.
Delete previous node pool, but not the nodes in pool.
Definition at line 147 of file AlpsSubTree.h.
double AlpsSubTree::getBestKnowledgeValue | ( | ) | const |
Get the quality of the best node in the subtree.
AlpsTreeNode* AlpsSubTree::getBestNode | ( | ) | const |
Get the "best" node in the subtree.
|
inline |
Get the knowledge broker.
Definition at line 166 of file AlpsSubTree.h.
|
inline |
Set a pointer to the knowledge broker.
Definition at line 169 of file AlpsSubTree.h.
|
inline |
Get the quality of this subtree.
Definition at line 175 of file AlpsSubTree.h.
|
inline |
Get the emtimated quality of this subtree.
Definition at line 178 of file AlpsSubTree.h.
double AlpsSubTree::calculateQuality | ( | ) |
Calcuate and return the quality of this subtree, which is measured by the quality of the specified number of nodes.
int AlpsSubTree::nextIndex | ( | ) |
Get the root node of this subtree.
int AlpsSubTree::getNextIndex | ( | ) | const |
Get the index of the next generated node.
void AlpsSubTree::setNextIndex | ( | int | next | ) |
Set the index of the next generated node.
|
inline |
Return the number of nodes on this subtree.
Definition at line 202 of file AlpsSubTree.h.
|
inline |
Set the node comparision rule.
Definition at line 216 of file AlpsSubTree.h.
AlpsSubTree* AlpsSubTree::splitSubTree | ( | int & | returnSize, |
int | size = 10 |
||
) |
The function split the subtree and return a subtree of the specified size or available size.
|
virtual |
Explore the subtree from root
as the root of the subtree for given number of nodes or time, depending on which one reach first.
Only for serial code.
AlpsReturnStatus AlpsSubTree::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.
leaveAsIt means exit immediately after reseach limits: do not put activeNode_ in pool, do not move nodes in divePool_ in regular pool.
|
virtual |
Generate required number (specified by a parameter) of nodes.
This function is used by master and hubs.
|
virtual |
This method should encode the content of the subtree and return a pointer to the encoded form.
Only parallel code need this function.
Reimplemented from AlpsKnowledge.
|
virtual |
This method should decode and return a pointer to a brand new object, i.e., the method must create a new object on the heap from the decoded data instead of filling up the object for which the method was invoked.
Only parallel code need this function.
Reimplemented from AlpsKnowledge.
|
inlinevirtual |
Create a AlpsSubtree object dynamically.
Only parallel code need this function.
Definition at line 273 of file AlpsSubTree.h.
|
inline |
Remove nodes in pools in the subtree.
Do not free memory.
Definition at line 278 of file AlpsSubTree.h.
|
inline |
Set root and active node to null.
Definition at line 288 of file AlpsSubTree.h.
|
inline |
Check whether we should keep diving or not.
Definition at line 294 of file AlpsSubTree.h.
|
inline |
Move nodes in node pool, null active node.
Definition at line 299 of file AlpsSubTree.h.
|
protected |
The root of the sub tree.
Definition at line 52 of file AlpsSubTree.h.
|
protected |
A node pool containing the leaf nodes awaiting processing.
Definition at line 55 of file AlpsSubTree.h.
|
protected |
A node pool used when diving.
Definition at line 58 of file AlpsSubTree.h.
|
protected |
Diving node comparing rule.
Definition at line 61 of file AlpsSubTree.h.
|
protected |
The next index to be assigned to a new search tree node.
This is the node that is currently being processed. Note that since this is the worker, there is only one.
Definition at line 68 of file AlpsSubTree.h.
|
protected |
A quantity indicating how good this subtree is.
Definition at line 71 of file AlpsSubTree.h.
|
protected |
A pointer to the knowledge broker of the process where this subtree is processed.
Definition at line 76 of file AlpsSubTree.h.