Chapter 7 Discrete Events Simulation with R

We are not going to explore this subject in depth, but at the end of this chapter we will understand what the discrete events simulation consists of, and we will carry out an example in R. Unlike Monte Carlo methods, which allow us to simulate events based on variables that change constantly over time, the discrete events simulation will help us to model the behavior of systems based on a sequence of discrete events over time. Remember that for both cases we use stochastic models.

Recall that different types of simulation apply depending on the nature of the system under consideration. A common model taxonomy classifies simulation problems along three main dimensions:

  1. deterministic vs. stochastic
  2. static vs. dynamic (depending on whether they require a time component)
  3. continuous vs. discrete (depending on how the system changes).

For instance, Monte Carlo methods are well-known examples of static stochastic simulation techniques. On the other hand, discrete-event simulation (DES) is a specific technique for modelling stochastic, dynamic and discretely evolving systems. As opposed to continuous simulation, which typically uses smoothly-evolving equational models, DES is characterized by sudden state changes at precise points of (simulated) time.

Customers arriving at a bank, products being manipulated in a supply chain, or packets traversing a network are common examples of such systems. The discrete nature of a given system arises as soon as its behavior can be described in terms of events, which is the most fundamental concept in DES. An event is an instantaneous occurrence that may change the state of the system, while, between events, all the state variables remain constant.

There are several world views, or programming styles, for DES (Banks 2005):

  • In the activity-oriented approach, a model consists of sequences of activities, or operations, waiting to be executed depending on some conditions. The simulation clock advances in fixed time increments. At each step, the whole list of activities is scanned, and their conditions, verified. Despite its simplicity, the simulation performance is too sensitive to the election of such a time increment. -Instead, the event-oriented approach completely bypasses this issue by maintaining a list of scheduled events ordered by time of occurrence. Then, the simulation just consists in jumping from event to event, sequentially executing the associated routines.
  • Finally, the process-oriented approach refines the latter with the addition of interacting processes, whose activation is triggered by events. In this case, the modeller defines a set of processes, which correspond to entities or objects of the real system, and their life cycle.

In this course we will use the simmer package to perform our DES. simmer (Ucar and Smeets 2019a) is a DES package for R which enables high-level process-oriented modelling, in line with other modern simulators. But in addition, it exploits the novel concept of trajectory: a common path in the simulation model for entities of the same type. In other words, a trajectory consist of a list of standardized actions which defines the life cycle of equivalent processes. This design pattern is flexible and simple to use. It is important to note that simmer package uses pipes in order to simplify the structure of the simulation.