JaCoP.core
Class SmallDenseDomain

java.lang.Object
  extended by JaCoP.core.Domain
      extended by JaCoP.core.IntDomain
          extended by JaCoP.core.SmallDenseDomain

public class SmallDenseDomain
extends IntDomain

Defines small dense domain based on bits within a long number.

Version:
3.1
Author:
Radoslaw Szymanek and Krzysztof Kuchcinski

Field Summary
 long bits
          It stores information about presence of the elements in the domain.
static SmallDenseDomain emptyDomain
          It is an empty domain returned by default when empty domain becomes a result of any function.
 int min
          The minimal value present in this domain encoding.
 IntDomain previousDomain
          It specifies the previous domain which was used by this domain.
 
Fields inherited from class JaCoP.core.IntDomain
ANY, BOUND, BoundDomainID, emptyIntDomain, eventsInclusion, GROUND, IntervalDomainID, MaxInt, MinInt, SmallDenseDomainID
 
Fields inherited from class JaCoP.core.Domain
modelConstraints, modelConstraintsToEvaluate, NOINFO, NONE, searchConstraints, searchConstraintsCloned, searchConstraintsToEvaluate, stamp
 
Constructor Summary
SmallDenseDomain()
          It creates an empty domain.
SmallDenseDomain(int min, int max)
          It creates a domain with values between min and max inclusive.
SmallDenseDomain(int min, long bits)
          It creates a domain of type small dense.
 
