choco.cp.solver.variables.integer
Class AbstractIntDomain

java.lang.Object
  extended by choco.cp.solver.variables.integer.AbstractIntDomain
All Implemented Interfaces:
IPretty, Domain, IntDomain
Direct Known Subclasses:
BipartiteIntDomain, BitSetIntDomain, BooleanDomain, IntervalBTreeDomain, IntervalIntDomain, LinkedIntDomain

public abstract class AbstractIntDomain
extends Object
implements IntDomain

History: 2007-12-07 : FR_1873619 CPRU: DomOverDeg+DomOverWDeg


Field Summary
protected  int currentInfPropagated
          for the delta domain: current value of the inf (domain lower bound) when the bound started beeing propagated (just to check that it does not change during the propagation phase)
protected  int currentSupPropagated
          for the delta domain: current value of the sup (domain upper bound) when the bound started beeing propagated (just to check that it does not change during the propagation phase)
 
Fields inherited from interface choco.kernel.solver.variables.integer.IntDomain
LOGGER
 
Constructor Summary
protected AbstractIntDomain(IntDomainVar aVariable, PropagationEngine propagationEngine)
           
 
Method Summary
 void clearDeltaDomain()
          cleans the data structure implementing the delta domain
 IDeltaDomain copyDelta()
           
 int fastNextValue(int x)
          Accessing the smallest value stored in the domain and strictly greater than x, assuming x is greater or equal to the lower bound.
 int fastPrevValue(int x)
          Accessing the largest value stored in the domain and strictly smaller than x, assuming x is less or equal to the upper bound.
 void freezeDeltaDomain()
          The delta domain container is "frozen" (it can no longer accept new value removals) so that this set of values can be iterated as such
 DisposableIntIterator getDeltaIterator()
          Returns an getIterator over the set of values that have been removed from the domain since the last propagation
 boolean getReleasedDeltaDomain()
          checks whether the delta domain has indeed been released (ie: chechks that no domain updates are pending)
 boolean instantiate(int x, SConstraint cause, boolean forceAwake)
          Internal var: instantiation of the variable caused by its i-th constraint Returns a boolean indicating whether the call indeed added new information.
 boolean releaseDeltaDomain()
          release the delta domain
 boolean removeInterval(int a, int b, SConstraint cause, boolean forceAwake)
          Internal var: remove an interval (a sequence of consecutive values) from the domain of a variable caused by its i-th constraint.
 boolean removeVal(int x, SConstraint cause, boolean forceAwake)
          Internal var: update (value removal) on the domain of a variable caused by its i-th constraint.
 String toString()
           
 boolean updateInf(int x, SConstraint cause, boolean forceAwake)
          Internal var: update on the variable lower bound caused by its i-th constraint.
 boolean updateSup(int x, SConstraint cause, boolean forceAwake)
          Internal var: update on the variable upper bound caused by its i-th constraint.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface choco.kernel.solver.variables.integer.IntDomain
contains, getInf, getIterator, getNextValue, getPrevValue, getRandomValue, getSize, getSup, hasNextValue, hasPrevValue, isBoolean, isEnumerated, remove, restrict, updateInf, updateSup
 
Methods inherited from interface choco.IPretty
pretty
 

Field Detail

currentInfPropagated

protected int currentInfPropagated
for the delta domain: current value of the inf (domain lower bound) when the bound started beeing propagated (just to check that it does not change during the propagation phase)


currentSupPropagated

protected int currentSupPropagated
for the delta domain: current value of the sup (domain upper bound) when the bound started beeing propagated (just to check that it does not change during the propagation phase)

Constructor Detail

AbstractIntDomain

protected AbstractIntDomain(IntDomainVar aVariable,
                            PropagationEngine propagationEngine)
Method Detail

fastNextValue

public int fastNextValue(int x)
Description copied from interface: IntDomain
Accessing the smallest value stored in the domain and strictly greater than x, assuming x is greater or equal to the lower bound.

To iterate over the values in a IntDomain, use the following loop:

 int ub = dom.getSup();
 for (int val = dom.getInf(); val <= ub; val = dom.fastNextValue(val)) {
     // operate on value 'val' here
 }

Specified by:
fastNextValue in interface IntDomain

fastPrevValue

