-
- All Superinterfaces:
Comparable<Variable>
,Identity
- All Known Implementing Classes:
AbstractVariable
,BitsetArrayIntVarImpl
,BitsetIntVarImpl
,BoolNotView
,BoolVarImpl
,EqView
,FixedBoolVarImpl
,FixedIntVarImpl
,FixedRealVarImpl
,IntBoolView
,IntervalIntVarImpl
,IntView
,LeqView
,MinusView
,OffsetView
,RealVarImpl
,RealView
,ScaleView
,SetVarImpl
public interface Variable extends Identity, Comparable<Variable>
To developers: any constructor of variable must pass in parameter the back-end ISolver, that is, in decreasing order: - the model portfolio, - the model (or portfolio workers but fes). Created by IntelliJ IDEA. User: xlorca, Charles Prud'homme
-
-
Field Summary
Fields Modifier and Type Field Description static int
BOOL
Kind of variable: boolean and integer too (unique).static int
CSTE
Type of variable: fixed (unique).static int
INT
Kind of variable: integer (unique).static int
KIND
Mask to get the kind of a variable.static int
REAL
Kind of variable: real.static int
SET
Kind of variable: set.static int
TYPE
Mask to get the type of a variable.static int
VAR
Type of variable: variable (unique).static int
VIEW
Type of variable: view (unique).
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addMonitor(IVariableMonitor monitor)
Build and add a monitor to the monitor list ofthis
.BoolVar
asBoolVar()
IntVar
asIntVar()
RealVar
asRealVar()
SetVar
asSetVar()
void
clearEvents()
Clear events stored temporarily bystoreEvents(int, ICause)
void
contradiction(ICause cause, String message)
Throws a contradiction exception based onvoid
createDelta()
Create a delta, if necessary, in order to observe removed values of a this.ICause
getCause()
IDelta
getDelta()
Return the delta domain of thisint
getDindex(int i)
This variable's propagators are stored in specific way which ease iteration based on propagation conditions.default IEnvironment
getEnvironment()
EvtScheduler
getEvtScheduler()
For scheduling purpose onlyint
getIndexInPropagator(int pidx)
Return the position of the variable in the propagator at position pidxint
getMask()
Model
getModel()
Return the associated modelString
getName()
Returns the name ofthis
int
getNbProps()
Return the number of propagatorsint
getNbViews()
int[]
getPIndices()
Propagator
getPropagator(int idx)
Return the "idx" th propagator of thisPropagator[]
getPropagators()
Return the array of propagators thisint
getTypeAndKind()
Return a MASK composed of 2 main information: TYPE and KIND.IView
getView(int p)
Get the view at position p in this variable views.boolean
isAConstant()
boolean
isInstantiated()
Indicates whetherthis
is instantiated (see implemtations to know what instantiation means).int
link(Propagator propagator, int idxInProp)
Link the propagator to thisvoid
notifyMonitors(IEventType event)
Notify monitors of observed variable modificationsvoid
notifyPropagators(IEventType event, ICause cause)
Ifthis
has changed, then notify all of its observers.
Each observer has its update method.void
notifyViews(IEventType event, ICause cause)
Notify views of observed variable modificationsvoid
removeMonitor(IVariableMonitor monitor)
Removesmonitor
form the list of this variable's monitors.void
setPIndice(int pos, int val)
Update the position of the variable in the propagator at position ingetPropagators()
.void
storeEvents(int mask, ICause cause)
Temporarily store modification events made on this.void
subscribeView(IView view)
Attaches a view to this variable.int
swapOnActivate(Propagator propagator, int idxInProp)
The propagator will be informed back of any modification of this.int
swapOnPassivate(Propagator propagator, int idxInProp)
The propagator will not be informed of any modification of this anymore.void
unlink(Propagator propagator, int idxInProp)
Remove a propagator from the list of propagator ofthis
.-
Methods inherited from interface java.lang.Comparable
compareTo
-
-
-
-
Field Detail
-
VAR
static final int VAR
Type of variable: variable (unique).- See Also:
- Constant Field Values
-
CSTE
static final int CSTE
Type of variable: fixed (unique).- See Also:
- Constant Field Values
-
VIEW
static final int VIEW
Type of variable: view (unique).- See Also:
- Constant Field Values
-
TYPE
static final int TYPE
Mask to get the type of a variable.- See Also:
- Constant Field Values
-
INT
static final int INT
Kind of variable: integer (unique).- See Also:
- Constant Field Values
-
BOOL
static final int BOOL
Kind of variable: boolean and integer too (unique).- See Also:
- Constant Field Values
-
SET
static final int SET
Kind of variable: set.- See Also:
- Constant Field Values
-
REAL
static final int REAL
Kind of variable: real.- See Also:
- Constant Field Values
-
KIND
static final int KIND
Mask to get the kind of a variable.- See Also:
- Constant Field Values
-
-
Method Detail
-
isInstantiated
boolean isInstantiated()
Indicates whetherthis
is instantiated (see implemtations to know what instantiation means).- Returns:
true
ifthis
is instantiated
-
getName
String getName()
Returns the name ofthis
- Returns:
- a String representing the name of
this
-
getPropagators
Propagator[] getPropagators()
Return the array of propagators this- Returns:
- the array of proapgators of this
-
getPropagator
Propagator getPropagator(int idx)
Return the "idx" th propagator of this- Parameters:
idx
- position of the propagator- Returns:
- a propagator
-
getNbProps
int getNbProps()
Return the number of propagators- Returns:
- number of propagators of this
-
getPIndices
int[] getPIndices()
- Returns:
- the array of indices of this variable in its propagators.
-
setPIndice
void setPIndice(int pos, int val)
Update the position of the variable in the propagator at position ingetPropagators()
.- Parameters:
pos
- position of the propagatorval
- position of this variable in the propagator
-
getDindex
int getDindex(int i)
This variable's propagators are stored in specific way which ease iteration based on propagation conditions. Any event indicates, through the dependency list which propagators should be executed. Thus, an event indicates a list ofi
s, passed as parameter, which help returning the right propagators.- Parameters:
i
- dependency index- Returns:
- index of the first propagator associated with that dependency.
-
getIndexInPropagator
int getIndexInPropagator(int pidx)
Return the position of the variable in the propagator at position pidx- Parameters:
pidx
- index of the propagator within the list of propagators of this- Returns:
- position of this in the propagator pidx
-
addMonitor
void addMonitor(IVariableMonitor monitor)
Build and add a monitor to the monitor list ofthis
. The monitor is inactive at the creation and must be activated (by the engine propagation).- Parameters:
monitor
- a variable monitor
-
removeMonitor
void removeMonitor(IVariableMonitor monitor)
Removesmonitor
form the list of this variable's monitors.- Parameters:
monitor
- the monitor to remove.
-
subscribeView
void subscribeView(IView view)
Attaches a view to this variable.- Parameters:
view
- a view to add to this variable.
-
getDelta
IDelta getDelta()
Return the delta domain of this- Returns:
- the delta domain of the variable
-
createDelta
void createDelta()
Create a delta, if necessary, in order to observe removed values of a this. If the delta already exists, has no effect.
-
link
int link(Propagator propagator, int idxInProp)
Link the propagator to this- Parameters:
propagator
- a newly added propagatoridxInProp
- index of the variable in the propagator- Returns:
- return the index of the propagator within the variable
-
swapOnPassivate
int swapOnPassivate(Propagator propagator, int idxInProp)
The propagator will not be informed of any modification of this anymore.- Parameters:
propagator
- the propagator to swapidxInProp
- index of the variable in the propagator- Returns:
- return the index of the propagator within the variable
-
swapOnActivate
int swapOnActivate(Propagator propagator, int idxInProp)
The propagator will be informed back of any modification of this.- Parameters:
propagator
- the propagator to swapidxInProp
- index of the variable in the propagator- Returns:
- return the index of the propagator within the variable
-
unlink
void unlink(Propagator propagator, int idxInProp)
Remove a propagator from the list of propagator ofthis
. SHOULD BE CONTAINED IN THIS.- Parameters:
propagator
- the propagator to removeidxInProp
- index of the variable in the propagator
-
notifyPropagators
void notifyPropagators(IEventType event, ICause cause) throws ContradictionException
Ifthis
has changed, then notify all of its observers.
Each observer has its update method.- Parameters:
event
- event on this objectcause
- object which leads to the modification of this object- Throws:
ContradictionException
- if a contradiction occurs during notification
-
notifyViews
void notifyViews(IEventType event, ICause cause) throws ContradictionException
Notify views of observed variable modifications- Parameters:
event
- the event which occurred on the variablecause
- the cause of the notification- Throws:
ContradictionException
- if the notification detects contradiction.
-
getNbViews
int getNbViews()
- Returns:
- the number of views attached to the variable
-
getView
IView getView(int p)
Get the view at position p in this variable views. The array is filled from position 0 to positiongetNbViews()
excluded.- Parameters:
p
- position of the view to return- Returns:
- view observing this variable, at position p
-
notifyMonitors
void notifyMonitors(IEventType event) throws ContradictionException
Notify monitors of observed variable modifications- Parameters:
event
- the event which occurred on the variable- Throws:
ContradictionException
- if the monitor detects contradiction.
-
contradiction
void contradiction(ICause cause, String message) throws ContradictionException
Throws a contradiction exception based on- Parameters:
cause
- ICause causing the exceptionmessage
- the detailed message @throws ContradictionException expected behavior- Throws:
ContradictionException
- the build contradiction.
-
getModel
Model getModel()
Return the associated model- Returns:
- a Model object
-
getEnvironment
default IEnvironment getEnvironment()
- Returns:
- the backtracking environment used for this variable
-
getTypeAndKind
int getTypeAndKind()
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;
- Returns:
- an int representing the type and kind of the variable
-
isAConstant
boolean isAConstant()
- Returns:
- true iff the variable is a constant (created with a singleton domain)
-
getEvtScheduler
EvtScheduler getEvtScheduler()
For scheduling purpose only- Returns:
- the scheduler
-
asIntVar
IntVar asIntVar()
- Returns:
- this cast into an IntVar.
- Throws:
ClassCastException
- if type is not compatible
-
asBoolVar
BoolVar asBoolVar()
- Returns:
- this cast into an BoolVar.
- Throws:
ClassCastException
- if type is not compatible
-
asRealVar
RealVar asRealVar()
- Returns:
- this cast into an RealVar.
- Throws:
ClassCastException
- if type is not compatible
-
asSetVar
SetVar asSetVar()
- Returns:
- this cast into an SetVar.
- Throws:
ClassCastException
- if type is not compatible
-
storeEvents
void storeEvents(int mask, ICause cause)
Temporarily store modification events made on this. This is requiered by the propagation engine.- Parameters:
mask
- event's maskcause
- what causes the modification (cannot be null)
-
clearEvents
void clearEvents()
Clear events stored temporarily bystoreEvents(int, ICause)
-
getMask
int getMask()
- Returns:
- possibly aggregated mask stored through by
storeEvents(int, ICause)
-
getCause
ICause getCause()
- Returns:
- cause stored through by
storeEvents(int, ICause)
orCause.Null
if differents causes modified this variable (this may happen when a view refers to this).
-
-