Method Summary
 void addDom(IntDomain domain)
          It adds values as specified by the parameter to the domain.
 java.lang.String checkInvariants()
          It checks if the domain has correct state.
 void clear()
          It removes all elements.
 Domain clone()
          It clones the domain object.
 SmallDenseDomain cloneLight()
          It clones the domain object, only data responsible for encoding domain values is cloned.
 IntDomain complement()
          It creates a complement of a domain.
 boolean contains(int value)
          It checks if value belongs to the domain.
 boolean contains(IntDomain domain)
          It specifies if the current domain contains the domain given as a parameter.
 boolean contains(int min, int max)
          It checks if an interval min..max belongs to the domain.
 int domainID()
          It returns an unique identifier of the domain.
 boolean eq(IntDomain domain)
          It specifies if the other int domain is equal to this one.
 int getElementAt(int index)
          It access the element at the specified position.
 Interval getInterval(int position)
          It returns required interval.
 int getRandomValue()
          It returns a random value from the domain.
 int getSize()
          It returns the size of the domain.
 int getSize(long input)
          It computes the number of 1's in the binary representation of the number given in the field input.
 void in(int storeLevel, Var var, IntDomain domain)
          It updates the domain to have values only within the domain.
 void in(int storeLevel, Var var, int min, int max)
          It updates the domain to have values only within the interval min..max.
 void in(int storeLevel, Var var, long domain)
           
 void inComplement(int storeLevel, Var var, int complement)
          It updates the domain to not contain the value complement.
 void inComplement(int storeLevel, Var var, int minComplement, int maxComplement)
          It updates the domain so it does not contain the supplied interval.
 void inMax(int storeLevel, Var var, int max)
          It updates the domain according to the maximum value and stamp value.
 void inMin(int storeLevel, Var var, int min)
          It updates the domain according to the minimum value and stamp value.
 void inShift(int storeLevel, Var var, IntDomain domain, int shift)
          It updates the domain to contain the elements as specifed by the domain, which is shifted.
 IntDomain intersect(IntDomain domain)
          It intersects current domain with the one given as a parameter.
 SmallDenseDomain intersect(IntervalDomain input, int shift)
           
 IntDomain intersect(int min, int max)
          In intersects current domain with the interval min..max.
 int intersectAdapt(IntDomain domain)
          It computes an intersection with a given domain and stores it in this domain.
 int intersectAdapt(int min, int max)
          It computes an intersection of this domain with an interval [min..max].
 IntervalEnumeration intervalEnumeration()
          It returns interval enumeration of the domain values.
 boolean isEmpty()
          It returns true if given domain is empty.
 boolean isIntersecting(IntDomain domain)
          Checks if two domains intersect.
 boolean isIntersecting(int min, int max)
          It checks if interval min..max intersects with current domain.
 boolean isNumeric()
          It specifies if domain is a finite domain of numeric values (integers).
 boolean isSparseRepresentation()
          It specifies if the domain type is more suited to representing sparse domain.
 int leftElement(int intervalNo)
          It returns the left most element of the given interval.
 int max()
          It returns the maximum value in a domain.
 int min()
          It returns the minimum value in a domain.
 int nextValue(int value)
          It gives next value in the domain from the given one (lexigraphical ordering).
 int noIntervals()
          It returns number of intervals required to represent this domain.
 int previousValue(int value)
          It gives previous value in the domain from the given one (lexigraphical ordering).
 void putModelConstraint(int storeLevel, Var var, Constraint C, int pruningEvent)
          It adds a constraint to a domain, it should only be called by putConstraint function of Variable object.
 void putSearchConstraint(int storeLevel, Var var, Constraint C)
          It adds a constraint to a domain, it should only be called by putConstraint function of Variable object.
 IntDomain recentDomainPruning(int storeLevel)
          It returns the values which have been removed at current store level.
 void removeLevel(int level, Var var)
          It removes the specified level.
 void removeModelConstraint(int storeLevel, Var var, Constraint c)
          It removes a constraint from a domain, it should only be called by removeConstraint function of Variable object.
 void removeSearchConstraint(int storeLevel, Var var, int position, Constraint C)
          It removes a constraint from a domain, it should only be called by removeConstraint function of Variable object.
 int rightElement(int intervalNo)
          It returns the right most element of the given interval.
 void setDomain(IntDomain domain)
          It sets the domain to the specified domain.
 void setDomain(int min, int max)
          It sets this domain to contain exactly all values between min and max.
 void shift(int shift)
          It shifts the domain.
 boolean singleton()
          It returns true if given domain has only one element.
 boolean singleton(int c)
          It returns true if given domain has only one element equal c.
 int sizeConstraintsOriginal()
          It returns all constraints which are associated with variable, even the ones which are already satisfied.
 int sizeOfIntersection(IntDomain domain)
          It computes the size of the intersection between this domain and the domain supplied as a parameter.
 IntDomain subtract(int value)
          It intersects with the domain which is a complement of value.
 IntDomain subtract(IntDomain domain)
          It subtracts domain from current domain and returns the result.
 IntDomain subtract(int min, int max)
          It subtracts interval min..max.
 void subtractAdapt(int value)
          It removes value from the domain.
 void subtractAdapt(int min, int max)
          It removes all values between min and max to the domain.
 IntervalDomain toIntervalDomain()
           
 java.lang.String toString()
          It returns string description of the domain (only values in the domain).
 java.lang.String toStringConstraints()
          It returns string description of the constraints attached to the domain.
 java.lang.String toStringFull()
          It returns complete string description containing all relevant information about the domain.
 IntDomain union(int value)
          It computes union of this domain and value.
 IntDomain union(IntDomain domain)
          It computes union of the supplied domain with this domain.
 IntDomain union(int min, int max)
          It computes union of this domain and the interval.
 void unionAdapt(int value)
          It adds a values to the domain.
 void unionAdapt(Interval i)
          It adds interval of values to the domain.
 void unionAdapt(int min, int max)
          It adds all values between min and max to the domain.
 ValueEnumeration valueEnumeration()
          It returns value enumeration of the domain values.
 
Methods inherited from class JaCoP.core.IntDomain
elementsSmallerThan, getEventsInclusion, in, inValue, lex, noConstraints, singleton, toIntArray, unionAdapt, value
 
Methods inherited from class JaCoP.core.Domain
constraints, noSearchConstraints, searchConstraints, setStamp, sizeConstraints, stamp
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

emptyDomain

public static final SmallDenseDomain emptyDomain
It is an empty domain returned by default when empty domain becomes a result of any function.


min

public int min
The minimal value present in this domain encoding. The domain can only encode small domains within a range [min .. min + 63].


