Generated on Sat Feb 7 2015 02:01:44 for Gecode by doxygen 1.8.9.1
Gecode::Gist::SpaceNode Class Reference

A node of a search tree of Gecode spaces. More...

#include <spacenode.hh>

Public Member Functions

 SpaceNode (int p)
 Construct node with parent p. More...
 
 SpaceNode (Space *root)
 Construct root node from Space root and branch-and-bound object better. More...
 
SpacegetSpace (NodeAllocator &na, BestNode *curBest, int c_d, int a_d)
 Return working space. Receiver must delete the space. More...
 
const SpacegetWorkingSpace (void) const
 Return working space (if present). More...
 
void purge (const NodeAllocator &na)
 Clear working space and copy (if present and this is not the root). More...
 
void dispose (void)
 Free allocated memory. More...
 
bool isCurrentBest (BestNode *curBest)
 Return whether this node is the currently best solution. More...
 
int getNumberOfChildNodes (NodeAllocator &na, BestNode *curBest, Statistics &stats, int c_d, int a_d)
 Compute and return the number of children. More...
 
NodeStatus getStatus (void) const
 Return current status of the node. More...
 
bool isOpen (void)
 Return whether this node still has open children. More...
 
bool hasFailedChildren (void)
 Return whether the subtree of this node has any failed children. More...
 
bool hasSolvedChildren (void)
 Return whether the subtree of this node has any solved children. More...
 
bool hasOpenChildren (void)
 Return whether the subtree of this node has any open children. More...
 
int getNoOfOpenChildren (const NodeAllocator &na)
 Return number of open children. More...
 
void setNoOfOpenChildren (int n)
 Set number of open children to n. More...
 
bool hasCopy (void)
 Return whether the node has a copy. More...
 
bool hasWorkingSpace (void)
 Return whether the node has a working space. More...
 
int getAlternative (const NodeAllocator &na) const
 Return alternative number of this node. More...
 
const ChoicegetChoice (void)
 Return choice of this node. More...
 
- Public Member Functions inherited from Gecode::Gist::Node
 Node (int p, bool failed=false)
 Construct node with parent p. More...
 
int getParent (void) const
 Return the parent. More...
 
VisualNodegetParent (const NodeAllocator &na) const
 Return the parent. More...
 
VisualNodegetChild (const NodeAllocator &na, int n) const
 Return child no n. More...
 
int getIndex (const NodeAllocator &na) const
 Return index of this node. More...
 
bool isRoot (void) const
 Check if this node is the root of a tree. More...
 
void setNumberOfChildren (unsigned int n, NodeAllocator &na)
 Set the number of children to n and initialize children. More...
 
unsigned int getNumberOfChildren (void) const
 Return the number of children. More...
 

Protected Types

enum  SpaceNodeFlags { HASOPENCHILDREN = FIRSTBIT, HASFAILEDCHILDREN, HASSOLVEDCHILDREN }
 Flags for SpaceNodes. More...
 

Protected Member Functions

void setDistance (unsigned int d)
 Set distance from copy. More...
 
unsigned int getDistance (void) const
 Return distance from copy. More...
 
void setFlag (int flag, bool value)
 Set status flag. More...
 
bool getFlag (int flag) const
 Return status flag. More...
 
void setStatus (NodeStatus s)
 Set status to s. More...
 
void acquireSpace (NodeAllocator &na, BestNode *curBest, int c_d, int a_d)
 Acquire working space, either from parent or by recomputation. More...
 
- Protected Member Functions inherited from Gecode::Gist::Node
bool isUndetermined (void) const
 Return whether this node is undetermined. More...
 
int getChild (int n) const
 Return index of child no n. More...
 

Protected Attributes

Spacecopy
 A copy used for recomputation, or NULL. More...
 
const Choicechoice
 
unsigned int nstatus
 Status of the node. More...
 

Static Protected Attributes

static const int LASTBIT = HASSOLVEDCHILDREN
 Last bit used for SpaceNode flags. More...
 

Additional Inherited Members

- Public Types inherited from Gecode::Gist::Node
typedef NodeAllocatorBase< VisualNodeNodeAllocator
 

Detailed Description

A node of a search tree of Gecode spaces.

Definition at line 93 of file spacenode.hh.

Member Enumeration Documentation

Flags for SpaceNodes.

Enumerator
HASOPENCHILDREN 
HASFAILEDCHILDREN 
HASSOLVEDCHILDREN 

Definition at line 125 of file spacenode.hh.

Constructor & Destructor Documentation

Gecode::Gist::SpaceNode::SpaceNode ( int  p)
inline

