choco.cp.solver.variables.integer
Class BipartiteIntDomain

java.lang.Object
  extended by choco.cp.solver.variables.integer.AbstractIntDomain
      extended by choco.cp.solver.variables.integer.BipartiteIntDomain
All Implemented Interfaces:
IPretty, Domain, IntDomain

public class BipartiteIntDomain
extends AbstractIntDomain

Author:
Guillaume Rochart This class is an integer domain implementation based on a bipartite set : values in the domain, and values outside. For instance :

World 1 : 1234 World 2 : 124 3 World 3 : 14 23 World 2 : 142 3 World 3 : 42 13 World 2 : 421 3 World 1 : 4213

On this implementation, we only need an integer list and a stored integer to know how many values are in the domain, and a list pointing all value indices in order to be able to remove values easily (without iterating the domain).


Field Summary
protected  BipartiteIntDomainIterator _iterator
           
 
Fields inherited from class choco.cp.solver.variables.integer.AbstractIntDomain
currentInfPropagated, currentSupPropagated
 
Fields inherited from interface choco.kernel.solver.variables.integer.IntDomain
LOGGER
 
Constructor Summary
BipartiteIntDomain(IntDomainVarImpl v, int[] sortedValues, IEnvironment environment, PropagationEngine propagationEngine)
          Constructs a new domain for the specified variable and bounds.
BipartiteIntDomain(IntDomainVarImpl v, int low, int up, IEnvironment environment, PropagationEngine propagationEngine)
          Constructs a new domain for the specified variable and bounds.
 
Method Summary
protected  boolean _removeVal(int x, SConstraint cause)
          Removing a value from the domain of a variable.
 boolean contains(int x)
          This method is volontarely inefficient!
 int getInf()
          Access the minimal value stored in the domain.
 DisposableIntIterator getIterator()
          Retrieve an getIterator for traversing the sequence of values contained in the domain
 int getNextValue(int x)
          Be careful, there is no order in the domain values in this implementation !
 int getPrevValue(int x)
          Be careful, there is no order in the domain values in this implementation !
 int getRandomValue()
          Draws a value at random from the domain.
 int getSize()
          Access the total number of values stored in the domain.
 int getSup()
          Access the maximal value stored in the domain/
 boolean hasNextValue(int x)
          Testing whether there are values in the domain that are strictly greater than x.
 boolean hasPrevValue(int x)
          Testing whether there are values in the domain that are strictly smaller than x.
 boolean isBoolean()
          Is it a 0/1 domain ?
 boolean isEnumerated()
           
 String pretty()
          pretty printing of the object.
 boolean remove(int x)
          Removing a single value from the 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.
 void restrict(int x)
          Restricting the domain to a singleton
 int updateInf(int x)
          Augment the minimal value stored in the domain.
 int updateSup(int x)
          Diminish the maximal value stored in the domain.
 
Methods inherited from class choco.cp.solver.variables.integer.AbstractIntDomain
clearDeltaDomain, copyDelta, fastNextValue, fastPrevValue, freezeDeltaDomain, getDeltaIterator, getReleasedDeltaDomain, instantiate, releaseDeltaDomain, removeVal, toString, updateInf, updateSup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_iterator

protected BipartiteIntDomainIterator _iterator
Constructor Detail

BipartiteIntDomain

public BipartiteIntDomain(IntDomainVarImpl v,
                          int[] sortedValues,
                          IEnvironment environment,
                          PropagationEngine propagationEngine)
Constructs a new domain for the specified variable and bounds.

Parameters:
v - The involved variable.
sortedValues - arry of sorted values.
environment -
propagationEngine -

BipartiteIntDomain

public BipartiteIntDomain(IntDomainVarImpl v,
                          int low,
                          int up,
                          IEnvironment environment,
                          PropagationEngine propagationEngine)
Constructs a new domain for the specified variable and bounds.

Parameters:
v - The involved variable.
low - Minimal value.
up - Maximal value.
environment -
propagationEngine -
Method Detail

getInf

public int getInf()
Description copied from interface: IntDomain
Access the minimal value stored in the domain.

Returns:
the lower bound

getSup

public int getSup()
Description copied from interface: IntDomain
Access the maximal value stored in the domain/

Returns:
the upper bound

contains

public boolean contains(int x)
This method is volontarely inefficient! It allows to be efficient for backtracking and so on.

Returns:
true if the value is still in the domain

getSize

public int getSize()
Description copied from interface: IntDomain
Access the total number of values stored in the domain.

Returns:
the number of values in the domain

getNextValue

public int getNextValue(int x)
Be careful, there is no order in the domain values in this implementation !

Parameters:
x - the previous value in the list
Returns:
the next value after x

getPrevValue

public int getPrevValue(int x)
Be careful, there is no order in the domain values in this implementation !

Parameters:
x - a value in the list
Returns:
the previous value before x

hasNextValue

public boolean hasNextValue(int x)
Description copied from interface: IntDomain
Testing whether there are values in the domain that are strictly greater than x. Does not require x to be in the domain.


hasPrevValue

public boolean hasPrevValue(int x)
Description copied from interface: IntDomain
Testing whether there are values in the domain that are strictly smaller than x. Does not require x to be in the domain.


removeInterval

public boolean removeInterval(int a,
                              int b,
                              SConstraint cause,
                              boolean forceAwake)
                       throws ContradictionException
Description copied from class: AbstractIntDomain
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.

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

_removeVal

protected boolean _removeVal(int x,
                             SConstraint cause)
                      throws ContradictionException
Removing a value from the domain of a variable. Returns true if this was a real modification on the domain.

Parameters:
x - the value to remove
cause -
Returns:
wether the removal has been done
Throws:
ContradictionException - contradiction excpetion

remove

public boolean remove(int x)
Description copied from interface: IntDomain
Removing a single value from the domain.


restrict

public void restrict(int x)
Description copied from interface: IntDomain
Restricting the domain to a singleton


updateInf

public int updateInf(int x)
Description copied from interface: IntDomain
Augment the minimal value stored in the domain. returns the new lower bound (x or more, in case x was not in the domain)


updateSup

public int updateSup(int x)
Description copied from interface: IntDomain
Diminish the maximal value stored in the domain. returns the new upper bound (x or more, in case x was not in the domain).


getRandomValue

public int getRandomValue()
Description copied from interface: IntDomain
Draws a value at random from the domain.


getIterator

public DisposableIntIterator getIterator()
Description copied from interface: IntDomain
Retrieve an getIterator for traversing the sequence of values contained in the domain


isEnumerated

public boolean isEnumerated()

isBoolean

public boolean isBoolean()
Description copied from interface: IntDomain
Is it a 0/1 domain ?


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.

Returns:
a readable string representation of the object


Copyright © 2012. All Rights Reserved.