Class RealView
- 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 doubleprecisionprotected IntVarvar-
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 voidcreateDelta()Create a delta, if necessary, in order to observe removed values of a this.protected EvtSchedulercreateScheduler()NoDeltagetDelta()Return the delta domain of thisdoublegetLB()Retrieves the lower bound of the variabledoublegetPrecision()intgetTypeAndKind()Return a MASK composed of 2 main information: TYPE and KIND.doublegetUB()Retrieves the upper bound of the variableIntVargetVariable()Return the basis variablebooleanisInstantiated()Indicates whetherthisis instantiated (see implemtations to know what instantiation means).voidjustifyEvent(IntVar var, ICause cause, 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.voidnotify(IEventType event)To notify a view that the variable is observed has been modified.voidnotifyMonitors(IEventType event)Notify monitors of observed variable modificationsStringtoString()IEventTypetransformEvent(IntEventType evt)booleanupdateBounds(double lowerbound, double upperbound, ICause cause)Updates the bounds of the domain ofthistovalue.booleanupdateLowerBound(double value, ICause cause)Updates the lower bound of the domain ofthistovalue.booleanupdateUpperBound(double value, ICause cause)Updates the upper bound of the domain ofthistovalue.-
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, getPIndices, getPropagator, getPropagators, getViews, isAConstant, isBool, link, 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.variables.Variable
addMonitor, asBoolVar, asIntVar, asRealVar, asSetVar, clearEvents, contradiction, getCause, getDindex, getEnvironment, getEvtScheduler, getIndexInPropagator, getMask, getModel, getName, getNbProps, getPIndices, getPropagator, getPropagators, getViews, isAConstant, link, 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:IViewReturn the basis variable- Specified by:
getVariablein interfaceIView- Returns:
- variable observed
-
justifyEvent
public void justifyEvent(IntVar var, ICause cause, IntEventType mask, int one, int two, int three)
Description copied from interface:IViewThis methods is related to explanations, it binds an event occurring on the observed variable to the view.- Specified by:
justifyEventin interfaceIView- Parameters:
var- modified variablecause- cause of the modificationmask- type of modificationone- an inttwo- an intthree- an int
-
createScheduler
protected EvtScheduler createScheduler()
- Specified by:
createSchedulerin classAbstractVariable
-
toString
public String toString()
- Overrides:
toStringin classAbstractVariable
-
getLB
public double getLB()
Description copied from interface:RealVarRetrieves the lower bound of the variable
-
getUB
public double getUB()
Description copied from interface:RealVarRetrieves the upper bound of the variable
-
updateLowerBound
public boolean updateLowerBound(double value, ICause cause) throws ContradictionExceptionDescription copied from interface:RealVarUpdates the lower bound of the domain ofthistovalue. The instruction comes frompropagator.- If
valueis smaller than the lower bound of the domain, nothing is done and the return value isfalse, - if updating the lower bound to
valueleads to a dead-end (domain wipe-out), aContradictionExceptionis thrown, - otherwise, if updating the lower bound to
valuecan 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:
updateLowerBoundin 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 ContradictionExceptionDescription copied from interface:RealVarUpdates the upper bound of the domain ofthistovalue. The instruction comes frompropagator.- If
valueis greater than the upper bound of the domain, nothing is done and the return value isfalse, - if updating the upper bound to
valueleads to a dead-end (domain wipe-out), aContradictionExceptionis thrown, - otherwise, if updating the upper bound to
valuecan 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:
updateUpperBoundin 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 ContradictionExceptionDescription copied from interface:RealVarUpdates the bounds of the domain ofthistovalue. 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
ContradictionExceptionis 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:
updateBoundsin 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:
getPrecisionin interfaceRealVar
-
isInstantiated
public boolean isInstantiated()
Description copied from interface:VariableIndicates whetherthisis instantiated (see implemtations to know what instantiation means).- Specified by:
isInstantiatedin interfaceVariable- Returns:
trueifthisis instantiated
-
getDelta
public NoDelta getDelta()
Description copied from interface:VariableReturn the delta domain of this
-
createDelta
public void createDelta()
Description copied from interface:VariableCreate a delta, if necessary, in order to observe removed values of a this. If the delta already exists, has no effect.- Specified by:
createDeltain interfaceVariable
-
notifyMonitors
public void notifyMonitors(IEventType event) throws ContradictionException
Description copied from interface:VariableNotify monitors of observed variable modifications- Specified by:
notifyMonitorsin interfaceVariable- Parameters:
event- the event which occurred on the variable- Throws:
ContradictionException- if the monitor detects contradiction.
-
notify
public void notify(IEventType event) throws ContradictionException
Description copied from interface:IViewTo notify a view that the variable is observed has been modified.- Specified by:
notifyin 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:VariableReturn 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:
getTypeAndKindin interfaceVariable- Returns:
- an int representing the type and kind of the variable
-
-