JaCoP.set.core
Class BoundSetDomain

java.lang.Object
  extended by JaCoP.core.Domain
      extended by JaCoP.set.core.SetDomain
          extended by JaCoP.set.core.BoundSetDomain

public class BoundSetDomain
extends SetDomain

Defines a set interval determined by a least upper bound(lub) and a greatest lower bound(glb). The domain consist of zero, one or several sets.

Version:
3.1
Author:
Radoslaw Szymanek, Krzysztof Kuchcinski and Robert Ã…kemalm

Field Summary
 IntDomain cardinality
          The cardinality of the set.
 IntDomain glb
          The greatest lower bound of the domain.
 IntDomain lub
          The least upper bound of the domain.
static java.lang.String[] xmlAttributes
          It specifies the arguments required to be saved by an XML format as well as the constructor being called to recreate an object from an XML format.
 
Fields inherited from class JaCoP.set.core.SetDomain
ANY, BOUND, CARDINALITY, emptyDomain, eventsInclusion, GLB, GROUND, LUB, previousDomain, SetDomainID
 
Fields inherited from class JaCoP.core.Domain
modelConstraints, modelConstraintsToEvaluate, NOINFO, NONE, searchConstraints, searchConstraintsCloned, searchConstraintsToEvaluate, stamp
 
Constructor Summary
BoundSetDomain()
          It is a constructor which will create an empty SetDomain.
BoundSetDomain(IntDomain glb, IntDomain lub)
          Creates a new instance of SetDomain.
BoundSetDomain(IntDomain glb, IntDomain lub, IntDomain cardinality)
          Creates BoundSetDomain object.
BoundSetDomain(int e1, int e2)
          It creates a new instance of SetDomain with glb empty and lub={e1..e2}
 
Method Summary
 void addDom(IntDomain set)
          Adds a set of value to the possible values used within this set domain.
 void addDom(Interval i)
          Adds an interval to the lub.
 void addDom(int min, int max)
          Adds an interval [min..max] to the domain.
 void addDom(SetDomain domain)
          Adds a set to the domain.
 IntDomain card()
          Returns the cardinality of the setDomain as [glb.card(), lub.card()]
 java.lang.String checkInvariants()
          It checks if the domain has correct state.
 void clear()
          Sets the domain to an empty SetDomain.
 SetDomain clone()
          Clones the domain.
 SetDomain cloneLight()
          It clones the domain object, only data responsible for encoding domain values is cloned.
 SetDomain complement()
          It creates a complement of a domain.
 boolean contains(int value)
          It checks if value belongs to the domain.
 boolean contains(IntDomain set)
          It checks if the supplied set or setDomain is a subset of this domain.
 boolean contains(SetDomain domain)
          It checks if the supplied set domain is a subset of this domain.
 int domainID()
          It returns an unique identifier of the domain.
 boolean eq(SetDomain domain)
          It checks if the domain is equal to the supplied domain.
 int getSize()
          Returns the number of elements in the domain.
 IntDomain glb()
          It returns the greatest lower bound of the domain.
 void in(int storeLevel, SetVar var, IntDomain inGLB, IntDomain inLUB)
          This function is equivalent to in(int storeLevel, Variable var, int min, int max).
 void in(int storeLevel, SetVar var, SetDomain setDom)
          It updates the domain to have values only within the domain.
 void inCardinality(int level, SetVar var, int min, int max)
          It restricts the possible cardinality of the set domain.
 void inGLB(int level, SetVar var, int element)
          It adds if necessary an element to glb.
 void inGLB(int level, SetVar var, IntDomain intersect)
          It specifies what elements must be in GLB.
 void inLUB(int level, SetVar var, IntDomain intersect)
          It specifies what elements can be in LUB.
 void inLUBComplement(int level, SetVar var, int element)
          It removes if necessary an element from lub.
 SetDomain intersect(IntDomain domain)
          It intersects current domain with the one given as a parameter.
 SetDomain intersect(SetDomain domain)
          It intersects current domain with the one given as a parameter.
 void inValue(int level, SetVar var, IntDomain set)
          It assigns a set variable to the specified value.
 void inValueGLB(int level, SetVar var)
          It assigns a set variable to glb of its current domain.
 void inValueLUB(int level, SetVar var)
          It assigns a set variable to lub of its current domain.
 boolean isEmpty()
          It returns true if given domain is empty.
 boolean isIntersecting(int min, int max)
          In intersects current domain with the interval min..max.
 boolean isIntersecting(SetDomain domain)
          It returns true if given domain intersects this domain.
 boolean isNumeric()
          A set is never numeric
 boolean isSparseRepresentation()
          A set is not sparse
 IntDomain lub()
          It returns the least upper bound of the domain.
 void setDomain(int min, int max)
          It sets the domain to the the set {min..max}.
 void setDomain(SetDomain domain)
          It sets the domain to the specified domain.
 boolean singleton()
          It returns true if given domain has only one set-element.
 boolean singleton(Domain value)
          It returns true if given domain has only one element.
 boolean singleton(IntDomain set)
          It returns true if given domain has only one set-element and this set-element only contains c.
 SetDomain subtract(int value)
          It subtracts the set {value}.
 SetDomain subtract(int min, int max)
          It subtracts the elements of the set {min..max}.
 SetDomain subtract(SetDomain domain)
          It subtracts domain from current domain and returns the result.
 java.lang.String toString()
          It returns string description of the domain.
 SetDomain union(int value)
          It computes union of this domain and value.
 SetDomain union(int min, int max)
          It computes union of this domain and the interval.
 SetDomain union(SetDomain domain)
          It computes union of the supplied domain with this domain.
 ValueEnumeration valueEnumeration()
          It returns value enumeration of the domain values.
 
