Discrete Event Systems: Lecture Notes of
Discrete Event Systems: Lecture Notes of
Lecture notes of
Discrete Event Systems
Simone Paoletti
Version 0.3
October 27, 2015
Indice
Notation 1
Introduction 2
Bibliography 23
Notation
Acronyms
DES Discrete Event System
Introduction
• a bank with different types of customers and services (desks, ATMs, etc.);
✫ ✪
Inputs are those variables that can be varied independently of the system,
and are fed to the system to modify its behavior. Outputs are those variables
describing how the systems reacts to the inputs. Different systems may react
differently to the same inputs. For instance, the same force may determine a
different acceleration depending on the mass of the body to which it is applied.
In this sense, the outputs depend on the inputs applied and on the system itself.
A (mathematical) model describes, implicitly or explicitly, a functional
relationship between the inputs and the outputs of a system. It should be
Basics of systems theory 4
always clear that the model is not the system. For instance, a resistor is not
the Ohm’s Law. The Ohm’s Law describes the voltage-current characteristic
of a resistor in the operating zone where it is approximately linear. In general,
a model differs from the system due to parameter uncertainties, unmodeled
dynamics, approximations. The structure, the accuracy and the complexity of
a model depend on the system to be described and on its intended use.
Definition 1.1 A system is termed static when the outputs at any time in-
stant depend only on the inputs applied at the same time instant.
Models of static systems are just functions mapping the inputs at time t to
the outputs at time t:
y(t) = f (u(t)). (1.1)
An example is the Ohm’s Law, mapping the current i passing through a resistor
to the voltage v across the resistor:
Definition 1.2 A system is termed dynamic when the outputs at any time
instant depend on the whole past history of the inputs.
Problem 1.1 Given a system, is it sufficient to know the inputs u(t) for all
t ≥ t0 in order to determine uniquely the outputs y(t) for all t ≥ t0 ?
For static systems, the answer is yes. What about dynamic systems?
Ma(t) = −f (1.5)
where M is the mass of the car, a(t) is the car acceleration, and f is the mod-
ulus of the braking force. Recalling that the acceleration is the first derivative
of the velocity, and integrating both sides of (1.5) between t0 (initial time) and
t > t0 , we get
f
v(t) = v(t0 ) − (t − t0 ) (1.6)
M
where v denotes the velocity of the car. Recalling that the velocity is the first
derivative of the position, and integrating both sides of (1.6) between t0 (initial
time) and t > t0 , we further get
f
∆x(t) = v(t0 )(t − t0 ) − (t − t0 )2 (1.7)
2M
where ∆x denotes the displacement. It can be observed that the displacement
does not depend only on the input (the braking force f ), but also on the value
of the velocity of the car at time t0 . This implies that the knowledge of the
input only, is not sufficient to determine uniquely the output. Also the value
v(t0 ) is needed. Notice that the velocity is neither an input, nor an output
of the system. It is rather an additional variable whose value at time t0 is
necessary in order to determine uniquely the output for a given input.
From Example 1.1 we understand that, for dynamic systems, the answer
to Problem 1.1 is no. This leads to the following definition.
Example 1.2 The queueing system of Figure 1.2 is formed by a single server
preceded by a queue (or storage space). The total capacity of the queueing
system is K, therefore the number of slots in the queue is K − 1.
queue server
Figure 1.2: Queueing system of Example 1.2.
Assume that one is interested in whether the server is idle or busy, and to this
aim defines the following variable:
0 if the server is idle
x= (1.8)
1 otherwise.
The question is whether (1.8) can be taken as a definition of state for the
system. The answer is no, and the reasoning is simple. Assume that x = 1.
This implies that the server is busy. What happens when the current service
terminates? Using only the information contained in x = 1, it is not possible
to determine uniquely whether the next value will be x′ = 0 or x′ = 1. On
the basis of Definition 1.3, the variable in (1.8) is therefore not a state for the
queueing system. Notice that the next value will be x′ = 0 if no customer is
waiting in the queue, and x′ = 1 otherwise. It is apparent that full information
about the number of customers in the system is needed for a proper definition
of state. This example will be continued in Example 1.4.
Notice that, for a given system, the definition of state is not unique. As will be
clear later (see, e.g., Example 1.5), different definitions of state can be given for
the same system, depending on the problem or application which is of interest.
Definition 1.4 A system is termed with continuous state when its state takes
values in a continuous set. It is termed with discrete state when its state takes
values in a discrete/countable set.
There exists a class of systems, called hybrid systems, for which some compo-
nents of the state are continuous, and others are discrete.
Basics of systems theory 7
30
28
26
°C 24
22
20
18
0 4 8 12 16 20 24
hour
Definition 1.5 A system is termed time-driven when all its variables (inputs,
state and outputs) may change at any time instant with regular/synchronous
ticking.
The above definition implies that time is an independent variable for time-
driven systems. There is an external clock, and all system variables may
change at any clock tick. Figure 1.3 shows an example of this type, where the
observed variable is the ambient temperature in a summer day. Differential
equations are typical models used to describe time-driven systems.
Definition 1.6 A system is termed event-driven when its state changes only
upon the (typically irregular/asynchronous) occurrence of events.
It will be clear later that, for event-driven systems, “time” (meaning the time
instants when the events occur) is a dependent variable of the system. An
example of sample path (or state trajectory) of an event-driven system is shown
in Figure 1.4. Its most evident characteristic is that it is piecewise constant,
with the time instants of the state jumps determined by the asynchronous
occurrence of events.
x(t)
system, it is clear that the state changes only upon the occurrence of events,
in particular:
• the state is increased by one when the arrival of a new customer occurs
(except when the system is full);
a a a a a
0 1 2 ... K-1 K
d d d d
Figure 1.5: State transition diagram for the queueing system of Example 1.4.
• an event-driven dynamics.
There exist real systems that can be naturally viewed as discrete event systems.
A typical example is provided next.
Example 1.4 Consider again the queueing system of Example 1.2, and define
the state x as the number of customers in the system. It turns out that x may
take values in the discrete state space
Moreover, the state x may change only upon the arrival of a new customer, or
upon the termination of a service (assuming that customers depart from the
system after service). We can thus define the event set
E = {a, d} (1.10)
where a denotes the arrival of a new customer, and d denotes the termination
of a service in the server. The event-driven dynamics of the queueing system
can be represented through the state transition diagram in Figure 1.5. In the
state transition diagram, the nodes represent the states of X , whereas labeled
arcs represent the state transitions: an arc from x to x′ with label e means
that, when the current state is x and the next event is e, the next state will
be x′ . Notice that in state x = K the queueing system is full, and therefore
arrivals of new customers (that are still possible) are rejected due to lack of
space (the state of the system does not change). Notice also that the state
transition diagram contains the information that event d is not possible in
Basics of systems theory 10
state x = 0 (there is no arc labeled with d exiting from node 0). Indeed, when
the queueing system is empty, no termination of service is possible.
In other cases, real systems that are naturally time-driven, can be modeled as
event-driven for particular applications.
Example 1.5 A cart moves along a track. Sensors are located at three points
of the track (they are denoted by A, B and C in Figure 1.6). Each sensor sends
an impulse when the cart crosses the corresponding point, in both directions.
For the sake of simplicity, it is assumed that the cart never changes direction
when it is across a sensor.
xxxxxx xxxxx
xxxxxx
xxxxxx xxxxx
xxxxx
xxxxxx xxxxx
xxxxxx
xxxxxx xxxxx
xxxxx
xxxxxx
xxxxxx xxxxx
xxxxx
xxxxxx xxxxx
xxxxxx xxxxx
xxxxxx xxxxx
xxxxxx
xxxxxx xxxxx
xxxxx
xxxxxx xxxxx
z A B C
The cart can be naturally seen as a time-driven system, whose motion is mod-
eled by the second Newton’s law:
where M is the mass of the cart, z is the position of the cart along the track,
and f is the tractive force applied to the cart. In principle, by integrating
twice (1.11), and given the initial position z(t0 ), the initial velocity ż(t0 ), and
the applied force f (t) for all t ≥ t0 , it is possible to know from the model
the exact position z(t) of the cart at any t ≥ t0 . In practice, uncertainty
on the aforementioned quantities may lead to discrepancies between the real
system and the model. However, in some applications, it is neither required
nor feasible to know the exact position of the cart. It is sufficient to know the
interval in which the cart is localized. To this aim, the input provided by the
sensors can be used. Define the state of the system as follows:
0 if z < A
1 if A ≤ z < B
x= (1.12)
2 if B ≤ z < C
3 if z ≥ C.
a b c
0 1 2 3
a b c
Figure 1.7: State transition diagram for the cart system of Example 1.5.
E = {a, b, c} (1.14)
where a means that an impulse is received from the sensor located at A, and
so on. With these definitions, we can construct the state transition diagram
in Figure 1.7. Notice that the dynamics of the system so described, turns out
to be an event-driven dynamics.
✫ ✪
Notice that the event sequence {e1 , e2 , . . .} is the model input, and the cor-
responding state sequence {x0 , x1 , x2 , . . .} is the model output, provided that
event ek is possible in state xk−1 for all k = 1, 2, . . .. To understand this, recall
the queueing system of Example 1.4, where event d is not possible in state 0.
An event sequence such that event d should occur in state 0, is infeasible for
the queueing system.
Untimed models of discrete event systems 13
The following rules describe how a state automaton operates, i.e. it gen-
erates the state sequence corresponding to a given event sequence.
Algorithm 2.1
1. Set k = 1
2. If ek ∈
/ Γ(xk−1 ), then goto step 5
3. Compute xk = f (xk−1 , ek )
5. Error exit
Notice that an error exit occurs in step 5 of Algorithm 2.1. This is because
the next event is one which is actually not possible in the current state. This
leads to the following definition of feasibility for an event sequence.
Definition 2.2 The event sequence {e1 , e2 , . . .} is said to be feasible for the
DES described by the state automaton (E, X , Γ, f, x0) if ek ∈ Γ(xk−1 ) for all
k = 1, 2, . . ., where x0 is the initial state and xk = f (xk−1 , ek ).
Example 2.1 Consider the queueing system of Example 1.2. The definitions
of E and X are given in Example 1.4. The other elements of the corresponding
state automaton (E, X , Γ, f, x0) are defined next.
Γ(0) = {a}
Γ(x) = {a, d}, x = 1, 2, . . . , K
Definition 2.3 A state automaton with outputs is a 7-tuple (E, X , Γ, f, x0, Y, g),
where:
For a state automaton with outputs, Algorithm 2.1 returns also the output
sequence {y0, y1 , y2 , . . .}, where yk = g(xk ), k = 0, 1, 2, . . ..
It is worthwhile to note that state automata with outputs include Moore
machines as special cases. In theory of computation, a Moore machine is a
finite-state machine whose output values are determined solely by the current
state. Moore machines are typically used in sequential logic implementation.
Example 2.2 Consider again the queueing system of Examples 1.2, 1.4 and
2.1, and assume that one is only interested in whether the server is idle or
busy. To this aim, one can extend the state automaton of Example 2.1 by
adding the output set Y = {0, 1} and the output function
0 if x = 0
g(x) =
1 otherwise
where outputs 0 and 1 mean that the server is idle and busy, respectively.
• The oriented and labeled arcs describe the state transition function f :
an oriented arc with label e is added from node x to node x′ if and only
if e ∈ Γ(x) and x′ = f (x, e).
e
✗✔ ✗✔
... ....
....... ........
.....
..
.... ✇ ..
x x′
✖✕✖✕
Untimed models of discrete event systems 16
a a a a a
0 1 2 ... K-1 K
d d d d
Figure 2.2: State transition diagram with outputs for the queueing system of
Example 2.2.
• The labels on the nodes describe the output function g: a label y is added
on node x if and only if y = g(x).
✗✔
...... .............
...... y ......... ...............
.....
... ✇ ....
.. .. ✇....
x
✖✕
✗✔
✲ x0
✖✕
..
′′
x
. ...
✖✕
...
....
........... ........✯
...... ...
...
....
e′′
Example 2.3 For the state automaton of Example 2.1, the state transition
diagram is shown in Figure 1.5. When the variant of Example 2.2 is considered,
the state transition diagram with outputs is shown in Figure 2.2.
3
As we have seen in the previous chapter, state automata describe only the
logical behaviour of discrete event systems. Given a sequence of events, a
state automaton returns the corresponding sequence of states. In this chapter,
we introduce timed automata as models of discrete event systems including
information about time instants when events (and thus state transitions) occur.
3.1 Introduction
One could argue that event times (i.e. time instants when events occur) could
be provided as inputs to the timed model of a DES. If this were the case,
there would be little to say. Recall that in discrete event systems state tran-
sitions occur only simultaneously with events. If event times were known, the
same would be for time instants when state transitions occur, and one would
only need to know the next state, given the current state and the next event.
That is, timed models of discrete event systems would remain merely logical
models. Now, recalling the definition of system input given in Section 1.1, the
question is whether event times can be actually considered as inputs to dis-
crete event systems. In other words, is it true that event times can be decided
independently of the system? The next example tries to answer this question.
• First In-First Out (FIFO) is a queueing discipline where the oldest task
of the queue is processed first;
Timed models of discrete event systems 18
• Round Robin (RR) is a queueing discipline where time slices are assigned
to each task of the queue in equal portions and in circular order.
In the case of FIFO, the ongoing task uses the resource until completion,
without interruption. In the case of RR, a time slice is assigned to the first
task of the queue. If processing of the task does not terminate before the time
slice expires, the task is relegated to the last position of the queue, and all
other tasks are shifted one position forward. On the other hand, if processing
of the task terminates before the time slice expires, the processed task leaves
the system, and all other tasks are shifted one position forward in the queue.
In both cases, the task on top of the queue is then assigned a new time slice.
Thanks to the cyclic and equitable assignment of the resource to all tasks of
the queue, one advantage of RR versus FIFO is that it is starvation-free.
Consider a resource, and tasks needing to use the resource. The system
can be modeled as the queueing system of Figure 1.2, where the resource plays
the role of the server, and the queue is the list of waiting tasks. Given the
tasks with characteristics specified in Table 3.1, we want to determine when
each task will be completed in case either FIFO or RR is applied. The resource
is assumed to be initially idle. In the following, we denote by ai and di the
arrival and the completion of the ith task, respectively.
FIFO
#1
#2 #1
#3 #2 #1
#3 #2
#3
a1 a2 a3 d1 d2 d3
RR
In the case of RR, expiration of the time slice is another event to be considered.
We denote this event by s. It is assumed that the time slice amounts to Ts = 1.5
time units.
Timed models of discrete event systems 20
#1
• At t2 = 2.5, the time slice expires (event s). Since task #1 is the only task
currently in the system, it is again assigned a time slice. The residual
execution time of task #1 amounts to 2.5 time units, which is greater
than the time slice. The assigned time slice will expire at t = 4.0.
#1
#2 #1
• At t4 = 4.0, the time slice expires (event s). Task #1 is added to the
waiting list with residual execution time equal to 1.0 time unit. Task #2
is assigned a time slice. The execution time of task #2 amounts to
2.0 time units, which is greater than the time slice. The assigned time
slice will expire at t = 5.5.
#1 #2
#3 #1 #2
Timed models of discrete event systems 21
• At t6 = 5.5, the time slice expires (event s). Task #2 is added to the
waiting list with residual execution time equal to 0.5 time units. Task #1
is assigned a time slice. The residual execution time of task #1 amounts
to 1.0 time unit, which is less than the time slice. Task #1 will be
completed at t = 6.5.
#2 #3 #1
#2 #3
• At t8 = 8.0, the time slice expires (event s). Task #3 is added to the
waiting list with residual execution time equal to 1.0 time unit. Task #2
is assigned a time slice. The residual execution time of task #2 amounts
to 0.5 time units, which is less than the time slice. Task #2 will be
completed at t = 8.5.
#3 #2
#3
a1 s a2 s a3 s d1 s d2 d3
0 1.0 2.5 3.5 4.0 4.5 5.5 6.5 8.0 8.5 9.5 time
The lesson we learn from Example 3.1, is that event times may depend on
the system, and therefore they cannot be taken as system inputs, in general.
Event times are rather system outputs, for which suitable modeling mecha-
nisms should be devised.
Bibliography