choco.cp.solver.constraints.reified
Class ReifiedAllSConstraint

java.lang.Object
  extended by choco.kernel.solver.propagation.Propagator
      extended by choco.kernel.solver.constraints.AbstractSConstraint
          extended by choco.cp.solver.constraints.reified.ReifiedAllSConstraint
All Implemented Interfaces:
IExtensionnable, IPretty, SConstraint, IntPropagator, RealPropagator, SetPropagator, Cloneable, EventListener

public class ReifiedAllSConstraint
extends AbstractSConstraint
implements IntPropagator, SetPropagator, RealPropagator

A constraint that allows to reify another constraint into a boolean value. b = 1 <=> cons is satisfied b = 0 <=> oppositeCons is satisfied

cons and oppositeCons do not need to be really the constraint and its opposite, it can be two different constraints as well


Field Summary
protected  AbstractSConstraint cons
           
protected  AbstractSConstraint oppositeCons
           
 
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
 
Method Summary
 void addExtension(int extensionNumber)
          Adds a new extension.
 void addListener(AbstractSConstraint thecons)
           
 void addListener(boolean dynamicAddition)
          This function connects a constraint with its variables in several ways.
 void awakeOnBounds(int varIdx)
           
 void awakeOnEnv(int varIdx, int x)
          Default propagation on enveloppe modification: propagation on removing a value from the enveloppe.
 void awakeOnEnvRemovals(int sIdx, DisposableIntIterator deltaDomain)
          BEWARE: No need to dipose the iterator, this done in the calling methode
 void awakeOnInf(int varIdx)
          Default propagation on improved lower bound: propagation on domain revision.
 void awakeOnInst(int varIdx)
          Default propagation on instantiation.
 void awakeOnKer(int varIdx, int x)
          Default propagation on kernel modification: propagation on adding a value to the kernel.
 void awakeOnkerAdditions(int sIdx, DisposableIntIterator deltaDomain)
          BEWARE: No need to dipose the iterator, this done in the calling methode
 void awakeOnRem(int varIdx, int val)
          Default propagation on one value removal: propagation on domain revision.
 void awakeOnRemovals(int varIdx, DisposableIntIterator deltaDomain)
           
 void awakeOnSup(int varIdx)
          Default propagation on improved upper bound: propagation on domain revision.
 void filter()
           
 void filterReifiedConstraintFromBool()
           
 void filterReifiedConstraintFromCons()
           
 SConstraintType getConstraintType()
          Return the type of constraint, ie the type of variable involved in the constraint
 int getIndex(AbstractVar v)
           
 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[] tuple)
           
static
<C extends AbstractSConstraint>
Var[]
makeTableVar(IntDomainVar bool, C cons, C oppcons)
           
 String pretty()
          pretty printing of the object.
 void propagate()
          Propagation: Propagating the constraint until local consistency is reached.
 void setPropagationEngine(PropagationEngine propEng)
          Define the propagation engine within the constraint.
 
Methods inherited from class choco.kernel.solver.constraints.AbstractSConstraint
clone, getAbstractSConstraintExtensionNumber, getConstraintIdx, getExtension, getFineDegree, getNbVarNotInst, getNbVars, getVar, getVarQuick, isCompletelyInstantiated, isEntailed, opposite, setConstraintIndex, setExtension, setVar, toString
 
Methods inherited from class choco.kernel.solver.propagation.Propagator
activate, awake, constAwake, fail, getEvent, getFilteredEventMask, getPriority, isActive, setActive, setActiveSilently, setEntailed, setPassive
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

cons

protected final AbstractSConstraint cons

oppositeCons

protected final AbstractSConstraint oppositeCons
Method Detail

makeTableVar

public static <C extends AbstractSConstraint> Var[] makeTableVar(IntDomainVar bool,
                                                                 C cons,
                                                                 C oppcons)

addExtension

public final void addExtension(int extensionNumber)
Adds a new extension.

Specified by:
addExtension in interface IExtensionnable
Overrides:
addExtension in class AbstractSConstraint
Parameters:
extensionNumber - should use the number returned by getAbstractSConstraintExtensionNumber

filterReifiedConstraintFromBool

public final void filterReifiedConstraintFromBool()
                                           throws ContradictionException
Throws:
ContradictionException

filterReifiedConstraintFromCons

public void filterReifiedConstraintFromCons()
                                     throws ContradictionException
