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:
java.lang.Cloneable
public class BoundSetDomain extends SetDomain implements java.lang.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.8
-
-
Field Summary
Fields Modifier and Type Field Description 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.-
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
Constructors Constructor Description BoundSetDomain()
It 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDom(int min, int max)
Adds an interval [min..max] to the domain.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(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 numericboolean
isSparseRepresentation()
A set is not sparseIntDomain
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 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
-
-
-
-
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.
-
addDom
public void addDom(SetDomain domain)
Adds a set to the domain.
-
addDom
public void addDom(int min, int max)
Adds an interval [min..max] to the domain.
-
card
public IntDomain card()
Returns the cardinality of the setDomain as [glb.card(), lub.card()]
-
clear
public void clear()
Sets the domain to an empty SetDomain.
-
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 classSetDomain
- 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.
-
contains
public boolean contains(SetDomain domain)
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
public boolean eq(SetDomain domain)
It checks if the domain is equal to the supplied domain.
-
getSize
public int getSize()
Returns the number of elements in the domain.
-
glb
public IntDomain glb()
It 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).
-
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.
-
intersect
public SetDomain intersect(SetDomain domain)
It intersects current domain with the one given as a parameter.
-
intersect
public SetDomain intersect(IntDomain domain)
It intersects current domain with the one given as a parameter.
-
isEmpty
public boolean isEmpty()
It returns true if given domain is empty.
-
isIntersecting
public boolean isIntersecting(SetDomain domain)
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
public IntDomain lub()
It returns the least upper bound of the domain.
-
setDomain
public void setDomain(SetDomain domain)
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
public boolean singleton(IntDomain set)
It returns true if given domain has 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.
-
subtract
public SetDomain subtract(int min, int max)
It subtracts the elements of the set {min..max}.
-
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.
-
toString
public java.lang.String toString()
It returns string description of the domain.
-
union
public SetDomain union(SetDomain domain)
It computes union of the supplied domain with this domain.
-
union
public SetDomain union(int min, int max)
It computes union of this domain and the interval.
-
union
public SetDomain union(int value)
It computes union of this domain and value.
-
valueEnumeration
public ValueEnumeration 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
public java.lang.String 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
public void inGLB(int level, SetVar var, int element)
It adds if necessary an element to glb.
-
inLUBComplement
public void inLUBComplement(int level, SetVar var, int element)
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
public void inValue(int level, SetVar var, IntDomain set)
Description copied from class:SetDomain
It assigns a set variable to the specified value.
-
singleton
public boolean singleton(Domain value)
Description copied from class:Domain
It returns true if given domain has 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.
-
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.
-
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.
-
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 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
-
-