Methods inherited from class JaCoP.set.core.SetDomain
getEventsInclusion, in, noConstraints, putModelConstraint, putSearchConstraint, recentDomainPruning, removeLevel, removeModelConstraint, removeSearchConstraint, sizeConstraintsOriginal, toStringConstraints, toStringFull
 
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

glb

public IntDomain glb
The greatest lower bound of the domain.


lub

public IntDomain lub
The least upper bound of the domain.


cardinality

public IntDomain cardinality
The cardinality of the set.


xmlAttributes

public static java.lang.String[] xmlAttributes
It specifies the arguments required to be saved by an XML format as well as the constructor being called to recreate an object from an XML format.

Constructor Detail

BoundSetDomain

public BoundSetDomain(IntDomain glb,
                      IntDomain lub,
                      IntDomain cardinality)
Creates BoundSetDomain object. It requires glb to be a subset of lub.

Parameters:
glb - it specifies the left bound of the SetDomain (inclusive).
lub - it specifies the right bound of the setDomain (inclusive).
cardinality - it specifies the allowed cardinality of the assigned set.

BoundSetDomain

public BoundSetDomain(IntDomain glb,
                      IntDomain lub)
Creates a new instance of SetDomain. It requires glb to be a subset of lub.

Parameters:
glb - it specifies the left bound of the SetDomain (inclusive).
lub - it specifies the right bound of the setDomain (inclusive).

BoundSetDomain

public BoundSetDomain()
It is a constructor which will create an empty SetDomain. An empty SetDomain has a glb and a lub that is empty.


BoundSetDomain

public BoundSetDomain(int e1,
                      int e2)
It creates a new instance of SetDomain with glb empty and lub={e1..e2}

Parameters:
e1 - the minimum element of lub.
e2 - the maximum element of lub.
Method Detail

addDom

public void addDom(IntDomain set)
Adds a set of value to the possible values used within this set domain. It changes the cardinality too to avoid cardinality constraining the domain.

Specified by:
addDom in class SetDomain
Parameters:
set - a set of values which can be taken by a set domain.

addDom

public void addDom(SetDomain domain)
Adds a set to the domain.

Specified by:
addDom in class SetDomain
Parameters:
domain - a set domain containing information what sets are being added.

addDom

public void addDom(int min,
                   int max)
Adds an interval [min..max] to the domain.

Specified by:
addDom in class SetDomain
Parameters:
min - min value in the set
max - max value in the set

card

public IntDomain card()
Returns the cardinality of the setDomain as [glb.card(), lub.card()]

Specified by:
card in class SetDomain
Returns:
The cardinality of the setDomain given as a boundDomain.

clear

public void clear()
Sets the domain to an empty SetDomain.

Specified by:
clear in class SetDomain

clone

public SetDomain clone()
Clones the domain.

Specified by:
clone in class Domain

cloneLight

