1. Discrete Event Simulation
What a discrete-event simulation consists of — entities, events, the event list, the clock, and statistical counters — walked through on a single-server FCFS queue.
1.1. Stochastic Dynamic Systems
A discrete-event simulation model consists of:
- entities — the objects in the system
- attributes — properties of an entity
- state — variables describing the system at time
- events — instants at which the state changes
- event list — the scheduled future events, in time order
- clock — the current simulated time
- statistical counters — running totals used to compute the outputs
1.2. Single-server queueing system with FCFS service discipline
Here is an example:
flowchart LR
A([arrival]) --> Q[waiting line] --> S((server)) --> D([departure])
Objective. Estimate the average delay of a customer, where
Let be the delay of the -th customer. Then .
Entities: customer, server
Attributes: arrival time of a customer; service time of a customer
State: = number of customers in the system at time ; = status of the server
Events: arrival, departure, end of simulation
Statistical counters: number of customers delayed, total delay , area under , area under
Notation
- : interarrival time; is the arrival time (), so the 2nd customer arrives at .
- : service time.
- : departure time (the figure writes ; it should be ).
- Delay : time spent in the queue, excluding service.
- Waiting time : time spent in the system, including service, so .
Under FCFS, customer begins service when customer departs (or immediately, if the server is idle):
Sample path (from the board, )
| 1 | 2 | 3 | 4 | 5 | |
|---|---|---|---|---|---|
| 55 | 32 | 24 | 40 | 12 | |
| 55 | 87 | 111 | 151 | 163 | |
| 43 | 36 | 34 | 16 | – | |
| 98 | 134 | 168 | 184 | – | |
| 0 | 11 | 23 | 17 | 21 |
gantt
title Single-server queue, T = 180
dateFormat X
axisFormat %s
section Customer 1
in service :done, c1s, 55, 98
section Customer 2
in queue :active, c2q, 87, 98
in service :done, c2s, 98, 134
section Customer 3
in queue :active, c3q, 111, 134
in service :done, c3s, 134, 168
section Customer 4
in queue :active, c4q, 151, 168
in service :done, c4s, 168, 184
section Customer 5
in queue :active, c5q, 163, 184
Equivalently, as a step function:
| interval | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| 0 | 1 | 2 | 1 | 2 | 1 | 2 | 3 | 2 | |
| 0 | 0 | 1 | 0 | 1 | 0 | 1 | 2 | 1 |
where is the number in the queue.
Time-average quantities
Average number in system.
Average number in queue.
Server utilization (proportion of time the server is busy).
If and , this is the queue.
How the simulation is driven
flowchart LR
U["random numbers<br/>U ~ U(0,1)"] --> Tr[transformation]
In[input distributions] --> Tr
Tr --> V["random variates<br/>X_i, Y_i"] --> P[simulation program] --> O["outputs<br/>D_1, D_2, ..., W_1, W_2, ..."]