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 IntDomaincardinalityThe cardinality of the set.IntDomainglbThe greatest lower bound of the domain.IntDomainlubThe 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 voidaddDom(int min, int max)Adds an interval [min..max] to the domain.voidaddDom(IntDomain set)Adds a set of value to the possible values used within this set domain.voidaddDom(Interval i)Adds an interval to the lub.voidaddDom(SetDomain domain)Adds a set to the domain.IntDomaincard()Returns the cardinality of the setDomain as [glb.card(), lub.card()]java.lang.StringcheckInvariants()It checks if the domain has correct state.voidclear()Sets the domain to an empty SetDomain.SetDomainclone()Clones the domain.SetDomaincloneLight()It clones the domain object, only data responsible for encoding domain values is cloned.SetDomaincomplement()It creates a complement of a domain.booleancontains(int value)It checks if value belongs to the domain.booleancontains(IntDomain set)It checks if the supplied set or setDomain is a subset of this domain.booleancontains(SetDomain domain)It checks if the supplied set domain is a subset of this domain.intdomainID()It returns an unique identifier of the domain.booleaneq(SetDomain domain)It checks if the domain is equal to the supplied domain.intgetSize()Returns the number of elements in the domain.IntDomainglb()It returns the greatest lower bound of the domain.voidin(int storeLevel, SetVar var, IntDomain inGLB, IntDomain inLUB)This function is equivalent to in(int storeLevel, Variable var, int min, int max).voidin(int storeLevel, SetVar var, SetDomain setDom)It updates the domain to have values only within the domain.voidinCardinality(int level, SetVar var, int min, int max)It restricts the possible cardinality of the set domain.voidinGLB(int level, SetVar var, int element)It adds if necessary an element to glb.voidinGLB(int level, SetVar var, IntDomain intersect)It specifies what elements must be in GLB.voidinLUB(int level, SetVar var, IntDomain intersect)It specifies what elements can be in LUB.voidinLUBComplement(int level, SetVar var, int element)It removes if necessary an element from lub.SetDomainintersect(IntDomain domain)It intersects current domain with the one given as a parameter.SetDomainintersect(SetDomain domain)It intersects current domain with the one given as a parameter.voidinValue(int level, SetVar var, IntDomain set)It assigns a set variable to the specified value.voidinValueGLB(int level, SetVar var)It assigns a set variable to glb of its current domain.voidinValueLUB(int level, SetVar var)It assigns a set variable to lub of its current domain.booleanisEmpty()It returns true if given domain is empty.booleanisIntersecting(int min, int max)In intersects current domain with the interval min..max.booleanisIntersecting(SetDomain domain)It returns true if given domain intersects this domain.booleanisNumeric()A set is never numericbooleanisSparseRepresentation()A set is not sparseIntDomainlub()It returns the least upper bound of the domain.voidsetDomain(int min, int max)It sets the domain to the the set {min..max}.voidsetDomain(SetDomain domain)It sets the domain to the specified domain.booleansingleton()It returns true if given domain has only one set-element.booleansingleton(Domain value)It returns true if given domain has only one element.booleansingleton(IntDomain set)It returns true if given domain has only one set-element and this set-element only contains c.SetDomainsubtract(int value)It subtracts the set {value}.SetDomainsubtract(int min, int max)It subtracts the elements of the set {min..max}.SetDomainsubtract(SetDomain domain)It subtracts domain from current domain and returns the result.java.lang.StringtoString()It returns string description of the domain.SetDomainunion(int value)It computes union of this domain and value.SetDomainunion(int min, int max)It computes union of this domain and the interval.SetDomainunion(SetDomain domain)It computes union of the supplied domain with this domain.ValueEnumerationvalueEnumeration()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:
cloneLightin 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:SetDomainIt 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:
isIntersectingin 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:
isIntersectingin 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:
isSparseRepresentationin 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:
valueEnumerationin 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:DomainIt checks if the domain has correct state.- Specified by:
checkInvariantsin 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:
inLUBComplementin 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:SetDomainIt assigns a set variable to the specified value.
-
singleton
public boolean singleton(Domain value)
Description copied from class:DomainIt returns true if given domain has only one element.
-
inLUB
public void inLUB(int level, SetVar var, IntDomain intersect)Description copied from class:SetDomainIt 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:SetDomainIt 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:SetDomainAdds an interval to the lub.
-
inCardinality
public void inCardinality(int level, SetVar var, int min, int max)Description copied from class:SetDomainIt restricts the possible cardinality of the set domain.- Specified by:
inCardinalityin 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
-
-