public class EqView extends IntView
_riterator, _viterator, delta, var
_plugexpl, mIdx, modificationEvents, monitors, MSG_BOUND, MSG_EMPTY, MSG_INST, MSG_LOW, MSG_REMOVE, MSG_UNKNOWN, MSG_UPP, name, solver
Modifier and Type | Method and Description |
---|---|
boolean |
contains(int value)
Checks if a value
v belongs to the domain of this |
IntVar |
duplicate()
Duplicate
this . |
void |
duplicate(Solver solver,
gnu.trove.map.hash.THashMap<Object,Object> identitymap)
Duplicate
this (which naturally adds it into solver ). |
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 |
instantiateTo(int value,
ICause cause)
Instantiates the domain of
this to value . |
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 next value just after v in
this . |
int |
previousValue(int v)
Returns the previous value just befor v in
this . |
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
value from the domain of this . |
String |
toString() |
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 . |
compareTo, contradiction, createDelta, getDelta, getDomainSize, getTypeAndKind, getVariable, hasEnumeratedDomain, isInstantiated, notifyMonitors, recordMask, transformEvent, why
addMonitor, getId, getIndexInPropagator, getName, getNbProps, getPIndices, getPropagator, getPropagators, getSolver, getViews, isBool, link, notifyPropagators, notifyViews, removeMonitor, subscribeView, unlink
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addMonitor, getIndexInPropagator, getName, getNbProps, getPIndices, getPropagator, getPropagators, getSolver, getViews, link, notifyPropagators, notifyViews, removeMonitor, subscribeView, unlink
public IIntDeltaMonitor monitorDelta(ICause propagator)
IntVar
this
.propagator
- the cause that requires to monitor deltapublic boolean removeValue(int value, ICause cause) throws ContradictionException
IntVar
value
from 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 true
value
- value to remove from the domain (int)cause
- removal releaserContradictionException
- if the domain become empty due to this actionpublic boolean removeInterval(int from, int to, ICause cause) throws ContradictionException
IntVar
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 true
from
- 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 instantiateTo(int value, ICause cause) throws ContradictionException
IntVar
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 actionpublic boolean updateLowerBound(int value, ICause cause) throws ContradictionException
IntVar
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 true
value
- new lower bound (included)cause
- updating releaserContradictionException
- if the domain become empty due to this actionpublic boolean updateUpperBound(int value, ICause cause) throws ContradictionException
IntVar
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 true
value
- new upper bound (included)cause
- update releaserContradictionException
- if the domain become empty due to this actionpublic 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
.
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 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 String toString()
toString
in class AbstractVariable
public IntVar duplicate()
Variable
this
.this
public void duplicate(Solver solver, gnu.trove.map.hash.THashMap<Object,Object> identitymap)
Variable
this
(which naturally adds it into solver
).solver
- target solveridentitymap
- a map to guarantee uniqueness of objectspublic 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
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
bottomUp
- way to iterate over ranges. true
means from lower bound to upper bound,
false
means from upper bound to lower bound.this
.Copyright © 2015. All rights reserved.