A node of a search tree of Gecode spaces. More...
#include <spacenode.hh>
Public Member Functions | |
SpaceNode (int p) | |
Construct node with parent p. | |
SpaceNode (Space *root) | |
Construct root node from Space root and branch-and-bound object better. | |
Space * | getSpace (NodeAllocator &na, BestNode *curBest, int c_d, int a_d) |
Return working space. Receiver must delete the space. | |
const Space * | getWorkingSpace (void) const |
Return working space (if present). | |
void | purge (const NodeAllocator &na) |
Clear working space and copy (if present and this is not the root). | |
void | dispose (void) |
Free allocated memory. | |
bool | isCurrentBest (BestNode *curBest) |
Return whether this node is the currently best solution. | |
int | getNumberOfChildNodes (NodeAllocator &na, BestNode *curBest, Statistics &stats, int c_d, int a_d) |
Compute and return the number of children. | |
NodeStatus | getStatus (void) const |
Return current status of the node. | |
bool | isOpen (void) |
Return whether this node still has open children. | |
bool | hasFailedChildren (void) |
Return whether the subtree of this node has any failed children. | |
bool | hasSolvedChildren (void) |
Return whether the subtree of this node has any solved children. | |
bool | hasOpenChildren (void) |
Return whether the subtree of this node has any open children. | |
int | getNoOfOpenChildren (const NodeAllocator &na) |
Return number of open children. | |
void | setNoOfOpenChildren (int n) |
Set number of open children to n. | |
bool | hasCopy (void) |
Return whether the node has a copy. | |
bool | hasWorkingSpace (void) |
Return whether the node has a working space. | |
int | getAlternative (const NodeAllocator &na) const |
Return alternative number of this node. | |
const Choice * | getChoice (void) |
Return choice of this node. | |
Public Member Functions inherited from Gecode::Gist::Node | |
Node (int p, bool failed=false) | |
Construct node with parent p. | |
int | getParent (void) const |
Return the parent. | |
VisualNode * | getParent (const NodeAllocator &na) const |
Return the parent. | |
VisualNode * | getChild (const NodeAllocator &na, int n) const |
Return child no n. | |
int | getIndex (const NodeAllocator &na) const |
Return index of this node. | |
bool | isRoot (void) const |
Check if this node is the root of a tree. | |
void | setNumberOfChildren (unsigned int n, NodeAllocator &na) |
Set the number of children to n and initialize children. | |
unsigned int | getNumberOfChildren (void) const |
Return the number of children. |
Protected Types | |
enum | SpaceNodeFlags { HASOPENCHILDREN = FIRSTBIT , HASFAILEDCHILDREN , HASSOLVEDCHILDREN } |
Flags for SpaceNodes. More... |
Protected Member Functions | |
void | setDistance (unsigned int d) |
Set distance from copy. | |
unsigned int | getDistance (void) const |
Return distance from copy. | |
void | setFlag (int flag, bool value) |
Set status flag. | |
bool | getFlag (int flag) const |
Return status flag. | |
void | setStatus (NodeStatus s) |
Set status to s. | |
void | acquireSpace (NodeAllocator &na, BestNode *curBest, int c_d, int a_d) |
Acquire working space, either from parent or by recomputation. | |
Protected Member Functions inherited from Gecode::Gist::Node | |
bool | isUndetermined (void) const |
Return whether this node is undetermined. | |
int | getChild (int n) const |
Return index of child no n. |
Protected Attributes | |
Space * | copy |
A copy used for recomputation, or NULL. | |
const Choice * | choice |
unsigned int | nstatus |
Status of the node. |
Static Protected Attributes | |
static const int | LASTBIT = HASSOLVEDCHILDREN |
Last bit used for SpaceNode flags. |
Additional Inherited Members | |
Public Types inherited from Gecode::Gist::Node | |
typedef NodeAllocatorBase< VisualNode > | NodeAllocator |
A node of a search tree of Gecode spaces.
Definition at line 89 of file spacenode.hh.
|
protected |
Flags for SpaceNodes.
Enumerator | |
---|---|
HASOPENCHILDREN | |
HASFAILEDCHILDREN | |
HASSOLVEDCHILDREN |
Definition at line 121 of file spacenode.hh.
|
inline |
Construct node with parent p.
Definition at line 89 of file spacenode.hpp.
Gecode::Gist::SpaceNode::SpaceNode | ( | Space * | root | ) |
Construct root node from Space root and branch-and-bound object better.
Definition at line 276 of file spacenode.cpp.
|
inlineprotected |
Set distance from copy.
Definition at line 76 of file spacenode.hpp.
|
inlineprotected |
Return distance from copy.
Definition at line 84 of file spacenode.hpp.
|
inlineprotected |
Set status flag.
Definition at line 37 of file spacenode.hpp.
|
inlineprotected |
Return status flag.
Definition at line 45 of file spacenode.hpp.
|
inlineprotected |
Set status to s.
Definition at line 65 of file spacenode.hpp.
|
protected |
Acquire working space, either from parent or by recomputation.
Definition at line 156 of file spacenode.cpp.
|
inline |
Return working space. Receiver must delete the space.
Definition at line 98 of file spacenode.hpp.
|
inline |
Return working space (if present).
Definition at line 112 of file spacenode.hpp.
|
inline |
Clear working space and copy (if present and this is not the root).
Definition at line 120 of file spacenode.hpp.
void Gecode::Gist::SpaceNode::dispose | ( | void | ) |
Free allocated memory.
Definition at line 291 of file spacenode.cpp.
|
inline |
Return whether this node is the currently best solution.
Definition at line 133 of file spacenode.hpp.
int Gecode::Gist::SpaceNode::getNumberOfChildNodes | ( | NodeAllocator & | na, |
BestNode * | curBest, | ||
Statistics & | stats, | ||
int | c_d, | ||
int | a_d ) |
Compute and return the number of children.
On a node whose status is already determined, this function just returns the number of children. On an undetermined node, it first acquires a Space (possibly through recomputation), and then asks for its status. If the space is solved or failed, the node's status will be set accordingly, and 0 will be returned. Otherwise, the status is SS_BRANCH, and as many new children will be created as the branch has alternatives, and the number returned.
Definition at line 298 of file spacenode.cpp.
|
inline |
Return current status of the node.
Definition at line 71 of file spacenode.hpp.
|
inline |
Return whether this node still has open children.
Definition at line 138 of file spacenode.hpp.
|
inline |
Return whether the subtree of this node has any failed children.
Definition at line 144 of file spacenode.hpp.
|
inline |
Return whether the subtree of this node has any solved children.
Definition at line 149 of file spacenode.hpp.
|
inline |
Return whether the subtree of this node has any open children.
Definition at line 154 of file spacenode.hpp.
int Gecode::Gist::SpaceNode::getNoOfOpenChildren | ( | const NodeAllocator & | na | ) |
Return number of open children.
Definition at line 369 of file spacenode.cpp.
void Gecode::Gist::SpaceNode::setNoOfOpenChildren | ( | int | n | ) |
Set number of open children to n.
|
inline |
Return whether the node has a copy.
Definition at line 159 of file spacenode.hpp.
|
inline |
Return whether the node has a working space.
Definition at line 164 of file spacenode.hpp.
|
inline |
Return alternative number of this node.
Definition at line 169 of file spacenode.hpp.
|
inline |
Return choice of this node.
Definition at line 181 of file spacenode.hpp.
|
protected |
A copy used for recomputation, or NULL.
If the copy is marked, it is a working copy, i.e., it does not have to be kept for recomputation.
Definition at line 96 of file spacenode.hh.
|
protected |
Definition at line 98 of file spacenode.hh.
|
protected |
Status of the node.
If the node has a working copy, the first 20 bits encode the distance to the closest copy. The next 5 bits encode the NodeStatus, and the remaining bits are used by the VisualNode class for further flags.
Definition at line 106 of file spacenode.hh.
|
staticprotected |
Last bit used for SpaceNode flags.
Definition at line 127 of file spacenode.hh.