bits

public long bits
It stores information about presence of the elements in the domain. If the least significant bit is set then min + 63 is present. The most significant bit is always set as this domain maintains invariant that minimum value always belongs to the domain.


previousDomain

public IntDomain previousDomain
It specifies the previous domain which was used by this domain. The old domain is stored here and can be easily restored if necessary.

Constructor Detail

SmallDenseDomain

public SmallDenseDomain()
It creates an empty domain.


SmallDenseDomain

public SmallDenseDomain(int min,
                        long bits)
It creates a domain of type small dense.

Parameters:
min - the minimum value present in this domain.
bits - the bits representing presence of any value from the range [ min .. min + 63].

SmallDenseDomain

public SmallDenseDomain(int min,
                        int max)
It creates a domain with values between min and max inclusive.

Parameters:
min -
max -
Method Detail

addDom

public void addDom(IntDomain domain)
Description copied from class: IntDomain
It adds values as specified by the parameter to the domain.

Overrides:
addDom in class IntDomain
Parameters:
domain - Domain which needs to be added to the domain.

complement

public IntDomain complement()
Description copied from class: IntDomain
It creates a complement of a domain.

Specified by:
complement in class IntDomain
Returns:
it returns the complement of this domain.

contains

public boolean contains(IntDomain domain)
Description copied from class: IntDomain
It specifies if the current domain contains the domain given as a parameter.

Overrides:
contains in class IntDomain
Parameters:
domain - for which we check if it is contained in the current domain.
Returns:
true if the supplied domain is cover by this domain.

contains

public boolean contains(int value)
Description copied from class: IntDomain
It checks if value belongs to the domain.

Overrides:
contains in class IntDomain
Parameters:
value - which is checked if it exists in the domain.
Returns:
true if value belongs to the domain.

eq

public boolean eq(IntDomain domain)
Description copied from class: IntDomain
It specifies if the other int domain is equal to this one.

Overrides:
eq in class IntDomain
Parameters:
domain - the domain which is compared to this domain.
Returns:
true if both domains contain the same elements, false otherwise.

getElementAt

public int getElementAt(int index)
Description copied from class: IntDomain
It access the element at the specified position.

Specified by:
getElementAt in class IntDomain
Parameters:
index - the position of the element, indexing starts from 0.
Returns:
the value at a given position in the domain.

getInterval

public Interval getInterval(int position)
Description copied from class: IntDomain
It returns required interval.

Specified by:
getInterval in class IntDomain
Parameters:
position - the position of the interval.
Returns:
the interval, or null if the required interval does not exist.

getSize

public int getSize()
Description copied from class: IntDomain
It returns the size of the domain.

Specified by:
getSize in class IntDomain
Returns:
number of elements in this domain.

getSize

public int getSize(long input)
It computes the number of 1's in the binary representation of the number given in the field input.

Parameters:
input - the 64bits for which calculation of number of 1's takes place.
Returns:
the number of 1's.

in

public void in(int storeLevel,
               Var var,
               int min,
               int max)
It updates the domain to have values only within the interval min..max. The type of update is decided by the value of stamp. It informs the variable of a change if it occurred.

Specified by:
in in class IntDomain
Parameters:
storeLevel - level of the store at which the update occurs.
var - variable for which this domain is used.
min - the minimum value to which the domain is updated.
max - the maximum value to which the domain is updated.

in

public void in(int storeLevel,
               Var var,
               long domain)

in

public void in(int storeLevel,
               Var var,
               IntDomain domain)
Description copied from class: IntDomain
It updates the domain to have values only within the domain. The type of update is decided by the value of stamp. It informs the variable of a change if it occurred.

Overrides:
in in class IntDomain
Parameters:
storeLevel - level of the store at which the update occurs.
var - variable for which this domain is used.
domain - the domain according to which the domain is updated.

inComplement

public void inComplement(int storeLevel,
                         Var var,
                         int complement)
Description copied from class: IntDomain
It updates the domain to not contain the value complement. It informs the variable of a change if it occurred.

