Cream version 1.06 Core API Specification

jp.ac.kobe_u.cs.cream
Class Variable

java.lang.Object
  extended by jp.ac.kobe_u.cs.cream.Variable
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
IntVariable

public class Variable
extends Object
implements Cloneable

Variables. A variable is a component of a constraint network. A variable is constructed with an initial domain which specifies the set of elements over which the variable ranges. See Network for example programs to construct variables and add them to a constraint network.

Since:
1.0
See Also:
Network, Domain

Constructor Summary
Variable(Network net, Domain d)
          Constructs a variable of the network with an initial domain d and a default name.
Variable(Network net, Domain d, String name)
          Constructs a variable of the network with an initial domain d and a name specified by the parameter name.
 
Method Summary
 Domain getDomain()
          Returns the domain of the variable.
 int getIndex()
          Returns the index of the variable in the network.
 String getName()
          Returns the name of this variable.
 Network getNetwork()
          Returns the constraint network.
 boolean isModified()
          Returns the modified flag.
 boolean isWatch()
          Returns the watch flag.
 void setDomain(Domain d)
          Sets the domain of the variables.
 void setIndex(int index)
          Sets the index of the variable in the network.
 void setModified(boolean modified)
          Sets the modified flag.
 void setName(String name)
          Sets the name of this variable.
 void setWatch(boolean watch)
          Sets the watch flag.
 String toString()
          Returns the name of this variable.
 void updateDomain(Domain d, Trail trail)
          Updates the domain of the variables.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Variable

public Variable(Network net,
                Domain d)
Constructs a variable of the network with an initial domain d and a default name. This constructor is equivalent to Variable(network, d, null).

Parameters:
net - the network
d - the initial domain

Variable

public Variable(Network net,
                Domain d,
                String name)
Constructs a variable of the network with an initial domain d and a name specified by the parameter name. When the parameter name is null, default names (v1, v2, and so on) are used.

Parameters:
net - the network
d - the initial domain
name - the name of the variable, or null for a default name
Method Detail

getNetwork

public Network getNetwork()
Returns the constraint network.

Returns:
the constraint network

setIndex

public void setIndex(int index)
Sets the index of the variable in the network. This is an internal method.

Parameters:
index - the index

getIndex

public int getIndex()
Returns the index of the variable in the network. This is an internal method.

Returns:
the index

getDomain

public Domain getDomain()
Returns the domain of the variable.

Returns:
the domain

setDomain

public void setDomain(Domain d)
Sets the domain of the variables. Modified flag is set when the domain is changed.

Parameters:
d - the domain.

updateDomain

public void updateDomain(Domain d,
                         Trail trail)
Updates the domain of the variables. Old domain is saved to the trail stack. Modified flag is set when the domain is changed. New domain is printed out when the watch flag is set.

Parameters:
d - the domain.
trail - the trail stack

isModified

public boolean isModified()
Returns the modified flag.

Returns:
the modified flag

setModified

public void setModified(boolean modified)
Sets the modified flag.

Parameters:
modified - the modified to set

isWatch

public boolean isWatch()
Returns the watch flag.

Returns:
the watch flag

setWatch

public void setWatch(boolean watch)
Sets the watch flag.

Parameters:
watch - the watch to set

getName

public String getName()
Returns the name of this variable.

Returns:
the name of this variable

setName

public void setName(String name)
Sets the name of this variable.

Parameters:
name - the name to set

toString

public String toString()
Returns the name of this variable.

Overrides:
toString in class Object
Returns:
the name of this variable

Cream version 1.06 Core API Specification

Cream: Constraint Programming Class Library for Java