public class MinusView extends IntView<IntVar>
Based on "Views and Iterators for Generic Constraint Implementations"
C. Shulte and G. Tack.
Eleventh International Conference on Principles and Practice of Constraint Programming
ArExpression.OperatormIdx, model, monitors, MSG_EMPTY, MSG_INST, name, propagatorsMAX_INT_BOUND, MIN_INT_BOUNDBOOL, CSTE, INT, KIND, REAL, SET, TYPE, VAR, VIEWNO_CHILD| Constructor and Description |
|---|
MinusView(IntVar var)
Create a -var view
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(int value)
Checks if a value
v belongs to the domain of this |
protected boolean |
doInstantiateVar(int value)
Action to execute on
IntView.var when this view requires to instantiate it |
protected boolean |
doRemoveIntervalFromVar(int from,
int to)
Action to execute on
IntView.var when this view requires to remove an interval from it |
protected boolean |
doRemoveValueFromVar(int value)
Action to execute on
IntView.var when this view requires to remove a value from it |
protected boolean |
doUpdateLowerBoundOfVar(int value)
Action to execute on
IntView.var when this view requires to update its lower bound |
protected boolean |
doUpdateUpperBoundOfVar(int value)
Action to execute on
IntView.var when this view requires to update its upper bound |
int |
getLB()
Retrieves the lower bound of the variable
|
DisposableRangeIterator |
getRangeIterator(boolean bottomUp)
Retrieves an iterator over ranges (or intervals) of
this. |
int |
getUB()
Retrieves the upper bound of the variable
|
int |
getValue()
Retrieves the current value of the variable if instantiated, otherwier the lower bound.
|
DisposableValueIterator |
getValueIterator(boolean bottomUp)
Retrieves an iterator over values of
this. |
boolean |
isInstantiatedTo(int value)
Checks wether
this is instantiated to val |
void |
justifyEvent(IntVar var,
ICause cause,
IntEventType mask,
int one,
int two,
int three)
This methods is related to explanations, it binds an event occurring on the observed
variable to the view.
|
IIntDeltaMonitor |
monitorDelta(ICause propagator)
Allow to monitor removed values of
this. |
int |
nextValue(int v)
Returns the first value just after v in
this which is in the domain. |
int |
nextValueOut(int v)
Returns the first value just after v in
this which is out of the domain. |
int |
previousValue(int v)
Returns the previous value just before v in
this. |
int |
previousValueOut(int v)
Returns the first value just before v in
this which is out of the domain. |
int |
reverseValue(int value) |
String |
toString() |
IEventType |
transformEvent(IEventType evt) |
int |
transformValue(int value) |
boolean |
updateBounds(int lb,
int ub,
ICause cause)
Updates the lower bound and the upper bound of the domain of
this to, resp. |
compareTo, createDelta, getDelta, getDomainSize, getRange, getTypeAndKind, getVariable, hasEnumeratedDomain, instantiateTo, isInstantiated, iterator, notify, notifyMonitors, removeAllValuesBut, removeInterval, removeValue, removeValues, updateLowerBound, updateUpperBound, why_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, unlinkclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetNoChild, intVar, isBool, isExpressionLeaf_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, subpublic MinusView(IntVar var)
var - a integer variablepublic IIntDeltaMonitor monitorDelta(ICause propagator)
IntVarthis.propagator - the cause that requires to monitor deltapublic 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 IntVarupdateBounds in class IntView<IntVar>lb - new lower bound (included)ub - new upper bound (included)cause - update releaserContradictionException - if the domain become empty due to this actionprotected boolean doInstantiateVar(int value)
throws ContradictionException
IntViewIntView.var when this view requires to instantiate itdoInstantiateVar in class IntView<IntVar>value - value before modification of the viewIntView.var has been modifiedContradictionException - if modification failsprotected boolean doUpdateLowerBoundOfVar(int value)
throws ContradictionException
IntViewIntView.var when this view requires to update its lower bounddoUpdateLowerBoundOfVar in class IntView<IntVar>value - value before modification of the viewIntView.var has been modifiedContradictionException - if modification failsprotected boolean doUpdateUpperBoundOfVar(int value)
throws ContradictionException
IntViewIntView.var when this view requires to update its upper bounddoUpdateUpperBoundOfVar in class IntView<IntVar>value - value before modification of the viewIntView.var has been modifiedContradictionException - if modification failsprotected boolean doRemoveValueFromVar(int value)
throws ContradictionException
IntViewIntView.var when this view requires to remove a value from itdoRemoveValueFromVar in class IntView<IntVar>value - value before modification of the viewIntView.var has been modifiedContradictionException - if modification failsprotected boolean doRemoveIntervalFromVar(int from,
int to)
throws ContradictionException
IntViewIntView.var when this view requires to remove an interval from itdoRemoveIntervalFromVar in class IntView<IntVar>from - first value of the interval before modification of the viewto - last value of the interval before modification of the viewIntView.var has been modifiedContradictionException - if modification failspublic boolean contains(int value)
IntVarv belongs to the domain of thisvalue - inttrue if the value belongs to the domain of this, false otherwise.public boolean isInstantiatedTo(int value)
IntVarthis is instantiated to valvalue - intthis is instantiated to val, false otherwisepublic int getValue()
IntVarpublic int getLB()
IntVarpublic int getUB()
IntVarpublic int nextValue(int v)
IntVarthis which is in the domain.
If no such value exists, returns Integer.MAX_VALUE;
To iterate over the values in a IntVar,
use the following loop:
int ub = iv.getUB();
for (int i = iv.getLB(); i <= ub; i = iv.nextValue(i)) {
// operate on value i here
}v - the value to start checking (exclusive)public int nextValueOut(int v)
IntVarthis which is out of the domain.
If v is less than or equal to IntVar.getLB()-2, returns v + 1,
if v is greater than or equal to IntVar.getUB(), returns v + 1.v - the value to start checking (exclusive)public int previousValue(int v)
IntVarthis.
If no such value exists, returns Integer.MIN_VALUE;
To iterate over the values in a IntVar,
use the following loop:
int lb = iv.getLB();
for (int i = iv.getUB(); i >= lb; i = iv.previousValue(i)) {
// operate on value i here
}v - the value to start checking (exclusive)public int previousValueOut(int v)
IntVarthis which is out of the domain.
If v is greater than or equal to IntVar.getUB()+2, returns v - 1,
if v is less than or equal to IntVar.getLB(), returns v - 1.v - the value to start checking (exclusive)public String toString()
toString in class AbstractVariablepublic 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 IntVargetValueIterator in class IntView<IntVar>bottomUp - 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 IntVargetRangeIterator in class IntView<IntVar>bottomUp - way to iterate over ranges. true means from lower bound to upper bound,
false means from upper bound to lower bound.this.public int transformValue(int value)
value - original valuepublic int reverseValue(int value)
value - original valuepublic IEventType transformEvent(IEventType evt)
transformEvent in interface IntVartransformEvent in class IntView<IntVar>evt - original eventpublic void justifyEvent(IntVar var, ICause cause, IntEventType mask, int one, int two, int three)
IViewvar - modified variablecause - cause of the modificationmask - type of modificationone - an inttwo - an intthree - an intCopyright © 2018. All rights reserved.