public SetDomain 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 SetDomain
Returns:
return a clone of the domain. It aims at getting domain of the proper class type.

complement

public SetDomain complement()
It creates a complement of a domain.

Returns:
it returns the complement of this domain.

contains

public boolean contains(IntDomain set)
It checks if the supplied set or setDomain is a subset of this domain.

Specified by:
contains in class SetDomain
Parameters:
set - the set for which we check the inclusion relation.
Returns:
true, if this domain contains provided set, false otherwise.

contains

public boolean contains(SetDomain domain)
Description copied from class: SetDomain
It checks if the supplied set domain is a subset of this domain.

Specified by:
contains in class SetDomain
Parameters:
domain - the domain for which we check the inclusion relation.
Returns:
true, if this domain contains provided domain, false otherwise.

contains

public boolean contains(int value)
It checks if value belongs to the domain.

Specified by:
contains in class SetDomain
Parameters:
value - value which is checked.
Returns:
true if the value being checked can still be included in the set, false otherwise.

domainID

public int domainID()
It returns an unique identifier of the domain.

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

eq

public boolean eq(SetDomain domain)
It checks if the domain is equal to the supplied domain.

Specified by:
eq in class SetDomain
Parameters:
domain - against which the equivalence test is performed.
Returns:
true if suppled domain has the same elements as this domain.

getSize

public int getSize()
Returns the number of elements in the domain.

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

glb

public IntDomain glb()
It returns the greatest lower bound of the domain.

Specified by:
glb in class SetDomain
Returns:
the greatest lower bound of the domain.

in

public void in(int storeLevel,
               SetVar var,
               IntDomain inGLB,
               IntDomain inLUB)
This function is equivalent to in(int storeLevel, Variable var, int min, int max).

Specified by:
in in class SetDomain
Parameters:
storeLevel - the level of the store at which the change occurrs.
var - the set variable for which the domain may change.
inGLB - the greatest lower bound of the domain.
inLUB - the least upper bound of the domain.

in

public void in(int storeLevel,
               SetVar var,
               SetDomain setDom)
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.

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

intersect

public SetDomain intersect(SetDomain domain)
It intersects current domain with the one given as a parameter.

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

intersect

public SetDomain intersect(IntDomain domain)
It intersects current domain with the one given as a parameter.

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

isEmpty

public boolean isEmpty()
It returns true if given domain is empty.

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

isIntersecting

public boolean isIntersecting(SetDomain domain)
It returns true if given domain intersects this domain.

Specified by:
isIntersecting in class SetDomain
Parameters:
domain - the domain against which the intersection is being checked.
Returns:
true if the given domain intersects this domain.

isIntersecting

public boolean isIntersecting(int min,
                              int max)
In intersects current domain with the interval min..max.

Specified by:
isIntersecting in class SetDomain
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.

isNumeric

public boolean isNumeric()
A set is never numeric

Specified by:
isNumeric in class SetDomain
Returns:
false

isSparseRepresentation

public boolean isSparseRepresentation()
A set is not sparse

Specified by:
isSparseRepresentation in class SetDomain
Returns:
false

lub

public IntDomain lub()
It returns the least upper bound of the domain.

Specified by:
lub in class SetDomain
Returns:
the least upper bound of the domain.

setDomain

public void setDomain(SetDomain domain)
It sets the domain to the specified domain.

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

setDomain

public void setDomain(int min,
                      int max)
It sets the domain to the the set {min..max}. It grounds it. FIXME should it be grounded?

Specified by:
setDomain in class SetDomain
Parameters:
min - the minimum value allowed to be taken within the set.
max - the maximal value allowed to be taken within the set.

singleton

public boolean singleton()
It returns true if given domain has only one set-element.

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

singleton

public boolean singleton(IntDomain set)
It returns true if given domain has only one set-element and this set-element only contains c.

Specified by:
singleton in class SetDomain
Parameters:
set - the set for which we check if it is equal to a value taken by this set domain.
Returns:
true if the domain contains only one set-element and this set-element only contains c.

subtract

public SetDomain subtract(SetDomain domain)
It subtracts domain from current domain and returns the result.

Specified by:
subtract in class SetDomain
Parameters:
domain - the domain which is subtracted from this domain.
Returns:
the result of the subtraction.

subtract

public SetDomain subtract(int min,
                          int max)
It subtracts the elements of the set {min..max}.

Specified by:
subtract in class SetDomain
Parameters:
min - the left bound of the set.
max - the right bound of the set.
Returns:
the domain after removing the int elements specified by the set.

subtract

public SetDomain subtract(int value)
It subtracts the set {value}. FIXME, it does not subtract set {value}, it subtracts value from the set domain.

Specified by:
subtract in class SetDomain
Parameters:
value - value which can not be used within any set value assigned to this set domain.
Returns:
the result of the subtraction.

toString

public java.lang.String toString()
It returns string description of the domain.

Specified by:
toString in class Domain

union

public SetDomain union(SetDomain domain)
It computes union of the supplied domain with this domain.

Specified by:
union in class SetDomain
Parameters:
domain - the domain for which the union is computed.
Returns:
the union of this domain with the supplied one.

union

public SetDomain union(int min,
                       int max)
It computes union of this domain and the interval.

Specified by:
union in class SetDomain
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 SetDomain union(int value)
It computes union of this domain and value.

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

valueEnumeration

public ValueEnumeration valueEnumeration()
It returns value enumeration of the domain values.

Specified by:
valueEnumeration in class SetDomain
Returns:
valueEnumeration which can be used to enumerate the sets of this domain one by one.

checkInvariants

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

Specified by:
checkInvariants in class SetDomain
Returns:
It returns the information about the first invariant which does not hold or null otherwise.

inGLB

public void inGLB(int level,
                  SetVar var,
                  int element)
It adds if necessary an element to glb.

Specified by:
inGLB in class SetDomain
Parameters:
level - level at which the change is recorded.
var - set variable to which the change applies to.
element - the element which must be in glb.

inLUBComplement

public void inLUBComplement(int level,
                            SetVar var,
                            int element)
It removes if necessary an element from lub.

Specified by:
inLUBComplement in class SetDomain
Parameters:
level - level at which the change is recorded.
var - set variable to which the change applies to.
element - the element which can not be in lub.

inValue

public void inValue(int level,
                    SetVar var,
                    IntDomain set)
Description copied from class: SetDomain
It assigns a set variable to the specified value.

Specified by:
inValue in class SetDomain
Parameters:
level - level at which the change is recorded.
var - set variable to which the change applies to.
set - the value assigned to a set variable.

singleton

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

Specified by:
singleton in class Domain
Parameters:
value - value represented as domain object to which the domain must be equal to.
Returns:
true if the domain contains only one element.

inLUB

public void inLUB(int level,
                  SetVar var,
                  IntDomain intersect)
Description copied from class: SetDomain
It specifies what elements can be in LUB. It will not add any new elements only removed the elements currently in LUB but not permitted by the argument domain.

Specified by:
inLUB in class SetDomain
Parameters:
level - level of the store at which this restriction takes place.
var - variable which domain is being restricted.
intersect - the domain specifying the allowed values the domain of the set variable.

inValueLUB

public void inValueLUB(int level,
                       SetVar var)
It assigns a set variable to lub of its current domain.

Parameters:
level - level of the store at which the change takes place.
var - variable for which the domain is changing.

inGLB

public void inGLB(int level,
                  SetVar var,
                  IntDomain intersect)
Description copied from class: SetDomain
It specifies what elements must be in GLB. It will add new elements if they are not already in GLB.

Specified by:
inGLB in class SetDomain
Parameters:
level - level of the store at which this addition takes place.
var - variable which domain is being restricted.
intersect - the domain specifying the required values of the set variable.

inValueGLB

public void inValueGLB(int level,
                       SetVar var)
It assigns a set variable to glb of its current domain.

Parameters:
level - level of the store at which the change takes place.
var - variable for which the domain is changing.

addDom

public void addDom(Interval i)
Description copied from class: SetDomain
Adds an interval to the lub.

Specified by:
addDom in class SetDomain
Parameters:
i - The interval to be added to the lub.

inCardinality

public void inCardinality(int level,
                          SetVar var,
                          int min,
                          int max)
Description copied from class: SetDomain
It restricts the possible cardinality of the set domain.

Specified by:
inCardinality in class SetDomain
Parameters:
level - level of the store at which the restriction takes place.
var - the variable which domain is being restricted.
min - the minimal allowed cardinality
max - the maximal allowed cardinality