choco.cp.solver.constraints.integer
Class MaxOfAList

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

public final class MaxOfAList
extends AbstractLargeIntSConstraint

Implements a constraint X = max(Y_0, Y_1...Y_n).


Field Summary
protected  IStateInt indexOfMaximumVariable
          Index of the maximum variable.
static int MAX_INDEX
          Index of the maximum 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.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
MaxOfAList(IEnvironment environment, IntDomainVar[] vars)
           
 
Method Summary
 void awakeOnInf(int idx)
          Propagation when lower bound is increased.
 void awakeOnInst(int idx)
          Propagation when a variable is instantiated.
 void awakeOnSup(int idx)
          Propagation when upper bound is decreased.
 int getFilteredEventMask(int idx)
           
 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 !
protected  int maxInf()
           
protected  int maxSup()
           
protected  void onlyOneMaxCandidatePropagation()
          If only one candidate to be the max of the list, some additionnal propagation can be performed (as in usual x == y constraint).
 String pretty()
          pretty printing of the object.
 void propagate()
          Propagation of the constraint.
protected  boolean testIfOneCandidateToTakeMaxValue()
          Checks if one of the variables in the list is instantiated to the max.
 
Methods inherited from class choco.kernel.solver.constraints.integer.AbstractIntSConstraint
awakeOnBounds, awakeOnRem, 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, 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

MAX_INDEX

public static final int MAX_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

indexOfMaximumVariable

protected final IStateInt indexOfMaximumVariable
Index of the maximum variable.

Constructor Detail

MaxOfAList

public MaxOfAList(IEnvironment environment,
                  IntDomainVar[] vars)
Method Detail

getFilteredEventMask

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

onlyOneMaxCandidatePropagation

protected void onlyOneMaxCandidatePropagation()
                                       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

testIfOneCandidateToTakeMaxValue

protected boolean testIfOneCandidateToTakeMaxValue()
Checks if one of the variables in the list is instantiated to the max.

Returns:
true if one variables in the list is instantaited to the max.

maxInf

protected final int maxInf()

maxSup

protected final int maxSup()

propagate

public void propagate()
               throws ContradictionException
Propagation of the constraint. It should be called only with initial propagation here, since no constraint events are posted.

Specified by:
propagate in class Propagator
Throws:
ContradictionException - if a domain becomes empty.

awakeOnInf

public void awakeOnInf(int idx)
                throws ContradictionException
Propagation when lower bound is increased.

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

awakeOnSup

public void awakeOnSup(int idx)
                throws ContradictionException
Propagation when upper bound is decreased.

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

awakeOnInst

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

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

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

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


Copyright © 2012. All Rights Reserved.