Title: Chapter 3 DEVS Simulators
1Chapter 3 DEVS Simulators
- Linking Models and Simulators
- DEVS Simulation Protocol Classes
- Atomic Model Simulator
- Basic DEVS Simulation Protocol
- Illustrating the DEVS Simulation Protocol within
DEVS itself - DEVS Simulation Protocol as Implemented in
DEVSJAVA
2We separated models and simulators now we bring
them together
DEVS Simulation Protocol
Single processor
C
Java
Distributed Simulator
DEVS
Simulator
Other Representation
Real-Time Simulator
Non DEVS
The DEVS simulation protocol is the agreement
between the DEVS modeler and the implemented
simulator
3DEVS Simulation Protocol Classes
Stand alone atomic models are assigned to
AtomicSimulators
Atomic models as components within coupled models
are assigned to coupledSimulators
Atomic Simulator
coordinator
coupledSimulator
1n
Coupled models are assigned to coordinators
1n
coupledCoordinator
Coupled models as components within coupled
models are assigned to coupledCoordinators
genDevs. simulation. coordinator
genDevs. simulation. coupledSimulator
4Atomic Model Simulator
- Every atomic model has a simulator assigned to
it which keeps track of the time of the last
event, tL and the time of the next event, tN. - Initially, the state of the model is
initialized as specified by the modeler to a
desired initial state, sinit. The event times,
tL and tN are set to 0 and ta(sinit),
respectively. - If there are no external events, the clock time,
t is advanced to tN, the output is generated and
the internal transition function of the model is
executed. The simulator then updates the event
times as shown, and processing continues to the
next cycle. - If an external event is injected to the model at
some time, text (no earlier than the current
clock and no later than tN), the clock is
advanced to text. - If text tN the output is generated.
- Then the input is processed by the confluent or
external event transition function, depending on
whether text coincides with tN or not.
m
timeline (abstract or logica)
tN
tL
inject at time t
s s init tL 0 tN ta(sinit)
If t tN generate output ? (s)
When receive m if m! null and t lt tN, s
?ext (s,t-tN,m) if m! null and t tN, s
?con (s,t-tN,m) if m null and t tN, s
?int (s)
Legend m message s state t clock time tL
time of last event tN time of next event
tL t tN t ta(s)
genDevs. simulation. atomicSimulator
5Basic DEVS Simulation Protocol
For a coupled model with atomic model components,
a coordinator is assigned to it and
coupledSimulators are assigned to its components.
In the basic DEVS Simulation Protocol, the
coordinator is responsible for stepping
simulators through the cycle of activities shown.
- Coupled Model Coordinator
- Coordinator sends nextTN to request tN from each
of the simulators. - All the simulators reply with their tNs in the
outTN message to the coordinator - Coordinator sends to each simulator a getOut
message containing the global tN (the minimum of
the tNs) - Each simulator checks if it is imminent (its tN
global tN) and if so, returns the output of its
model in a message to the coordinator in a
sendOut message. - Coordinator uses the coupling specification to
distribute the outputs as accumulated messages
back to the simulators in an applyDelt message to
the simulators for those simulators not
receiving any input, the messages sent are empty.
1 nextTN
Coupled Model
coordinator
After each transition tN t ta(), tL t
- Each simulator reacts to the incoming message as
follows - If it is imminent and its input message is empty,
then it invokes its models internal transition
function - If it is imminent and its input message is not
empty, it invokes its models confluence
transition function - If is not imminent and its input message is not
empty, it invokes its models external transition
function - If is not imminent and its input message is empty
then nothing happens.
6Illustrating The DEVS Simulation Protocol within
DEVS itself
The DEVS Simulation Protocol can be illustrated
within DEVSJAVA itself as follows The coupled
model, simTrip, represents the simulation of
coupled model gpt. We define simulator and
sCoordinator subclasses of atomic. The components
of simTrip are 3 instances of the simulator
class, one each for g, p, and t 1 instance of
the sCoordinator class.
SimpArc gpt
SimpArc simTrip
SimpArc sCoordinator
gpt
SimpArc simulator
7DEVS Simulation Protocol as Implemented in
DEVSJAVA
The DEVS Simulation Protocol implemented in
DEVSJAVA is basically the same as the one just
discussed. However, instead of having simulators
send their output messages to the coordinator,
they exchange messages when told to do so by the
coordinator. To be able to do so, they need the
coupling that is relevant to their attached
models this is transmitted to them in a a step,
called informCoupling, that is performed by the
coordinator at start up.
simulators.
tellAll
("initialize)
simulators.
tellAll
("initialize) --- at start of simulation
genDevs. simulation. coordinator
coordinator
simulators.
AskAll
(
nextTN
)
simulators.
AskAll
(
nextTN
)
simulators.
tellAll
simulators.
tellAll
(computeInputOutput)
simulators.
tellAll
("
sendMessages
")
simulators.
tellAll
("
sendMessages
")
DEVS cycle
simulators.
tellAll
("
DeltFunc
)
simulators.
tellAll
("
DeltFunc
)
message
message
coupledSimulator
coupledSimulator
coupledSimulator
Atomic Model
Atomic Model
Atomic Model
Atoimc3
genDevs. simulation. coupledSimulator
coupling
For example, the simulator for generator, g in
the coupled model gpt, knows that an output on
port out should be paired with port in in a
message to the simulator for processor p.