- All Superinterfaces:
ConcreteVar,CPVar,Var
- All Known Implementing Classes:
CPFixedSetVar,CPSetVarImpl
A set variable is a variable that represents a set of integers from an original universe set.
Its domain is conceptually represented by:
- a set of included integers I
- a set of possible integers P
- a set of excluded integers S
I,P and S are disjoint sets and their union is the universe of the set variable.
In addition, a cardinality variable represents the cardinality of the set
The variable is considered fixed when the set of possible integers is empty.
At this point, the cardinality variable is equal to the size of the set of included integers.
-
Method Summary
Modifier and TypeMethodDescriptioncard()Returns a variable that represents the cardinality of the set.voidexclude(int v) Excludes a value from the set.voidExcludes all the possible values from the set.intfillExcluded(int[] dest) Copies the values (in an arbitrary order) of the set of excluded elements into an array.intfillIncluded(int[] dest) Copies the values (in an arbitrary order) of the set of included elements into an array.intfillPossible(int[] dest) Copies the values (in an arbitrary order) of the set of possible elements into an array.Returns the solver of the set variable.voidinclude(int v) Includes a value in the set.voidIncludes all the possible values in the set.booleanisExcluded(int v) Returns if a value is excluded from the set.booleanisFixed()Returns if the set variable is fixed.booleanisIncluded(int v) Returns if a value is included in the set.booleanisPossible(int v) Returns if a value is possible in the set.intReturns the size of the set of excluded elementsintReturns the size of the set of included elementsintReturns the size of the set of possible elementsvoidAsk that theCPConstraint.propagate()method of the constraint c is called when the domain of the set variable changes (I,P or E).intsize()
-
Method Details
-
card
CPIntVar card()Returns a variable that represents the cardinality of the set.- Returns:
- the cardinality variable
-
isFixed
boolean isFixed()Returns if the set variable is fixed. -
nIncluded
int nIncluded()Returns the size of the set of included elements- Returns:
- the size of the set of included elements
-
nPossible
int nPossible()Returns the size of the set of possible elements- Returns:
- the size of the set of possible elements
-
nExcluded
int nExcluded()Returns the size of the set of excluded elements- Returns:
- the size of the set of excluded elements
-
isIncluded
boolean isIncluded(int v) Returns if a value is included in the set.- Parameters:
v- the value to check- Returns:
- true if the value is included, false otherwise
-
isPossible
boolean isPossible(int v) Returns if a value is possible in the set.- Parameters:
v- the value to check- Returns:
- true if the value is possible, false otherwise
-
isExcluded
boolean isExcluded(int v) Returns if a value is excluded from the set.- Parameters:
v- the value to check- Returns:
- true if the value is excluded, false otherwise
-
include
void include(int v) Includes a value in the set.- Parameters:
v- the value to include, it must be a possible value from the universe otherwise an exception is thrown. The method has no effect if the value is already included.
-
exclude
void exclude(int v) Excludes a value from the set.- Parameters:
v- the value to exclude, it must be a possible value from the universe otherwise an exception is thrown The method has no effect if the value is already excluded.
-
includeAll
void includeAll()Includes all the possible values in the set. -
excludeAll
void excludeAll()Excludes all the possible values from the set. -
fillIncluded
int fillIncluded(int[] dest) Copies the values (in an arbitrary order) of the set of included elements into an array.- Parameters:
dest- an array large enoughdest.length >= nIncluded()- Returns:
- the size of the set of included elements
-
fillPossible
int fillPossible(int[] dest) Copies the values (in an arbitrary order) of the set of possible elements into an array.- Parameters:
dest- an array large enoughdest.length >= nPossible()- Returns:
- the size of the set of possible elements
-
fillExcluded
int fillExcluded(int[] dest) Copies the values (in an arbitrary order) of the set of excluded elements into an array.- Parameters:
dest- an array large enoughdest.length >= nExcluded()- Returns:
- the size of the set of excluded elements
-
size
int size() -
propagateOnDomainChange
Ask that theCPConstraint.propagate()method of the constraint c is called when the domain of the set variable changes (I,P or E). If intererested also in the change of the cardinality variable, callCPIntVar.propagateOnBoundChange(CPConstraint)on the cardinality variable.- Parameters:
c- the constraint to notify
-
getSolver
CPSolver getSolver()Returns the solver of the set variable.- Returns:
- the solver of the set variable
-
getModelProxy
ModelProxy getModelProxy()- Specified by:
getModelProxyin interfaceVar
-