Class FixedRealVarImpl
- java.lang.Object
-
- org.chocosolver.solver.variables.impl.AbstractVariable
-
- org.chocosolver.solver.variables.impl.FixedRealVarImpl
-
- All Implemented Interfaces:
Comparable<Variable>
,CArExpression
,Identity
,RealVar
,Variable
public class FixedRealVarImpl extends AbstractVariable implements RealVar
Project: choco-solver.
- Since:
- 13/05/2016.
- 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 FixedRealVarImpl(String name, double value, Model model)
Create the shared data of any type of variable.
-
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()
IDelta
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 variableboolean
isInstantiated()
Indicates whetherthis
is instantiated (see implemtations to know what instantiation means).void
notifyMonitors(IEventType event)
Notify monitors of observed variable modificationsboolean
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, notifyPropagators, notifyViews, removeMonitor, setPIndice, storeEvents, subscribeView, swapOnActivate, swapOnPassivate, toString, 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, getNbViews, getPIndices, getPropagator, getPropagators, getView, isAConstant, link, notifyPropagators, notifyViews, removeMonitor, setPIndice, storeEvents, subscribeView, swapOnActivate, swapOnPassivate, unlink
-
-
-
-
Method Detail
-
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 IDelta 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
-
notifyMonitors
public void notifyMonitors(IEventType event) throws ContradictionException
Description copied from interface:Variable
Notify monitors of observed variable modifications- Specified by:
notifyMonitors
in interfaceVariable
- Overrides:
notifyMonitors
in classAbstractVariable
- Parameters:
event
- the event which occurred on the variable- Throws:
ContradictionException
- if the monitor detects contradiction.
-
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
-
createScheduler
protected EvtScheduler createScheduler()
- Specified by:
createScheduler
in classAbstractVariable
-
-