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

java.lang.Object
  extended byjopt.csp.spi.arcalgorithm.graph.node.AbstractNode
      extended byjopt.csp.spi.arcalgorithm.graph.node.LongNode
All Implemented Interfaces:
ChoicePointDataSource, Node, NodeChangeSource, NumNode, Storable, TrigExpr

public class LongNode
extends AbstractNode
implements NumNode

Node for long numeric domains


Nested Class Summary
 
Nested classes inherited from class jopt.csp.spi.arcalgorithm.graph.node.AbstractNode
AbstractNode.DomainListener
 
Constructor Summary
LongNode()
          Constructor that gives the node a unique name and a domain from Long.MIN_VALUE to Long.MAX_VALUE
LongNode(java.lang.String name, LongDomain domain)
          Constructor
 
Method Summary
 boolean choicePointStackSet()
          Returns true if a call to setChoicePointStack will fail
 void clearDelta()
          Clears the delta set for this node's domain
 jopt.csp.util.NumberIterator deltaValues()
          Returns iterator of values in node's delta
 jopt.csp.util.NumSet getDomain()
          Returns domain of node as a set of Number and NumInterval objects
 java.lang.Number getMax()
          Returns the maximum domain value for this node
 java.lang.Number getMin()
          Returns the minimum domain value for this node
 java.lang.Number getNextHigher(java.lang.Number n)
          Returns the next higher domain value for a given n.
 java.lang.Number getNextLower(java.lang.Number n)
          Returns the next lower domain value for a given n.
 int getNumberType()
          Returns the type of number this node is based on.
 java.lang.Number getNumMax()
          Returns the maximum domain value for this expression
 java.lang.Number getNumMin()
          Returns the minimum domain value for this expression
 double getPrecision()
          Returns precision associated with this domain for real numbers
 int getSize()
          Returns size of domain for this node.
 java.lang.Object getState()
          Stores appropriate data for future restoration.
 boolean isBound()
          Returns true if domain for this node is bound to a single value
 boolean isInDomain(java.lang.Number val)
          Returns true if value is in domain
 boolean isInDomain(java.lang.Object n)
          Returns true if a value n is contained in this node's domain
 void removeDomain(jopt.csp.util.NumSet s)
          Removes all values in this node's domain contained within set S
 void removeRange(java.lang.Number start, java.lang.Number end)
          Removes a range of values from the domain of this node
 void removeValue(java.lang.Number n)
          Removes a single value from the domain of this node
 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 setDomain(jopt.csp.util.NumSet s)
          Restricts node's domain to values contained within set S
 void setMax(java.lang.Number n)
          Restricts domain to all values less than or equal to value given
 void setMin(java.lang.Number n)
          Restricts domain to all values greater than or equal to value given
 void setRange(java.lang.Number start, java.lang.Number end)
          Restricts domain of this node to a range of values
 void setValue(java.lang.Number n)
          Restricts domain to a single value
 java.lang.String toString()
          Returns string representation of node
 jopt.csp.util.NumberIterator values()
          Returns iterator of values in node's domain
 
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
 
Methods inherited from interface jopt.csp.spi.arcalgorithm.graph.node.Node
addedToGraph, getName, inGraph, removedFromGraph, setName
 
Methods inherited from interface jopt.csp.spi.arcalgorithm.graph.node.NodeChangeSource
addDomainChangeListener, addRangeChangeListener, addValueChangeListener, removeDomainChangeListener, removeRangeChangeListener, removeValueChangeListener
 

Constructor Detail

LongNode

public LongNode(java.lang.String name,
                LongDomain domain)
Constructor


LongNode

public LongNode()
Constructor that gives the node a unique name and a domain from Long.MIN_VALUE to Long.MAX_VALUE

Method Detail

getPrecision

public double getPrecision()
Returns precision associated with this domain for real numbers

Specified by:
getPrecision in interface NumNode

getMax

public java.lang.Number getMax()
Returns the maximum domain value for this node

Specified by:
getMax in interface NumNode

getMin

public java.lang.Number getMin()
Returns the minimum domain value for this node

Specified by:
getMin in interface NumNode

