jopt.csp.spi.arcalgorithm.graph.node
Class GenericBooleanNode

java.lang.Object
  extended byjopt.csp.spi.arcalgorithm.graph.node.AbstractNode
      extended byjopt.csp.spi.arcalgorithm.graph.node.GenericBooleanNode
All Implemented Interfaces:
ChoicePointDataSource, ChoicePointEntryListener, GenericNode, Node, NodeChangeListener, NodeChangeSource, Storable

public class GenericBooleanNode
extends AbstractNode
implements NodeChangeListener, ChoicePointEntryListener, GenericNode

A generic node relating to a generic variable such as Xi which represents X1, X2, etc.


Nested Class Summary
 
Nested classes inherited from class jopt.csp.spi.arcalgorithm.graph.node.AbstractNode
AbstractNode.DomainListener
 
Constructor Summary
GenericBooleanNode(java.lang.String name, GenericIndex[] indices, BooleanNode[] nodes)
          Constructor
 
Method Summary
 void afterChoicePointPopEvent()
          Indicates that the current choice point has been rolled back and domain data must be reset
 void afterChoicePointPushEvent()
          Indicates that current choice point has been updated and domain data must be restored
 void beforeChoicePointPopEvent()
          Indicates that the current choice point is about to be rolled back and domain data must be reset
 void beforeChoicePointPushEvent()
          Indicates that current choice point is about to be pushed to allow data to be recorded in stack
 boolean choicePointStackSet()
          Returns true if a call to setChoicePointStack will fail
 void clearDelta()
          Clears the delta set for this node's domain
 int domainModifiedMaxOffset()
          Returns maximum offset of a node having a domain-modification
 int domainModifiedMinOffset()
          Returns minimum offset of a node having a domain-modification
 GenericIndex[] getIndices()
          Returns the generic index that is associated with this node
 Node getNode(int offset)
          Returns a node from the internal array
 int getNodeCount()
          Returns the number of nodes that are wrapped by this generic node
 Node getNodeForIndex()
          Returns the internal node corresponding to the associated index's current value
 int getSize()
          Returns size of domain for this node.
 java.lang.Object getState()
          Stores appropriate data for future restoration.
 boolean isAllFalse()
          Returns true if all nodes in the array evaluate to false
 boolean isAllFalse(int s, int e)
          Returns true if all nodes in the array evaluate to false within start and end indices
 boolean isAllTrue()
          Returns true if all nodes in the array evaluate to true
 boolean isAllTrue(int s, int e)
          Returns true if all nodes in the array evaluate to true within start and end indices
 boolean isAnyFalse()
          Returns true if any node in the array evaluates to false
 boolean isAnyFalse(int s, int e)
          Returns true if any node in the array evaluates to false within start and end indices
 boolean isAnyTrue()
          Returns true if any node in the array evaluates to false
 boolean isAnyTrue(int s, int e)
          Returns true if any node in the array evaluates to true within start and end indices
 boolean isBound()
          Returns true if all internal nodes are bound
 boolean isInDomain(java.lang.Object val)
          Returns true if a value is contained in this node's domain
 boolean isOverRealInterval()
          Returns true if domain of node is over real intervals
 void nodeChange(NodeChangeEvent ev)
          Called by internally wrapped node when it is altered.
 void restoreState(java.lang.Object state)
          Restores variable information from stored data.
 void setChoicePointStack(ChoicePointStack cps)
          Sets the choicepoint stack associated with this graph Can only be set once
 void setIndicesToNodeOffset(int offset)
          Updates associated indices to values corresponding to the node offset in the internal array
 java.util.Iterator values()
           
 
Methods inherited from class jopt.csp.spi.arcalgorithm.graph.node.AbstractNode
addDomainChangeListener, addedToGraph, addRangeChangeListener, addValueChangeListener, equals, getName, hashCode, inGraph, removedFromGraph, removeDomainChangeListener, removeRangeChangeListener, removeValueChangeListener, setName
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericBooleanNode

public GenericBooleanNode(java.lang.String name,
                          GenericIndex[] indices,
                          BooleanNode[] nodes)
Constructor

Parameters:
name - unique name of this node
indices - array of indices that generic node is based upon
nodes - array of nodes that this generic node wraps
Method Detail

isBound

public boolean isBound()
Returns true if all internal nodes are bound

Specified by:
isBound in interface Node

getIndices

public GenericIndex[] getIndices()
Description copied from interface: GenericNode
Returns the generic index that is associated with this node

