public interface IntVar extends ICause, Variable, Iterable<Integer>, ArExpression
CPRU r544: remove default implementation
ArExpression.Operator| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_INT_BOUND
Provide a minimum value for integer variable lower bound.
|
static int |
MIN_INT_BOUND
Provide a minimum value for integer variable lower bound.
|
BOOL, CSTE, INT, KIND, REAL, SET, TYPE, VAR, VIEWNO_CHILD| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(int value)
Checks if a value
v belongs to the domain of this |
int |
getDomainSize()
Returns the size of this domain, that is the number of elements in this domain.
|
int |
getLB()
Retrieves the lower bound of the variable
|
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 |
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 |
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. |
default IntVar |
intVar() |
boolean |
isBool() |
default boolean |
isExpressionLeaf() |
boolean |
isInstantiatedTo(int value)
Checks wether
this is instantiated to val |
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. |
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. |
default int |
reverseValue(int value) |
default IEventType |
transformEvent(IEventType evt) |
default 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. |
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. |
default boolean |
why(RuleStore ruleStore,
IntVar modifiedVar,
IEventType evt,
int value)
Add new rules to the rule store
|
_schedIter, addMonitor, contradiction, createDelta, getDelta, getDindex, getEnvironment, getIndexInPropagator, getModel, getName, getNbProps, getPIndices, getPropagator, getPropagators, getTypeAndKind, getViews, isAConstant, isInstantiated, link, notifyMonitors, notifyPropagators, notifyViews, removeMonitor, setPIndice, subscribeView, unlinkcompareToforEach, iterator, 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, substatic final int MIN_INT_BOUND
static final int MAX_INT_BOUND
boolean removeValue(int value,
ICause cause)
throws ContradictionException
valuefrom 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 truevalue - value to remove from the domain (int)cause - removal releaserContradictionException - if the domain become empty due to this actionboolean removeValues(IntIterableSet values, ICause cause) throws ContradictionException
valuesfrom 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 truevalues - set of ordered values to removecause - removal releaseContradictionException - if the domain become empty due to this actionboolean removeAllValuesBut(IntIterableSet values, ICause cause) throws ContradictionException
this 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 truevalues - set of ordered values to keep in the domaincause - removal releaseContradictionException - if the domain become empty due to this actionboolean removeInterval(int from,
int to,
ICause cause)
throws ContradictionException
from, 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 truefrom - 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 actionboolean instantiateTo(int value,
ICause cause)
throws ContradictionException
this 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.value - instantiation value (int)cause - instantiation releaserContradictionException - if the domain become empty due to this actionboolean updateLowerBound(int value,
ICause cause)
throws ContradictionException
this 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 truevalue - new lower bound (included)cause - updating releaserContradictionException - if the domain become empty due to this actionboolean updateUpperBound(int value,
ICause cause)
throws ContradictionException
this 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 truevalue - new upper bound (included)cause - update releaserContradictionException - if the domain become empty due to this actionboolean updateBounds(int lb,
int ub,
ICause cause)
throws ContradictionException
this 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 truelb - new lower bound (included)ub - new upper bound (included)cause - update releaserContradictionException - if the domain become empty due to this actionboolean contains(int value)
v belongs to the domain of thisvalue - inttrue if the value belongs to the domain of this, false otherwise.boolean isInstantiatedTo(int value)
this is instantiated to valvalue - intthis is instantiated to val, false otherwiseint getValue()
int getLB()
int getUB()
int getDomainSize()
int getRange()
int nextValue(int v)
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)int nextValueOut(int v)
this which is out of the domain.
If v is less than or equal to getLB()-2, returns v + 1,
if v is greater than or equal to getUB(), returns v + 1.v - the value to start checking (exclusive)int previousValue(int v)
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)int previousValueOut(int v)
this which is out of the domain.
If v is greater than or equal to getUB()+2, returns v - 1,
if v is less than or equal to getLB(), returns v - 1.v - the value to start checking (exclusive)DisposableValueIterator getValueIterator(boolean bottomUp)
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.bottomUp - way to iterate over values. true means from lower bound to upper bound,
false means from upper bound to lower bound.this.DisposableRangeIterator getRangeIterator(boolean bottomUp)
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.bottomUp - way to iterate over ranges. true means from lower bound to upper bound,
false means from upper bound to lower bound.this.boolean hasEnumeratedDomain()
this has an enumerated domain (represented in extension)
or not (only bounds)true if the domain is enumerated, false otherwise.IIntDeltaMonitor monitorDelta(ICause propagator)
this.propagator - the cause that requires to monitor deltaboolean isBool()
default boolean why(RuleStore ruleStore, IntVar modifiedVar, IEventType evt, int value)
ICausedefault IEventType transformEvent(IEventType evt)
evt - original eventdefault int transformValue(int value)
value - original valuedefault int reverseValue(int value)
value - original valuedefault IntVar intVar()
intVar in interface ArExpressionIntVar.
If necessary, it creates intermediary variable and posts intermediary constraintsdefault boolean isExpressionLeaf()
isExpressionLeaf in interface ArExpressionCopyright © 2017. All rights reserved.