Class EqView
- java.lang.Object
-
- org.chocosolver.solver.variables.impl.AbstractVariable
-
- org.chocosolver.solver.variables.view.IntView<IntVar>
-
- org.chocosolver.solver.variables.view.IntBoolView
-
- org.chocosolver.solver.variables.view.EqView
-
- All Implemented Interfaces:
Cloneable
,Comparable<Variable>
,Iterable<Integer>
,ILogical
,ArExpression
,ReExpression
,ICause
,Identity
,BoolVar
,IntVar
,Variable
,IView
public final class EqView extends IntBoolView
declare an BoolVar based on X and C, such as (X = C) is reified by this.
Based on "Views and Iterators for Generic Constraint Implementations"
C. Shulte and G. Tack.
Eleventh International Conference on Principles and Practice of Constraint Programming- Since:
- 04/02/11
- Author:
- Charles Prud'homme
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.chocosolver.solver.expression.discrete.arithmetic.ArExpression
ArExpression.Operator
-
Nested classes/interfaces inherited from interface org.chocosolver.solver.expression.discrete.relational.ReExpression
ReExpression.Operator
-
-
Field Summary
-
Fields inherited from class org.chocosolver.solver.variables.view.IntBoolView
cste
-
Fields inherited from class org.chocosolver.solver.variables.impl.AbstractVariable
mIdx, model, monitors, MSG_EMPTY, MSG_INST, name, propagators
-
Fields inherited from interface org.chocosolver.solver.expression.discrete.arithmetic.ArExpression
NO_CHILD
-
Fields inherited from interface org.chocosolver.solver.variables.IntVar
MAX_INT_BOUND, MIN_INT_BOUND
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(int value)
Checks if a valuev
belongs to the domain ofthis
void
explain(ExplanationForSignedClause explanation, ValueSortedMap<IntVar> front, Implications ig, int p)
Clausal explanation for this cause.ESat
getBooleanValue()
int
getLB()
Retrieves the lower bound of the variableint
getUB()
Retrieves the upper bound of the variableboolean
instantiateTo(int value, ICause cause)
Instantiates the domain ofthis
tovalue
.boolean
isInstantiated()
Indicates whetherthis
is instantiated (see implemtations to know what instantiation means).boolean
isInstantiatedTo(int value)
Checks wetherthis
is instantiated toval
void
justifyEvent(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.int
nextValue(int v)
Returns the first value just after v inthis
which is in the domain.int
nextValueOut(int v)
Returns the first value just after v inthis
which is out of the domain.int
previousValue(int v)
Returns the previous value just before v inthis
.int
previousValueOut(int v)
Returns the first value just before v inthis
which is out of the domain.-
Methods inherited from class org.chocosolver.solver.variables.view.IntBoolView
_setNot, createDelta, createScheduler, getRangeIterator, getTypeAndKind, getValue, getValueIterator, hasNot, isLit, isNot, monitorDelta, not, removeAllValuesBut, removeInterval, removeValue, removeValues, setNot, setToFalse, setToTrue, toString, updateBounds, updateLowerBound, updateUpperBound
-
Methods inherited from class org.chocosolver.solver.variables.view.IntView
compareTo, doInstantiateVar, doRemoveIntervalFromVar, doRemoveValueFromVar, doUpdateLowerBoundOfVar, doUpdateUpperBoundOfVar, forEachIntVar, getDelta, getDomainSize, getRange, getVariable, hasEnumeratedDomain, iterator, notify, transformEvent
-
Methods inherited from class org.chocosolver.solver.variables.impl.AbstractVariable
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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.chocosolver.solver.expression.discrete.arithmetic.ArExpression
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
-
Methods inherited from interface org.chocosolver.solver.variables.BoolVar
boolVar, extractVar, intVar
-
Methods inherited from interface java.lang.Comparable
compareTo
-
Methods inherited from interface org.chocosolver.solver.variables.IntVar
forEachIntVar, getDomainSize, getNoChild, getRange, hasEnumeratedDomain, isBool, isExpressionLeaf, transformEvent
-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Methods inherited from interface org.chocosolver.solver.expression.discrete.relational.ReExpression
and, beval, decompose, extension, getModel, ieval, iff, ift, ift, ift, ift, imp, or, post, xor
-
Methods inherited from interface org.chocosolver.solver.variables.Variable
addMonitor, asBoolVar, asIntVar, asRealVar, asSetVar, clearEvents, contradiction, getCause, getDelta, getDindex, getEnvironment, getEvtScheduler, getIndexInPropagator, getMask, getModel, getName, getNbProps, getNbViews, getPIndices, getPropagator, getPropagators, getView, isAConstant, link, notifyMonitors, notifyPropagators, notifyViews, removeMonitor, setPIndice, storeEvents, subscribeView, swapOnActivate, swapOnPassivate, unlink
-
-
-
-
Constructor Detail
-
EqView
public EqView(IntVar var, int cste)
A boolean view based on var such that var = cste- Parameters:
var
- an integer variablecste
- an int
-
-
Method Detail
-
getBooleanValue
public ESat getBooleanValue()
-
instantiateTo
public boolean instantiateTo(int value, ICause cause) throws ContradictionException
Description copied from interface:IntVar
Instantiates the domain ofthis
tovalue
. The instruction comes frompropagator
.- If the domain of
this
is already instantiated tovalue
, nothing is done and the return value isfalse
, - If the domain of
this
is already instantiated to another value, then aContradictionException
is thrown, - Otherwise, the domain of
this
is restricted tovalue
and the observers are notified and the return value istrue
.
- Specified by:
instantiateTo
in interfaceIntVar
- Overrides:
instantiateTo
in classIntView<IntVar>
- Parameters:
value
- instantiation value (int)cause
- instantiation releaser- Returns:
- true if the instantiation is done, false otherwise
- Throws:
ContradictionException
- if the domain become empty due to this action
- If the domain of
-
isInstantiated
public boolean isInstantiated()
Description copied from interface:Variable
Indicates whetherthis
is instantiated (see implemtations to know what instantiation means).- Specified by:
isInstantiated
in interfaceVariable
- Overrides:
isInstantiated
in classIntView<IntVar>
- Returns:
true
ifthis
is instantiated
-
contains
public boolean contains(int value)
Description copied from interface:IntVar
Checks if a valuev
belongs to the domain ofthis
- Parameters:
value
- int- Returns:
true
if the value belongs to the domain ofthis
,false
otherwise.
-
isInstantiatedTo
public boolean isInstantiatedTo(int value)
Description copied from interface:IntVar
Checks wetherthis
is instantiated toval
- Parameters:
value
- int- Returns:
- true if
this
is instantiated toval
, false otherwise
-
getLB
public int getLB()
Description copied from interface:IntVar
Retrieves the lower bound of the variable- Returns:
- the lower bound
-
getUB
public int getUB()
Description copied from interface:IntVar
Retrieves the upper bound of the variable- Returns:
- the upper bound
-
nextValue
public int nextValue(int v)
Description copied from interface:IntVar
Returns the first value just after v inthis
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 }
- Parameters:
v
- the value to start checking (exclusive)- Returns:
- the next value in the domain
-
nextValueOut
public int nextValueOut(int v)
Description copied from interface:IntVar
Returns the first value just after v inthis
which is out of the domain. If v is less than or equal toIntVar.getLB()
-2, returns v + 1, if v is greater than or equal toIntVar.getUB()
, returns v + 1.- Parameters:
v
- the value to start checking (exclusive)- Returns:
- the next value out of the domain
-
previousValue
public int previousValue(int v)
Description copied from interface:IntVar
Returns the previous value just before v inthis
. 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 }
- Parameters:
v
- the value to start checking (exclusive)- Returns:
- the previous value in the domain
-
previousValueOut
public int previousValueOut(int v)
Description copied from interface:IntVar
Returns the first value just before v inthis
which is out of the domain. If v is greater than or equal toIntVar.getUB()
+2, returns v - 1, if v is less than or equal toIntVar.getLB()
, returns v - 1.- Parameters:
v
- the value to start checking (exclusive)- Returns:
- the previous value out of the domain
-
justifyEvent
public void justifyEvent(IntEventType mask, int one, int two, int three)
Description copied from interface:IView
This methods is related to explanations, it binds an event occurring on the observed variable to the view.- Parameters:
mask
- type of modificationone
- an inttwo
- an intthree
- an int
-
explain
public void explain(ExplanationForSignedClause explanation, ValueSortedMap<IntVar> front, Implications ig, int p)
Description copied from interface:ICause
Clausal explanation for this cause.This method must filled explanations with inferred literals. These literals are inferred from the analysis of (a subset of) conflicting nodes stored in front, the implication graph ig and the current node in conflict, not yet contained in front.
Optionally, this method can update front by looking for a predecessor of any node that seems more relevant than the declared one.
- Parameters:
explanation
- explanation to computefront
- ordered map of (variable,node> in the conflict frontier of the implication graph.ig
- an implication graphp
- the pivot node out of front
-
-