jopt.csp.spi.search.tree
Class RecalculatingStateManager

java.lang.Object
  extended byjopt.csp.spi.search.tree.RecalculatingStateManager
All Implemented Interfaces:
TreeStateManager

public class RecalculatingStateManager
extends java.lang.Object
implements TreeStateManager

State manager that recalculates state of search tree as it is traversed so that no unnecessary information or nodes are maintained.

Design Notes
This method was created one night as Nick bolted straight up from a sound sleep and pronounced, "Eureka! I have the answer".

Ok, so it wasn't quite that dramatic, but it was a sudden answer that came after much debate about how the state of a search tree could utilize an optimal amount of memory. It is based on the assumption that any given search node will produce the same children in the same way no matter how many times the parent node is activated / recalculated.

This state manager takes advantage of this situation by creating references to any node based on the path followed to reach the child from the root of the tree. To reach a previously closed node, this manager simply reactivates each child node as it is made current in the tree so that the same child nodes will be produced as before.

This state manager can only be used with the CrawlingSearchTree and is the default state manager used by the CspSolver.

Version:
$Revision: 1.14 $
Author:
Nick Coleman
See Also:
ProblemStateManager, DeltaStateManager, CrawlingSearchTree

Constructor Summary
RecalculatingStateManager(ConstraintStore store)
          Basic constructor
 
Method Summary
 void ascendedToClosedNode(TreeNode previous, TreeNode current)
          Called by search tree when the current node is changed to a parent node of existing current node Node must have previously been activated.
 void descendedToClosedNode(TreeNode previous, TreeNode current)
          Called by search tree when the current node is changed to a child node of existing current node.
 void descendedToOpenNode(TreeNode previous, TreeNode current)
          Called by search tree when the node that is being moved to is a node that has not yet been activated
 void jumpedToClosedNode(TreeNode previous, TreeNode current)
          Called by search tree when the current node in the tree has changed from one node to another and no direct relationship between the two nodes may exist Node must have previously been activated.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RecalculatingStateManager

public RecalculatingStateManager(ConstraintStore store)
Basic constructor

Parameters:
store - the ConstraintStore associated with this problem
Method Detail

descendedToClosedNode

public void descendedToClosedNode(TreeNode previous,
                                  TreeNode current)
Description copied from interface: TreeStateManager
Called by search tree when the current node is changed to a child node of existing current node. Node must have previously been activated.

Specified by:
descendedToClosedNode in interface TreeStateManager
Parameters:
previous - Node that was current in tree
current - Node that is now current in tree

ascendedToClosedNode

public void ascendedToClosedNode(TreeNode previous,
                                 TreeNode current)
Description copied from interface: TreeStateManager
Called by search tree when the current node is changed to a parent node of existing current node Node must have previously been activated.

Specified by:
ascendedToClosedNode in interface TreeStateManager
Parameters:
previous - Node that was current in tree
current - Node that is now current in tree

descendedToOpenNode

public void descendedToOpenNode(TreeNode previous,
                                TreeNode current)
Description copied from interface: TreeStateManager
Called by search tree when the node that is being moved to is a node that has not yet been activated

Specified by:
descendedToOpenNode in interface TreeStateManager
Parameters:
previous - Node that was current in tree
current - Node that is now current in tree

jumpedToClosedNode

public void jumpedToClosedNode(TreeNode previous,
                               TreeNode current)
Description copied from interface: TreeStateManager
Called by search tree when the current node in the tree has changed from one node to another and no direct relationship between the two nodes may exist Node must have previously been activated.

Specified by:
jumpedToClosedNode in interface TreeStateManager
Parameters:
previous - Node that was current in tree
current - Node that is now current in tree