Package org.chocosolver.solver.variables
Interface SetVar
-
- All Superinterfaces:
Comparable<Variable>,Identity,Variable
- All Known Implementing Classes:
SetVarImpl
public interface SetVar extends Variable
A Set Variable is defined by a domain which is a set interval [LB,UB], where: LB is the set of integers that must belong to every single solution. UB is the set of integers that may belong to at least one solution. One must notice that in this context, a VALUE of the variable is a set of integers.- Since:
- 15 nov. 2012 Major update 2016
- Author:
- Charles Prud'homme, Jean-Guillaume Fages
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description booleanforce(int element, ICause cause)Adds element to the lower bound, i.e. every solution must includeelementIntVargetCard()get the constrained cardinality variable of this set.ISetgetLB()Get SetVar Lower Bound : the set of integers that must belong to every solution (i.e. a subset of all solutions) To iterate over this set, use the following loop: ISet lbSet = getLB(); for(int i : lbSet){ ... } This object is read-only.ISetgetUB()Get SetVar Upper Bound : the set of integers that may belong to a solution (i.e. a superset of all solutions) To iterate over this set, use the following loop: ISet ubSet = getUB(); for(int i : ubSet){ ... } This object is read-only.default ISetgetValue()Retrieves the current value of the variable if instantiated, otherwise the lower bound (kernel).booleanhasCard()booleaninstantiateTo(int[] value, ICause cause)Enforces the set variable to contain exactly the set of integers given in parameterISetDeltaMonitormonitorDelta(ICause propagator)Allow propagator to monitor element removal/enforcing of thisbooleanremove(int element, ICause cause)Removes element from the upper bound, i.e. the set variable cannot containelementanymorevoidsetCard(IntVar card)ensure a variable is equal to the cardinality of this set.-
Methods inherited from interface java.lang.Comparable
compareTo
-
Methods inherited from interface org.chocosolver.solver.variables.Variable
addMonitor, asBoolVar, asIntVar, asRealVar, asSetVar, clearEvents, contradiction, createDelta, getCause, getDelta, getDindex, getEnvironment, getEvtScheduler, getIndexInPropagator, getMask, getModel, getName, getNbProps, getPIndices, getPropagator, getPropagators, getTypeAndKind, getViews, isAConstant, isInstantiated, link, notifyMonitors, notifyPropagators, notifyViews, removeMonitor, setPIndice, storeEvents, subscribeView, swapOnActivate, swapOnPassivate, unlink
-
-
-
-
Method Detail
-
getLB
ISet getLB()
Get SetVar Lower Bound : the set of integers that must belong to every solution (i.e. a subset of all solutions) To iterate over this set, use the following loop: ISet lbSet = getLB(); for(int i : lbSet){ ... } This object is read-only. Use variable methodsforceto update the domain- Returns:
- the lower bound of this SetVar.
-
getUB
ISet getUB()
Get SetVar Upper Bound : the set of integers that may belong to a solution (i.e. a superset of all solutions) To iterate over this set, use the following loop: ISet ubSet = getUB(); for(int i : ubSet){ ... } This object is read-only. Use variable methodsremoveto update the domain- Returns:
- the lower bound of this SetVar.
-
getCard
IntVar getCard()
get the constrained cardinality variable of this set.- if no variable already has this role, creates a new variable, store and constraint it.
- if a variable already has this role, return it.
- Returns:
- a variable constrained to this set cardinality. Successive calls should return the same value
-
hasCard
boolean hasCard()
- Returns:
- true if a variable is constrained to this set's cardinality, false otherwise
-
setCard
void setCard(IntVar card)
ensure a variable is equal to the cardinality of this set.- If not call has been already performed to this set cardinality, post a constraint on the number of variables
- if this set already has a variable constrained to the cardinality, post an equality
- Parameters:
card- a variable of the same model.
-
force
boolean force(int element, ICause cause) throws ContradictionExceptionAdds element to the lower bound, i.e. every solution must includeelement- Parameters:
element- value to addcause- cause of value addition- Returns:
- true iff element has been added to the lower bound
- Throws:
ContradictionException
-
remove
boolean remove(int element, ICause cause) throws ContradictionExceptionRemoves element from the upper bound, i.e. the set variable cannot containelementanymore- Parameters:
element- value to removecause- cause of value removal- Returns:
- true iff element has been removed from the upper bound
- Throws:
ContradictionException
-
instantiateTo
boolean instantiateTo(int[] value, ICause cause) throws ContradictionExceptionEnforces the set variable to contain exactly the set of integers given in parameter- Parameters:
value- a set of integerscause- cause of instantiation- Returns:
- true iff a domain modification occurred
- Throws:
ContradictionException
-
getValue
default ISet getValue()
Retrieves the current value of the variable if instantiated, otherwise the lower bound (kernel).- Returns:
- the current value (or kernel if not yet instantiated).
-
monitorDelta
ISetDeltaMonitor monitorDelta(ICause propagator)
Allow propagator to monitor element removal/enforcing of this- Parameters:
propagator- observer- Returns:
- a new SetDeltaMonitor
-
-