choco.cp.solver.constraints.global
Class Occurrence

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.Occurrence
All Implemented Interfaces:
IExtensionnable, IPretty, SConstraint<IntDomainVar>, IntPropagator, Cloneable, EventListener

public final class Occurrence
extends AbstractLargeIntSConstraint


Field Summary
 boolean constrainOnInfNumber
           
 boolean constrainOnSupNumber
           
 int nbListVars
           
 IStateInt nbPossible
          Store the number of variables which can still take the occurence value
 IStateInt nbSure
          Store the number of variables which are instantiated to the occurence value
 IntDomainVar[] relevantVar
           
 
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
Occurrence(IntDomainVar[] vars, int occval, boolean onInf, boolean onSup, IEnvironment environment)
          Constructor, API: should be used through the Model.createOccurrence API Define an occurence constraint setting size{forall v in lvars | v = occval} <= or >= or = occVar assumes the occVar variable to be the last of the variables of the constraint: vars = [lvars | occVar] with lvars = list of variables for which the occurence of occval in their domain is constrained
 
Method Summary
 void awake()
          Propagation: Propagating the constraint for the very first time until local consistency is reached.
 void awakeOnInf(int idx)
          Default propagation on improved lower bound: propagation on domain revision.
 void awakeOnInst(int idx)
          Default propagation on instantiation: full constraint re-propagation.
 void awakeOnRemovals(int idx, DisposableIntIterator deltaDomain)
          The default implementation of propagation when a variable has been modified consists in iterating all values that have been removed (the delta domain) and propagate them one after another, incrementally.
 void awakeOnSup(int idx)
          Default propagation on improved upper bound: propagation on domain revision.
 void checkNbPossible()
           
 void checkNbSure()
           
 void filter()
           
 int getFilteredEventMask(int idx)
           
 void init(int occval, boolean onInf, boolean onSup, IEnvironment environment)
           
 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 !
 String pretty()
          pretty printing of the object.
 void propagate()
          Propagation: Propagating the constraint until local consistency is reached.
 
Methods inherited from class choco.kernel.solver.constraints.integer.AbstractIntSConstraint
awakeOnBounds, awakeOnRem, 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, 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

nbPossible

public IStateInt nbPossible
Store the number of variables which can still take the occurence value


nbSure

public IStateInt nbSure
Store the number of variables which are instantiated to the occurence value


constrainOnInfNumber

public boolean constrainOnInfNumber

constrainOnSupNumber

public boolean constrainOnSupNumber

relevantVar

public IntDomainVar[] relevantVar

nbListVars

public int nbListVars
Constructor Detail

Occurrence

public Occurrence(IntDomainVar[] vars,
                  int occval,
                  boolean onInf,
                  boolean onSup,
                  IEnvironment environment)
Constructor, API: should be used through the Model.createOccurrence API Define an occurence constraint setting size{forall v in lvars | v = occval} <= or >= or = occVar assumes the occVar variable to be the last of the variables of the constraint: vars = [lvars | occVar] with lvars = list of variables for which the occurence of occval in their domain is constrained

Parameters:
vars - variables
occval - checking value
onInf - if true, constraint insures size{forall v in lvars | v = occval} >= occVar
onSup - if true, constraint insure size{forall v in lvars | v = occval} <= occVar
environment -
Method Detail

init

public void init(int occval,
                 boolean onInf,
                 boolean onSup,
                 IEnvironment environment)

getFilteredEventMask

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

awakeOnInf

public void awakeOnInf(int idx)
                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

awakeOnSup

public void awakeOnSup(int idx)
                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

awakeOnInst

public void awakeOnInst(int idx)
                 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

awakeOnRemovals

public void awakeOnRemovals(int idx,
                            DisposableIntIterator deltaDomain)
                     throws ContradictionException
Description copied from class: AbstractIntSConstraint
The default implementation of propagation when a variable has been modified consists in iterating all values that have been removed (the delta domain) and propagate them one after another, incrementally.

Specified by:
awakeOnRemovals in interface IntPropagator
Overrides:
awakeOnRemovals in class AbstractIntSConstraint
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

checkNbPossible

public void checkNbPossible()
                     throws ContradictionException
Throws:
ContradictionException

checkNbSure

public void checkNbSure()
                 throws ContradictionException
Throws:
ContradictionException

filter

public void filter()
            throws ContradictionException
Throws:
ContradictionException

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

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

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

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


Copyright © 2012. All Rights Reserved.