choco.cp.solver.constraints.global
Class BoundGcc

java.lang.Object
  extended by choco.kernel.solver.propagation.Propagator
      extended by choco.kernel.solver.constraints.AbstractSConstraint<IntDomainVar>
          extended by choco.kernel.solver.constraints.integer.AbstractIntSConstraint
              extended by choco.kernel.solver.constraints.integer.AbstractLargeIntSConstraint
                  extended by choco.cp.solver.constraints.global.BoundGccVar
                      extended by choco.cp.solver.constraints.global.BoundGcc
All Implemented Interfaces:
IExtensionnable, IPretty, SConstraint<IntDomainVar>, IntPropagator, Cloneable, EventListener

public final class BoundGcc
extends BoundGccVar

A constraint to enforce BoundConsistency on a global cardinality based on the implementation of : C.-G. Quimper, P. van Beek, A. Lopez-Ortiz, A. Golynski, and S.B. Sadjad. An efficient bounds consistency algorithm for the global cardinality constraint. CP-2003.


Nested Class Summary
 
Nested classes/interfaces inherited from class choco.cp.solver.constraints.global.BoundGccVar
BoundGccVar.Interval
 
Field Summary
 
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
BoundGcc(IntDomainVar[] vars, int firstDomainValue, int lastDomainValue, int[] minOccurrences, int[] maxOccurrences, IEnvironment environment)
          Bound Global cardinality : Given an array of variables vars, min the minimal value over all variables, and max the maximal value over all variables, the constraint ensures that the number of occurences of the value i among the variables is between low[i - min] and up[i - min].
 
Method Summary
 void awake()
          Propagation: Propagating the constraint for the very first time until local consistency is reached.
 void awakeOnInf(int i)
          Default propagation on improved lower bound: propagation on domain revision.
 void awakeOnInst(int i)
          Default propagation on instantiation: full constraint re-propagation.
 void awakeOnRem(int idx, int val)
          Only maintain the data structure and update upperbounds of card
 void awakeOnSup(int i)
          Default propagation on improved upper bound: propagation on domain revision.
 boolean directInconsistentCount()
           
 int getMaxOcc(int i)
           
 int getMinOcc(int i)
           
protected  void init()
           
 Boolean isEntailed()
          Indicates if the constraint is entailed, from now on will be always satisfied
 boolean isSatisfied()
          Default implementation of the isSatisfied by delegating to the isSatisfied(int[] tuple)
 boolean isSatisfied(int[] tuple)
          TEMPORARY: if not overriden by the constraint, throws an error to avoid bug using reified constraints in constraints that have not been changed to fulfill this api yet !
 String pretty()
          pretty printing of the object.
 void propagate()
          Propagation: Propagating the constraint until local consistency is reached.
 
Methods inherited from class choco.cp.solver.constraints.global.BoundGccVar
dynamicInitOfPartialSum, filterBCOnInf, filterBCOnInst, filterBCOnRem, filterBCOnSup, filterLowerMax, filterLowerMin, filterUpperMax, filterUpperMin, initBackDataStruct, makeVarTable, pathmax, pathmin, pathset, propagateSumCard, sortIt
 
Methods inherited from class choco.kernel.solver.constraints.integer.AbstractIntSConstraint
awakeOnBounds, awakeOnRemovals, getConstraintType, isConsistent
 
Methods inherited from class choco.kernel.solver.constraints.AbstractSConstraint
addExtension, addListener, clone, getAbstractSConstraintExtensionNumber, getConstraintIdx, getExtension, getFineDegree, getNbVarNotInst, getNbVars, getVar, getVarQuick, isCompletelyInstantiated, opposite, setConstraintIndex, setExtension, setVar, toString
 
Methods inherited from class choco.kernel.solver.propagation.Propagator
activate, constAwake, fail, getEvent, getFilteredEventMask, 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

BoundGcc

public BoundGcc(IntDomainVar[] vars,
                int firstDomainValue,
                int lastDomainValue,
                int[] minOccurrences,
                int[] maxOccurrences,
                IEnvironment environment)
Bound Global cardinality : Given an array of variables vars, min the minimal value over all variables, and max the maximal value over all variables, the constraint ensures that the number of occurences of the value i among the variables is between low[i - min] and up[i - min]. Note that the length of low and up should be max - min + 1. Use the propagator of : C.-G. Quimper, P. van Beek, A. Lopez-Ortiz, A. Golynski, and S.B. Sadjad. An efficient bounds consistency algorithm for the global cardinality constraint. CP-2003.

Method Detail

getMaxOcc

public int getMaxOcc(int i)
Overrides:
getMaxOcc in class BoundGccVar

getMinOcc

public int getMinOcc(int i)
Overrides:
getMinOcc in class BoundGccVar

init

protected void init()
Overrides:
init in class BoundGccVar

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 BoundGccVar
Throws:
ContradictionException - contradiction exception

directInconsistentCount

public boolean directInconsistentCount()
Overrides:
directInconsistentCount in class BoundGccVar

propagate

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

Overrides:
propagate in class BoundGccVar
Throws:
ContradictionException - contradiction exception

awakeOnInf

public void awakeOnInf(int i)
                throws ContradictionException
Description copied from class: AbstractIntSConstraint
Default propagation on improved lower bound: propagation on domain revision.

Specified by:
awakeOnInf in interface IntPropagator
Overrides:
awakeOnInf in class BoundGccVar
Throws:
ContradictionException

awakeOnSup

public void awakeOnSup(int i)
                throws ContradictionException
Description copied from class: AbstractIntSConstraint
Default propagation on improved upper bound: propagation on domain revision.

Specified by:
awakeOnSup in interface IntPropagator
Overrides:
awakeOnSup in class BoundGccVar
Throws:
ContradictionException

awakeOnInst

public void awakeOnInst(int i)
                 throws ContradictionException
Description copied from class: AbstractIntSConstraint
Default propagation on instantiation: full constraint re-propagation.

Specified by:
awakeOnInst in interface IntPropagator
Overrides:
awakeOnInst in class BoundGccVar
Throws:
ContradictionException

awakeOnRem

public void awakeOnRem(int idx,
                       int val)
                throws ContradictionException
Description copied from class: BoundGccVar
Only maintain the data structure and update upperbounds of card

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

isSatisfied

public boolean isSatisfied()
Description copied from class: AbstractIntSConstraint
Default implementation of the isSatisfied by delegating to the isSatisfied(int[] tuple)

Specified by:
isSatisfied in interface SConstraint<IntDomainVar>
Overrides:
isSatisfied in class AbstractIntSConstraint
Returns:
true if the constraint is satisfied

isSatisfied

public boolean isSatisfied(int[] tuple)
Description copied from class: AbstractIntSConstraint
TEMPORARY: if not overriden by the constraint, throws an error to avoid bug using reified constraints in constraints that have not been changed to fulfill this api yet !

Specified by:
isSatisfied in interface IntPropagator
Overrides:
isSatisfied in class BoundGccVar

pretty

public 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 BoundGccVar
Returns:
a readable string representation of the object

isEntailed

public Boolean isEntailed()
Description copied from class: AbstractSConstraint
Indicates if the constraint is entailed, from now on will be always satisfied

Overrides:
isEntailed in class BoundGccVar
Returns:
wether the constraint is entailed


Copyright © 2012. All Rights Reserved.