choco.bool
Class Cardinality

java.lang.Object
  extended by choco.AbstractEntity
      extended by choco.AbstractConstraint
          extended by choco.bool.AbstractCompositeConstraint
              extended by choco.bool.AbstractLargeCompositeConstraint
                  extended by choco.bool.AbstractLargeBoolConstraint
                      extended by choco.bool.AbstractLargeBoolConstraintWithCounterOpposite
                          extended by choco.bool.Cardinality
All Implemented Interfaces:
BoolConstraint, CompositeConstraint, Constraint, Entity, IntConstraint, IntVarEventListener, VarEventListener, Propagator, java.lang.Cloneable, java.util.EventListener

public class Cardinality
extends AbstractLargeBoolConstraintWithCounterOpposite

A class for cardinality/atleast/atmost constraints (constraints modelling by a domain variable the number of subconstraints that are true among a list


Field Summary
protected  boolean constrainOnInfNumber
           
protected  boolean constrainOnSupNumber
           
 
Fields inherited from class choco.bool.AbstractLargeBoolConstraint
nbFalseStatus, nbTrueStatus, statusBitVector
 
Fields inherited from class choco.bool.AbstractLargeCompositeConstraint
additionalIndices, additionalVars, constraints, nbConstraints, offsets
 
Fields inherited from class choco.AbstractConstraint
active, constAwakeEvent, hook, priority
 
Fields inherited from class choco.AbstractEntity
problem
 
Constructor Summary
Cardinality(Constraint[] alternatives, IntDomainVar cardVar, boolean constrainOnInf, boolean constrainOnSup)
           
 
Method Summary
 void awake()
          Default initial propagation: full constraint re-propagation.
 void awakeOnBounds(int varIdx)
           
 void awakeOnInf(int varIdx)
          Default propagation on improved lower bound: propagation on domain revision.
 void awakeOnInst(int varIdx)
          Default propagation on instantiation: full constraint re-propagation.
protected  void awakeOnNbFalse()
           
protected  void awakeOnNbTrue()
           
 void awakeOnRem(int varIdx, int val)
          Default propagation on one value removal: propagation on domain revision.
 void awakeOnRemovals(int varIdx, IntIterator deltaDomain)
           
 void awakeOnSup(int varIdx)
          Default propagation on improved upper bound: propagation on domain revision.
 void checkStatus(int constIdx)
           
 java.lang.Object clone()
          returns a copy of the constraint.
protected  IntDomainVarImpl getCardVar()
          a local short-cut accessor
protected  int getCardVarIndex()
          a local short-cut accessor
 boolean isConsistent()
          tests if the constraint is consistent with respect to the current state of domains
 java.lang.Boolean isEntailed()
          Checks whether the constraint is definitely satisfied, no matter what further restrictions occur to the domain of its variables.
 boolean isSatisfied()
          Semantic: Testing if the constraint is satisfied.
 void propagate()
          Propagation: Propagating the constraint until local consistency is reached.
 
Methods inherited from class choco.bool.AbstractLargeBoolConstraintWithCounterOpposite
assignIndices, getOppositeSubConstraint, initAbstractLargeBoolConstraintWithCounterOpposite, setSubConstraintStatus
 
Methods inherited from class choco.bool.AbstractLargeBoolConstraint
getStatus, getTargetStatus, initAbstractLargeBoolConstraint, setStatus, setTargetStatus
 
Methods inherited from class choco.bool.AbstractLargeCompositeConstraint
getConstraintIdx, getIntVar, getLocalVarIndex, getNbSubConstraints, getNbVars, getNbVarsFromSubConst, getSubConstraint, getSubConstraintIdx, getVar, getVarIdxInOpposite, isCompletelyInstantiated, setConstraintIndex, setVar
 
Methods inherited from class choco.bool.AbstractCompositeConstraint
addListener, getGlobalVarIndex
 
Methods inherited from class choco.AbstractConstraint
awakeOnVar, connectVar, constAwake, delete, fail, getEvent, getPlugIn, getPriority, getProblem, 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.bool.CompositeConstraint
getGlobalVarIndex, getNbSubConstraints, getSubConstraint, getSubConstraintIdx
 
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.integer.IntConstraint
getIntVar
 
Methods inherited from interface choco.Propagator
awakeOnVar, constAwake, delete, getEvent, getPlugIn, getPriority, isCompletelyInstantiated
 
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
 

Field Detail

constrainOnInfNumber

protected boolean constrainOnInfNumber

constrainOnSupNumber

protected boolean constrainOnSupNumber
Constructor Detail

Cardinality

public Cardinality(Constraint[] alternatives,
                   IntDomainVar cardVar,
                   boolean constrainOnInf,
                   boolean constrainOnSup)
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 AbstractLargeBoolConstraintWithCounterOpposite
Returns:
Throws:
java.lang.CloneNotSupportedException

getCardVar

protected IntDomainVarImpl getCardVar()
a local short-cut accessor

Returns:
the "meta"-variable denoting the number of constraints that will hold

getCardVarIndex

protected int getCardVarIndex()
a local short-cut accessor

Returns:
the index of the "meta"-variable denoting the number of constraints that will hold

awakeOnNbTrue

protected void awakeOnNbTrue()
                      throws ContradictionException
Throws:
ContradictionException

awakeOnNbFalse

protected void awakeOnNbFalse()
                       throws ContradictionException
Throws:
ContradictionException

checkStatus

public void checkStatus(int constIdx)
                 throws ContradictionException
Throws:
ContradictionException

awakeOnInf

public void awakeOnInf(int varIdx)
                throws ContradictionException
Description copied from interface: IntVarEventListener
Default propagation on improved lower bound: propagation on domain revision.

Throws:
ContradictionException

awakeOnSup

public void awakeOnSup(int varIdx)
                throws ContradictionException
Description copied from interface: IntVarEventListener
Default propagation on improved upper bound: propagation on domain revision.

Throws:
ContradictionException

awakeOnBounds

public void awakeOnBounds(int varIdx)
                   throws ContradictionException
Specified by:
awakeOnBounds in interface IntConstraint
Overrides:
awakeOnBounds in class AbstractCompositeConstraint
Throws:
ContradictionException

awakeOnInst

public void awakeOnInst(int varIdx)
                 throws ContradictionException
Description copied from interface: IntVarEventListener
Default propagation on instantiation: full constraint re-propagation.

Throws:
ContradictionException

awakeOnRem

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

Throws:
ContradictionException

awake

public void awake()
           throws ContradictionException
Description copied from class: AbstractConstraint
Default initial propagation: full constraint re-propagation.

Specified by:
awake in interface Propagator
Overrides:
awake in class AbstractConstraint
Throws:
ContradictionException

propagate

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

Throws:
ContradictionException

isSatisfied

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


isEntailed

public java.lang.Boolean isEntailed()
Description copied from interface: Propagator
Checks whether the constraint is definitely satisfied, no matter what further restrictions occur to the domain of its variables.

Specified by:
isEntailed in interface Propagator
Overrides:
isEntailed in class AbstractConstraint

isConsistent

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


awakeOnRemovals

public void awakeOnRemovals(int varIdx,
                            IntIterator deltaDomain)
                     throws ContradictionException
Specified by:
awakeOnRemovals in interface IntConstraint
Overrides:
awakeOnRemovals in class AbstractCompositeConstraint
Throws:
ContradictionException