Construct node with parent p.

Definition at line 93 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 280 of file spacenode.cpp.

Member Function Documentation

void Gecode::Gist::SpaceNode::setDistance ( unsigned int  d)
inlineprotected

Set distance from copy.

Definition at line 80 of file spacenode.hpp.

unsigned int Gecode::Gist::SpaceNode::getDistance ( void  ) const
inlineprotected

Return distance from copy.

Definition at line 88 of file spacenode.hpp.

void Gecode::Gist::SpaceNode::setFlag ( int  flag,
bool  value 
)
inlineprotected

Set status flag.

Definition at line 41 of file spacenode.hpp.

bool Gecode::Gist::SpaceNode::getFlag ( int  flag) const
inlineprotected

Return status flag.

Definition at line 49 of file spacenode.hpp.

void Gecode::Gist::SpaceNode::setStatus ( NodeStatus  s)
inlineprotected

Set status to s.

Definition at line 69 of file spacenode.hpp.

void Gecode::Gist::SpaceNode::acquireSpace ( NodeAllocator na,
BestNode curBest,
int  c_d,
int  a_d 
)
protected

Acquire working space, either from parent or by recomputation.

Definition at line 160 of file spacenode.cpp.

Space * Gecode::Gist::SpaceNode::getSpace ( NodeAllocator na,
BestNode curBest,
int  c_d,
int  a_d 
)
inline

Return working space. Receiver must delete the space.

Definition at line 102 of file spacenode.hpp.

const Space * Gecode::Gist::SpaceNode::getWorkingSpace ( void  ) const
inline

Return working space (if present).

Definition at line 116 of file spacenode.hpp.

void Gecode::Gist::SpaceNode::purge ( const NodeAllocator na)
inline

Clear working space and copy (if present and this is not the root).

Definition at line 124 of file spacenode.hpp.

void Gecode::Gist::SpaceNode::dispose ( void  )

Free allocated memory.

Definition at line 295 of file spacenode.cpp.

bool Gecode::Gist::SpaceNode::isCurrentBest ( BestNode curBest)
inline

Return whether this node is the currently best solution.

Definition at line 137 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 302 of file spacenode.cpp.

NodeStatus Gecode::Gist::SpaceNode::getStatus ( void  ) const
inline

Return current status of the node.

Definition at line 75 of file spacenode.hpp.

bool Gecode::Gist::SpaceNode::isOpen ( void  )
inline

Return whether this node still has open children.

Definition at line 142 of file spacenode.hpp.

bool Gecode::Gist::SpaceNode::hasFailedChildren ( void  )
inline

Return whether the subtree of this node has any failed children.

Definition at line 148 of file spacenode.hpp.

bool Gecode::Gist::SpaceNode::hasSolvedChildren ( void  )
inline

Return whether the subtree of this node has any solved children.

Definition at line 153 of file spacenode.hpp.

bool Gecode::Gist::SpaceNode::hasOpenChildren ( void  )
inline

Return whether the subtree of this node has any open children.

Definition at line 158 of file spacenode.hpp.

int Gecode::Gist::SpaceNode::getNoOfOpenChildren ( const NodeAllocator na)

Return number of open children.

Definition at line 373 of file spacenode.cpp.

void Gecode::Gist::SpaceNode::setNoOfOpenChildren ( int  n)

Set number of open children to n.

bool Gecode::Gist::SpaceNode::hasCopy ( void  )
inline

Return whether the node has a copy.

Definition at line 163 of file spacenode.hpp.

bool Gecode::Gist::SpaceNode::hasWorkingSpace ( void  )
inline

Return whether the node has a working space.

Definition at line 168 of file spacenode.hpp.

int Gecode::Gist::SpaceNode::getAlternative ( const NodeAllocator na) const
inline

Return alternative number of this node.

Definition at line 173 of file spacenode.hpp.

const Choice * Gecode::Gist::SpaceNode::getChoice ( void  )
inline

Return choice of this node.

Definition at line 185 of file spacenode.hpp.

Member Data Documentation

Space* Gecode::Gist::SpaceNode::copy
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 100 of file spacenode.hh.

const Choice* Gecode::Gist::SpaceNode::choice
protected

Definition at line 102 of file spacenode.hh.

unsigned int Gecode::Gist::SpaceNode::nstatus
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 110 of file spacenode.hh.

const int Gecode::Gist::SpaceNode::LASTBIT = HASSOLVEDCHILDREN
staticprotected

Last bit used for SpaceNode flags.

Definition at line 131 of file spacenode.hh.


The documentation for this class was generated from the following files: