A formal definition of simulation models can efficiently rely on Discrete Event Systems Specification (DEVS), which is a set-theoretic formalism introduced
in the early 70s [184], and can be seen as an extension of the Moore machine formalism [183]. While the Moore machine formalism is essentially a finite state
automaton whose output is determined by its state only, DEVS (i) makes the output directly depend on the input, (ii) associates a lifespan with each state,
Basically, DEVS1 provides a formalism used both to design hierarchically
decomposable discrete-event models and to have a general understanding of discrete event systems, decoupling them from the computer-generated models.
At the same time it provides a framework for model generation and execution via its abstract simulator concepts. The formalism defines a basic DEVS model
(namely the atomic model ) to be a structure:
M = hX, S, s0, Y, δint, δext, λ, tai (2.1)
where we have:
X: a set of external events;
S: a set of sequential states. A state’s definition can be extended with the σ
state variable, which tells the maximum time spent in a state when no external events are received, before triggering an internal transition. s0: the initial simulation state;
Y : a set of output events;
δint: S → S: the internal transition function, which specifies to which next state
the system will transit after the steady time specified for a given state
without the arrival of an external event has elapsed;
δext: Q × X → S : the external transition function, where Q = {(s, e)|s ∈ S, 0 ≤ e ≤ ta(s)}, and e is the elapsed time since the last state transition,
which specifies how the system changes state when an input is received; λ : S → Y : the output function, which generates an external output just before
an internal transition takes place;
ta : S → R0→∞: time advance function, which determines the permanence time
in the state. Once the time assigned to the state is consumed, an internal
1
transition is triggered. When the σ variable is present in the state, the
amount of time specified by σ is returned.
A model designed according to the DEVS formalism expressed by Equation
(2.1) transits along the states in S via its transition functions. If no events occur, the time advances according to the ta function applied to the current
state. A new state is determined by δintapplied to the old state. Output events are generated by the model right before an internal transition takes place. The
function δextproduces a state transition if an external event occurs, applied on the old state, the time spent in the old state, and the external event itself.
As hinted, DEVS defines the concept of coupled model as well:
DN = hXself, Yself, D, {Mi}, {Ii}, {Zi,j}, selecti (2.2)
where
Xself: is set of external events handled by the coupled model;
Yself: is set of output events handled by the coupled model;
D: a set of component references, i.e. the name set of sub-components of the
model;
{Mi}: a set such that ∀i ∈ D: Mi is a component structure, i.e. a DEVS model
definition;
{Ii}: a set such that ∀i ∈ D ∪ {self }: Ii are the influencees of i, i.e. the set of
external input couplings;
{Zi,j}: a set such that ∀j ∈ Ij: Zi,j is the i-to-j output translation function,
i.e. a function which maps events generated by one of the models in D to any other model in D;
the set of simultaneous events.
The structure is subject to the constraints that for ∀i ∈ D, the i-th model
is defined according to Equation (2.1), i.e. like:
Mi = hXi, Si, si0, Yi, δi, λi, taii
and that:
Ii ⊆ D ∪ {self }, i 6∈ Ii i.e. influencees of i must be taken only among the avail- able model definitions, and i cannot influence itself;
Zself,j : Xself → Xj i.e. external events handled by the coupled model can be
translated to external events of model j ∈ D;
Zi,self : Yi → Yself i.e. output events generated by any component structure
i ∈ D can be handled by the coupled model;
Zi,j : Yi→ Xj i.e. output events generated by any component structure i ∈ D
can be translated to input events of any component model j ∈ D;
A coupled model, therefore, tells how to connect several component models together to form a new model. The latter model is a DEVS model itself (thanks
to a closure property under coupling [185]), and can therefore be employed as a component in a larger coupled model. This means that component structured
present in {Mi} can be defined either according to Equation (2.1) or Equation (2.2). This is where the hierarchical notion of composable models comes into
effect.
To give an example of application of the DEVS formalism, let’s build the
model description of a producer-consumer system, according to the diagram in Figure 2.1. The behaviour of the system is described by input and output
Producer Consumer !produce ?produced ?consumed !consume Produce,0.1 Wait,∞ !produce ?consumed Consume,0.1 Wait,∞ !consume ?produced
Figure 2.1: Sample DEVS model: Producer/Consumer
put events are !produce and !consume. Both the producer and the consumer
have their states, namely Produce/Wait and Consume/Wait. Producer starts the simulation in the Produce state, while Consumer in the Wait state. Pro-
duce takes 0.1 seconds to produce an item, and similarly Consume takes 0.1 to consume it. When an item is produced, the output event !produce is sent out;
when the item is consumed, the output event !consume is similarly sent out.
The goal of this simulation model is to interconnect two sub-models (namely, the producer and the consumer) into a larger simulation model. In order to
formalize the producer and the consumer, two atomic DEVS models can be specified, by relying on the formalism expressed in Equation (2.1):
P roducer = hXP, SP, sP0, YP, δintP , δextP , λP, taPi (2.3)
where:
XP = {?consumed}
SP = {(d, σ)|d ∈ {P roduce, W ait}, σ ∈ [0, ∞]}
sP0 = (P roduce, 0.1)
taP(s) = σ, ∀s ∈ S
δPext(((W ait, σ), te), ?consumed) = (P roduce, 0.1)
δintP (P roduce, σ) = (W ait, ∞)
δPint(W ait, σ) = (P roduce, 0.1)
λP(P roduce, σ) =!produce
λP(W ait, σ) = ∅
and similarly:
Consumer = hXC, SC, sC0, YC, δintC , δextC , λC, taCi (2.4)
where: XC = {?produced} YC = {!consume} SC = {(d, σ)|d ∈ {Consume, W ait}, σ ∈ [0, ∞]} sC0 = (Consume, 0.1) taC(s) = σ, ∀s ∈ S
δextC (((W ait, σ), te), ?produced) = (Consume, 0.1)
δCint(Consume, σ) = (W ait, ∞)
δintC (W ait, σ) = (Consume, 0.1)
λC(W ait, σ) = ∅
The final (larger) simulation model can be therefore expressed by merging the atomic models expressed by equations (2.4) and (2.3) as a coupled DEVS model according to Equation (2.2):
DN = hXself, Yself, D, {Mi}, {Ii}, {Zi,j}, selecti
where:
Xself ={}
Yself ={}
D =P roducer, Consumer
MP roducer and MConsumer are defined according to Equations (2.4) and (2.3)
Ii={}
Zi,j ={(P roducer.!produce, Consumer.?produced),
(Consumer.!consume, P roducer.?consumed)}
Although it might look cumbersome to rely on a formal definition to describe such an easy model, there are two main advantages:
1) The model definition can undergo a verification and validation process, to
check if it is accurate and credible [148, 87]. This is a very important factor, considering that simulation models are just an imitation of the real world
phenomenon, and cannot exactly reproduce it. Therefore, depending on the actual purpose of the application, it should be verified and validated
2) The model definition can be transformed into an actual computer model,
which can be run by a simulation algorithm. This can be a fully-automated or a user-aided process, depending on the typology of the model.
As for point 1, when a given DEVS model falls in DEVS extensions like Schedule-Preserving DEVS (SP-DEVS) [70], Finite & Deterministic DEVS (FD-
DEVS) [71], or Finite & Real-time DEVS (FRT-DEVS) [69], it is formally proven that a behaviourally isomorphic finite structure can be derived from the infinite
state structure of the original model. This implies that a reachability graph can be derived from the structure, allowing, e.g., to decide whether the model
suffers from deadlock and/or livelock [68, 71, 69]. In the case of SP-DEVS, it is possible as well to define minimum and maximum execution time bounds [70].
Concerning point 2, in order to transform the formal definition of a model into an actual computer simulation, DEVS handles atomic and coupled models
in a different way. In particular, the simulation of an atomic model is carried out by a simulator, while the simulation of a coupled model is carried out by
a coordinator. The coordinator’s main role is to enforce time synchronization and support message propagation. The former controls the advancement of the
simulation time in all the atomic models, in order to always have them aligned. The latter transmits a triggering message (either input or output) along the
associated couplings, which are defined in the coupled DEVS model. As an example, the CD++ simulation toolkit [175] allows many simulation models
to be automatically defined. In this way, the construction of new models is simplified, along with their validation and verification.
Overall, this formal approach to discrete-event simulation has the benefit that the simulation model can “exist” even though there is no actual implemen-
analysis of the model itself, so that its properties can be studied/modified be-
fore the actual implementation is realized. Nevertheless, such analysis is diffi- cult, and therefore «direct computer simulation will remain a primary means of
generating, and studying, model behaviour »[187].