choco.palm.integer.constraints
Class PalmElt

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.palm.integer.AbstractPalmBinIntConstraint
                      extended by choco.palm.integer.constraints.PalmElt
All Implemented Interfaces:
Constraint, Entity, IntConstraint, IntVarEventListener, PalmIntVarListener, PalmConstraint, PalmVarListener, VarEventListener, Propagator, java.lang.Cloneable, java.util.EventListener

public class PalmElt
extends AbstractPalmBinIntConstraint

Created by IntelliJ IDEA. User: Hadrien Date: 18 janv. 2004 Time: 19:22:28 To change this template use Options | File Templates.


Field Summary
protected  int cste
          Uses the cste slot: l[i + cste] = x.
protected  int[] lvals
          Values the variable should be equal to.
 
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
PalmElt(IntDomainVar v0, IntDomainVar v1, int cste, int[] lvals)
          Element constraint accessing the ith element in a list of values, where i is a variable.
 
Method Summary
 void awakeOnInf(int idx)
          Propagation when a lower bound is increased.
 void awakeOnRem(int idx, int val)
          Propagation when a value is removed from a domain.
 void awakeOnRestore(int idx)
          Propagation when a value is restored to a domain (for repairing a contradiction for instance).
 void awakeOnRestoreInf(int idx)
          Propagation when values are restored to a domain (for repairing a contradiction for instance).
 void awakeOnRestoreSup(int idx)
          Propagation when values are restored to a domain (for repairing a contradiction for instance).
 void awakeOnRestoreVal(int idx, int val)
          Propagation when a value is restored to a domain (for repairing a contradiction for instance).
 void awakeOnSup(int idx)
          Propagation when an upper bound is decreased.
 java.lang.Boolean isEntailed()
          Checks if the constraint is entailed (it can be proven that the constraint will be satisfied).
 boolean isSatisfied()
          When variables are instantiated, checks that the constraint is satisfied.
 void propagate()
          Generic propagation algorithm.
 java.util.Set whyIsFalse()
          Determines why the constraints is not satified.
 java.util.Set whyIsTrue()
          Determines why the constraints is satified.
 
Methods inherited from class choco.palm.integer.AbstractPalmBinIntConstraint
awakeOnInst, awakeOnRestoreVal, getIntVar, takeIntoAccountStatusChange, updateDataStructuresOnConstraint, updateDataStructuresOnRestoreConstraint
 
Methods inherited from class choco.integer.constraints.AbstractBinIntConstraint
assignIndices, getConstraintIdx, getNbVars, getVar, isCompletelyInstantiated, setConstraintIndex, setVar
 
Methods inherited from class choco.integer.constraints.AbstractIntConstraint
awakeOnBounds, awakeOnRemovals, getSelfIndex, isConsistent
 
Methods inherited from class choco.AbstractConstraint
addListener, awake, awakeOnVar, clone, connectVar, constAwake, delete, fail, getEvent, getPlugIn, getPriority, getProblem, getVarIdxInOpposite, isActive, 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.palm.PalmVarListener
getConstraintIdx, setConstraintIndex
 
Methods inherited from interface choco.prop.VarEventListener
addListener, isActive, setActive, setPassive
 
Methods inherited from interface choco.integer.var.IntVarEventListener
getConstraintIdx, setConstraintIndex
 
Methods inherited from interface choco.prop.VarEventListener
addListener, isActive, setActive, setPassive
 
Methods inherited from interface choco.Propagator
assignIndices, awake, awakeOnVar, constAwake, delete, getEvent, getPlugIn, getPriority, isCompletelyInstantiated, isConsistent
 
Methods inherited from interface choco.prop.VarEventListener
addListener, isActive, setActive, setPassive
 
Methods inherited from interface choco.Constraint
clone, getConstraintIdx, getNbVars, getVar, getVarIdxInOpposite, isEquivalentTo, opposite, setConstraintIndex, setVar
 
Methods inherited from interface choco.Entity
getProblem, pretty
 
Methods inherited from interface choco.palm.PalmVarListener
getConstraintIdx, setConstraintIndex
 
Methods inherited from interface choco.prop.VarEventListener
addListener, isActive, setActive, setPassive
 

Field Detail

cste

