Class AtomicModel<T extends Number & Comparable<T>>

java.lang.Object
org.djutils.event.LocalEventProducer
Type Parameters:
T - the time type
All Implemented Interfaces:
Serializable, Remote, org.djutils.event.EventProducer

public abstract class AtomicModel<T extends Number & Comparable<T>> extends AbstractDevsPortModel<T>
AtomicModel class. Implements the Classic Parallel DEVS Atomic Model with Ports cf Zeigler et al (2000), section 4.2.2. and section 4.3 (pp. 84 ff). The algorithms for parallel DEVS are explained in Chapters 6 and 7.

Copyright (c) 2009-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can be found at https://https://simulation.tudelft.nl/dsol/docs/latest/license.html.

Author:
Mamadou Seck
, Alexander Verbraeck
See Also:
  • Field Details

    • sigma

      protected T extends Number & Comparable<T> sigma
      remaining TimeAdvance.
    • phase

      protected Phase phase
      the current phase (if applicable).
    • timeLastEvent

      protected T extends Number & Comparable<T> timeLastEvent
      the time of the previous event in this component.
    • timeNextEvent

      protected T extends Number & Comparable<T> timeNextEvent
      the time of the next scheduled event in this component.
    • elapsedTime

      protected T extends Number & Comparable<T> elapsedTime
      the time span since the last event.
    • activePort

      protected InputPort<T extends Number & Comparable<T>,?> activePort
      the active input port that is currently processed in Parallel DEVS.
    • INTERNAL_FIRST

      public static final boolean INTERNAL_FIRST
      conflict handling static: first the internal event.
      See Also:
    • EXTERNAL_FIRST

      public static final boolean EXTERNAL_FIRST
      conflict handling static: first the external event.
      See Also:
    • conflictStrategy

      protected boolean conflictStrategy
      applied conflict handling strategy in this component.
    • conflict

      protected boolean conflict
      conflict means that both an external event and an internal event happen at the same time; the strategy applied indicates what to do when this happens.
  • Constructor Details

    • AtomicModel

      public AtomicModel(String modelName, DevsSimulatorInterface<T> simulator, T e, Phase initphase)
      Constructor for a stand-alone atomic model with explicit phases.
      Parameters:
      modelName - String; the name of this component
      simulator - DevsSimulatorInterface<T>; the simulator to schedule on
      e - T; initial elapsed time
      initphase - Phase; the initial phase of the model
    • AtomicModel

      public AtomicModel(String modelName, CoupledModel<T> parentModel, T e, Phase initphase)
      Constructor for an atomic model within a coupled model with explicit phases.
      Parameters:
      modelName - String; the name of this component
      parentModel - CoupledModel<T>; the coupled model this atomic model is part of
      e - T; initial elapsed time
      initphase - Phase; the initial phase of the model
    • AtomicModel

      public AtomicModel(String modelName, CoupledModel<T> parentModel)
      Parameters:
      modelName - String; the name of this component
      parentModel - CoupledModel<T>; the coupled model this atomic model is part of
    • AtomicModel

      public AtomicModel(String modelName, DevsSimulatorInterface<T> simulator)
      Parameters:
      modelName - String; the name of this component
      simulator - DevsSimulatorInterface<T>; the simulator to schedule on
    • AtomicModel

      public AtomicModel(String modelName, DevsSimulatorInterface<T> simulator, T e, Phase initphase, boolean conflictStrategy)
      Constructor for a stand-alone atomic model with explicit phases and a conflict strategy.
      Parameters:
      modelName - String; the name of this component
      simulator - DevsSimulatorInterface<T>; the simulator to schedule on
      e - T; initial elapsed time
      initphase - Phase; the initial phase of the model to use for explicit phase models
      conflictStrategy - boolean; the conflict strategy to use when internal and external events take place at the same time
    • AtomicModel

      public AtomicModel(String modelName, CoupledModel<T> parentModel, T e, Phase initphase, boolean conflictStrategy)
      Constructor for an atomic model within a coupled model with explicit phases and a conflict strategy.
      Parameters:
      modelName - String; the name of this component
      parentModel - CoupledModel<T>; the coupled model this atomic model is part of
      e - T; initial elapsed time
      initphase - Phase; the initial phase of the model to use for explicit phase models
      conflictStrategy - boolean; the conflict strategy to use when internal and external events take place at the same time
  • Method Details

    • initialize

      public void initialize(T e)
      Initialize the atomic model. Start the first internal event based on the time 'e'. See Zeigler's model definition for the definition of 'e'.
      Parameters:
      e - T; elapsed time since the last state transition
    • elapsedTime

      protected T elapsedTime(T eventTime) throws RemoteException
      Return the elapsed time (e) since the last event.
      Parameters:
      eventTime - T; the time of the event for which we want to calculate the elapsed time.
      Returns:
      the elapsed time (e) since the last event.
      Throws:
      RemoteException - a remote exception occurred
    • deltaExternalEventHandler

      protected void deltaExternalEventHandler(T e, Object value)
      This method handles an incoming external event. As part of its function, it calls the deltaExternal method that is defined in an extension of this class.
      Parameters:
      e - T; the elapsed time since the last state transition
      value - Object; the value that is passed through the port, which triggered the external event
    • deltaConfluent

      protected void deltaConfluent(T e, Object value)
      Parameters:
      e - T; the elapsed time since the last state transition
      value - Object; the value that is passed through the port, which triggered the external event
    • deltaInternalEventHandler

      protected void deltaInternalEventHandler()
      This method handles an internal event. As part of its function, it calls the deltaInternal method that is defined in an extension of this class.
    • printModel

      public void printModel(String space)
      Print the model, preceded by a user provided string.
      Specified by:
      printModel in class AbstractDevsModel<T extends Number & Comparable<T>>
      Parameters:
      space - String; the user provided string to print in front of the model (e.g. newlines, header).
    • getNextEvent

      public SimEvent<T> getNextEvent()
      Returns:
      the next simulation event for this atomic model.
    • getTimeLastEvent

      public T getTimeLastEvent()
      Returns:
      the timestamp of the last executed simulation event.
    • getTimeNextEvent

      public T getTimeNextEvent()
      Returns:
      the timestamp of the simulation event to execute next.
    • isConflict

      public boolean isConflict()
      Returns:
      if there is a conflict between an intenal event and an external event that take place at the same time.
    • setConflict

      public void setConflict(boolean conflict)
      Parameters:
      conflict - boolean; indicate whether there is a conflict between an intenal event and an external event that take place at the same time.
    • deltaInternal

      protected abstract void deltaInternal()
      the delta internal function that should be implemented by the extending class.
    • deltaExternal

      protected abstract void deltaExternal(T e, Object value)
      The user defined deltaExternal method that is defined in an extension of this class.
      Parameters:
      e - T; the elapsed time since the last state transition
      value - Object; the value that has been passed through the port
    • lambda

      protected abstract void lambda()
      the lambda function that should be implemented by the extending class.
    • timeAdvance

      protected abstract T timeAdvance()
      the time advance function that should be implemented by the extending class.
      Returns:
      the ta, which is the time advance from one state to the next.