Overrides:
inComplement in class IntDomain
Parameters:
storeLevel - level of the store at which the update occurs.
var - variable for which this domain is used.
complement - value which is removed from the domain if it belonged to the domain.

inComplement

public void inComplement(int storeLevel,
                         Var var,
                         int minComplement,
                         int maxComplement)
Description copied from class: IntDomain
It updates the domain so it does not contain the supplied interval. It informs the variable of a change if it occurred.

Specified by:
inComplement in class IntDomain
Parameters:
storeLevel - level of the store at which the update occurs.
var - variable for which this domain is used.
minComplement - the left bound of the interval (inclusive).
maxComplement - the right bound of the interval (inclusive).

inMax

public void inMax(int storeLevel,
                  Var var,
                  int max)
Description copied from class: IntDomain
It updates the domain according to the maximum value and stamp value. It informs the variable of a change if it occurred.

Overrides:
inMax in class IntDomain
Parameters:
storeLevel - level of the store at which the update occurs.
var - variable for which this domain is used.
max - the maximum value to which the domain is updated.

inMin

public void inMin(int storeLevel,
                  Var var,
                  int min)
Description copied from class: IntDomain
It updates the domain according to the minimum value and stamp value. It informs the variable of a change if it occurred.

Overrides:
inMin in class IntDomain
Parameters:
storeLevel - level of the store at which the update occurs.
var - variable for which this domain is used.
min - the minimum value to which the domain is updated.

inShift

public void inShift(int storeLevel,
                    Var var,
                    IntDomain domain,
                    int shift)
Description copied from class: IntDomain
It updates the domain to contain the elements as specifed by the domain, which is shifted. E.g. {1..4} + 3 = 4..7

Specified by:
inShift in class IntDomain
Parameters:
storeLevel - level of the store at which the update occurs.
var - variable for which this domain is used.
domain - the domain according to which the domain is updated.
shift - the shift which is used to shift the domain supplied as argument.

intersect

public SmallDenseDomain intersect(IntervalDomain input,
                                  int shift)

intersect

public IntDomain intersect(IntDomain domain)
Description copied from class: IntDomain
It intersects current domain with the one given as a parameter.

Specified by:
intersect in class IntDomain
Parameters:
domain - domain with which the intersection needs to be computed.
Returns:
the intersection between supplied domain and this domain.

intersect

public IntDomain intersect(int min,
                           int max)
Description copied from class: IntDomain
In intersects current domain with the interval min..max.

Specified by:
intersect in class IntDomain
Parameters:
min - the left bound of the interval (inclusive)
max - the right bound of the interval (inclusive)
Returns:
the intersection between the specified interval and this domain.

intersectAdapt

public int intersectAdapt(IntDomain domain)
Description copied from class: IntDomain
It computes an intersection with a given domain and stores it in this domain.

Specified by:
intersectAdapt in class IntDomain
Parameters:
domain - domain with which the intersection is being computed.
Returns:
type of event which has occurred due to the operation.

intersectAdapt

public int intersectAdapt(int min,
                          int max)
Description copied from class: IntDomain
It computes an intersection of this domain with an interval [min..max]. It adapts this domain to the result of the intersection.

Specified by:
intersectAdapt in class IntDomain
Parameters:
min - the minimum value of the interval used in the intersection computation.
max - the maximum value of the interval used in the intersection computation.
Returns:
it returns information about the pruning event which has occurred due to this operation.

intervalEnumeration

public IntervalEnumeration intervalEnumeration()
Description copied from class: IntDomain
It returns interval enumeration of the domain values.

Specified by:
intervalEnumeration in class IntDomain
Returns:
intervalEnumeration which can be used to enumerate intervals in this domain.

isIntersecting

public boolean isIntersecting(IntDomain domain)
Description copied from class: IntDomain
Checks if two domains intersect.

Overrides:
isIntersecting in class IntDomain
Parameters:
domain - the domain for which intersection is checked.
Returns:
true if domains are intersecting.

isIntersecting

public boolean isIntersecting(int min,
                              int max)
