choco.cp.solver.constraints.global
Class BoundGccVar

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
All Implemented Interfaces:
IExtensionnable, IPretty, SConstraint<IntDomainVar>, IntPropagator, Cloneable, EventListener
Direct Known Subclasses:
BoundGcc

public class BoundGccVar
extends AbstractLargeIntSConstraint

User: hcambaza Bound Global cardinality : Given an array of variables vars, an array of variables card to represent the cardinalities, the constraint ensures that the number of occurences of the value i among the variables is equal to card[i]. this constraint enforces : - Bound Consistency over vars regarding the lower and upper bounds of cards - maintain the upperbound of card by counting the number of variables in which each value can occur - maintain the lowerbound of card by counting the number of variables instantiated to a value - enforce card[0] + ... + card[m] = n (n = the number of variables, m = number of values)


Nested Class Summary
protected static class 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
BoundGccVar(IntDomainVar[] vars, IntDomainVar[] card, int firstCardValue, int lastCardValue, 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 (or a table IntDomainVar to represent the cardinalities), 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 i)
          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()
           
 void dynamicInitOfPartialSum()
           
 void filterBCOnInf(int i)
           
 void filterBCOnInst(int val)
          Enforce simple occurrences reasonnings on value val no need to reason on the number of possible (instead of sure) values as this will be done as part of the BC on vars
 void filterBCOnRem(int val)
           
 void filterBCOnSup(int i)
           
protected  void filterLowerMax()
          Shrink the lower bounds for the max occurences
 void filterLowerMin()
           
protected  void filterUpperMax()
          Shrink the upper bounds for the max occurences
 void filterUpperMin()
           
 int getMaxOcc(int i)
           
 int getMinOcc(int i)
           
protected  void init()
           
 void initBackDataStruct()
           
 Boolean isEntailed()
          Indicates if the constraint is entailed, from now on will be always satisfied
 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 !
static IntDomainVar[] makeVarTable(IntDomainVar[] vars, IntDomainVar[] card)
           
protected  int pathmax(int[] tab, int i)
           
protected  int pathmin(int[] tab, int i)
           
protected  void pathset(int[] tab, int start, int end, int to)
           
 String pretty()
          pretty printing of the object.
 void propagate()
          Propagation: Propagating the constraint until local consistency is reached.
 void propagateSumCard()
          Enforce sum of the cardinalities = nbVariable
protected  void sortIt()
           
 
Methods inherited from class choco.kernel.solver.constraints.integer.AbstractIntSConstraint
awakeOnBounds, awakeOnRemovals, getConstraintType, isConsistent, isSatisfied
 
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

BoundGccVar

public BoundGccVar(IntDomainVar[] vars,
                   IntDomainVar[] card,
                   int firstCardValue,
                   int lastCardValue,
                   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 (or a table IntDomainVar to represent the cardinalities), 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

makeVarTable

public static IntDomainVar[] makeVarTable(IntDomainVar[] vars,
                                          IntDomainVar[] card)

getMaxOcc

public int getMaxOcc(int i)

getMinOcc

public int getMinOcc(int i)

init

protected void init()

sortIt

protected final void sortIt()

pathset

protected final void pathset(int[] tab,
                             int start,
                             int end,
                             int to)

pathmin

protected final int pathmin(int[] tab,
                            int i)

pathmax

protected final int pathmax(int[] tab,
                            int i)

filterLowerMax

protected final void filterLowerMax()
                             throws ContradictionException
Shrink the lower bounds for the max occurences

Throws:
ContradictionException

filterUpperMax

protected final void filterUpperMax()
                             throws ContradictionException
Shrink the upper bounds for the max occurences

Throws:
ContradictionException

filterLowerMin

public final void filterLowerMin()
                          throws ContradictionException
Throws:
ContradictionException

filterUpperMin

public final void filterUpperMin()
                          throws ContradictionException
Throws:
ContradictionException

initBackDataStruct

public final void initBackDataStruct()
                              throws ContradictionException
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

directInconsistentCount

public boolean directInconsistentCount()

dynamicInitOfPartialSum

public final void dynamicInitOfPartialSum()

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

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 AbstractIntSConstraint
Throws:
ContradictionException

filterBCOnInf

public final void filterBCOnInf(int i)
                         throws ContradictionException
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 AbstractIntSConstraint
Throws:
ContradictionException

filterBCOnSup

public final void filterBCOnSup(int i)
                         throws ContradictionException
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 AbstractIntSConstraint
Throws:
ContradictionException

filterBCOnInst

public final void filterBCOnInst(int val)
                          throws ContradictionException
Enforce simple occurrences reasonnings on value val no need to reason on the number of possible (instead of sure) values as this will be done as part of the BC on vars

Parameters:
val -
Throws:
ContradictionException

filterBCOnRem

public final void filterBCOnRem(int val)
                         throws ContradictionException
Throws:
ContradictionException

awakeOnRem

public void awakeOnRem(int idx,
                       int i)
                throws ContradictionException
Only maintain the data structure and update upperbounds of card

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

propagateSumCard

public final void propagateSumCard()
                            throws ContradictionException
Enforce sum of the cardinalities = nbVariable

Throws:
ContradictionException

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 AbstractIntSConstraint

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 AbstractSConstraint<IntDomainVar>
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 AbstractSConstraint<IntDomainVar>
Returns:
wether the constraint is entailed


Copyright © 2012. All Rights Reserved.