Package org.jacop.set.core
Class SetDomain
java.lang.Object
org.jacop.core.Domain
org.jacop.set.core.SetDomain
- Direct Known Subclasses:
BoundSetDomain
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 TypeFieldDescriptionstatic final int
Any event.static final int
Bound event.static final int
It specifies event that has changed the cardinality of the set.static final SetDomain
It predefines empty domain so there is no need to constantly create it when needed.(package private) static final int[][]
It specifies for each event what other events are subsumed by this event.static final int
It specifies event that GLB has grown.static final int
It specifies event that Set variable became singleton.static final int
It specifies event that LUB has shrank.static final int
It specifies the maximum element in the set domain.static final int
It specifies the minimum element in the set domain.It specifies the previous domain which was used by this domain.static final int
It specifies an unique ID for the domain.Fields inherited from class org.jacop.core.Domain
failException, modelConstraints, modelConstraintsToEvaluate, NOINFO, NONE, searchConstraints, searchConstraintsCloned, searchConstraintsToEvaluate, stamp
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
addDom
(int min, int max) Adds an interval [min..max] to the domain.abstract void
Adds a set of values to the set of possible values used within this set domain.abstract void
Adds an interval to the lub.abstract void
Adds a set domain to this set domain.abstract IntDomain
card()
Returns the cardinality of the setDomain as [glb.card(), lub.card()]abstract String
It checks if the domain has correct state.abstract void
clear()
Sets the domain to an empty SetDomain.abstract SetDomain
clone()
It clones the domain object.abstract SetDomain
It clones the domain object, only data responsible for encoding domain values is cloned.abstract boolean
contains
(int value) It checks if value belongs to the domain of the set.abstract boolean
It checks if the supplied set or setDomain is still potentially a subset of this domain.abstract boolean
It checks if the supplied set domain is a subset of this domain.abstract int
domainID()
It returns an unique identifier of the domain.abstract boolean
It checks if the domain is equal to the supplied domain.int[]
getEventsInclusion
(int pruningEvent) It helps to specify what events should be executed if a given event occurs.abstract IntDomain
glb()
It returns the least upper bound of the domain.void
It enforces that this domain is included within the specified domain.abstract void
This function is equivalent to in(int storeLevel, Variable var, int min, int max).abstract void
It updates the domain to have values only within the domain.abstract void
inCardinality
(int level, SetVar a, int i, int j) It restricts the possible cardinality of the set domain.abstract void
It adds if necessary an element to glb.abstract void
It specifies what elements must be in GLB.abstract void
It specifies what elements can be in LUB.abstract void
inLUBComplement
(int level, SetVar var, int element) It specifies the element which can *NOT* be used as an element within a set assign to a set variable.abstract SetDomain
It intersects current domain with the set of allowed values to be taken by the set domain.abstract SetDomain
It intersects current domain with the one given as a parameter.abstract void
It assigns a set variable to the specified value.abstract boolean
isEmpty()
It returns true if given domain is empty.abstract boolean
isIntersecting
(int min, int max) In intersects current domain with the interval min..max.abstract boolean
isIntersecting
(SetDomain domain) It returns true if this domain intersects with the supplied domain.abstract boolean
A set is never numericabstract boolean
A set is not sparseabstract IntDomain
lub()
It returns the least upper bound of the domain.int
It returns the number of constraintsvoid
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.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.abstract void
setDomain
(int min, int max) It sets the domain to contain any values in between min and max.abstract void
It sets the domain to the specified domain.abstract boolean
It returns true if given domain has only one set-element.abstract boolean
It check whether the set domain is singleton and its value is equal to the specified set.int
It returns all constraints which are associated with variable, even the ones which are already satisfied.abstract SetDomain
subtract
(int value) It removes the value from any set allowed to be taken by this set domain.abstract SetDomain
subtract
(int min, int max) It subtracts the set {min..max}.abstract SetDomain
It subtracts domain from current domain and returns the result.It returns string description of the constraints attached to the domain.not implemented.abstract SetDomain
union
(int value) It computes union of this domain and value.abstract SetDomain
union
(int min, int max) It computes union of this domain and the interval.abstract SetDomain
It computes union of the supplied domain with this domain.abstract ValueEnumeration
It returns value enumeration of the domain values.Methods inherited from class org.jacop.core.Domain
constraints, getSize, noSearchConstraints, searchConstraints, setStamp, singleton, sizeConstraints, stamp, toString
-
Field Details
-
MinElement
public static final int MinElementIt specifies the minimum element in the set domain. -
MaxElement
public static final int MaxElementIt specifies the maximum element in the set domain. -
SetDomainID
public static final int SetDomainIDIt specifies an unique ID for the domain.- See Also:
-
GROUND
public static final int GROUNDIt specifies event that Set variable became singleton.- See Also:
-
GLB
public static final int GLBIt specifies event that GLB has grown.- See Also:
-
LUB
public static final int LUBIt specifies event that LUB has shrank.- See Also:
-
BOUND
public static final int BOUNDBound event. Both bounds have changed.- See Also:
-
ANY
public static final int ANYAny event.- See Also:
-
CARDINALITY
public static final int CARDINALITYIt specifies event that has changed the cardinality of the set.- See Also:
-
eventsInclusion
static final int[][] eventsInclusionIt specifies for each event what other events are subsumed by this event. Possibly implement this by bit flags in int. -
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. -
emptyDomain
It predefines empty domain so there is no need to constantly create it when needed.
-
-
Constructor Details
-
SetDomain
public SetDomain()
-
-
Method Details
-
getEventsInclusion
public int[] getEventsInclusion(int pruningEvent) It helps to specify what events should be executed if a given event occurs.- Specified by:
getEventsInclusion
in classDomain
- Parameters:
pruningEvent
- the pruning event for which we want to know what events it encompasses.- Returns:
- an array specifying what events should be included given this event.
-
addDom
Adds an interval to the lub.- Parameters:
i
- The interval to be added to the lub.
-
addDom
Adds a set of values to the set of possible values used within this set domain. It changes the cardinality too to avoid cardinality constraining the domain.- Parameters:
set
- a set of values which can be taken by a set domain.
-
addDom
Adds a set domain to this set domain. This operation may add more sets than intended if for example used in the context of BoundSetDomain which can not represent arbitrary union of two sets.- Parameters:
domain
- a set domain containing information what sets are being added.
-
addDom
public abstract void addDom(int min, int max) Adds an interval [min..max] to the domain.- Parameters:
min
- min value in the setmax
- max value in the set
-
card
Returns the cardinality of the setDomain as [glb.card(), lub.card()]- Returns:
- The cardinality of the setDomain given as a boundDomain.
-
clear
public abstract void clear()Sets the domain to an empty SetDomain. -
contains
It checks if the supplied set or setDomain is still potentially a subset of this domain.- Parameters:
set
- the set for which we check the inclusion relation.- Returns:
- true, if this domain contains provided set, false otherwise.
-
contains
It checks if the supplied set domain is a subset of this domain.- Parameters:
domain
- the domain for which we check the inclusion relation.- Returns:
- true, if this domain contains provided domain, false otherwise.
-
contains
public abstract boolean contains(int value) It checks if value belongs to the domain of the set.- Parameters:
value
- value which is checked.- Returns:
- true if the value being checked can still be included in the set, false otherwise.
-
domainID
public abstract int domainID()It returns an unique identifier of the domain. -
eq
It checks if the domain is equal to the supplied domain.- Parameters:
domain
- against which the equivalence test is performed.- Returns:
- true if suppled domain has the same elements as this domain.
-
in
This function is equivalent to in(int storeLevel, Variable var, int min, int max).- Parameters:
storeLevel
- the level of the store at which the change occurrs.var
- the set variable for which the domain may change.glb
- the greatest lower bound of the domain.lub
- the least upper bound of the domain.
-
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.- 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.
-
intersect
It intersects current domain with the one given as a parameter.- Parameters:
domain
- domain with which the intersection needs to be computed.- Returns:
- the intersection between supplied domain and this domain.
-
intersect
It intersects current domain with the set of allowed values to be taken by the set domain.- Parameters:
set
- set of values which are allowed to be used within a set.- Returns:
- the intersection of this domain with the set of allowed values.
-
isEmpty
public abstract boolean isEmpty()It returns true if given domain is empty. -
isIntersecting
It returns true if this domain intersects with the supplied domain.- Parameters:
domain
- the domain against which the intersection is being checked.- Returns:
- true if the given domain intersects this domain.
-
isIntersecting
public abstract boolean isIntersecting(int min, int max) In intersects current domain with the interval min..max.- 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 abstract boolean isNumeric()A set is never numeric -
isSparseRepresentation
public abstract boolean isSparseRepresentation()A set is not sparse- Specified by:
isSparseRepresentation
in classDomain
- Returns:
- false
-
lub
It returns the least upper bound of the domain.- Returns:
- the least upper bound of the domain.
-
glb
It returns the least upper bound of the domain.- Returns:
- the least upper bound of the domain.
-
clone
It clones the domain object. -
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 classDomain
- Returns:
- return a clone of the domain. It aims at getting domain of the proper class type.
-
putModelConstraint
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 classDomain
- 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
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:
putSearchConstraint
in classDomain
- 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.
-
recentDomainPruning
It returns the values which have been removed at current store level.- 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.
-
removeLevel
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 classDomain
- Parameters:
level
- the level which is being removed.var
- the variable to which this domain belonged to.
-
removeSearchConstraint
It removes a constraint from a domain, it should only be called by removeConstraint function of Variable object.- Specified by:
removeSearchConstraint
in classDomain
- 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.
-
removeModelConstraint
It removes a constraint from a domain, it should only be called by removeConstraint function of Variable object.- Specified by:
removeModelConstraint
in classDomain
- 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.
-
setDomain
It sets the domain to the specified domain.- Parameters:
domain
- the domain from which this domain takes all elements.
-
setDomain
public abstract void setDomain(int min, int max) It sets the domain to contain any values in between min and max.- 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 abstract boolean singleton()It returns true if given domain has only one set-element. -
singleton
It check whether the set domain is singleton and its value is equal to the specified set.- Parameters:
set
- the set for which we check if it is equal to a value taken by this set domain.- Returns:
- true, if this set domain is equal to supplied set, false otherwise.
-
sizeConstraintsOriginal
public int sizeConstraintsOriginal()It returns all constraints which are associated with variable, even the ones which are already satisfied.- Specified by:
sizeConstraintsOriginal
in classDomain
- Returns:
- the number of constraints attached to the original domain of the variable associated with this domain.
-
subtract
It subtracts domain from current domain and returns the result.- Parameters:
domain
- the domain which is subtracted from this domain.- Returns:
- the result of the subtraction.
-
subtract
It subtracts the set {min..max}.- Parameters:
min
- the left bound of the set.max
- the right bound of the set.- Returns:
- the result of the subtraction.
-
subtract
It removes the value from any set allowed to be taken by this set domain.- Parameters:
value
- value which can not be used within any set value assigned to this set domain.- Returns:
- the domain which does not allow specified value to be used.
-
toStringConstraints
It returns string description of the constraints attached to the domain.- Specified by:
toStringConstraints
in classDomain
- Returns:
- the string description.
-
toStringFull
not implemented.- Specified by:
toStringFull
in classDomain
- Returns:
- complete description of the domain.
-
union
It computes union of the supplied domain with this domain.- Parameters:
domain
- the domain for which the union is computed.- Returns:
- the union of this domain with the supplied one.
-
union
It computes union of this domain and the interval.- 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
It computes union of this domain and value.- Parameters:
value
- it specifies the value which is being added.- Returns:
- domain which is a union of this one and the value.
-
valueEnumeration
It returns value enumeration of the domain values.- Specified by:
valueEnumeration
in classDomain
- 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 classDomain
- Returns:
- It returns the information about the first invariant which does not hold or null otherwise.
-
in
Description copied from class:Domain
It enforces that this domain is included within the specified domain. -
inLUB
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.- Parameters:
level
- level of the store at which this restriction takes place.var
- variable which domain is being restricted.domain
- the domain specifying the allowed values the domain of the set variable.
-
inLUBComplement
It specifies the element which can *NOT* be used as an element within a set assign to a set variable.- Parameters:
level
- level of the store at which this restriction takes place.var
- variable which domain is being restricted.element
- the value being removed from the domain of the set variable.
-
inGLB
It specifies what elements must be in GLB. It will add new elements if they are not already in GLB.- Parameters:
level
- level of the store at which this addition takes place.var
- variable which domain is being restricted.domain
- the domain specifying the required values of the set variable.
-
inGLB
It adds if necessary an element to glb.- 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.
-
inValue
It assigns a set variable to the specified value.- 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.
-
noConstraints
public int noConstraints()It returns the number of constraints- Specified by:
noConstraints
in classDomain
- Returns:
- the number of constraints attached to this domain.
-
inCardinality
It restricts the possible cardinality of the set domain.- Parameters:
level
- level of the store at which the restriction takes place.a
- the variable which domain is being restricted.i
- the minimal allowed cardinalityj
- the maximal allowed cardinality
-