Class AtomicModel<T extends Number & Comparable<T>>
java.lang.Object
org.djutils.event.LocalEventProducer
nl.tudelft.simulation.dsol.formalisms.devs.esdevs.AbstractDevsModel<T>
nl.tudelft.simulation.dsol.formalisms.devs.esdevs.AbstractDevsPortModel<T>
nl.tudelft.simulation.dsol.formalisms.devs.esdevs.AtomicModel<T>
- 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:
-
Nested Class Summary
Nested classes/interfaces inherited from class nl.tudelft.simulation.dsol.formalisms.devs.esdevs.AbstractDevsModel
AbstractDevsModel.StateUpdate
-
Field Summary
Modifier and TypeFieldDescriptionthe active input port that is currently processed in Parallel DEVS.protected boolean
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.protected boolean
applied conflict handling strategy in this component.protected T
the time span since the last event.static final boolean
conflict handling static: first the external event.static final boolean
conflict handling static: first the internal event.protected Phase
the current phase (if applicable).protected T
remaining TimeAdvance.protected T
the time of the previous event in this component.protected T
the time of the next scheduled event in this component.Fields inherited from class nl.tudelft.simulation.dsol.formalisms.devs.esdevs.AbstractDevsPortModel
inputPortMap, outputPortMap
Fields inherited from class nl.tudelft.simulation.dsol.formalisms.devs.esdevs.AbstractDevsModel
fullName, modelName, parentModel, simulator, STATE_UPDATE
Fields inherited from interface org.djutils.event.EventProducer
FIRST_POSITION, LAST_POSITION
-
Constructor Summary
ConstructorDescriptionAtomicModel
(String modelName, CoupledModel<T> parentModel) AtomicModel
(String modelName, CoupledModel<T> parentModel, T e, Phase initphase) Constructor for an atomic model within a coupled model with explicit phases.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.AtomicModel
(String modelName, DevsSimulatorInterface<T> simulator) AtomicModel
(String modelName, DevsSimulatorInterface<T> simulator, T e, Phase initphase) Constructor for a stand-alone atomic model with explicit phases.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. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
deltaConfluent
(T e, Object value) protected abstract void
deltaExternal
(T e, Object value) The user defined deltaExternal method that is defined in an extension of this class.protected void
deltaExternalEventHandler
(T e, Object value) This method handles an incoming external event.protected abstract void
the delta internal function that should be implemented by the extending class.protected void
This method handles an internal event.protected T
elapsedTime
(T eventTime) Return the elapsed time (e) since the last event.void
initialize
(T e) Initialize the atomic model.boolean
protected abstract void
lambda()
the lambda function that should be implemented by the extending class.void
printModel
(String space) Print the model, preceded by a user provided string.void
setConflict
(boolean conflict) protected abstract T
the time advance function that should be implemented by the extending class.Methods inherited from class nl.tudelft.simulation.dsol.formalisms.devs.esdevs.AbstractDevsPortModel
addInputPort, addOutputPort, getInputPortMap, getOutputPortMap, removeInputPort, removeOutputPort
Methods inherited from class nl.tudelft.simulation.dsol.formalisms.devs.esdevs.AbstractDevsModel
fireUpdatedState, getFullName, getModelName, getParentModel, getSimulator, setSimulator, toString
Methods inherited from class org.djutils.event.LocalEventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventListenerMap, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener
-
Field Details
-
sigma
remaining TimeAdvance. -
phase
the current phase (if applicable). -
timeLastEvent
the time of the previous event in this component. -
timeNextEvent
the time of the next scheduled event in this component. -
elapsedTime
the time span since the last event. -
activePort
the active input port that is currently processed in Parallel DEVS. -
INTERNAL_FIRST
public static final boolean INTERNAL_FIRSTconflict handling static: first the internal event.- See Also:
-
EXTERNAL_FIRST
public static final boolean EXTERNAL_FIRSTconflict handling static: first the external event.- See Also:
-
conflictStrategy
protected boolean conflictStrategyapplied conflict handling strategy in this component. -
conflict
protected boolean conflictconflict 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
Constructor for a stand-alone atomic model with explicit phases.- Parameters:
modelName
- String; the name of this componentsimulator
- DevsSimulatorInterface<T>; the simulator to schedule one
- T; initial elapsed timeinitphase
- Phase; the initial phase of the model
-
AtomicModel
Constructor for an atomic model within a coupled model with explicit phases.- Parameters:
modelName
- String; the name of this componentparentModel
- CoupledModel<T>; the coupled model this atomic model is part ofe
- T; initial elapsed timeinitphase
- Phase; the initial phase of the model
-
AtomicModel
- Parameters:
modelName
- String; the name of this componentparentModel
- CoupledModel<T>; the coupled model this atomic model is part of
-
AtomicModel
- Parameters:
modelName
- String; the name of this componentsimulator
- 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 componentsimulator
- DevsSimulatorInterface<T>; the simulator to schedule one
- T; initial elapsed timeinitphase
- Phase; the initial phase of the model to use for explicit phase modelsconflictStrategy
- 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 componentparentModel
- CoupledModel<T>; the coupled model this atomic model is part ofe
- T; initial elapsed timeinitphase
- Phase; the initial phase of the model to use for explicit phase modelsconflictStrategy
- boolean; the conflict strategy to use when internal and external events take place at the same time
-
-
Method Details
-
initialize
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
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
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 transitionvalue
- Object; the value that is passed through the port, which triggered the external event
-
deltaConfluent
- Parameters:
e
- T; the elapsed time since the last state transitionvalue
- 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
Print the model, preceded by a user provided string.- Specified by:
printModel
in classAbstractDevsModel<T extends Number & Comparable<T>>
- Parameters:
space
- String; the user provided string to print in front of the model (e.g. newlines, header).
-
getNextEvent
- Returns:
- the next simulation event for this atomic model.
-
getTimeLastEvent
- Returns:
- the timestamp of the last executed simulation event.
-
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
The user defined deltaExternal method that is defined in an extension of this class.- Parameters:
e
- T; the elapsed time since the last state transitionvalue
- 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
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.
-