Class RealVarImpl
- java.lang.Object
-
- org.chocosolver.solver.variables.impl.AbstractVariable
-
- org.chocosolver.solver.variables.impl.RealVarImpl
-
- All Implemented Interfaces:
Comparable<Variable>,CArExpression,Identity,RealVar,Variable
public class RealVarImpl extends AbstractVariable implements RealVar
An implementation of RealVar, variable for continuous constraints (solved using IBEX).- Since:
- 18/07/12
- Author:
- Charles Prud'homme
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.chocosolver.solver.expression.continuous.arithmetic.CArExpression
CArExpression.Operator
-
-
Field Summary
-
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
-
-
Constructor Summary
Constructors Constructor Description RealVarImpl(String name, double lb, double ub, double precision, Model model)
-
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 variablebooleanisInstantiated()Indicates whetherthisis instantiated (see implemtations to know what instantiation means).voidnotifyMonitors(IEventType event)Notify monitors of observed variable modificationsStringtoString()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
-
-
-
-
Method Detail
-
getPrecision
public double getPrecision()
- Specified by:
getPrecisionin interfaceRealVar
-
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 [
-
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.
-
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
-
createScheduler
protected EvtScheduler createScheduler()
- Specified by:
createSchedulerin classAbstractVariable
-
toString
public String toString()
- Overrides:
toStringin classAbstractVariable
-
-