Description copied from class: IntDomain
It checks if interval min..max intersects with current domain.

Specified by:
isIntersecting in class IntDomain
Parameters:
min - the left bound of the interval.
max - the right bound of the interval.
Returns:
true if domain intersects with the specified interval.

leftElement

public int leftElement(int intervalNo)
Description copied from class: IntDomain
It returns the left most element of the given interval.

Overrides:
leftElement in class IntDomain
Parameters:
intervalNo - the interval number.
Returns:
the left bound of the specified interval.

max

public int max()
Description copied from class: IntDomain
It returns the maximum value in a domain.

Specified by:
max in class IntDomain
Returns:
the largest value present in the domain.

min

public int min()
Description copied from class: IntDomain
It returns the minimum value in a domain.

Specified by:
min in class IntDomain
Returns:
the smallest value present in the domain.

nextValue

public int nextValue(int value)
Description copied from class: IntDomain
It gives next value in the domain from the given one (lexigraphical ordering). If no value can be found then returns the same value.

Specified by:
nextValue in class IntDomain
Parameters:
value - it specifies the value after which a next value has to be found.
Returns:
next value after the specified one which belong to this domain.

noIntervals

public int noIntervals()
Description copied from class: IntDomain
It returns number of intervals required to represent this domain.

Specified by:
noIntervals in class IntDomain
Returns:
the number of intervals in the domain.

previousValue

public int previousValue(int value)
Description copied from class: IntDomain
It gives previous value in the domain from the given one (lexigraphical ordering). If no value can be found then returns the same value.

Specified by:
previousValue in class IntDomain
Parameters:
value - before which a value is seeked for.
Returns:
it returns the value before the one specified as a parameter.

recentDomainPruning

public IntDomain recentDomainPruning(int storeLevel)
Description copied from class: IntDomain
It returns the values which have been removed at current store level.

Specified by:
recentDomainPruning in class IntDomain
Parameters:
storeLevel - the current store level.
Returns:
emptyDomain if domain did not change at current level, or the set of values which have been removed at current level.

rightElement

public int rightElement(int intervalNo)
Description copied from class: IntDomain
It returns the right most element of the given interval.

Overrides:
rightElement in class IntDomain
Parameters:
intervalNo - the interval number.
Returns:
the right bound of the specified interval.

setDomain

public void setDomain(IntDomain domain)
Description copied from class: IntDomain
It sets the domain to the specified domain.

Specified by:
setDomain in class IntDomain
Parameters:
domain - the domain from which this domain takes all elements.

setDomain

public void setDomain(int min,
                      int max)
Description copied from class: IntDomain
It sets this domain to contain exactly all values between min and max.

Specified by:
setDomain in class IntDomain
Parameters:
min - the left bound of the interval (inclusive).
max - the right bound of the interval (inclusive).

singleton

public boolean singleton(int c)
Description copied from class: IntDomain
It returns true if given domain has only one element equal c.

Overrides:
singleton in class IntDomain
Parameters:
c - the value to which the only element should be equal to.
Returns:
true if the domain contains only one element c.

sizeOfIntersection

public int sizeOfIntersection(IntDomain domain)
Description copied from class: IntDomain
It computes the size of the intersection between this domain and the domain supplied as a parameter.

Overrides:
sizeOfIntersection in class IntDomain
Parameters:
domain - the domain with which the intersection is computed.
Returns:
the size of the intersection.

subtract

public IntDomain subtract(int value)
Description copied from class: IntDomain
It intersects with the domain which is a complement of value.

Overrides:
subtract in class IntDomain
Parameters:
value - the value for which the complement is computed
Returns:
the domain which does not contain specified value.

subtract

public IntDomain subtract(IntDomain domain)
Description copied from class: IntDomain
It subtracts domain from current domain and returns the result.

Overrides:
subtract in class IntDomain
Parameters:
domain - the domain which is subtracted from this domain.
Returns:
the result of the subtraction.

subtractAdapt

public void subtractAdapt(int min,
                          int max)
Description copied from class: IntDomain
It removes all values between min and max to the domain.

