public abstract class IntBoolView extends IntView<IntVar> implements BoolVar
IntVar
.EqView
,
Project: choco-solver.
ReExpression.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
Modifier and Type | Method and Description |
---|---|
void |
_setNot(BoolVar neg) |
void |
createDelta()
Create a delta, if necessary, in order to observe removed values of a this.
|
protected EvtScheduler |
createScheduler() |
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.
|
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 |
hasNot() |
boolean |
isLit()
Current tree is a literal
|
boolean |
isNot()
Current tree is rooted with NOT logical operator
This is a one way relationship: in case a = not(b)
a.isNot() returns true whereas b.isNot() returns false (unless b = not(c)...)
|
IIntDeltaMonitor |
monitorDelta(ICause propagator)
Allow to monitor removed values of
this . |
BoolVar |
not() |
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
value from the domain of this . |
boolean |
removeValues(IntIterableSet values,
ICause cause)
Removes the value in
values from the domain of this . |
void |
setNot(boolean isNot)
States whether or not this variable is the negation of another.
|
boolean |
setToFalse(ICause cause) |
boolean |
setToTrue(ICause cause) |
String |
toString() |
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 . |
compareTo, doInstantiateVar, doRemoveIntervalFromVar, doRemoveValueFromVar, doUpdateLowerBoundOfVar, doUpdateUpperBoundOfVar, forEachIntVar, getDelta, getDomainSize, getRange, getVariable, hasEnumeratedDomain, instantiateTo, isInstantiated, iterator, notify, transformEvent
addMonitor, asBoolVar, asIntVar, asRealVar, asSetVar, clearEvents, contradiction, getCause, getDindex, getEvtScheduler, getId, getIndexInPropagator, getMask, getModel, getName, getNbProps, getNbViews, getPIndices, getPropagator, getPropagators, getView, isAConstant, isBool, link, notifyMonitors, notifyPropagators, notifyViews, removeMonitor, setPIndice, storeEvents, subscribeView, swapOnActivate, swapOnPassivate, unlink
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
boolVar, extractVar, getBooleanValue, intVar
contains, forEachIntVar, getDomainSize, getLB, getNoChild, getRange, getUB, hasEnumeratedDomain, instantiateTo, isBool, isExpressionLeaf, isInstantiatedTo, nextValue, nextValueOut, previousValue, previousValueOut, transformEvent
addMonitor, asBoolVar, asIntVar, asRealVar, asSetVar, clearEvents, contradiction, getCause, getDelta, getDindex, getEnvironment, getEvtScheduler, getIndexInPropagator, getMask, getModel, getName, getNbProps, getNbViews, getPIndices, getPropagator, getPropagators, getView, isAConstant, isInstantiated, link, notifyMonitors, notifyPropagators, notifyViews, removeMonitor, setPIndice, storeEvents, subscribeView, swapOnActivate, swapOnPassivate, unlink
compareTo
forEach, iterator, spliterator
and, beval, decompose, extension, getModel, ieval, iff, ift, ift, ift, ift, imp, or, post, xor
abs, add, add, add, dist, dist, div, div, eq, eq, eq, ge, ge, getExpressionChild, gt, gt, le, le, lt, lt, max, max, max, min, min, min, mod, mod, mul, mul, mul, ne, ne, neg, pow, pow, sqr, sub, sub
explain, justifyEvent
public final boolean setToTrue(ICause cause) throws ContradictionException
setToTrue
in interface BoolVar
ContradictionException
public final boolean setToFalse(ICause cause) throws ContradictionException
setToFalse
in interface BoolVar
ContradictionException
public final 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
removeValue
in interface IntVar
removeValue
in class IntView<IntVar>
value
- value to remove from the domain (int)cause
- removal releaserContradictionException
- if the domain become empty due to this actionpublic final boolean removeValues(IntIterableSet values, ICause cause) throws ContradictionException
IntVar
values
from 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 true
removeValues
in interface IntVar
removeValues
in class IntView<IntVar>
values
- set of ordered values to removecause
- removal releaseContradictionException
- if the domain become empty due to this actionpublic final boolean removeAllValuesBut(IntIterableSet values, ICause cause) throws ContradictionException
IntVar
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 true
removeAllValuesBut
in interface IntVar
removeAllValuesBut
in class IntView<IntVar>
values
- set of ordered values to keep in the domaincause
- removal releaseContradictionException
- if the domain become empty due to this actionpublic final 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
removeInterval
in interface IntVar
removeInterval
in class IntView<IntVar>
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 final 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
updateLowerBound
in interface IntVar
updateLowerBound
in class IntView<IntVar>
value
- new lower bound (included)cause
- updating releaserContradictionException
- if the domain become empty due to this actionpublic final 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
updateUpperBound
in interface IntVar
updateUpperBound
in class IntView<IntVar>
value
- new upper bound (included)cause
- update releaserContradictionException
- if the domain become empty due to this actionpublic final boolean updateBounds(int lb, int ub, ICause cause) throws ContradictionException
IntVar
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 true
updateBounds
in interface IntVar
updateBounds
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 actionpublic final int getTypeAndKind()
Variable
int 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 Variable
getTypeAndKind
in class IntView<IntVar>
public final int getValue()
IntVar
protected final EvtScheduler createScheduler()
createScheduler
in class AbstractVariable
public final String toString()
toString
in class AbstractVariable
public final 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 final 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 final void createDelta()
Variable
createDelta
in interface Variable
createDelta
in class IntView<IntVar>
public final IIntDeltaMonitor monitorDelta(ICause propagator)
IntVar
this
.monitorDelta
in interface IntVar
propagator
- the cause that requires to monitor deltapublic final BoolVar not()
not
in interface ReExpression
not
in interface BoolVar
public final boolean isLit()
ILogical
public final boolean isNot()
ILogical
public final void setNot(boolean isNot)
ILogical
Copyright © 2018. All rights reserved.