choco.cp.solver.constraints.set
Class AbstractBoundOfASet

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.AbstractBoundOfASet
All Implemented Interfaces:
IExtensionnable, IPretty, SConstraint<Var>, IntPropagator, SetPropagator, Cloneable, EventListener
Direct Known Subclasses:
MaxOfASet, MinOfASet

public abstract class AbstractBoundOfASet
extends AbstractLargeSetIntSConstraint

An abstract class used for MaxOfASet and MinOfaSet constraints

Since:
8 déc. 2008 version 2.0.1
Version:
2.0.1
Author:
Arnaud Malapert

Nested Class Summary
static class AbstractBoundOfASet.EmptySetPolicy
           
 
Field Summary
static int BOUND_INDEX
          Index of the maximum variable.
static int SET_INDEX
          Index of the set variable
static int VARS_OFFSET
          First index of the variables among which the maximum should be chosen.
 
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
AbstractBoundOfASet(IEnvironment environment, IntDomainVar[] intvars, SetVar setvar, AbstractBoundOfASet.EmptySetPolicy emptySetPolicy)
           
 
Method Summary
 void awakeOnEnvRemovals(int idx, DisposableIntIterator deltaDomain)
          BEWARE: No need to dipose the iterator, this done in the calling methode
 void awakeOnInst(int idx)
          Propagation when a variable is instantiated.
protected abstract  void awakeOnKer()
           
 void awakeOnKer(int varIdx, int x)
          Default propagation on kernel modification: propagation on adding a value to the kernel.
 void awakeOnkerAdditions(int idx, DisposableIntIterator deltaDomain)
          BEWARE: No need to dipose the iterator, this done in the calling methode
protected abstract  void awakeOnRem()
           
 void awakeOnRem(int varIdx, int val)
          Default propagation on one value removal: propagation on domain revision.
protected abstract  void filter()
           
 int getFilteredEventMask(int idx)
           
protected abstract  int getSatisfiedValue(DisposableIntIterator iter)
           
protected  SetDomain getSetDomain()
           
 boolean isConsistent()
          tests if the constraint is consistent with respect to the current state of domains
protected  boolean isEmptySet()
           
protected  boolean isInEnveloppe(int idx)
           
protected  boolean isInKernel(int idx)
           
protected  boolean isNotEmptySet()
           
 boolean isSatisfied()
          Semantic: Testing if the constraint is satisfied.
protected  boolean isSetInstantiated()
           
protected  void onlyOneCandidatePropagation()
          If only one candidate to be the max of the list, some additionnal propagation can be performed (as in usual x == y constraint).
protected  String pretty(String name)
           
 void propagate()
          Propagation: Propagating the constraint until local consistency is reached.
protected  boolean remFromEnveloppe()
           
protected abstract  boolean removeFromEnv(int idx)
           
protected  boolean removeGreaterFromEnv(int idx, int maxValue)
           
protected  boolean removeLowerFromEnv(int idx, int minValue)
           
protected  boolean updateBoundInf(int val)
           
protected  boolean updateBoundSup(int val)
           
protected abstract  int updateIndexOfCandidateVariable()
           
 
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, awakeOnEnv, awakeOnInf, 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, awake, 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
 

Field Detail

SET_INDEX

public static final int SET_INDEX
Index of the set variable

See Also:
Constant Field Values

BOUND_INDEX

public static final int BOUND_INDEX
Index of the maximum variable.

See Also:
Constant Field Values

VARS_OFFSET

public static final int VARS_OFFSET
First index of the variables among which the maximum should be chosen.

See Also:
Constant Field Values
Constructor Detail

AbstractBoundOfASet

public AbstractBoundOfASet(IEnvironment environment,
                           IntDomainVar[] intvars,
                           SetVar setvar,
                           AbstractBoundOfASet.EmptySetPolicy emptySetPolicy)
Method Detail

getFilteredEventMask

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

isInKernel

protected final boolean isInKernel(int idx)

isInEnveloppe

protected final boolean isInEnveloppe(int idx)

getSetDomain

protected final SetDomain getSetDomain()

isEmptySet

protected final boolean isEmptySet()

isNotEmptySet

protected final boolean isNotEmptySet()

isSetInstantiated

protected final boolean isSetInstantiated()

updateBoundInf

protected final boolean updateBoundInf(int val)
                                throws ContradictionException
Throws:
ContradictionException

updateBoundSup

protected final boolean updateBoundSup(int val)
                                throws ContradictionException
Throws:
ContradictionException

removeFromEnv

protected abstract boolean removeFromEnv(int idx)
                                  throws ContradictionException
Throws:
ContradictionException

removeGreaterFromEnv

protected final boolean removeGreaterFromEnv(int idx,
                                             int maxValue)
                                      throws ContradictionException
Throws:
ContradictionException

removeLowerFromEnv

protected final boolean removeLowerFromEnv(int idx,
                                           int minValue)
                                    throws ContradictionException
Throws:
ContradictionException

remFromEnveloppe

protected final boolean remFromEnveloppe()
                                  throws ContradictionException
Throws:
ContradictionException

awakeOnEnvRemovals

public final void awakeOnEnvRemovals(int idx,
                                     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
Overrides:
awakeOnEnvRemovals in class AbstractMixedSetIntSConstraint
Throws:
ContradictionException

awakeOnRem

public final void awakeOnRem(int varIdx,
                             int val)
                      throws ContradictionException
Description copied from class: AbstractMixedSetIntSConstraint
Default propagation on one value removal: propagation on domain revision.

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

awakeOnRem

protected abstract void awakeOnRem()
                            throws ContradictionException
Throws:
ContradictionException

awakeOnkerAdditions

public final void awakeOnkerAdditions(int idx,
                                      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
Overrides:
awakeOnkerAdditions in class AbstractMixedSetIntSConstraint
Throws:
ContradictionException

awakeOnKer

public final void awakeOnKer(int varIdx,
                             int x)
                      throws ContradictionException
Description copied from interface: SetPropagator
Default propagation on kernel modification: propagation on adding a value to the kernel.

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

awakeOnKer

protected abstract void awakeOnKer()
                            throws ContradictionException
Throws:
ContradictionException

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

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

filter

protected abstract void filter()
                        throws ContradictionException
Throws:
ContradictionException

awakeOnInst

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

Specified by:
awakeOnInst in interface IntPropagator
Specified by:
awakeOnInst in interface SetPropagator
Overrides:
awakeOnInst in class AbstractMixedSetIntSConstraint
Parameters:
idx - the index of the modified variable.
Throws:
ContradictionException - if a domain becomes empty.

updateIndexOfCandidateVariable

protected abstract int updateIndexOfCandidateVariable()

onlyOneCandidatePropagation

protected void onlyOneCandidatePropagation()
                                    throws ContradictionException
If only one candidate to be the max of the list, some additionnal propagation can be performed (as in usual x == y constraint).

Throws:
ContradictionException

getSatisfiedValue

protected abstract int getSatisfiedValue(DisposableIntIterator iter)

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

pretty

protected String pretty(String name)


Copyright © 2012. All Rights Reserved.