choco.cp.solver.variables.integer
Class IntervalBTreeDomain

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

public final class IntervalBTreeDomain
extends AbstractIntDomain

Created by IntelliJ IDEA. User: julien Date: Apr 25, 2008 Time: 9:34:40 AM

A choco domain class represented by a binary tree of int interval


Field Summary
protected  IntDomainIterator _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
IntervalBTreeDomain(IntDomainVarImpl v, int[] sortedValues, IEnvironment environment, PropagationEngine propagationEngine)
          Construct a new domain represented by a Binary Tree of Interval
IntervalBTreeDomain(IntDomainVarImpl v, int a, int b, IEnvironment environment, PropagationEngine propagationEngine)
          Construct a new domain represented by a Binary Tree of Interval
 
Method Summary
 boolean contains(int x)
          Checks wether a value is in the domain
 int getInf()
          Gets the lowest value of the domain
 DisposableIntIterator getIterator()
          Retrieve an getIterator for traversing the sequence of values contained in the domain
 int getNextValue(int x)
          gets the next value of x in this domain
 int getPrevValue(int x)
          gets the previous value of x in this domain
 int getRandomValue()
          Easy way to get a random value in the domain Definitely not selected through an uniform distribution TODO: Find a better way to select a value really at random
 int getSize()
          Indicates the number of value in the domain
 int getSup()
          Gets the greatest value of the domain
 boolean hasNextValue(int x)
          Has this domain a value greater than the parameter TODO: getSup is to slow for that kind of operation
 boolean hasPrevValue(int x)
          Has this domain a value lower than the parameter TODO: it is not efficient to call getInf
 boolean isBoolean()
          Check if this domain is a 0-1 domain
 boolean isEnumerated()
          Check wether this domain is Enumerated or not
 String pretty()
          pretty print of the domain
 boolean remove(int x)
          Removes a value from the domain
 void restrict(int x)
          Restrict the domain to one value TODO: must existe a better way to remove all the other Node in the tree
 String toString()
           
 int updateInf(int x)
          Updates the inf bound of the domain to the given value TODO: Must exist a better way than removing all values until the new inf is reached
 int updateSup(int x)
          Updates the sup of the domain to the given value TODO: Must exist a better way than removing all values (e.g. removing all the node but the one containing the sup)
 
Methods inherited from class choco.cp.solver.variables.integer.AbstractIntDomain
clearDeltaDomain, copyDelta, fastNextValue, fastPrevValue, freezeDeltaDomain, getDeltaIterator, getReleasedDeltaDomain, instantiate, releaseDeltaDomain, removeInterval, removeVal, updateInf, updateSup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_iterator

protected IntDomainIterator _iterator
Constructor Detail

IntervalBTreeDomain

public IntervalBTreeDomain(IntDomainVarImpl v,
                           int a,
                           int b,
                           IEnvironment environment,
                           PropagationEngine propagationEngine)
Construct a new domain represented by a Binary Tree of Interval

Parameters:
v - the associatede variable
a - the lower bound
b - the upper bound
environment -
propagationEngine -

IntervalBTreeDomain

public IntervalBTreeDomain(IntDomainVarImpl v,
                           int[] sortedValues,
                           IEnvironment environment,
                           PropagationEngine propagationEngine)
Construct a new domain represented by a Binary Tree of Interval

Parameters:
v - the associatede variable
sortedValues - array of values
environment -
propagationEngine -
Method Detail

getInf

public int getInf()
Gets the lowest value of the domain

Returns:
the lower bound of the domain

getSup

public int getSup()
Gets the greatest value of the domain

Returns:
the greater bound of the domain

updateInf

public int updateInf(int x)
Updates the inf bound of the domain to the given value TODO: Must exist a better way than removing all values until the new inf is reached

Parameters:
x - integer value
Returns:
the new lower bound

updateSup

public int updateSup(int x)
Updates the sup of the domain to the given value TODO: Must exist a better way than removing all values (e.g. removing all the node but the one containing the sup)

Parameters:
x - integer value
Returns:
the new greater bound

contains

public boolean contains(int x)
Checks wether a value is in the domain

Parameters:
x - the value to be checked
Returns:
true if x is in the domain, false otherwise

remove

public boolean remove(int x)
Removes a value from the domain

Parameters:
x - the value to be removed
Returns:
true if removal is a success, false otherwise

restrict

public void restrict(int x)
Restrict the domain to one value TODO: must existe a better way to remove all the other Node in the tree

Parameters:
x - integer value

getSize

public int getSize()
Indicates the number of value in the domain

Returns:
the size of the domain

getIterator

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


getNextValue

public int getNextValue(int x)
gets the next value of x in this domain

Parameters:
x - integer value
Returns:
-infinity if not found, the next value otherwise

getPrevValue

public int getPrevValue(int x)
gets the previous value of x in this domain

Parameters:
x - integer value
Returns:
-infinity if not found, the previous value otherwise

hasNextValue

public boolean hasNextValue(int x)
Has this domain a value greater than the parameter TODO: getSup is to slow for that kind of operation

Parameters:
x - integer value
Returns:
wether the domain contains a greater value

hasPrevValue

public boolean hasPrevValue(int x)
Has this domain a value lower than the parameter TODO: it is not efficient to call getInf

Parameters:
x - integer value
Returns:
wether this domain contains a lower value

getRandomValue

public int getRandomValue()
Easy way to get a random value in the domain Definitely not selected through an uniform distribution TODO: Find a better way to select a value really at random

Returns:
a value selected at random in the domain

isEnumerated

public boolean isEnumerated()
Check wether this domain is Enumerated or not

Returns:
true

isBoolean

public boolean isBoolean()
Check if this domain is a 0-1 domain

Returns:
false

pretty

public String pretty()
pretty print of the domain

Returns:
a new string

toString

public String toString()
Overrides:
toString in class AbstractIntDomain


Copyright © 2012. All Rights Reserved.