Throws:
ContradictionException

filter

public final void filter()
                  throws ContradictionException
Throws:
ContradictionException

propagate

public final 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

awakeOnInf

public void awakeOnInf(int varIdx)
                throws ContradictionException
Default propagation on improved lower bound: propagation on domain revision.

Specified by:
awakeOnInf in interface IntPropagator
Specified by:
awakeOnInf in interface RealPropagator
Throws:
ContradictionException

awakeOnSup

public void awakeOnSup(int varIdx)
                throws ContradictionException
Default propagation on improved upper bound: propagation on domain revision.

Specified by:
awakeOnSup in interface IntPropagator
Specified by:
awakeOnSup in interface RealPropagator
Throws:
ContradictionException

awakeOnRem

public void awakeOnRem(int varIdx,
                       int val)
                throws ContradictionException
Default propagation on one value removal: propagation on domain revision.

Specified by:
awakeOnRem in interface IntPropagator
Throws:
ContradictionException

awakeOnRemovals

public void awakeOnRemovals(int varIdx,
                            DisposableIntIterator deltaDomain)
                     throws ContradictionException
Specified by:
awakeOnRemovals in interface IntPropagator
Throws:
ContradictionException

awakeOnBounds

public void awakeOnBounds(int varIdx)
                   throws ContradictionException
Specified by:
awakeOnBounds in interface IntPropagator
Throws:
ContradictionException

awakeOnKer

public void awakeOnKer(int varIdx,
                       int x)
                throws ContradictionException
Default propagation on kernel modification: propagation on adding a value to the kernel.

Specified by:
awakeOnKer in interface SetPropagator
Throws:
ContradictionException

awakeOnEnv

public void awakeOnEnv(int varIdx,
                       int x)
                throws ContradictionException
Default propagation on enveloppe modification: propagation on removing a value from the enveloppe.

Specified by:
awakeOnEnv in interface SetPropagator
Throws:
ContradictionException

awakeOnInst

public void awakeOnInst(int varIdx)
                 throws ContradictionException
Default propagation on instantiation.

Specified by:
awakeOnInst in interface IntPropagator
Specified by:
awakeOnInst in interface SetPropagator
Throws:
ContradictionException

awakeOnkerAdditions

public void awakeOnkerAdditions(int sIdx,
                                DisposableIntIterator deltaDomain)
                         throws ContradictionException
Description copied from interface: SetPropagator
BEWARE: No need to dipose the iterator, this done in the calling methode

Specified by:
awakeOnkerAdditions in interface SetPropagator
Throws:
ContradictionException

awakeOnEnvRemovals

public void awakeOnEnvRemovals(int sIdx,
                               DisposableIntIterator deltaDomain)
                        throws ContradictionException
Description copied from interface: SetPropagator
BEWARE: No need to dipose the iterator, this done in the calling methode

Specified by:
awakeOnEnvRemovals in interface SetPropagator
Throws:
ContradictionException

isConsistent

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

Specified by:
isConsistent in class Propagator
Returns:
wether the constraint is consistent

addListener

public final void addListener(AbstractSConstraint thecons)

getIndex

public final int getIndex(AbstractVar v)

addListener

public final void addListener(boolean dynamicAddition)
Description copied from class: AbstractSConstraint
This function connects a constraint with its variables in several ways. Note that it may only be called once the constraint has been fully created and is being posted to a model. Note that it should be called only once per constraint. This can be a dynamic addition (undone upon backtracking) or not

Overrides:
addListener in class AbstractSConstraint
Parameters:
dynamicAddition - if the addition should be dynamical

setPropagationEngine

public final void setPropagationEngine(PropagationEngine propEng)
Define the propagation engine within the constraint. Mandatory to throw ContradictionException.

Overrides:
setPropagationEngine in class Propagator
Parameters:
propEng - the current propagation engine

pretty

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

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

isSatisfied

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

Specified by:
isSatisfied in interface SConstraint
Returns:
true if the constraint is satisfied

getConstraintType

public SConstraintType getConstraintType()
Description copied from interface: SConstraint
Return the type of constraint, ie the type of variable involved in the constraint

Specified by:
getConstraintType in interface SConstraint
Returns:

isSatisfied

public boolean isSatisfied(int[] tuple)
Specified by:
isSatisfied in interface IntPropagator


Copyright © 2012. All Rights Reserved.