public abstract class IntView extends AbstractVariable implements IView, IntVar
Modifier and Type | Field and Description |
---|---|
protected DisposableRangeIterator |
_riterator |
protected DisposableValueIterator |
_viterator |
protected IntDelta |
delta |
protected IntVar |
var |
_plugexpl, mIdx, modificationEvents, monitors, MSG_BOUND, MSG_EMPTY, MSG_INST, MSG_LOW, MSG_REMOVE, MSG_UNKNOWN, MSG_UPP, name, solver
Constructor and Description |
---|
IntView(String name,
IntVar var,
Solver solver) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Variable o) |
void |
contradiction(ICause cause,
IEventType event,
String message)
Throws a contradiction exception based on
|
void |
createDelta()
Create a delta, if necessary, in order to observe removed values of a this.
|
IDelta |
getDelta()
Return the delta domain of this
|
int |
getDomainSize()
Returns the size of the domain of
this |
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.
|
DisposableValueIterator |
getValueIterator(boolean bottomUp)
Retrieves an iterator over values of
this . |
IntVar |
getVariable()
Return the basis variable
|
boolean |
hasEnumeratedDomain()
Indicates wether (or not)
this has an enumerated domain (represented in extension)
or not (only bounds) |
boolean |
isInstantiated()
Indicates whether
this is instantiated (see implemtations to know what instantiation means). |
void |
notifyMonitors(IEventType event)
Notify monitors of observed variable modifications
|
void |
recordMask(int mask)
Analysis propagator event reaction on this, and adapt this
|
void |
transformEvent(IEventType evt,
ICause cause)
Transform the original event wrt the view
|
boolean |
why(RuleStore ruleStore,
IntVar var,
IEventType evt,
int value)
Add new rules to the rule store
|
addMonitor, getId, getIndexInPropagator, getName, getNbProps, getPIndices, getPropagator, getPropagators, getSolver, getViews, isBool, link, notifyPropagators, notifyViews, removeMonitor, subscribeView, toString, unlink
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
contains, getLB, getUB, getValue, instantiateTo, isBool, isInstantiatedTo, monitorDelta, nextValue, previousValue, removeInterval, removeValue, updateLowerBound, updateUpperBound
addMonitor, duplicate, duplicate, getIndexInPropagator, getName, getNbProps, getPIndices, getPropagator, getPropagators, getSolver, getViews, link, notifyPropagators, notifyViews, removeMonitor, subscribeView, unlink
protected final IntVar var
protected IntDelta delta
protected DisposableValueIterator _viterator
protected DisposableRangeIterator _riterator
public final void recordMask(int mask)
Variable
recordMask
in interface Variable
recordMask
in class AbstractVariable
mask
- event maskpublic 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
public IntVar getVariable()
IView
getVariable
in interface IView
public int getDomainSize()
IntVar
this
getDomainSize
in interface IntVar
public boolean hasEnumeratedDomain()
IntVar
this
has an enumerated domain (represented in extension)
or not (only bounds)hasEnumeratedDomain
in interface IntVar
true
if the domain is enumerated, false
otherwise.public boolean isInstantiated()
Variable
this
is instantiated (see implemtations to know what instantiation means).isInstantiated
in interface Variable
true
if this
is instantiatedpublic IDelta getDelta()
Variable
public void createDelta()
Variable
createDelta
in interface Variable
public int compareTo(Variable o)
compareTo
in interface Comparable<Variable>
compareTo
in class AbstractVariable
public void notifyMonitors(IEventType event) throws ContradictionException
Variable
notifyMonitors
in interface Variable
event
- the event which occurred on the variableContradictionException
public void transformEvent(IEventType evt, ICause cause) throws ContradictionException
IView
transformEvent
in interface IView
evt
- original eventcause
- cause of the modificationContradictionException
- can encounter a contradictionpublic void contradiction(ICause cause, IEventType event, String message) throws ContradictionException
Variable
contradiction
in interface Variable
cause
- ICause causing the exceptionevent
- event causing the contradictionmessage
- the detailed message @throws ContradictionException expected behaviorContradictionException
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
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
bottomUp
- way to iterate over ranges. true
means from lower bound to upper bound,
false
means from upper bound to lower bound.this
.public boolean why(RuleStore ruleStore, IntVar var, IEventType evt, int value)
ICause
Copyright © 2015. All rights reserved.