choco.integer.constraints
Class EqualXC

java.lang.Object
  extended by choco.AbstractEntity
      extended by choco.AbstractConstraint
          extended by choco.integer.constraints.AbstractIntConstraint
              extended by choco.integer.constraints.AbstractUnIntConstraint
                  extended by choco.integer.constraints.EqualXC
All Implemented Interfaces:
Constraint, Entity, IntConstraint, IntVarEventListener, VarEventListener, Propagator, java.lang.Cloneable, java.util.EventListener

public class EqualXC
extends AbstractUnIntConstraint

Implements a constraint X = C, with X a variable and C a constant.


Field Summary
protected  int cste
          The search constant of the constraint
 
Fields inherited from class choco.integer.constraints.AbstractUnIntConstraint
cIdx0, v0
 
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
EqualXC(IntDomainVar x0, int c)
          Constructs the constraint with the specified variables and constant.
 
Method Summary
 void awakeOnInf(int idx)
          Default propagation on improved lower bound: propagation on domain revision.
 void awakeOnInst(int idx)
          Default propagation on instantiation: full constraint re-propagation.
 void awakeOnRem(int idx, int x)
          Default propagation on one value removal: propagation on domain revision.
 void awakeOnSup(int idx)
          Default propagation on improved upper bound: propagation on domain revision.
 void awakeOnVar(int idx)
          Default propagation on variable revision: full constraint re-propagation.
 java.lang.Object clone()
          returns a copy of the constraint.
 boolean isConsistent()
          tests if the constraint is consistent with respect to the current state of domains
 java.lang.Boolean isEntailed()
          Checks if the listeners must be checked or must fail.
 boolean isEquivalentTo(Constraint compareTo)
          tests the equivalence (logical equality of the conditions) between two constraints.
 boolean isSatisfied()
          Checks if the constraint is satisfied when the variables are instantiated.
 AbstractConstraint opposite()
          computes the constraint modelling the counter-opposite condition of this
 java.lang.String pretty()
          Pretty print of the constraint.
 void propagate()
          The one and only propagation method.
 
Methods inherited from class choco.integer.constraints.AbstractUnIntConstraint
assignIndices, getConstraintIdx, getIntVar, getNbVars, getVar, isCompletelyInstantiated, setConstraintIndex, setVar
 
Methods inherited from class choco.integer.constraints.AbstractIntConstraint
awakeOnBounds, awakeOnRemovals, getSelfIndex
 
Methods inherited from class choco.AbstractConstraint
addListener, awake, connectVar, constAwake, delete, fail, getEvent, getPlugIn, getPriority, getProblem, getVarIdxInOpposite, isActive, setActive, setEntailed, setPassive, setPlugIn, substituteVar
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface choco.Propagator
awake, constAwake, delete, getEvent, getPlugIn, getPriority
 
Methods inherited from interface choco.prop.VarEventListener
addListener, isActive, setActive, setPassive
 
Methods inherited from interface choco.prop.VarEventListener
addListener, isActive, setActive, setPassive
 

Field Detail

cste

protected final int cste
The search constant of the constraint

Constructor Detail

EqualXC

public EqualXC(IntDomainVar x0,
               int c)
Constructs the constraint with the specified variables and constant.

Parameters:
x0 - the search valued domain variable
c - the search constant used in the equality.
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Description copied from interface: Constraint
returns a copy of the constraint. This copy is a new object, may be a recursive copy in case of composite constraints. The original and the copy share the same variables & plugins

Specified by:
clone in interface Constraint
Overrides:
clone in class AbstractConstraint
Returns:
Throws:
java.lang.CloneNotSupportedException

pretty

public java.lang.String pretty()
Pretty print of the constraint.

Specified by:
pretty in interface Entity
Overrides:
pretty in class AbstractEntity
Returns:
a readable string representation of the object

propagate

public void propagate()
               throws ContradictionException
The one and only propagation method.
Note that after the first propagation, the constraint could be set passive (to prevent from further calls to propagation methods), but this management seems too heavy to be worthwhile

Specified by:
propagate in interface Propagator
Overrides:
propagate in class AbstractUnIntConstraint
Throws:
ContradictionException

awakeOnVar

public void awakeOnVar(int idx)
                throws ContradictionException
Description copied from class: AbstractConstraint
Default propagation on variable revision: full constraint re-propagation.

Specified by:
awakeOnVar in interface VarEventListener
Specified by:
awakeOnVar in interface Propagator
Overrides:
awakeOnVar in class AbstractConstraint
Throws:
ContradictionException

awakeOnInf

public void awakeOnInf(int idx)
                throws ContradictionException
Description copied from class: AbstractIntConstraint
Default propagation on improved lower bound: propagation on domain revision.

Specified by:
awakeOnInf in interface IntVarEventListener
Overrides:
awakeOnInf in class AbstractIntConstraint
Throws:
ContradictionException

awakeOnSup

public void awakeOnSup(int idx)
                throws ContradictionException
Description copied from class: AbstractIntConstraint
Default propagation on improved upper bound: propagation on domain revision.

Specified by:
awakeOnSup in interface IntVarEventListener
Overrides:
awakeOnSup in class AbstractIntConstraint
Throws:
ContradictionException

awakeOnInst

public void awakeOnInst(int idx)
                 throws ContradictionException
Description copied from class: AbstractIntConstraint
Default propagation on instantiation: full constraint re-propagation.

Specified by:
awakeOnInst in interface IntVarEventListener
Overrides:
awakeOnInst in class AbstractIntConstraint
Throws:
ContradictionException

awakeOnRem

public void awakeOnRem(int idx,
                       int x)
                throws ContradictionException
Description copied from class: AbstractIntConstraint
Default propagation on one value removal: propagation on domain revision.

Specified by:
awakeOnRem in interface IntVarEventListener
Overrides:
awakeOnRem in class AbstractIntConstraint
Throws:
ContradictionException

isEntailed

public java.lang.Boolean isEntailed()
Checks if the listeners must be checked or must fail.

Specified by:
isEntailed in interface Propagator
Overrides:
isEntailed in class AbstractConstraint

isSatisfied

public boolean isSatisfied()
Checks if the constraint is satisfied when the variables are instantiated.


isConsistent

public boolean isConsistent()
tests if the constraint is consistent with respect to the current state of domains

Specified by:
isConsistent in interface Propagator
Overrides:
isConsistent in class AbstractIntConstraint
Returns:
true iff the constraint is bound consistent (same as arc consistent)

opposite

public AbstractConstraint opposite()
Description copied from interface: Constraint
computes the constraint modelling the counter-opposite condition of this

Specified by:
opposite in interface Constraint
Overrides:
opposite in class AbstractConstraint
Returns:
a new constraint (modelling the opposite condition)

isEquivalentTo

public final boolean isEquivalentTo(Constraint compareTo)
Description copied from interface: Constraint
tests the equivalence (logical equality of the conditions) between two constraints. In particular whenever c1.equals(c2), then c1.isEquivalent(c2).

Specified by:
isEquivalentTo in interface Constraint
Overrides:
isEquivalentTo in class AbstractConstraint
Parameters:
compareTo - the constraint to be compared to
Returns:
true if and only if the constraints model the same logical condition.