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 Details

    • clock

      public double clock
    • iter

      public int iter
    • timeStep

      public double timeStep
    • idFactory

      protected IDFactory idFactory
  • Constructor Details

    • DynamicModelEngine

      public DynamicModelEngine​(double ts)
    • DynamicModelEngine

      public DynamicModelEngine​(double ts, DynamicModel model)
  • Method Details

    • setTimeStep

      public void setTimeStep​(double ts)
    • getModel

      public DynamicModel getModel()
    • executeModel

      public void executeModel​(int iters) throws DynamicModelException
      Executes the model for iterations.
      Throws:
      DynamicModelException
    • setModel

      public void setModel​(DynamicModel model)
      Set the model for this engine to execute.
      Parameters:
      model -
    • reset

      public void reset()
    • getIterations

      public int getIterations()
    • getClock

      public double getClock()
    • addComponent

      public void addComponent​(DynamicModelComponent c)
      Add c 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, use setModel().

      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

      public void removeComponent​(DynamicModelComponent c)
    • componentAdded

      public void componentAdded​(DynamicModelComponent c)
      Specified by:
      componentAdded in interface DynamicModelListener
    • componentRemoved

      public void componentRemoved​(DynamicModelComponent c)
      Specified by:
      componentRemoved in interface DynamicModelListener
    • seek

      public int seek​(DynamicModelComponent c)
      Returns the index of component c. Same rules as for Collections.binarySearch
      Parameters:
      c -
      Returns: