Package org.jacop.set.core
Class BoundSetDomain
java.lang.Object
org.jacop.core.Domain
org.jacop.set.core.SetDomain
org.jacop.set.core.BoundSetDomain
- All Implemented Interfaces:
Cloneable
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:
- 4.10
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe cardinality of the set.The greatest lower bound of the domain.The least upper bound of the domain.Fields inherited from class org.jacop.set.core.SetDomain
ANY, BOUND, CARDINALITY, emptyDomain, eventsInclusion, GLB, GROUND, LUB, MaxElement, MinElement, previousDomain, SetDomainID
Fields inherited from class org.jacop.core.Domain
failException, modelConstraints, modelConstraintsToEvaluate, NOINFO, NONE, searchConstraints, searchConstraintsCloned, searchConstraintsToEvaluate, stamp
-
Constructor Summary
ConstructorsConstructorDescriptionIt is a constructor which will create an empty SetDomain.BoundSetDomain
(int e1, int e2) It creates a new instance of SetDomain with glb empty and lub={e1..e2}BoundSetDomain
(IntDomain glb, IntDomain lub) Creates a new instance of SetDomain.BoundSetDomain
(IntDomain glb, IntDomain lub, IntDomain cardinality) Creates BoundSetDomain object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDom
(int min, int max) Adds an interval [min..max] to the domain.void
Adds a set of value to the possible values used within this set domain.void
Adds an interval to the lub.void
Adds a set to the domain.card()
Returns the cardinality of the setDomain as [glb.card(), lub.card()]It checks if the domain has correct state.void
clear()
Sets the domain to an empty SetDomain.clone()
Clones the domain.It clones the domain object, only data responsible for encoding domain values is cloned.It creates a complement of a domain.boolean
contains
(int value) It checks if value belongs to the domain.boolean
It checks if the supplied set or setDomain is a subset of this domain.boolean
It checks if the supplied set domain is a subset of this domain.int
domainID()
It returns an unique identifier of the domain.boolean
It checks if the domain is equal to the supplied domain.int
getSize()
Returns the number of elements in the domain.glb()
It returns the greatest lower bound of the domain.void
This function is equivalent to in(int storeLevel, Variable var, int min, int max).void
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
It adds if necessary an element to glb.void
It specifies what elements must be in GLB.void
It specifies what elements can be in LUB.void
inLUBComplement
(int level, SetVar var, int element) It removes if necessary an element from lub.It intersects current domain with the one given as a parameter.It intersects current domain with the one given as a parameter.void
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
A set is never numericboolean
A set is not sparselub()
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
It sets the domain to the specified domain.boolean
It returns true if given domain has only one set-element.boolean
It returns true if given domain has only one element.boolean
It returns true if given domain has only one set-element and this set-element only contains c.subtract
(int value) It subtracts the set {value}.subtract
(int min, int max) It subtracts the elements of the set {min..max}.It subtracts domain from current domain and returns the result.toString()
It returns string description of the domain.union
(int value) It computes union of this domain and value.union
(int min, int max) It computes union of this domain and the interval.It computes union of the supplied domain with this domain.It returns value enumeration of the domain values.Methods inherited from class org.jacop.set.core.SetDomain
getEventsInclusion, in, noConstraints, putModelConstraint, putSearchConstraint, recentDomainPruning, removeLevel, removeModelConstraint, removeSearchConstraint, sizeConstraintsOriginal, toStringConstraints, toStringFull
Methods inherited from class org.jacop.core.Domain
constraints, noSearchConstraints, searchConstraints, setStamp, sizeConstraints, stamp
-
Field Details
-
glb
The greatest lower bound of the domain. -
lub
The least upper bound of the domain. -
cardinality
The cardinality of the set.
-
-
Constructor Details
-
BoundSetDomain
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
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 Details
-
addDom
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. -
addDom
Adds a set to the domain. -
addDom
public void addDom(int min, int max) Adds an interval [min..max] to the domain. -
card
Returns the cardinality of the setDomain as [glb.card(), lub.card()] -
clear
public void clear()Sets the domain to an empty SetDomain. -
clone
Clones the domain. -
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 classSetDomain
- Returns:
- return a clone of the domain. It aims at getting domain of the proper class type.
-
complement
It creates a complement of a domain.- Returns:
- it returns the complement of this domain.
-
contains
It checks if the supplied set or setDomain is a subset of this domain. -
contains
Description copied from class:SetDomain
It checks if the supplied set domain is a subset of this domain. -
contains
public boolean contains(int value) It checks if value belongs to the domain. -
domainID
public int domainID()It returns an unique identifier of the domain. -
eq
It checks if the domain is equal to the supplied domain. -
getSize
public int getSize()Returns the number of elements in the domain. -
glb
It returns the greatest lower bound of the domain. -
in
This function is equivalent to in(int storeLevel, Variable var, int min, int max). -
in
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. -
intersect
It intersects current domain with the one given as a parameter. -
intersect
It intersects current domain with the one given as a parameter. -
isEmpty
public boolean isEmpty()It returns true if given domain is empty. -
isIntersecting
It returns true if given domain intersects this domain.- Specified by:
isIntersecting
in classSetDomain
- 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 classSetDomain
- 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 -
isSparseRepresentation
public boolean isSparseRepresentation()A set is not sparse- Specified by:
isSparseRepresentation
in classSetDomain
- Returns:
- false
-
lub
It returns the least upper bound of the domain. -
setDomain
It sets the domain to the specified domain. -
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? -
singleton
public boolean singleton()It returns true if given domain has only one set-element. -
singleton
It returns true if given domain has only one set-element and this set-element only contains c. -
subtract
It subtracts domain from current domain and returns the result. -
subtract
It subtracts the elements of the set {min..max}. -
subtract
It subtracts the set {value}. FIXME, it does not subtract set {value}, it subtracts value from the set domain. -
toString
It returns string description of the domain. -
union
It computes union of the supplied domain with this domain. -
union
It computes union of this domain and the interval. -
union
It computes union of this domain and value. -
valueEnumeration
It returns value enumeration of the domain values.- Specified by:
valueEnumeration
in classSetDomain
- Returns:
- valueEnumeration which can be used to enumerate the sets of this domain one by one.
-
checkInvariants
Description copied from class:Domain
It checks if the domain has correct state.- Specified by:
checkInvariants
in classSetDomain
- Returns:
- It returns the information about the first invariant which does not hold or null otherwise.
-
inGLB
It adds if necessary an element to glb. -
inLUBComplement
It removes if necessary an element from lub.- Specified by:
inLUBComplement
in classSetDomain
- 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
Description copied from class:SetDomain
It assigns a set variable to the specified value. -
singleton
Description copied from class:Domain
It returns true if given domain has only one element. -
inLUB
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. -
inValueLUB
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
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. -
inValueGLB
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
Description copied from class:SetDomain
Adds an interval to the lub. -
inCardinality
Description copied from class:SetDomain
It restricts the possible cardinality of the set domain.- Specified by:
inCardinality
in classSetDomain
- Parameters:
level
- level of the store at which the restriction takes place.var
- the variable which domain is being restricted.min
- the minimal allowed cardinalitymax
- the maximal allowed cardinality
-