public class SetVarImpl extends AbstractVariable implements SetVar
| Modifier and Type | Field and Description |
|---|---|
protected IntVar |
cardinality |
protected SetDelta |
delta |
protected ISet |
lb |
protected ISet |
lbReadOnly |
protected boolean |
reactOnModification |
protected ISet |
ub |
protected ISet |
ubReadOnly |
mIdx, model, monitors, MSG_EMPTY, MSG_INST, name, propagators| Constructor and Description |
|---|
SetVarImpl(String name,
int[] value,
Model model)
Creates a fixed Set variable, equal to
value |
SetVarImpl(String name,
int[] ker,
SetType kerType,
int[] env,
SetType envType,
Model model)
Creates a Set variable
|
SetVarImpl(String name,
ISet lb,
ISet ub,
Model model)
Creates a set variable, of domain
[lb, ub]
Beware : Use this constructor with caution (domain is directly accessible)
lb and ub should be created properly (e.g. lb subset of ub) and should not be modified externally
Both lb and ub should be backtrackable sets (stored sets): use SetFactory.makeStoredSet to build them |
SetVarImpl(String name,
ISet value,
Model model)
Creates a fixed Set variable, equal to
value
Beware : Use this constructor with caution (domain is directly accessible)
value should be created properly and should not be modified afterward |
| Modifier and Type | Method and Description |
|---|---|
void |
createDelta()
Create a delta, if necessary, in order to observe removed values of a this.
|
boolean |
force(int element,
ICause cause)
Adds element to the lower bound, i.e. every solution must include
element |
IntVar |
getCard()
get the constrained cardinality variable of this set.
|
SetDelta |
getDelta()
Return the delta domain of this
|
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.
|
int |
getTypeAndKind()
Return a MASK composed of 2 main information: TYPE and KIND.
|
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.
|
boolean |
hasCard() |
boolean |
instantiateTo(int[] value,
ICause cause)
Enforces the set variable to contain exactly the set of integers given in parameter
|
boolean |
isInstantiated()
Indicates whether
this is instantiated (see implemtations to know what instantiation means). |
SetDeltaMonitor |
monitorDelta(ICause propagator)
Allow propagator to monitor element removal/enforcing of this
|
void |
notifyMonitors(IEventType event)
Notify monitors of observed variable modifications
|
boolean |
remove(int element,
ICause cause)
Removes element from the upper bound, i.e. the set variable cannot contain
element anymore |
void |
setCard(IntVar card)
ensure a variable is equal to the cardinality of this set.
|
String |
toString() |
_schedIter, addMonitor, asBoolVar, asIntVar, asRealVar, asSetVar, clearEvents, compareTo, contradiction, getCause, getDindex, getId, getIndexInPropagator, getMask, getModel, getName, getNbProps, getPIndices, getPropagator, getPropagators, getViews, isAConstant, isBool, link, notifyPropagators, notifyViews, removeMonitor, setPIndice, storeEvents, subscribeView, swapOnActivate, swapOnPassivate, unlinkclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait_schedIter, addMonitor, asBoolVar, asIntVar, asRealVar, asSetVar, clearEvents, contradiction, getCause, getDindex, getEnvironment, getIndexInPropagator, getMask, getModel, getName, getNbProps, getPIndices, getPropagator, getPropagators, getViews, isAConstant, link, notifyPropagators, notifyViews, removeMonitor, setPIndice, storeEvents, subscribeView, swapOnActivate, swapOnPassivate, unlinkcompareToprotected final ISet lb
protected final ISet ub
protected final ISet lbReadOnly
protected final ISet ubReadOnly
protected SetDelta delta
protected boolean reactOnModification
protected IntVar cardinality
public SetVarImpl(String name, int[] ker, SetType kerType, int[] env, SetType envType, Model model)
name - name of the variableker - initial kernel domainkerType - data structure of the kernelenv - initial envelope domainenvType - data structure of the envelopemodel - solver of the variable.public SetVarImpl(String name, ISet lb, ISet ub, Model model)
[lb, ub]
Beware : Use this constructor with caution (domain is directly accessible)
lb and ub should be created properly (e.g. lb subset of ub) and should not be modified externally
Both lb and ub should be backtrackable sets (stored sets): use SetFactory.makeStoredSet to build themname - name of the variablelb - lower bound of the set variable (mandatory elements)ub - upper bound of the set variable (potential elements)model - solver of the variable.public SetVarImpl(String name, ISet value, Model model)
value
Beware : Use this constructor with caution (domain is directly accessible)
value should be created properly and should not be modified afterwardname - name of the variablevalue - value of the set variablemodel - solver of the variable.public boolean isInstantiated()
Variablethis is instantiated (see implemtations to know what instantiation means).isInstantiated in interface Variabletrue if this is instantiatedpublic ISet getLB()
SetVarforce to update the domainpublic ISet getUB()
SetVarremove to update the domainpublic IntVar getCard()
SetVarpublic boolean hasCard()
public void setCard(IntVar card)
SetVarpublic boolean force(int element,
ICause cause)
throws ContradictionException
SetVarelementforce in interface SetVarelement - value to addcause - cause of value additionContradictionExceptionpublic boolean remove(int element,
ICause cause)
throws ContradictionException
SetVarelement anymoreremove in interface SetVarelement - value to removecause - cause of value removalContradictionExceptionpublic boolean instantiateTo(int[] value,
ICause cause)
throws ContradictionException
SetVarinstantiateTo in interface SetVarvalue - a set of integerscause - cause of instantiationContradictionExceptionpublic SetDelta getDelta()
Variablepublic int getTypeAndKind()
Variableint type = var.getTypeAndKind() & Variable.TYPE;To get the KIND of a variable:
int kind = var.getTypeAndKind() & Variable.KIND;To check a specific type or kind of a variable:
boolean isVar = (var.getTypeAndKind() & Variable.VAR) !=0;
boolean isInt = (var.getTypeAndKind() & Variable.INT) !=0;
getTypeAndKind in interface Variablepublic String toString()
toString in class AbstractVariablepublic void createDelta()
VariablecreateDelta in interface Variablepublic SetDeltaMonitor monitorDelta(ICause propagator)
SetVarmonitorDelta in interface SetVarpropagator - observerpublic void notifyMonitors(IEventType event) throws ContradictionException
VariablenotifyMonitors in interface Variableevent - the event which occurred on the variableContradictionException - if the monitor detects contradiction.Copyright © 2018. All rights reserved.