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

java.lang.Object
  extended byjopt.csp.spi.arcalgorithm.graph.node.AbstractNode
      extended byjopt.csp.spi.arcalgorithm.graph.node.GenericNumNode
All Implemented Interfaces:
ChoicePointDataSource, ChoicePointEntryListener, GenericNode, Node, NodeChangeListener, NodeChangeSource, Storable
Direct Known Subclasses:
GenericDoubleNode, GenericFloatNode, GenericIntNode, GenericLongNode

public abstract class GenericNumNode
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
GenericNumNode(java.lang.String name, GenericIndex[] indices, NumNode[] nodes, int nodeType)
          Constructor
 
Method Summary
 void addInternalRangeChangeListener(NodeChangeListener listener)
          Adds a listener to this node's internal nodes interested in range and value events
 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
 java.lang.Number getLargestMax()
          Returns that largest maximal value of all variables in array
 java.lang.Number getLargestMax(int start, int end)
          Returns that largest maximal value of all variables in array within start and end indices
 java.lang.Number getLargestMin()
          Returns that largest minimal value of all variables in array
 java.lang.Number getLargestMin(int start, int end)
          Returns that largest minimal value of all variables in array within start and end indices
 java.lang.Number getMax()
          Returns maximum value of node
 java.lang.Number getMin()
          Returns minimal value of 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
 NumNode[] getNodes()
          Returns all the nodes wrapped by this generic node
abstract  int getNumberType()
          Returns the type of number this node is based on.
 double getPrecision()
          Returns precision associated with this domain
 int getSize()
          Returns size of domain for this node.
 java.lang.Number getSmallestMax()
          Returns that smallest maximal value of all variables in array
 java.lang.Number getSmallestMax(int start, int end)
          Returns that smallest maximal value of all variables in array within start and end indices
 java.lang.Number getSmallestMin()
          Returns that smallest minimal value of all variables in array
 java.lang.Number getSmallestMin(int start, int end)
          Returns that smallest minimal value of all variables in array within start and end indices
 java.lang.Object getState()
          Stores appropriate data for future restoration.
 boolean isAnyBound()
          Returns true if any internal node is bound
 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.
 int rangeModifiedMaxOffset()
          Returns maximum offset of a node having a range-modification
 int rangeModifiedMinOffset()
          Returns minimum offset of a node having a range-modification
 void restoreState(java.lang.Object state)
          Restores variable information from stored data.
 void setChoicePointEventListener(ChoicePointEventListener cpel)
           
 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.lang.String toString()
          Displays name of node along with indices
 int valueModifiedMaxOffset()
          Returns maximum offset of a node having a value-modification
 int valueModifiedMinOffset()
          Returns minimum offset of a node having a value-modification
 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, wait, wait, wait
 

Constructor Detail

GenericNumNode

public GenericNumNode(java.lang.String name,
                      GenericIndex[] indices,
                      NumNode[] nodes,
                      int nodeType)
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

isAnyBound

public boolean isAnyBound()
Returns true if any internal node is bound


getPrecision

public double getPrecision()
Returns precision associated with this domain


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

getNodes

public NumNode[] getNodes()
Returns all the nodes wrapped by this generic node


getLargestMax

public java.lang.Number getLargestMax()
Returns that largest maximal value of all variables in array


getMin

public java.lang.Number getMin()
Returns minimal value of node


getMax

public java.lang.Number getMax()
Returns maximum value of node


getLargestMax

public java.lang.Number getLargestMax(int start,
                                      int end)
Returns that largest maximal value of all variables in array within start and end indices


getSmallestMax

public java.lang.Number getSmallestMax()
Returns that smallest maximal value of all variables in array


getSmallestMax

public java.lang.Number getSmallestMax(int start,
                                       int end)
Returns that smallest maximal value of all variables in array within start and end indices


getLargestMin

public java.lang.Number getLargestMin()
Returns that largest minimal value of all variables in array


getLargestMin

public java.lang.Number getLargestMin(int start,
                                      int end)
Returns that largest minimal value of all variables in array within start and end indices


getSmallestMin

public java.lang.Number getSmallestMin()
Returns that smallest minimal value of all variables in array


getSmallestMin

public java.lang.Number getSmallestMin(int start,
                                       int end)
Returns that smallest minimal value of all variables in array within start and end indices


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 and how much they've 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

valueModifiedMinOffset

public int valueModifiedMinOffset()
Returns minimum offset of a node having a value-modification


valueModifiedMaxOffset

public int valueModifiedMaxOffset()
Returns maximum offset of a node having a value-modification


rangeModifiedMinOffset

public int rangeModifiedMinOffset()
Returns minimum offset of a node having a range-modification


rangeModifiedMaxOffset

public int rangeModifiedMaxOffset()
Returns maximum offset of a node having a range-modification


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


setChoicePointEventListener

public void setChoicePointEventListener(ChoicePointEventListener cpel)

addInternalRangeChangeListener

public void addInternalRangeChangeListener(NodeChangeListener listener)
Adds a listener to this node's internal nodes interested in range and value events


toString

public java.lang.String toString()
Displays name of node along with indices


getNumberType

public abstract int getNumberType()
Returns the type of number this node is based on.