public final class OffsetView extends IntView<IntVar>
ArExpression.Operator
Modifier and Type | Field and Description |
---|---|
int |
cste
A constant value
|
mIdx, model, monitors, MSG_EMPTY, MSG_INST, name, propagators
MAX_INT_BOUND, MIN_INT_BOUND
BOOL, CSTE, INT, KIND, REAL, SET, TYPE, VAR, VIEW
NO_CHILD
Constructor and Description |
---|
OffsetView(IntVar var,
int cste)
A view based on var such that var + cste
|
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() |
int |
transformValue(int value) |
compareTo, createDelta, getDelta, getDomainSize, getRange, getTypeAndKind, getVariable, hasEnumeratedDomain, instantiateTo, isInstantiated, iterator, notify, notifyMonitors, removeAllValuesBut, removeInterval, removeValue, removeValues, transformEvent, updateBounds, 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, unlink
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getNoChild, 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, unlink
forEach, spliterator
abs, 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, sub
public OffsetView(IntVar var, int cste)
var
- an integer variablecste
- an intpublic IIntDeltaMonitor monitorDelta(ICause propagator)
IntVar
this
.propagator
- the cause that requires to monitor deltaprotected boolean doInstantiateVar(int value) throws ContradictionException
IntView
IntView.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
IntView
IntView.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
IntView
IntView.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
IntView
IntView.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
IntView
IntView.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)
IntVar
v
belongs to the domain of this
value
- inttrue
if the value belongs to the domain of this
, false
otherwise.public boolean isInstantiatedTo(int value)
IntVar
this
is instantiated to val
value
- intthis
is instantiated to val
, false otherwisepublic int getValue()
IntVar
public int getLB()
IntVar
public int getUB()
IntVar
public int nextValue(int v)
IntVar
this
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)
IntVar
this
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)
IntVar
this
.
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)
IntVar
this
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 AbstractVariable
public DisposableValueIterator getValueIterator(boolean bottomUp)
IntVar
this
.
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 IntVar
getValueIterator
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)
IntVar
this
.
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 IntVar
getRangeIterator
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 void justifyEvent(IntVar var, ICause cause, IntEventType mask, int one, int two, int three)
IView
var
- modified variablecause
- cause of the modificationmask
- type of modificationone
- an inttwo
- an intthree
- an intCopyright © 2018. All rights reserved.