choco.integer.constraints
Class GreaterOrEqualXYC

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

public class GreaterOrEqualXYC
extends AbstractBinIntConstraint

Implements a constraint X > Y + C, with X and Y two variables and C a constant.


Field Summary
protected  int cste
          The search constant of the constraint
 
Fields inherited from class choco.integer.constraints.AbstractBinIntConstraint
cIdx0, cIdx1, v0, v1
 
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
GreaterOrEqualXYC(IntDomainVar x0, IntDomainVar x1, int c)
          Constructs the constraint with the specified variables and constant.
 
Method Summary
 void awakeOnInf(int idx)
          Propagation when a minimal bound of a variable was modified.
 void awakeOnInst(int idx)
          Propagation when a variable is instantiated.
 void awakeOnRem(int idx, int x)
          Propagation when a value x of variable is removed.
 void awakeOnSup(int idx)
          Propagation when a maximal bound of a variable was modified.
 void awakeOnVar(int idx)
          Default propagation on variable revision: full constraint re-propagation.
 java.lang.Object clone()
          returns a copy of the constraint.
 int getVarIdxInOpposite(int i)
          computes the index of the i-th variable in the counter-opposite 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 printing of the object.
 void propagate()
          The propagation on constraint awake events.
 
Methods inherited from class choco.integer.constraints.AbstractBinIntConstraint
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, 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

GreaterOrEqualXYC

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

Parameters:
x0 - Should be greater than x0+c.
x1 - Should be less than x0-c.
c - The search constant used in the inequality.
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

propagate

public void propagate()
               throws ContradictionException
The propagation on constraint awake events.

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

awakeOnInf

public void awakeOnInf(int idx)
                throws ContradictionException
Propagation when a minimal bound of a variable was modified.

Specified by:
awakeOnInf in interface IntVarEventListener
Overrides:
awakeOnInf in class AbstractIntConstraint
Parameters:
idx - The index of the variable.
Throws:
ContradictionException

awakeOnSup

public void awakeOnSup(int idx)
                throws ContradictionException
Propagation when a maximal bound of a variable was modified.

Specified by:
awakeOnSup in interface IntVarEventListener
Overrides:
awakeOnSup in class AbstractIntConstraint
Parameters:
idx - The index of the variable.
Throws:
ContradictionException

awakeOnInst

public void awakeOnInst(int idx)
                 throws ContradictionException
Propagation when a variable is instantiated.

Specified by:
awakeOnInst in interface IntVarEventListener
Overrides:
awakeOnInst in class AbstractIntConstraint
Parameters:
idx - The index of the variable.
Throws:
ContradictionException

awakeOnRem

public void awakeOnRem(int idx,
                       int x)
                throws ContradictionException
Propagation when a value x of variable is removed.

Not implemented yet.

Specified by:
awakeOnRem in interface IntVarEventListener
Overrides:
awakeOnRem in class AbstractIntConstraint
Parameters:
idx - The index of the variable.
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

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.

Returns:
true if the constraint is satisfied

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 (weaker than 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)

getVarIdxInOpposite

public int getVarIdxInOpposite(int i)
Description copied from interface: Constraint
computes the index of the i-th variable in the counter-opposite of the constraint

Specified by:
getVarIdxInOpposite in interface Constraint
Overrides:
getVarIdxInOpposite in class AbstractConstraint
Parameters:
i - the index of the variable in the current constraint (this)
Returns:
the index of the variable in the opposite constraint (this.opposite())

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.

pretty

public java.lang.String pretty()
Description copied from interface: Entity
pretty printing of the object. This String is not constant and may depend on the context.

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