public int fastPrevValue(int x)
Description copied from interface: IntDomain
Accessing the largest value stored in the domain and strictly smaller than x, assuming x is less or equal to the upper bound.

To iterate over the values in a IntDomain, use the following loop:

 int lb = dom.getInf();
 for (int val = dom.getSup(); val >= lb; val = dom.fastPrevValue(val)) {
     // operate on value 'val' here
 }

Specified by:
fastPrevValue in interface IntDomain

updateSup

public boolean updateSup(int x,
                         SConstraint cause,
                         boolean forceAwake)
                  throws ContradictionException
Internal var: update on the variable upper bound caused by its i-th constraint. Returns a boolean indicating whether the call indeed added new information.

Parameters:
x - The new upper bound
cause - constraint causing the modification
forceAwake -
Returns:
a boolean indicating whether the call indeed added new information.
Throws:
ContradictionException - contradiction exception

updateInf

public boolean updateInf(int x,
                         SConstraint cause,
                         boolean forceAwake)
                  throws ContradictionException
Internal var: update on the variable lower bound caused by its i-th constraint. Returns a boolean indicating whether the call indeed added new information

Parameters:
x - The new lower bound.
cause - constraint causing the modification
forceAwake -
Returns:
a boolean indicating whether the call indeed added new information
Throws:
ContradictionException - contradiction exception

removeVal

public boolean removeVal(int x,
                         SConstraint cause,
                         boolean forceAwake)
                  throws ContradictionException
Internal var: update (value removal) on the domain of a variable caused by its i-th constraint. Note: Whenever the hole results in a stronger var (such as a bound update or an instantiation, then we forget about the index of the var generating constraint. Indeed the propagated var is stronger than the initial one that was generated; thus the generating constraint should be informed about such a new var. Returns a boolean indicating whether the call indeed added new information.

Parameters:
x - The removed value
cause - constraint causing the modification
forceAwake -
Returns:
a boolean indicating whether the call indeed added new information.
Throws:
ContradictionException - contradiction exception

removeInterval

public boolean removeInterval(int a,
                              int b,
                              SConstraint cause,
                              boolean forceAwake)
                       throws ContradictionException
Internal var: remove an interval (a sequence of consecutive values) from the domain of a variable caused by its i-th constraint. Returns a boolean indicating whether the call indeed added new information.

Parameters:
a - the first removed value
b - the last removed value
cause - constraint causing the modification
forceAwake -
Returns:
a boolean indicating whether the call indeed added new information.
Throws:
ContradictionException - contradiction exception

instantiate

public boolean instantiate(int x,
                           SConstraint cause,
                           boolean forceAwake)
                    throws ContradictionException
Internal var: instantiation of the variable caused by its i-th constraint Returns a boolean indicating whether the call indeed added new information.

Parameters:
x - the new upper bound
cause - constraint causing the modification
forceAwake -
Returns:
a boolean indicating whether the call indeed added new information.
Throws:
ContradictionException - contradiction exception

toString

public String toString()
Overrides:
toString in class Object

getDeltaIterator

public final DisposableIntIterator getDeltaIterator()
Description copied from interface: IntDomain
Returns an getIterator over the set of values that have been removed from the domain since the last propagation

Specified by:
getDeltaIterator in interface IntDomain

freezeDeltaDomain

public void freezeDeltaDomain()
Description copied from interface: IntDomain
The delta domain container is "frozen" (it can no longer accept new value removals) so that this set of values can be iterated as such

Specified by:
freezeDeltaDomain in interface IntDomain

releaseDeltaDomain

public boolean releaseDeltaDomain()
release the delta domain

Specified by:
releaseDeltaDomain in interface IntDomain
Returns:
wether it was a new update

clearDeltaDomain

public final void clearDeltaDomain()
Description copied from interface: IntDomain
cleans the data structure implementing the delta domain

Specified by:
clearDeltaDomain in interface IntDomain

getReleasedDeltaDomain

public boolean getReleasedDeltaDomain()
checks whether the delta domain has indeed been released (ie: chechks that no domain updates are pending)

Specified by:
getReleasedDeltaDomain in interface IntDomain

copyDelta

public final IDeltaDomain copyDelta()
Specified by:
copyDelta in interface IntDomain


Copyright © 2012. All Rights Reserved.