choco.cp.solver.constraints.integer
Class Absolute

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.AbstractBinIntSConstraint
                  extended by choco.cp.solver.constraints.integer.Absolute
All Implemented Interfaces:
IExtensionnable, IPretty, SConstraint<IntDomainVar>, IntPropagator, Cloneable, EventListener

public final class Absolute
extends AbstractBinIntSConstraint

The absolute constraint X = |Y| is a binary constraint with X = v0 and Y = v1


Field Summary
 
Fields inherited from class choco.kernel.solver.constraints.integer.AbstractBinIntSConstraint
v0, v1
 
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
Absolute(IntDomainVar x0, IntDomainVar x1)
          Constructs the constraint with the specified variables.
 
Method Summary
 void awakeOnInf(int idx)
          If X.inf increases, values from -X.inf to X.inf are forbidden for Y If Y.inf increases, it depends on the situation
 void awakeOnInst(int idx)
          When X is instantiated, Y is restricted to 2 values : X.value and -(X.value) When Y is instantiated, X is instantiated to abs(Y)
 void awakeOnRem(int idx, int x)
          When a value is removed from the domain of X: then this value and its opposite are removed from the domain of Y.
 void awakeOnSup(int idx)
          If X.sup decreases, Y is limited to (-(X.sup) ..
protected  void detectSymetricalHoles(int inf, int sup)
          Try to detect symetrical holes (ie value such that both value and -(value) are not in the domain of Y, in which case abs(value) can be removed from the domain of X)
 int getFilteredEventMask(int idx)
           
 boolean isConsistent()
          tests if the constraint is consistent with respect to the current state of domains
 Boolean isEntailed()
          Checks if the listeners must be checked or must fail.
 boolean isSatisfied(int[] tuple)
          Checks if the constraint is satisfied when the variables are instantiated.
 AbstractSConstraint<IntDomainVar> opposite(Solver solver)
          Get the opposite constraint
 String pretty()
          pretty printing of the object.
 void propagate()
          The initial propagation consist in enforcing X to be positive executing all standard propagation methods executing specific propagation methods
protected  void updateMinFromHoles()
          Deduce the minimum value of X from the eventual central gap in the domain of Y.
 
Methods inherited from class choco.kernel.solver.constraints.integer.AbstractIntSConstraint
awakeOnBounds, awakeOnRemovals, getConstraintType, isSatisfied
 
Methods inherited from class choco.kernel.solver.constraints.AbstractSConstraint
addExtension, addListener, clone, getAbstractSConstraintExtensionNumber, getConstraintIdx, getExtension, getFineDegree, getNbVarNotInst, getNbVars, getVar, getVarQuick, isCompletelyInstantiated, 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
 

Constructor Detail

Absolute

public Absolute(IntDomainVar x0,
                IntDomainVar x1)
Constructs the constraint with the specified variables.

Parameters:
x0 - first IntDomainVar
x1 - second IntDomainVar
Method Detail

getFilteredEventMask

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

propagate

public void propagate()
               throws ContradictionException
The initial propagation consist in enforcing X to be positive executing all standard propagation methods executing specific propagation methods

Specified by:
propagate in class Propagator
Throws:
ContradictionException - contradiction exception

awakeOnInf

public void awakeOnInf(int idx)
                throws ContradictionException
If X.inf increases, values from -X.inf to X.inf are forbidden for Y If Y.inf increases, it depends on the situation

Specified by:
awakeOnInf in interface IntPropagator
Overrides:
awakeOnInf in class AbstractIntSConstraint
Parameters:
idx -
Throws:
ContradictionException

awakeOnSup

public void awakeOnSup(int idx)
                throws ContradictionException
If X.sup decreases, Y is limited to (-(X.sup) .. X.sup) If Y.sup decreases, it depends on the situation

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

awakeOnInst

public void awakeOnInst(int idx)
                 throws ContradictionException
When X is instantiated, Y is restricted to 2 values : X.value and -(X.value) When Y is instantiated, X is instantiated to abs(Y)

Specified by:
awakeOnInst in interface IntPropagator
Overrides:
awakeOnInst in class AbstractIntSConstraint
Parameters:
idx -
Throws:
ContradictionException

awakeOnRem

public void awakeOnRem(int idx,
                       int x)
                throws ContradictionException
When a value is removed from the domain of X: then this value and its opposite are removed from the domain of Y. When a value is removed from the domain of Y: IF its opposite is not in the domain of Y either, then its absolute value is removed from the domain of X.

Specified by:
awakeOnRem in interface IntPropagator
Overrides:
awakeOnRem in class AbstractIntSConstraint
Parameters:
idx -
x -
Throws:
ContradictionException

detectSymetricalHoles

protected void detectSymetricalHoles(int inf,
                                     int sup)
                              throws ContradictionException
Try to detect symetrical holes (ie value such that both value and -(value) are not in the domain of Y, in which case abs(value) can be removed from the domain of X)

Throws:
ContradictionException

updateMinFromHoles

protected void updateMinFromHoles()
                           throws ContradictionException
Deduce the minimum value of X from the eventual central gap in the domain of Y.

Throws:
ContradictionException

isEntailed

public Boolean isEntailed()
Checks if the listeners must be checked or must fail.

Overrides:
isEntailed in class AbstractSConstraint<IntDomainVar>
Returns:
wether the constraint is entailed

isSatisfied

public boolean isSatisfied(int[] tuple)
Checks if the constraint is satisfied when the variables are instantiated.

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

isConsistent

public boolean isConsistent()
tests if the constraint is consistent with respect to the current state of domains

Overrides:
isConsistent in class AbstractIntSConstraint
Returns:
true iff the constraint is bound consistent (weaker than arc consistent)

opposite

public AbstractSConstraint<IntDomainVar> opposite(Solver solver)
Description copied from class: AbstractSConstraint
Get the opposite constraint

Specified by:
opposite in interface SConstraint<IntDomainVar>
Overrides:
opposite in class AbstractSConstraint<IntDomainVar>
Parameters:
solver - the current solver
Returns:
the opposite constraint @param solver

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.