protected final int cste
Uses the cste slot: l[i + cste] = x. (ex: cste = 1 allows to use and index from 0 to length(l) - 1.


lvals

protected int[] lvals
Values the variable should be equal to.

Constructor Detail

PalmElt

public PalmElt(IntDomainVar v0,
               IntDomainVar v1,
               int cste,
               int[] lvals)
Element constraint accessing the ith element in a list of values, where i is a variable. The slot v0 represents the index and the slot v1 represents the value. Propagation with complete arc consistency from values to indices (v1 to v0). Propagation with interval approximation from indices to values (v0 to v1).

Parameters:
v0 - The index variable.
v1 - The value variable.
cste - The offset for the index in the values array.
lvals - Values among which the variable should be affected to.
Method Detail

propagate

public void propagate()
               throws ContradictionException
Generic propagation algorithm. It propagates from index variable to value variable and then from value to index.

Specified by:
propagate in interface Propagator
Overrides:
propagate in class AbstractBinIntConstraint
Throws:
ContradictionException - if a contradiction occurs or a domain becomes empty.

awakeOnInf

public void awakeOnInf(int idx)
                throws ContradictionException
Propagation when a lower bound is increased. The other variable is updated accordingly.

Specified by:
awakeOnInf in interface IntVarEventListener
Overrides:
awakeOnInf in class AbstractIntConstraint
Parameters:
idx - the index of the modified variable
Throws:
ContradictionException - if a contradiction occurs or a domain becomes empty.

awakeOnSup

public void awakeOnSup(int idx)
                throws ContradictionException
Propagation when an upper bound is decreased. The other variable is updated accordingly.

Specified by:
awakeOnSup in interface IntVarEventListener
Overrides:
awakeOnSup in class AbstractIntConstraint
Parameters:
idx - the index of the modified variable
Throws:
ContradictionException - if a contradiction occurs or a domain becomes empty.

awakeOnRem

public void awakeOnRem(int idx,
                       int val)
                throws ContradictionException
Propagation when a value is removed from a domain.

Specified by:
awakeOnRem in interface IntVarEventListener
Overrides:
awakeOnRem in class AbstractIntConstraint
Parameters:
idx - the index of the modified variable
val - the removed value
Throws:
ContradictionException - if a contradiction occurs or a domain becomes empty.

awakeOnRestore

public void awakeOnRestore(int idx)
                    throws ContradictionException
Propagation when a value is restored to a domain (for repairing a contradiction for instance).

Parameters:
idx - the index of the modified variable
Throws:
ContradictionException - if a contradiction occurs or a domain becomes empty.

awakeOnRestoreInf

public void awakeOnRestoreInf(int idx)
                       throws ContradictionException
Propagation when values are restored to a domain (for repairing a contradiction for instance).

Specified by:
awakeOnRestoreInf in interface PalmIntVarListener
Overrides:
awakeOnRestoreInf in class AbstractPalmBinIntConstraint
Parameters:
idx - the index of the modified variable
Throws:
ContradictionException - if a contradiction occurs or a domain becomes empty.

awakeOnRestoreSup

public void awakeOnRestoreSup(int idx)
                       throws ContradictionException
Propagation when values are restored to a domain (for repairing a contradiction for instance).

Specified by:
awakeOnRestoreSup in interface PalmIntVarListener
Overrides:
awakeOnRestoreSup in class AbstractPalmBinIntConstraint
Parameters:
idx - the index of the modified variable
Throws:
ContradictionException - if a contradiction occurs or a domain becomes empty.

awakeOnRestoreVal

public void awakeOnRestoreVal(int idx,
                              int val)
                       throws ContradictionException
Propagation when a value is restored to a domain (for repairing a contradiction for instance).

Parameters:
idx - the index of the modified variable
val - the restored value
Throws:
ContradictionException - if a contradiction occurs or a domain becomes empty.

isEntailed

public java.lang.Boolean isEntailed()
Checks if the constraint is entailed (it can be proven that the constraint will be satisfied).

Specified by:
isEntailed in interface Propagator
Overrides:
isEntailed in class AbstractConstraint
Returns:
Boolean.TRUE if the constraint will be satisfied, Boolean.FALSE if it will not, null if we do not know yet.

isSatisfied

public boolean isSatisfied()
When variables are instantiated, checks that the constraint is satisfied.

Returns:
true if the constraint is satified by the current instantiation.

whyIsTrue

public java.util.Set whyIsTrue()
Determines why the constraints is satified.

Returns:
an explanation justifying that the constraint is satified.

whyIsFalse

public java.util.Set whyIsFalse()
Determines why the constraints is not satified.

Returns:
an explanation justifying that the constraint is not satified.