public abstract class IntView<I extends IntVar> extends AbstractVariable implements IView, IntVar
ArExpression.Operator| Modifier and Type | Field and Description |
|---|---|
protected IntDelta |
delta
To store removed values
|
protected I |
var
Observed variable
|
mIdx, model, monitors, MSG_EMPTY, MSG_INST, name, propagatorsMAX_INT_BOUND, MIN_INT_BOUNDBOOL, CSTE, INT, KIND, REAL, SET, TYPE, VAR, VIEWNO_CHILD| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Variable o) |
void |
createDelta()
Create a delta, if necessary, in order to observe removed values of a this.
|
protected boolean |
doInstantiateVar(int value)
Action to execute on
var when this view requires to instantiate it |
protected boolean |
doRemoveIntervalFromVar(int from,
int to)
Action to execute on
var when this view requires to remove an interval from it |
protected boolean |
doRemoveValueFromVar(int value)
Action to execute on
var when this view requires to remove a value from it |
protected boolean |
doUpdateLowerBoundOfVar(int value)
Action to execute on
var when this view requires to update its lower bound |
protected boolean |
doUpdateUpperBoundOfVar(int value)
Action to execute on
var when this view requires to update its upper bound |
IDelta |
getDelta()
Return the delta domain of this
|
int |
getDomainSize()
Returns the size of this domain, that is the number of elements in this domain.
|
int |
getRange()
Returns the range of this domain, that is, the difference between the upper bound and the lower bound.
|
DisposableRangeIterator |
getRangeIterator(boolean bottomUp)
Retrieves an iterator over ranges (or intervals) of
this. |
int |
getTypeAndKind()
Return a MASK composed of 2 main information: TYPE and KIND.
|
DisposableValueIterator |
getValueIterator(boolean bottomUp)
Retrieves an iterator over values of
this. |
IntVar |
getVariable()
Return the basis variable
|
boolean |
hasEnumeratedDomain()
Indicates wether (or not)
this has an enumerated domain (represented in extension)
or not (only bounds) |
boolean |
instantiateTo(int value,
ICause cause)
Instantiates the domain of
this to value. |
boolean |
isInstantiated()
Indicates whether
this is instantiated (see implemtations to know what instantiation means). |
Iterator<Integer> |
iterator() |
void |
notify(IEventType event)
To notify a view that the variable is observed has been modified.
|
void |
notifyMonitors(IEventType event)
Notify monitors of observed variable modifications
|
boolean |
removeAllValuesBut(IntIterableSet values,
ICause cause)
Removes all values from the domain of
this except those in values. |
boolean |
removeInterval(int from,
int to,
ICause cause)
Removes values between [
from, to] from the domain of this. |
boolean |
removeValue(int value,
ICause cause)
Removes
valuefrom the domain of this. |
boolean |
removeValues(IntIterableSet values,
ICause cause)
Removes the value in
valuesfrom the domain of this. |
IEventType |
transformEvent(IEventType evt) |
boolean |
updateBounds(int lb,
int ub,
ICause cause)
Updates the lower bound and the upper bound of the domain of
this to, resp. |
boolean |
updateLowerBound(int value,
ICause cause)
Updates the lower bound of the domain of
this to value. |
boolean |
updateUpperBound(int value,
ICause cause)
Updates the upper bound of the domain of
this to value. |
boolean |
why(RuleStore ruleStore,
IntVar modifiedVar,
IEventType evt,
int value)
Add new rules to the rule store
|
_schedIter, addMonitor, asBoolVar, asIntVar, asRealVar, asSetVar, clearEvents, contradiction, getCause, getDindex, getId, getIndexInPropagator, getMask, getModel, getName, getNbProps, getPIndices, getPropagator, getPropagators, getViews, isAConstant, isBool, link, notifyPropagators, notifyViews, removeMonitor, setPIndice, storeEvents, subscribeView, swapOnActivate, swapOnPassivate, toString, unlinkclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitjustifyEventcontains, getLB, getNoChild, getUB, getValue, intVar, isBool, isExpressionLeaf, isInstantiatedTo, monitorDelta, nextValue, nextValueOut, previousValue, previousValueOut, reverseValue, transformValue_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, unlinkforEach, spliteratorabs, add, add, add, dist, dist, div, div, eq, eq, eq, extractVar, ge, ge, getExpressionChild, getModel, gt, gt, ieval, le, le, lt, lt, max, max, max, min, min, min, mod, mod, mul, mul, mul, ne, ne, neg, pow, pow, sqr, sub, subprotected IntDelta delta
protected boolean doInstantiateVar(int value)
throws ContradictionException
var when this view requires to instantiate itvalue - value before modification of the viewvar has been modifiedContradictionException - if modification failsprotected boolean doUpdateLowerBoundOfVar(int value)
throws ContradictionException
var when this view requires to update its lower boundvalue - value before modification of the viewvar has been modifiedContradictionException - if modification failsprotected boolean doUpdateUpperBoundOfVar(int value)
throws ContradictionException
var when this view requires to update its upper boundvalue - value before modification of the viewvar has been modifiedContradictionException - if modification failsprotected boolean doRemoveValueFromVar(int value)
throws ContradictionException
var when this view requires to remove a value from itvalue - value before modification of the viewvar has been modifiedContradictionException - if modification failsprotected boolean doRemoveIntervalFromVar(int from,
int to)
throws ContradictionException
var when this view requires to remove an interval from itfrom - first value of the interval before modification of the viewto - last value of the interval before modification of the viewvar has been modifiedContradictionException - if modification failspublic boolean removeValue(int value,
ICause cause)
throws ContradictionException
IntVarvaluefrom the domain of this. The instruction comes from propagator.
value is out of the domain, nothing is done and the return value is false,value leads to a dead-end (domain wipe-out),
a ContradictionException is thrown,value from the domain can be done safely,
the event type is created (the original event can be promoted) and observers are notified
and the return value is trueremoveValue in interface IntVarvalue - value to remove from the domain (int)cause - removal releaserContradictionException - if the domain become empty due to this actionpublic boolean removeValues(IntIterableSet values, ICause cause) throws ContradictionException
IntVarvaluesfrom the domain of this. The instruction comes from propagator.
false,ContradictionException is thrown,values from the domain can be done safely,
the event type is created (the original event can be promoted) and observers are notified
and the return value is trueremoveValues in interface IntVarvalues - set of ordered values to removecause - removal releaseContradictionException - if the domain become empty due to this actionpublic boolean removeInterval(int from,
int to,
ICause cause)
throws ContradictionException
IntVarfrom, to] from the domain of this. The instruction comes from propagator.
false,value leads to a dead-end (domain wipe-out),
a ContradictionException is thrown,value from the domain can be done safely,
the event type is created (the original event can be promoted) and observers are notified
and the return value is trueremoveInterval in interface IntVarfrom - lower bound of the interval to remove (int)to - upper bound of the interval to remove(int)cause - removal releaserContradictionException - if the domain become empty due to this actionpublic boolean removeAllValuesBut(IntIterableSet values, ICause cause) throws ContradictionException
IntVarthis except those in values. The instruction comes from propagator.
ContradictionException is thrown,false,values from the domain can be done safely,
the event type is created (the original event can be promoted) and observers are notified
and the return value is trueremoveAllValuesBut in interface IntVarvalues - set of ordered values to keep in the domaincause - removal releaseContradictionException - if the domain become empty due to this actionpublic boolean instantiateTo(int value,
ICause cause)
throws ContradictionException
IntVarthis to value. The instruction comes from propagator.
this is already instantiated to value,
nothing is done and the return value is false,this is already instantiated to another value,
then a ContradictionException is thrown,this is restricted to value and the observers are notified
and the return value is true.instantiateTo in interface IntVarvalue - instantiation value (int)cause - instantiation releaserContradictionException - if the domain become empty due to this actionpublic boolean updateLowerBound(int value,
ICause cause)
throws ContradictionException
IntVarthis to value.
The instruction comes from propagator.
value is smaller than the lower bound of the domain, nothing is done and the return value is false,value leads to a dead-end (domain wipe-out),
a ContradictionException is thrown,value can be done safely,
the event type is created (the original event can be promoted) and observers are notified
and the return value is trueupdateLowerBound in interface IntVarvalue - new lower bound (included)cause - updating releaserContradictionException - if the domain become empty due to this actionpublic boolean updateUpperBound(int value,
ICause cause)
throws ContradictionException
IntVarthis to value.
The instruction comes from propagator.
value is greater than the upper bound of the domain, nothing is done and the return value is false,value leads to a dead-end (domain wipe-out),
a ContradictionException is thrown,value can be done safely,
the event type is created (the original event can be promoted) and observers are notified
and the return value is trueupdateUpperBound in interface IntVarvalue - new upper bound (included)cause - update releaserContradictionException - if the domain become empty due to this actionpublic boolean updateBounds(int lb,
int ub,
ICause cause)
throws ContradictionException
IntVarthis to, resp. lb and ub.
The instruction comes from propagator.
lb is smaller than the lower bound of the domain
and ub is greater than the upper bound of the domain,
nothing is done and the return value is false,
lb, or updating the upper bound to ub leads to a dead-end (domain wipe-out),
or if lb is strictly greater than ub,
a ContradictionException is thrown,lb and/or the upper bound to ub
can be done safely can be done safely,
the event type is created (the original event can be promoted) and observers are notified
and the return value is trueupdateBounds in interface IntVarlb - new lower bound (included)ub - new upper bound (included)cause - update releaserContradictionException - if the domain become empty due to this actionpublic 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 IntVar getVariable()
IViewgetVariable in interface IViewpublic int getDomainSize()
IntVargetDomainSize in interface IntVarpublic int getRange()
IntVarpublic boolean hasEnumeratedDomain()
IntVarthis has an enumerated domain (represented in extension)
or not (only bounds)hasEnumeratedDomain in interface IntVartrue if the domain is enumerated, false otherwise.public boolean isInstantiated()
Variablethis is instantiated (see implemtations to know what instantiation means).isInstantiated in interface Variabletrue if this is instantiatedpublic IDelta getDelta()
Variablepublic void createDelta()
VariablecreateDelta in interface Variablepublic int compareTo(Variable o)
compareTo in interface Comparable<Variable>compareTo in class AbstractVariablepublic void notifyMonitors(IEventType event) throws ContradictionException
VariablenotifyMonitors in interface Variableevent - the event which occurred on the variableContradictionException - if the monitor detects contradiction.public void notify(IEventType event) throws ContradictionException
IViewnotify in interface IViewevent - the event received by the observed variableContradictionException - if a failure occurspublic IEventType transformEvent(IEventType evt)
transformEvent in interface IntVarevt - original eventpublic DisposableValueIterator getValueIterator(boolean bottomUp)
IntVarthis.
The values can be iterated in a bottom-up way or top-down way.
To bottom-up iterate over the values in a IntVar,
use the following loop:
DisposableValueIterator vit = var.getValueIterator(true);
while(vit.hasNext()){
int v = vit.next();
// operate on value v here
}
vit.dispose();
To top-down iterate over the values in a IntVar,
use the following loop:
DisposableValueIterator vit = var.getValueIterator(false);
while(vit.hasPrevious()){
int v = vit.previous();
// operate on value v here
}
vit.dispose();
Using both previous and next can lead to unexpected behaviour.getValueIterator in interface IntVarbottomUp - way to iterate over values. true means from lower bound to upper bound,
false means from upper bound to lower bound.this.public DisposableRangeIterator getRangeIterator(boolean bottomUp)
IntVarthis.
The ranges can be iterated in a bottom-up way or top-down way.
To bottom-up iterate over the values in a IntVar,
use the following loop:
DisposableRangeIterator rit = var.getRangeIterator(true);
while (rit.hasNext()) {
int from = rit.min();
int to = rit.max();
// operate on range [from,to] here
rit.next();
}
rit.dispose();
To top-down iterate over the values in a IntVar,
use the following loop:
DisposableRangeIterator rit = var.getRangeIterator(false);
while (rit.hasPrevious()) {
int from = rit.min();
int to = rit.max();
// operate on range [from,to] here
rit.previous();
}
rit.dispose();
Using both previous and next can lead to unexpected behaviour.getRangeIterator in interface IntVarbottomUp - way to iterate over ranges. true means from lower bound to upper bound,
false means from upper bound to lower bound.this.public boolean why(RuleStore ruleStore, IntVar modifiedVar, IEventType evt, int value)
ICauseCopyright © 2018. All rights reserved.