Specified by:
getIndices in interface GenericNode

getNodeForIndex

public Node getNodeForIndex()
Description copied from interface: GenericNode
Returns the internal node corresponding to the associated index's current value

Specified by:
getNodeForIndex in interface GenericNode

getNodeCount

public int getNodeCount()
Description copied from interface: GenericNode
Returns the number of nodes that are wrapped by this generic node

Specified by:
getNodeCount in interface GenericNode

getNode

public Node getNode(int offset)
Description copied from interface: GenericNode
Returns a node from the internal array

Specified by:
getNode in interface GenericNode
Parameters:
offset - Offset of node in internal node array

isInDomain

public boolean isInDomain(java.lang.Object val)
Returns true if a value is contained in this node's domain

Specified by:
isInDomain in interface Node

getSize

public int getSize()
Returns size of domain for this node. If domain is infinite, value is Integer.MAX_VALUE

Specified by:
getSize in interface Node

values

public java.util.Iterator values()

isOverRealInterval

public boolean isOverRealInterval()
Returns true if domain of node is over real intervals


nodeChange

public void nodeChange(NodeChangeEvent ev)
Called by internally wrapped node when it is altered. This allows the generic node to track the indices of nodes that have been altered

Specified by:
nodeChange in interface NodeChangeListener

clearDelta

public void clearDelta()
Clears the delta set for this node's domain

Specified by:
clearDelta in interface Node

setChoicePointStack

public void setChoicePointStack(ChoicePointStack cps)
Sets the choicepoint stack associated with this graph Can only be set once

Specified by:
setChoicePointStack in interface Node

choicePointStackSet

public boolean choicePointStackSet()
Returns true if a call to setChoicePointStack will fail

Specified by:
choicePointStackSet in interface Node

beforeChoicePointPopEvent

public void beforeChoicePointPopEvent()
Description copied from interface: ChoicePointEntryListener
Indicates that the current choice point is about to be rolled back and domain data must be reset

Specified by:
beforeChoicePointPopEvent in interface ChoicePointEntryListener

afterChoicePointPopEvent

public void afterChoicePointPopEvent()
Description copied from interface: ChoicePointEntryListener
Indicates that the current choice point has been rolled back and domain data must be reset

Specified by:
afterChoicePointPopEvent in interface ChoicePointEntryListener

beforeChoicePointPushEvent

public void beforeChoicePointPushEvent()
Description copied from interface: ChoicePointEntryListener
Indicates that current choice point is about to be pushed to allow data to be recorded in stack

Specified by:
beforeChoicePointPushEvent in interface ChoicePointEntryListener

afterChoicePointPushEvent

public void afterChoicePointPushEvent()
Description copied from interface: ChoicePointEntryListener
Indicates that current choice point has been updated and domain data must be restored

Specified by:
afterChoicePointPushEvent in interface ChoicePointEntryListener

getState

public java.lang.Object getState()
Stores appropriate data for future restoration.

Specified by:
getState in interface Storable

restoreState

public void restoreState(java.lang.Object state)
Restores variable information from stored data.

Specified by:
restoreState in interface Storable

setIndicesToNodeOffset

public void setIndicesToNodeOffset(int offset)
Description copied from interface: GenericNode
Updates associated indices to values corresponding to the node offset in the internal array

Specified by:
setIndicesToNodeOffset in interface GenericNode

domainModifiedMinOffset

public int domainModifiedMinOffset()
Returns minimum offset of a node having a domain-modification


domainModifiedMaxOffset

public int domainModifiedMaxOffset()
Returns maximum offset of a node having a domain-modification


isAnyFalse

public boolean isAnyFalse()
Returns true if any node in the array evaluates to false


isAnyFalse

public boolean isAnyFalse(int s,
                          int e)
Returns true if any node in the array evaluates to false within start and end indices


isAllFalse

public boolean isAllFalse()
Returns true if all nodes in the array evaluate to false


isAllFalse

public boolean isAllFalse(int s,
                          int e)
Returns true if all nodes in the array evaluate to false within start and end indices


isAnyTrue

public boolean isAnyTrue()
Returns true if any node in the array evaluates to false


isAnyTrue

public boolean isAnyTrue(int s,
                         int e)
Returns true if any node in the array evaluates to true within start and end indices


isAllTrue

public boolean isAllTrue()
Returns true if all nodes in the array evaluate to true


isAllTrue

public boolean isAllTrue(int s,
                         int e)
Returns true if all nodes in the array evaluate to true within start and end indices