Specified by:
subtractAdapt in class IntDomain
Parameters:
min - the left bound of the interval being removed.
max - the right bound of the interval being removed.

subtract

public IntDomain subtract(int min,
                          int max)
Description copied from class: IntDomain
It subtracts interval min..max.

Specified by:
subtract in class IntDomain
Parameters:
min - the left bound of the interval (inclusive).
max - the right bound of the interval (inclusive).
Returns:
the result of the subtraction.

subtractAdapt

public void subtractAdapt(int value)
Description copied from class: IntDomain
It removes value from the domain. It adapts current (this) domain.

Specified by:
subtractAdapt in class IntDomain
Parameters:
value - the value for which the complement is computed

union

public IntDomain union(IntDomain domain)
Description copied from class: IntDomain
It computes union of the supplied domain with this domain.

Overrides:
union in class IntDomain
Parameters:
domain - the domain for which the union is computed.
Returns:
the union of this domain with the supplied one.

union

public IntDomain union(int min,
                       int max)
Description copied from class: IntDomain
It computes union of this domain and the interval.

Overrides:
union in class IntDomain
Parameters:
min - the left bound of the interval (inclusive).
max - the right bound of the interval (inclusive).
Returns:
the union of this domain and the interval.

union

public IntDomain union(int value)
Description copied from class: IntDomain
It computes union of this domain and value.

Overrides:
union in class IntDomain
Parameters:
value - it specifies the value which is being added.
Returns:
domain which is a union of this one and the value.

unionAdapt

public void unionAdapt(Interval i)
Description copied from class: IntDomain
It adds interval of values to the domain.

Overrides:
unionAdapt in class IntDomain
Parameters:
i - Interval which needs to be added to the domain.

unionAdapt

public void unionAdapt(int min,
                       int max)
Description copied from class: IntDomain
It adds all values between min and max to the domain.

Specified by:
unionAdapt in class IntDomain
Parameters:
min - the left bound of the interval being added.
max - the right bound of the interval being added.

unionAdapt

public void unionAdapt(int value)
Description copied from class: IntDomain
It adds a values to the domain.

Overrides:
unionAdapt in class IntDomain
Parameters:
value - value being added to the domain.

valueEnumeration

public ValueEnumeration valueEnumeration()
Description copied from class: IntDomain
It returns value enumeration of the domain values.

Specified by:
valueEnumeration in class IntDomain
Returns:
valueEnumeration which can be used to enumerate one by one value from this domain.

checkInvariants

public java.lang.String checkInvariants()
Description copied from class: Domain
It checks if the domain has correct state.

Specified by:
checkInvariants in class Domain
Returns:
null if everything is ok, otherwise a string describing the problem.

clear

public void clear()
Description copied from class: Domain
It removes all elements.

Specified by:
clear in class Domain

clone

public Domain clone()
Description copied from class: Domain
It clones the domain object.

Specified by:
clone in class Domain

domainID

public int domainID()
Description copied from class: Domain
It returns an unique identifier of the domain.

Specified by:
domainID in class Domain
Returns:
it returns an integer id of the domain.

isEmpty

public boolean isEmpty()
Description copied from class: Domain
It returns true if given domain is empty.

Specified by:
isEmpty in class Domain
Returns:
true if the given domain is empty.

isNumeric

public boolean isNumeric()
Description copied from class: Domain
It specifies if domain is a finite domain of numeric values (integers).

Specified by:
isNumeric in class Domain
Returns:
true if domains contains numeric values.

isSparseRepresentation

public boolean isSparseRepresentation()
Description copied from class: Domain
It specifies if the domain type is more suited to representing sparse domain.

Specified by:
isSparseRepresentation in class Domain
Returns:
true if sparse, false otherwise.

cloneLight

public SmallDenseDomain cloneLight()
It clones the domain object, only data responsible for encoding domain values is cloned. All other fields must be set separately.

Specified by:
cloneLight in class IntDomain
Returns:
It returns a clone of this domain.

putModelConstraint

