Cream version 1.06 Core API Specification

jp.ac.kobe_u.cs.cream
Class Network

java.lang.Object
  extended by jp.ac.kobe_u.cs.cream.Network
All Implemented Interfaces:
Cloneable

public class Network
extends Object
implements Cloneable

Constraint networks. A constraint network consists of variables, constraints, and an objective variable (optional). Variables and constraints are added by add methods:

 Network net = new Network();
 Domain d = new IntDomain(0, IntDomain.MAX_VALUE);
 Variable x = new Variable(net, d);
 Variable y = new Variable(net, d);
 new NotEquals(net, x, y);
 

Please note that any variable or any constraint can not be added to two different networks. In other words, a network can not share a variable or a constraint with another network.

Since:
1.0
See Also:
Variable, Constraint

Constructor Summary
Network()
          Constructs an empty constraint network.
 
Method Summary
 Object clone()
          Returns a copy of this network.
 Constraint getConstraint(int i)
          Returns the i-th constraint of this network.
 List<Constraint> getConstraints()
          Returns the list of constraints of this network.
 Variable getObjective()
          Returns the objective variable of this network.
 Variable getVariable(int i)
          Returns the i-th variable of this network.
 List<Variable> getVariables()
          Returns the list of variables of this network.
 void setObjective(Variable v)
          Sets the objective variable of this network.
 String toString()
          Returns a readable string representation of this network.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Network

public Network()
Constructs an empty constraint network.

Method Detail

setObjective

public void setObjective(Variable v)
Sets the objective variable of this network. If v is null, this network is set to have no objective variable. If v is not null, the objective variable is automatically added to the network.

Parameters:
v - the objective variable

getObjective

public Variable getObjective()
Returns the objective variable of this network.

Returns:
the objective variable or null if the network has no objective variable

getVariables

public List<Variable> getVariables()
Returns the list of variables of this network.

Returns:
the list of variables

getConstraints

public List<Constraint> getConstraints()
Returns the list of constraints of this network.

Returns:
the list of constraints

getVariable

public Variable getVariable(int i)
Returns the i-th variable of this network. The index starts from 0.

Parameters:
i - the index value of the variable to be returned
Returns:
the i-th variable
Throws:
IndexOutOfBoundsException - if i is out-of-range

getConstraint

public Constraint getConstraint(int i)
Returns the i-th constraint of this network. The index starts from 0.

Parameters:
i - the index value of the constraint to be returned
Returns:
the i-th constraint
Throws:
IndexOutOfBoundsException - if i is out-of-range

clone

public Object clone()
Returns a copy of this network. The new network has the same structure as the original network.

Overrides:
clone in class Object
Returns:
a copy of this network

toString

public String toString()
Returns a readable string representation of this network.

Overrides:
toString in class Object
Returns:
the readable string representation

Cream version 1.06 Core API Specification

Cream: Constraint Programming Class Library for Java