choco.integer.constraints
Class AbstractTernIntConstraint

java.lang.Object
  extended by choco.AbstractEntity
      extended by choco.AbstractConstraint
          extended by choco.integer.constraints.AbstractIntConstraint
              extended by choco.integer.constraints.AbstractTernIntConstraint
All Implemented Interfaces:
Constraint, Entity, IntConstraint, IntVarEventListener, VarEventListener, Propagator, java.lang.Cloneable, java.util.EventListener
Direct Known Subclasses:
AbstractPalmTernIntConstraint, TimesXYZ

public abstract class AbstractTernIntConstraint
extends AbstractIntConstraint

An abstract class for all implementations of (unary) listeners over one search variable.


Field Summary
protected  int cIdx0
          The index of the constraint among all listeners of its first variable.
protected  int cIdx1
          The index of the constraint among all listeners of its second variable.
protected  int cIdx2
          The index of the constraint among all listeners of its third variable.
protected  IntDomainVar v0
          The first variable of the constraint.
protected  IntDomainVar v1
          The second variable of the constraint.
protected  IntDomainVar v2
          The third variable of the constraint.
 
Fields inherited from class choco.integer.constraints.AbstractIntConstraint
logger
 
Fields inherited from class choco.AbstractConstraint
active, constAwakeEvent, hook, priority
 
Fields inherited from class choco.AbstractEntity
problem
 
Constructor Summary
AbstractTernIntConstraint(IntDomainVar x0, IntDomainVar x1, IntDomainVar x2)
          Builds a ternary constraint with the specified variables.
 
Method Summary
 int assignIndices(AbstractCompositeConstraint root, int i, boolean dynamicAddition)
          Assign indices to variables for this constraint but also for global constraint if this constraint is included in a global boolean meta-constraint.
 int getConstraintIdx(int idx)
          Returns the index of the constraint in the specified variable.
 IntDomainVar getIntVar(int i)
          Gets the ith search valued variable.
 int getNbVars()
          Returns the number of variables.
 Var getVar(int i)
          Gets the specified variable.
 boolean isCompletelyInstantiated()
          Checks if all the variables are instantiated.
 void propagate()
          Propagation for the constraint awake var.
 void setConstraintIndex(int i, int val)
          Let v be the i-th var of c, records that c is the constraint n according to v.
 void setVar(int i, Var v)
          Sets the association between variable and index of this variable.
 
Methods inherited from class choco.integer.constraints.AbstractIntConstraint
awakeOnBounds, awakeOnInf, awakeOnInst, awakeOnRem, awakeOnRemovals, awakeOnSup, getSelfIndex, isConsistent
 
Methods inherited from class choco.AbstractConstraint
addListener, awake, awakeOnVar, clone, connectVar, constAwake, delete, fail, getEvent, getPlugIn, getPriority, getProblem, getVarIdxInOpposite, isActive, isEntailed, isEquivalentTo, opposite, setActive, setEntailed, setPassive, setPlugIn, substituteVar
 
Methods inherited from class choco.AbstractEntity
pretty
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface choco.Propagator
awake, awakeOnVar, constAwake, delete, getEvent, getPlugIn, getPriority, isEntailed
 
Methods inherited from interface choco.prop.VarEventListener
addListener, isActive, setActive, setPassive
 
Methods inherited from interface choco.prop.VarEventListener
addListener, isActive, setActive, setPassive
 

Field Detail

v0

protected IntDomainVar v0
The first variable of the constraint.


v1

protected IntDomainVar v1
The second variable of the constraint.


v2

protected IntDomainVar v2
The third variable of the constraint.


cIdx0

protected int cIdx0
The index of the constraint among all listeners of its first variable.


cIdx1

protected int cIdx1
The index of the constraint among all listeners of its second variable.


cIdx2

protected int cIdx2
The index of the constraint among all listeners of its third variable.

Constructor Detail

AbstractTernIntConstraint

public AbstractTernIntConstraint(IntDomainVar x0,
                                 IntDomainVar x1,
                                 IntDomainVar x2)
Builds a ternary constraint with the specified variables.

Parameters:
x0 - the first variable
x1 - the second variable
x2 - the third variable
Method Detail

setConstraintIndex

public void setConstraintIndex(int i,
                               int val)
Let v be the i-th var of c, records that c is the constraint n according to v.

Parameters:
i - the variable index
val - the constraint index according to the variable

getConstraintIdx

public int getConstraintIdx(int idx)
Returns the index of the constraint in the specified variable.

Parameters:
idx - the variable index
Returns:
the constraint index according to the variable

isCompletelyInstantiated

public boolean isCompletelyInstantiated()
Checks if all the variables are instantiated.

Specified by:
isCompletelyInstantiated in interface Propagator
Overrides:
isCompletelyInstantiated in class AbstractIntConstraint
Returns:
true if all variables are sintantiated

getNbVars

public int getNbVars()
Returns the number of variables.

Returns:
the number of variables, here always 3.

getVar

public Var getVar(int i)
Gets the specified variable.

Parameters:
i - the variable index
Returns:
the variable with the specified index according to this constraint

setVar

public void setVar(int i,
                   Var v)
Sets the association between variable and index of this variable.

Parameters:
i - the variable index
v - the variable

propagate

public void propagate()
               throws ContradictionException
Propagation for the constraint awake var.

Throws:
ContradictionException - if a domain becomes empty or the filtering algorithm infers a contradiction

getIntVar

public IntDomainVar getIntVar(int i)
Gets the ith search valued variable.

Parameters:
i - the variable index
Returns:
the variable with index i

assignIndices

public int assignIndices(AbstractCompositeConstraint root,
                         int i,
                         boolean dynamicAddition)
Assign indices to variables for this constraint but also for global constraint if this constraint is included in a global boolean meta-constraint.

Parameters:
root - the global constraint
i - the current available index for the global constraint
dynamicAddition - states if the constraint is definitive
Returns:
the new available index for the global constraint that is i+3 here