public void putModelConstraint(int storeLevel,
                               Var var,
                               Constraint C,
                               int pruningEvent)
It adds a constraint to a domain, it should only be called by putConstraint function of Variable object. putConstraint function from Variable must make a copy of a vector of constraints if vector was not cloned.

Specified by:
putModelConstraint in class Domain
Parameters:
storeLevel - the level at which the model constraint is to be added.
var - variable to which the constraint is attached to.
C - the constraint which is being attached to a variable.
pruningEvent - the type of the prunning event required to check the consistency of the attached constraint.

putSearchConstraint

public void putSearchConstraint(int storeLevel,
                                Var var,
                                Constraint C)
Description copied from class: Domain
It adds a constraint to a domain, it should only be called by putConstraint function of Variable object. putConstraint function from Variable must make a copy of a list of search constraints if vector was not cloned.

Specified by:
putSearchConstraint in class Domain
Parameters:
storeLevel - the level at which the search constraint is to be added.
var - variable to which the constraint is attached to.
C - the constraint which is being attached to a variable.

removeLevel

public void removeLevel(int level,
                        Var var)
Description copied from class: Domain
It removes the specified level. This function may re-instantiate the old copy of the domain (previous value) or recover from changes done at stamp level to get the previous value at level lower at provided level.

Specified by:
removeLevel in class Domain
Parameters:
level - the level which is being removed.
var - the variable to which this domain belonged to.

removeModelConstraint

public void removeModelConstraint(int storeLevel,
                                  Var var,
                                  Constraint c)
Description copied from class: Domain
It removes a constraint from a domain, it should only be called by removeConstraint function of Variable object. It is called for example in a situation when a constraint is satisfied.

Specified by:
removeModelConstraint in class Domain
Parameters:
storeLevel - specifies the current level of the store, from which it should be removed.
var - specifies variable for which the constraint is being removed.
c - the constraint which is being removed.

removeSearchConstraint

public void removeSearchConstraint(int storeLevel,
                                   Var var,
                                   int position,
                                   Constraint C)
Description copied from class: Domain
It removes a constraint from a domain, it should only be called by removeConstraint function of Variable object.

Specified by:
removeSearchConstraint in class Domain
Parameters:
storeLevel - specifies the current level of the store, from which it should be removed.
var - specifies variable for which the constraint is being removed.
position - specifies the position of the removed constraint.
C - the constraint which is being removed.

singleton

public boolean singleton()
Description copied from class: Domain
It returns true if given domain has only one element.

Specified by:
singleton in class Domain
Returns:
true if the domain contains only one element.

sizeConstraintsOriginal

public int sizeConstraintsOriginal()
Description copied from class: Domain
It returns all constraints which are associated with variable, even the ones which are already satisfied.

Specified by:
sizeConstraintsOriginal in class Domain
Returns:
the number of constraints attached to the original domain of the variable associated with this domain.

toString

public java.lang.String toString()
Description copied from class: Domain
It returns string description of the domain (only values in the domain).

Specified by:
toString in class Domain

toStringConstraints

public java.lang.String toStringConstraints()
Description copied from class: Domain
It returns string description of the constraints attached to the domain.

Specified by:
toStringConstraints in class Domain
Returns:
the string description.

toStringFull

public java.lang.String toStringFull()
Description copied from class: Domain
It returns complete string description containing all relevant information about the domain.

Specified by:
toStringFull in class Domain
Returns:
complete description of the domain.

getRandomValue

public int getRandomValue()
Description copied from class: IntDomain
It returns a random value from the domain.

Overrides:
getRandomValue in class IntDomain
Returns:
random value.

contains

public boolean contains(int min,
                        int max)
Description copied from class: IntDomain
It checks if an interval min..max belongs to the domain.

Specified by:
contains in class IntDomain
Parameters:
min - the minimum value of the interval being checked
max - the maximum value of the interval being checked
Returns:
true if value belongs to the domain.

shift

public void shift(int shift)
It shifts the domain.

Parameters:
shift - how much should the domain be shifted.

toIntervalDomain

public IntervalDomain toIntervalDomain()