Package mgui.models.dynamic
Class DynamicModelEngine
java.lang.Object
mgui.models.dynamic.DynamicModelEngine
- All Implemented Interfaces:
DynamicModelListener
public class DynamicModelEngine extends java.lang.Object implements DynamicModelListener
The main engine class for coordinating a dynamic model. DynamicModelEngine has the
following main functions:
- Sending time-step signals to all dynamic components in a dynamic model
- Update a model environment at every time-step
- Handle discrete causal events fired by dynamic components
- Version:
- 1.0
- Author:
- Andrew Reid
-
Field Summary
-
Constructor Summary
Constructors Constructor Description DynamicModelEngine(double ts)
DynamicModelEngine(double ts, DynamicModel model)
-
Method Summary
Modifier and Type Method Description void
addComponent(DynamicModelComponent c)
Addc
to this engine.void
componentAdded(DynamicModelComponent c)
void
componentRemoved(DynamicModelComponent c)
void
executeModel(int iters)
Executes the model foriterations. double
getClock()
int
getIterations()
DynamicModel
getModel()
void
removeComponent(DynamicModelComponent c)
void
reset()
int
seek(DynamicModelComponent c)
Returns the index of component c.void
setModel(DynamicModel model)
Set the model for this engine to execute.void
setTimeStep(double ts)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
clock
public double clock -
iter
public int iter -
timeStep
public double timeStep -
idFactory
-
-
Constructor Details
-
DynamicModelEngine
public DynamicModelEngine(double ts) -
DynamicModelEngine
-
-
Method Details
-
setTimeStep
public void setTimeStep(double ts) -
getModel
-
executeModel
Executes the model foriterations. - Throws:
DynamicModelException
-
setModel
Set the model for this engine to execute.- Parameters:
model
-
-
reset
public void reset() -
getIterations
public int getIterations() -
getClock
public double getClock() -
addComponent
Addc
to this engine. Note that adding a component to an engine assigns it a new ID; thus, it is a very bad idea to attach the same model to more than one engine. If component is already in list, does nothing. Note this method requires two binary search operations; if adding an entire model, usesetModel()
.TODO enforce this restriction
TODO consider making this protected, so that components can only be added via the setModel and componentAdded methods...
- Parameters:
c
- DynamicModelComponent to add
-
removeComponent
-
componentAdded
- Specified by:
componentAdded
in interfaceDynamicModelListener
-
componentRemoved
- Specified by:
componentRemoved
in interfaceDynamicModelListener
-
seek
Returns the index of component c. Same rules as for Collections.binarySearch- Parameters:
c
-- Returns:
-