getNumMax

public java.lang.Number getNumMax()
Description copied from interface: TrigExpr
Returns the maximum domain value for this expression

Specified by:
getNumMax in interface TrigExpr

getNumMin

public java.lang.Number getNumMin()
Description copied from interface: TrigExpr
Returns the minimum domain value for this expression

Specified by:
getNumMin in interface TrigExpr

isInDomain

public boolean isInDomain(java.lang.Number val)
Returns true if value is in domain

Specified by:
isInDomain in interface NumNode

getNextHigher

public java.lang.Number getNextHigher(java.lang.Number n)
Returns the next higher domain value for a given n. Returns n if no higher value exists

Specified by:
getNextHigher in interface NumNode

getNextLower

public java.lang.Number getNextLower(java.lang.Number n)
Returns the next lower domain value for a given n. Returns n if no lower value exists

Specified by:
getNextLower in interface NumNode

isBound

public boolean isBound()
Returns true if domain for this node is bound to a single value

Specified by:
isBound in interface Node

isInDomain

public boolean isInDomain(java.lang.Object n)
Returns true if a value n 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 Long.MAX_VALUE

Specified by:
getSize in interface Node

values

public jopt.csp.util.NumberIterator values()
Returns iterator of values in node's domain

Specified by:
values in interface NumNode

deltaValues

public jopt.csp.util.NumberIterator deltaValues()
Returns iterator of values in node's delta

Specified by:
deltaValues in interface NumNode

setMax

public void setMax(java.lang.Number n)
            throws jopt.csp.variable.PropagationFailureException
Restricts domain to all values less than or equal to value given

Specified by:
setMax in interface NumNode
Throws:
jopt.csp.variable.PropagationFailureException - If domain is empty

setMin

public void setMin(java.lang.Number n)
            throws jopt.csp.variable.PropagationFailureException
Restricts domain to all values greater than or equal to value given

Specified by:
setMin in interface NumNode
Throws:
jopt.csp.variable.PropagationFailureException - If domain is empty

removeValue

public void removeValue(java.lang.Number n)
                 throws jopt.csp.variable.PropagationFailureException
Removes a single value from the domain of this node

Specified by:
removeValue in interface NumNode
Throws:
jopt.csp.variable.PropagationFailureException - If domain is empty

setValue

public void setValue(java.lang.Number n)
              throws jopt.csp.variable.PropagationFailureException
Restricts domain to a single value

Specified by:
setValue in interface NumNode
Throws:
jopt.csp.variable.PropagationFailureException - If domain is empty

removeRange

public void removeRange(java.lang.Number start,
                        java.lang.Number end)
                 throws jopt.csp.variable.PropagationFailureException
Removes a range of values from the domain of this node

Specified by:
removeRange in interface NumNode
Throws:
jopt.csp.variable.PropagationFailureException - If domain is empty

setRange

public void setRange(java.lang.Number start,
                     java.lang.Number end)
              throws jopt.csp.variable.PropagationFailureException
Restricts domain of this node to a range of values

Specified by:
setRange in interface NumNode
Throws:
jopt.csp.variable.PropagationFailureException - If domain is empty

removeDomain

public void removeDomain(jopt.csp.util.NumSet s)
                  throws jopt.csp.variable.PropagationFailureException
Removes all values in this node's domain contained within set S

Specified by:
removeDomain in interface NumNode
Throws:
jopt.csp.variable.PropagationFailureException - If domain is empty

setDomain

public void setDomain(jopt.csp.util.NumSet s)
               throws jopt.csp.variable.PropagationFailureException
Restricts node's domain to values contained within set S

Specified by:
setDomain in interface NumNode
Throws:
jopt.csp.variable.PropagationFailureException - If domain is empty

getDomain

public jopt.csp.util.NumSet getDomain()
Returns domain of node as a set of Number and NumInterval objects

Specified by:
getDomain in interface NumNode
Throws:
jopt.csp.variable.PropagationFailureException - If domain is empty

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

toString

public java.lang.String toString()
Returns string representation of node


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

getNumberType

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

Specified by:
getNumberType in interface NumNode