choco.cp.solver.constraints.set
Class InverseSetInt

java.lang.Object
  extended by choco.kernel.solver.propagation.Propagator
      extended by choco.kernel.solver.constraints.AbstractSConstraint<Var>
          extended by choco.kernel.solver.constraints.set.AbstractMixedSetIntSConstraint
              extended by choco.kernel.solver.constraints.set.AbstractLargeSetIntSConstraint
                  extended by choco.cp.solver.constraints.set.InverseSetInt
All Implemented Interfaces:
IExtensionnable, IPretty, SConstraint<Var>, IntPropagator, SetPropagator, Cloneable, EventListener

public final class InverseSetInt
extends AbstractLargeSetIntSConstraint

A constraint stating that value j belongs to the s[i] set variable iff integer variable x[j] equals to i. This constraint models the inverse s: I -> P(J) of a function x: J -> I (I and J sets of integers) adapted from InverseChanneling

Author:
Sophie Demassey

Field Summary
 
Fields inherited from class choco.kernel.solver.constraints.set.AbstractLargeSetIntSConstraint
ivars, svars
 
Fields inherited from class choco.kernel.solver.constraints.AbstractSConstraint
cIndices, constraintType, extensions, vars
 
Fields inherited from class choco.kernel.solver.propagation.Propagator
active, constAwakeEvent, priority, propagationEngine
 
Fields inherited from interface choco.kernel.solver.constraints.SConstraint
LOGGER
 
Constructor Summary
InverseSetInt(IntDomainVar[] x, SetVar[] s)
           
 
Method Summary
 void awake()
          Propagation: Propagating the constraint for the very first time until local consistency is reached.
 void awakeOnEnv(int i, int j)
          Filtering Rule 2 : j \not\in s[i] => x[j]!
 void awakeOnInst(int x)
          Filtering Rule 3 : x[j]=i => j \in s[i] and j \not\in s[i'] \forall i'!
 void awakeOnKer(int i, int j)
          Filtering Rule 1 : j \in s[i] => x[j]=i (then propagate Rule 3)
 void awakeOnRem(int x, int v)
          Filtering Rule 4 : x[j]!
 void awakeOnVar(int x)
          propagation on a var: Rules 1 & 2 (integer) or 3 & 4 (set)
 void filterFromIndices()
          Filtering Rule 0 : i>s.length => x[j]!
 int getFilteredEventMask(int idx)
           
 boolean isConsistent()
          tests if the constraint is consistent with respect to the current state of domains
 boolean isSatisfied()
          Semantic: Testing if the constraint is satisfied.
 boolean isSatisfied(int j)
           
 void propagate()
          Propagation: Propagating the constraint until local consistency is reached.
 
Methods inherited from class choco.kernel.solver.constraints.set.AbstractLargeSetIntSConstraint
getIntVarIndex, getNbIntVars, getNbSetVars, isIntVarIndex, isSetVarIndex
 
Methods inherited from class choco.kernel.solver.constraints.set.AbstractMixedSetIntSConstraint
awakeOnBounds, awakeOnEnvRemovals, awakeOnInf, awakeOnkerAdditions, awakeOnRemovals, awakeOnSup, getConstraintType, isSatisfied
 
Methods inherited from class choco.kernel.solver.constraints.AbstractSConstraint
addExtension, addListener, clone, getAbstractSConstraintExtensionNumber, getConstraintIdx, getExtension, getFineDegree, getNbVarNotInst, getNbVars, getVar, getVarQuick, isCompletelyInstantiated, isEntailed, opposite, pretty, setConstraintIndex, setExtension, setVar, toString
 
Methods inherited from class choco.kernel.solver.propagation.Propagator
activate, constAwake, fail, getEvent, getPriority, isActive, setActive, setActiveSilently, setEntailed, setPassive, setPropagationEngine
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InverseSetInt

public InverseSetInt(IntDomainVar[] x,
                     SetVar[] s)
Method Detail

getFilteredEventMask

public int getFilteredEventMask(int idx)
Overrides:
getFilteredEventMask in class Propagator

filterFromIndices

public void filterFromIndices()
                       throws ContradictionException
Filtering Rule 0 : i>s.length => x[j]!=i \forall j j>x.length => j \not\in s[i] \forall i

Throws:
ContradictionException

awake

public void awake()
           throws ContradictionException
Description copied from class: Propagator
Propagation: Propagating the constraint for the very first time until local consistency is reached.

Overrides:
awake in class Propagator
Throws:
ContradictionException - contradiction exception

awakeOnKer

public void awakeOnKer(int i,
                       int j)
                throws ContradictionException
Filtering Rule 1 : j \in s[i] => x[j]=i (then propagate Rule 3)

Specified by:
awakeOnKer in interface SetPropagator
Overrides:
awakeOnKer in class AbstractMixedSetIntSConstraint
Throws:
ContradictionException

awakeOnEnv

public void awakeOnEnv(int i,
                       int j)
                throws ContradictionException
Filtering Rule 2 : j \not\in s[i] => x[j]!=i

Specified by:
awakeOnEnv in interface SetPropagator
Overrides:
awakeOnEnv in class AbstractMixedSetIntSConstraint
Throws:
ContradictionException

awakeOnInst

public void awakeOnInst(int x)
                 throws ContradictionException
Filtering Rule 3 : x[j]=i => j \in s[i] and j \not\in s[i'] \forall i'!=i Rules 1 & 2 : s[i]=V => x[j]=i \iff j \in V

Specified by:
awakeOnInst in interface IntPropagator
Specified by:
awakeOnInst in interface SetPropagator
Overrides:
awakeOnInst in class AbstractMixedSetIntSConstraint
Throws:
ContradictionException

awakeOnRem

public void awakeOnRem(int x,
                       int v)
                throws ContradictionException
Filtering Rule 4 : x[j]!=i => j \not\in s[i]

Specified by:
awakeOnRem in interface IntPropagator
Overrides:
awakeOnRem in class AbstractMixedSetIntSConstraint
Throws:
ContradictionException

awakeOnVar

public void awakeOnVar(int x)
                throws ContradictionException
propagation on a var: Rules 1 & 2 (integer) or 3 & 4 (set)

Throws:
ContradictionException

propagate

public void propagate()
               throws ContradictionException
Description copied from class: Propagator
Propagation: Propagating the constraint until local consistency is reached.

Specified by:
propagate in class Propagator
Throws:
ContradictionException - contradiction exception

isSatisfied

public boolean isSatisfied(int j)
Returns:
true if the set vars are all consistent with the j-th integer (instantiated)

isSatisfied

public boolean isSatisfied()
Description copied from interface: SConstraint
Semantic: Testing if the constraint is satisfied. Note that all variables involved in the constraint must be instantiated when this method is called.

Returns:
true if the constraint is satisfied

isConsistent

public boolean isConsistent()
Description copied from class: AbstractMixedSetIntSConstraint
tests if the constraint is consistent with respect to the current state of domains

Overrides:
isConsistent in class AbstractMixedSetIntSConstraint
Returns:
wether the constraint is consistent


Copyright © 2012. All Rights Reserved.