- java.lang.Object
-
- org.chocosolver.solver.variables.impl.AbstractVariable
-
- org.chocosolver.solver.variables.view.RealView
-
- All Implemented Interfaces:
Comparable<Variable>
,CArExpression
,ICause
,Identity
,RealVar
,Variable
,IView
public class RealView extends AbstractVariable implements IView, RealVar
- Since:
- 20/07/12
- Author:
- Charles Prud'homme, Jean-Guillaume Fages
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.chocosolver.solver.expression.continuous.arithmetic.CArExpression
CArExpression.Operator
-
-
Field Summary
Fields Modifier and Type Field Description protected double
precision
protected IntVar
var
-
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.continuous.arithmetic.CArExpression
NO_CHILD
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
createDelta()
Create a delta, if necessary, in order to observe removed values of a this.protected EvtScheduler
createScheduler()
void
explain(ExplanationForSignedClause clause, ValueSortedMap<IntVar> front, Implications ig, int p)
Clausal explanation for this cause.NoDelta
getDelta()
Return the delta domain of thisdouble
getLB()
Retrieves the lower bound of the variabledouble
getPrecision()
int
getTypeAndKind()
Return a MASK composed of 2 main information: TYPE and KIND.double
getUB()
Retrieves the upper bound of the variableIntVar
getVariable()
Return the basis variableboolean
isInstantiated()
Indicates whetherthis
is instantiated (see implemtations to know what instantiation means).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.void
notify(IEventType event)
To notify a view that the variable is observed has been modified.String
toString()
IEventType
transformEvent(IntEventType evt)
boolean
updateBounds(double lowerbound, double upperbound, ICause cause)
Updates the bounds of the domain ofthis
tovalue
.boolean
updateLowerBound(double value, ICause cause)
Updates the lower bound of the domain ofthis
tovalue
.boolean
updateUpperBound(double value, ICause cause)
Updates the upper bound of the domain ofthis
tovalue
.-
Methods inherited from class org.chocosolver.solver.variables.impl.AbstractVariable
addMonitor, asBoolVar, asIntVar, asRealVar, asSetVar, clearEvents, compareTo, 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.continuous.arithmetic.CArExpression
abs, acos, acosh, add, add, asin, asinh, atan, atan2, atan2, atanh, cos, cosh, div, div, eq, eq, exp, ge, ge, getModel, gt, gt, le, le, ln, lt, lt, max, max, min, min, mul, mul, neg, pow, pow, sin, sinh, sqrt, sub, sub, tan, tanh
-
Methods inherited from interface java.lang.Comparable
compareTo
-
Methods inherited from interface org.chocosolver.solver.ICause
forEachIntVar
-
Methods inherited from interface org.chocosolver.solver.variables.Variable
addMonitor, asBoolVar, asIntVar, asRealVar, asSetVar, clearEvents, contradiction, getCause, 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
-
-
-
-
Field Detail
-
var
protected final IntVar var
-
precision
protected final double precision
-
-
Constructor Detail
-
RealView
public RealView(IntVar var, double precision)
-
-
Method Detail
-
getVariable
public IntVar getVariable()
Description copied from interface:IView
Return the basis variable- Specified by:
getVariable
in interfaceIView
- Returns:
- variable observed
-
createScheduler
protected EvtScheduler createScheduler()
- Specified by:
createScheduler
in classAbstractVariable
-
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.- Specified by:
justifyEvent
in interfaceIView
- Parameters:
mask
- type of modificationone
- an inttwo
- an intthree
- an int
-
explain
public void explain(ExplanationForSignedClause clause, 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.
-
toString
public String toString()
- Overrides:
toString
in classAbstractVariable
-
getLB
public double getLB()
Description copied from interface:RealVar
Retrieves the lower bound of the variable
-
getUB
public double getUB()
Description copied from interface:RealVar
Retrieves the upper bound of the variable
-
updateLowerBound
public boolean updateLowerBound(double value, ICause cause) throws ContradictionException
Description copied from interface:RealVar
Updates the lower bound of the domain ofthis
tovalue
. The instruction comes frompropagator
.- If
value
is smaller than the lower bound of the domain, nothing is done and the return value isfalse
, - if updating the lower bound to
value
leads to a dead-end (domain wipe-out), aContradictionException
is thrown, - otherwise, if updating the lower bound to
value
can be done safely, the event type is created (the original event can be promoted) and observers are notified and the return value istrue
- Specified by:
updateLowerBound
in interfaceRealVar
- Parameters:
value
- new lower bound (included)cause
- updating releaser- Returns:
- true if the lower bound has been updated, false otherwise
- Throws:
ContradictionException
- if the domain become empty due to this action
- If
-
updateUpperBound
public boolean updateUpperBound(double value, ICause cause) throws ContradictionException
Description copied from interface:RealVar
Updates the upper bound of the domain ofthis
tovalue
. The instruction comes frompropagator
.- If
value
is greater than the upper bound of the domain, nothing is done and the return value isfalse
, - if updating the upper bound to
value
leads to a dead-end (domain wipe-out), aContradictionException
is thrown, - otherwise, if updating the upper bound to
value
can be done safely, the event type is created (the original event can be promoted) and observers are notified and the return value istrue
- Specified by:
updateUpperBound
in interfaceRealVar
- Parameters:
value
- new upper bound (included)cause
- update releaser- Returns:
- true if the upper bound has been updated, false otherwise
- Throws:
ContradictionException
- if the domain become empty due to this action
- If
-
updateBounds
public boolean updateBounds(double lowerbound, double upperbound, ICause cause) throws ContradictionException
Description copied from interface:RealVar
Updates the bounds of the domain ofthis
tovalue
. The instruction comes frompropagator
.- If the interval defined by [
lowerbound
,upperbound
] includes the domain of this, nothing is done and the return value isfalse
, - if updating the domain leads to a dead-end (domain wipe-out),
a
ContradictionException
is thrown, - otherwise, if updating the domain be done safely,
the event type is created (the original event can be promoted) and observers are notified
and the return value is
true
- Specified by:
updateBounds
in interfaceRealVar
- Parameters:
lowerbound
- new lower bound (included)upperbound
- new upper bound (included)cause
- update releaser- Returns:
- true if the upper bound has been updated, false otherwise
- Throws:
ContradictionException
- if the domain become empty due to this action
- If the interval defined by [
-
getPrecision
public double getPrecision()
- Specified by:
getPrecision
in interfaceRealVar
-
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
- Returns:
true
ifthis
is instantiated
-
getDelta
public NoDelta getDelta()
Description copied from interface:Variable
Return the delta domain of this
-
createDelta
public void createDelta()
Description copied from interface:Variable
Create a delta, if necessary, in order to observe removed values of a this. If the delta already exists, has no effect.- Specified by:
createDelta
in interfaceVariable
-
notify
public void notify(IEventType event) throws ContradictionException
Description copied from interface:IView
To notify a view that the variable is observed has been modified.- Specified by:
notify
in interfaceIView
- Parameters:
event
- the event received by the observed variable- Throws:
ContradictionException
- if a failure occurs
-
transformEvent
public IEventType transformEvent(IntEventType evt)
-
getTypeAndKind
public int getTypeAndKind()
Description copied from interface:Variable
Return a MASK composed of 2 main information: TYPE and KIND.
TYPE is defined in the 3 first bits : VAR ( 1 << 0), CSTE (1 << 1) or VIEW (1 << 2)
KIND is defined on the other bits : INT (1 << 3), BOOL (INT + 1 << 4), GRAPH (1 << 5) or META (1 << 6) To get the TYPE of a 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;
- Specified by:
getTypeAndKind
in interfaceVariable
- Returns:
- an int representing the type and kind of the variable
-
-