omnics
Class Tuple

java.lang.Object
  extended by omnics.Tuple
All Implemented Interfaces:
java.io.Serializable

public class Tuple
extends java.lang.Object
implements java.io.Serializable

A tuple represents an instantiation of variables: (x1=a1,x2=a2,...,xk=ak)

Author:
Cristian Frasinaru
See Also:
Serialized Form

Constructor Summary
Tuple()
          Creates a new instance of Tuple
Tuple(Tuple tuple)
          Creates a new instance of Tuple
Tuple(Var[] varArray, java.lang.Object[] values)
          Creates a new instance of Tuple
Tuple(Var var, java.lang.Object value)
          Creates a new instance of Tuple
Tuple(VarSet vars, java.lang.Object[] values)
          Creates a new instance of Tuple
 
Method Summary
 boolean contains(Var x)
           
 boolean equals(java.lang.Object object)
           
 java.lang.Object get(int index)
          Returns the value of the variable with the given index.
 java.lang.Object get(Var var)
          Returns the value of the given variable.
 Problem getProblem()
          Returns the problem.
 java.lang.Object getValue(java.lang.String name)
          Returns the value of a variable of the tuple specified by name
 Var[] getVarArray()
          Returns the variables of the problem as an array
 Var getVariable(java.lang.String name)
          Returns a variable of the tuple specified by name
 Constraint getViolatedConstraint()
          Tests if this tuple is consistent relative only to the constraints that include the specified variable
 boolean isConsistent()
          Returns a constraint which is not satisfied bu this tuple.
 boolean isConsistent(Constraint constraint)
          Tests if this tuple is consistent relative to the given constraint
 boolean isConsistent(Var var)
          Tests if this tuple is consistent relative only to the constraints that include the specified variable
 boolean isFeasible(Var var)
          Tests if this tuple is feasible with the specified variable, that is if it exists a value a for the variable var such that the instantiation formed by this tuple and var=a is consistent.
 Tuple join(Tuple other)
          Returns the join with the specified tuple.
 Tuple projection(VarSet vars)
          Return the projection on the specified set of variables
 java.lang.Object put(Var var, java.lang.Object value)
          Adds a new pair (variable, value)
 java.lang.Object remove(Var var)
          Removes a variable.
 int size()
          Returns the size of the tuple.
 java.lang.String toString()
          Returns a string representation of the tuple.
 Tuple union(Tuple other)
          Returns the union with the specified tuple.
 VarSet variables()
          Returns the variables of the tuple as a VarSet
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Tuple

public Tuple()
Creates a new instance of Tuple


Tuple

public Tuple(Var var,
             java.lang.Object value)
Creates a new instance of Tuple


Tuple

public Tuple(VarSet vars,
             java.lang.Object[] values)
Creates a new instance of Tuple


Tuple

public Tuple(Var[] varArray,
             java.lang.Object[] values)
Creates a new instance of Tuple


Tuple

public Tuple(Tuple tuple)
Creates a new instance of Tuple

Method Detail

getProblem

public Problem getProblem()
Returns the problem.


put

public java.lang.Object put(Var var,
                            java.lang.Object value)
Adds a new pair (variable, value)


get

public java.lang.Object get(Var var)
Returns the value of the given variable.


get

public java.lang.Object get(int index)
Returns the value of the variable with the given index.


remove

public java.lang.Object remove(Var var)
Removes a variable.


variables

public VarSet variables()
Returns the variables of the tuple as a VarSet


size

public int size()
Returns the size of the tuple.


getVarArray

public Var[] getVarArray()
Returns the variables of the problem as an array


getVariable

public Var getVariable(java.lang.String name)
Returns a variable of the tuple specified by name


getValue

public java.lang.Object getValue(java.lang.String name)
Returns the value of a variable of the tuple specified by name


projection

public Tuple projection(VarSet vars)
Return the projection on the specified set of variables


union

public Tuple union(Tuple other)
Returns the union with the specified tuple. The method copies all of the values from the specified tuple to this tuple. These values will replace any values that this tuple had for any of the variables currently in the specified tuple.


join

public Tuple join(Tuple other)
Returns the join with the specified tuple. If the tuples had no common variables it returns the union of the two. If the values of the common variables are not the same it returns the empty tuple.


equals

public boolean equals(java.lang.Object object)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Returns a string representation of the tuple.

Overrides:
toString in class java.lang.Object

contains

public boolean contains(Var x)

isConsistent

public boolean isConsistent(Constraint constraint)
Tests if this tuple is consistent relative to the given constraint


isConsistent

public boolean isConsistent(Var var)
Tests if this tuple is consistent relative only to the constraints that include the specified variable


isConsistent

public boolean isConsistent()
Returns a constraint which is not satisfied bu this tuple.


getViolatedConstraint

public Constraint getViolatedConstraint()
Tests if this tuple is consistent relative only to the constraints that include the specified variable


isFeasible

public boolean isFeasible(Var var)
Tests if this tuple is feasible with the specified variable, that is if it exists a value a for the variable var such that the instantiation formed by this tuple and var=a is consistent.