jopt.csp.spi.search.tree
Interface TreeNode

All Superinterfaces:
jopt.csp.search.SearchNode
All Known Implementing Classes:
BasicSearchNode

public interface TreeNode
extends jopt.csp.search.SearchNode

The TreeNode.java is an interface implemented by search nodes that are used in searching.

Author:
Chris Johnson, Nick Coleman

Method Summary
 SearchTechniqueChange activate(jopt.csp.search.SearchGoal goal)
          Called by search when node should be activated.
 void deactivate()
          Called by search if child and state data should be discarded.
 void disconnect()
          Called by search to disconnect a child node from a parent node.
 jopt.csp.search.SearchAction getAction()
          Returns the search action associated with this node
 java.util.BitSet getBinaryPath()
          Returns a bitset representing the path from the root to this node as a series of left-right movements.
 TreeNode getChild(int index)
          Returns the child at the specified index
 int getChildCount()
          Returns the number of children this node contains
 int getChildNumberWithinParent()
          Returns the number of the child within the parent
 jopt.csp.search.SearchGoal getGoal()
          Gets the goal value associated with this node
 TreeNode getNextOpenChild()
          Returns the next open child in the tree
 double getObjectiveVal()
          Gets the objective value associated with this node
 TreeNode getParent()
          Retrieves the parent of this search node
 java.util.List getPath()
          Returns a list of Integers containing the list of movements followed to reach this node.
 java.lang.Object getStateData()
          Returns state data associated with this node
 boolean isBinary()
          Returns true if this node is binary
 boolean isClosed()
          Returns true if node is closed or pruned or deactivated.
 boolean isDeactivated()
          Returns true if node is closed and the deactivate() method has been called on this node
 boolean isDisconnected()
          Returns true if node is opened but is disconnected from it's parent node
 boolean isPruned()
          Returns true if node has been pruned
 void prune()
          Called by search to prune node which will discard all child nodes and state information.
 void reactivate(TreeNode parent)
          Called by search if child and state data should be recalculated.
 void reconnect(TreeNode parent)
          Called by search to reconnect a child node to a parent node.
 void setGoal(jopt.csp.search.SearchGoal goal)
          Sets the goal value associated with this node
 void setObjectiveVal(double objectiveVal)
          Sets the objective value associated with this node
 void setStateData(java.lang.Object stateData)
          Sets state data associated with this node
 
Methods inherited from interface jopt.csp.search.SearchNode
getDepth
 

Method Detail

getChildNumberWithinParent

public int getChildNumberWithinParent()
Returns the number of the child within the parent


getParent

public TreeNode getParent()
Retrieves the parent of this search node

Returns:
the parent of this search node or null if no parent exists (root node)

activate

public SearchTechniqueChange activate(jopt.csp.search.SearchGoal goal)
                               throws jopt.csp.variable.PropagationFailureException
Called by search when node should be activated. This will cause the node to be closed and generate the children for this node. Only an open node can be activated.

Parameters:
goal - Optional goal to that is being sought after
Returns:
Object containing change for technique to use in child nodes, null if no change
Throws:
jopt.csp.variable.PropagationFailureException

deactivate

public void deactivate()
Called by search if child and state data should be discarded. This method is similar to prune(), but it does not set the isPruned flag. This is used in re-calculating trees to allow a node to be reactivated later. All references to other nodes including child and parents are removed to allow node to be reconnected at a later time. A node can only be deactivated if it was already closed and is not pruned.


reactivate

public void reactivate(TreeNode parent)
Called by search if child and state data should be recalculated. This method is similar to activate, but it will not fail since it has already been calculated before. A node should only be reactivated if it was previously deactivated.

Parameters:
parent - Parent node to reconnect node to tree

disconnect

public void disconnect()
Called by search to disconnect a child node from a parent node. Only an open node can be disconnected. TODO: Currently RecalculatingStateManager does sometimes call disconnect on a pruned node. For this reason, the requirement that only an open node can be disconnected has been temporarily removed. Is this right in the long term?


reconnect

public void reconnect(TreeNode parent)
Called by search to reconnect a child node to a parent node.


prune

public void prune()
Called by search to prune node which will discard all child nodes and state information. The isPruned flag is set after calling this method.


isClosed

public boolean isClosed()
Returns true if node is closed or pruned or deactivated.


isPruned

public boolean isPruned()
Returns true if node has been pruned


isDeactivated

public boolean isDeactivated()
Returns true if node is closed and the deactivate() method has been called on this node


isDisconnected

public boolean isDisconnected()
Returns true if node is opened but is disconnected from it's parent node


getChildCount

public int getChildCount()
Returns the number of children this node contains


getChild

public TreeNode getChild(int index)
Returns the child at the specified index


getNextOpenChild

public TreeNode getNextOpenChild()
Returns the next open child in the tree


getPath

public java.util.List getPath()
Returns a list of Integers containing the list of movements followed to reach this node. Each Integer represents a childNumber.


getBinaryPath

public java.util.BitSet getBinaryPath()
Returns a bitset representing the path from the root to this node as a series of left-right movements. Left is a zero value and right is a one. Because search nodes are allowed to have more than two children, any child that has childNum > 0 is treated as a right-ward movement. For this reason, getBinaryPath does not return unique values for every node; two sibling nodes that are not the first child of their parent will have identical binary paths.


getStateData

public java.lang.Object getStateData()
Returns state data associated with this node


setStateData

public void setStateData(java.lang.Object stateData)
Sets state data associated with this node


isBinary

public boolean isBinary()
Returns true if this node is binary


setGoal

public void setGoal(jopt.csp.search.SearchGoal goal)
Sets the goal value associated with this node


getGoal

public jopt.csp.search.SearchGoal getGoal()
Gets the goal value associated with this node


setObjectiveVal

public void setObjectiveVal(double objectiveVal)
Sets the objective value associated with this node


getObjectiveVal

public double getObjectiveVal()
Gets the objective value associated with this node


getAction

public jopt.csp.search.SearchAction getAction()
Returns the search action associated with this node