omnics.constraint
Class BinaryConstraint

java.lang.Object
  extended by omnics.Constraint
      extended by omnics.constraint.BinaryConstraint
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
BinaryIntConstraint, DistEq, DistNeq, Less, LessOrEqual, NotEqual

public abstract class BinaryConstraint
extends Constraint

Convenience abstract class that defines a binary constraint. It exposes for subclasses the variables x,y and their indices xIndex, yIndex

Author:
Cristian Frasinaru
See Also:
Serialized Form

Field Summary
protected  Var x
           
protected  int xIndex
           
protected  Var y
           
protected  int yIndex
           
 
Fields inherited from class omnics.Constraint
ALLOWED, filter, FORBIDDEN, MAX, MIN, name, problem, variables
 
Constructor Summary
BinaryConstraint(Var x, Var y)
          Creates a new instance of BinaryConstraint
 
Method Summary
abstract  int eval(java.lang.Object a, java.lang.Object b)
          This is the method that evaluates the tuple (x=a,y=b).
 int eval(Tuple tuple)
          Method used by the solver.
 int eval(Var x, Var y, java.lang.Object a, java.lang.Object b)
          Method used by the General Arc Consistency algorithm.
 
Methods inherited from class omnics.Constraint
eval, getFilter, getName, getProblem, getTuples, getVarArray, getVariables, setFilter, setName, setVariables, setVariables, toString, variable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

protected Var x

y

protected Var y

xIndex

protected int xIndex

yIndex

protected int yIndex
Constructor Detail

BinaryConstraint

public BinaryConstraint(Var x,
                        Var y)
Creates a new instance of BinaryConstraint

Method Detail

eval

public abstract int eval(java.lang.Object a,
                         java.lang.Object b)
This is the method that evaluates the tuple (x=a,y=b). Must be implemented in the subclasses.


eval

public int eval(Var x,
                Var y,
                java.lang.Object a,
                java.lang.Object b)
Method used by the General Arc Consistency algorithm.

Overrides:
eval in class Constraint
Parameters:
x - some variable of the constraint
y - some variable of the constraint
a - some value in x's domain
b - some value in y's domain
Returns:
a value between ValuationStructure.MIN and ValuationStructure.MAX.
See Also:
Constraint.eval(Tuple), ValuationStructure

eval

public int eval(Tuple tuple)
Method used by the solver.

Specified by:
eval in class Constraint
Parameters:
tuple - some tuple
Returns:
a value between ValuationStructure.MIN and ValuationStructure.MAX.
See Also:
Constraint.eval(Tuple), ValuationStructure