The
A checkout queue seems to change continuously, but look closely and it only ever changes at discrete instants: the moment a customer arrives, the moment a service starts, the moment a customer departs. Between those instants the state — how many are in the system, whether the server is busy — sits perfectly still. So there is no point simulating the gaps. DES keeps a simulation clock that does not tick second by second; it jumps straight to the time of the next event, does whatever that event requires, and jumps again.
The engine is a simple loop: pop the earliest event, advance the clock to it, update the state, and schedule whatever new events it triggers (an arrival schedules the next arrival; a service-start schedules the matching departure). Repeat until the clock passes your stopping time.
Take one server, first-come-first-served. Five customers arrive at times
The clock visits only the ten instants
| Clock | Event | Action taken | In system |
|---|---|---|---|
| 0 | C1 arrives | server idle → start C1, depart at 4 | 1 |
| 2 | C2 arrives | server busy → C2 waits | 2 |
| 3 | C3 arrives | server busy → C3 waits | 3 |
| 4 | C1 departs | start C2, depart at 7 | 2 |
| 7 | C2 departs | start C3, depart at 9 | 1 |
| 8 | C4 arrives | server busy → C4 waits | 2 |
| 9 | C3 departs | start C4, depart at 10 | 1 |
| 10 | C4 departs | server goes idle | 0 |
| 12 | C5 arrives | server idle → start C5, depart at 15 | 1 |
| 15 | C5 departs | server goes idle | 0 |
Now read off any statistic you like. The times spent waiting in the queue before service are
That trace used five particular service times. Draw five different random ones and you'd get a
different average wait. A single simulation run is exactly one draw of a
You could advance the clock in fixed steps (every second, say) and check "did anything happen?" — that is time-driven simulation, and it is how many physics and video-game loops work. But for a queue it is wasteful: almost every tick nothing changes, so you burn compute doing nothing, and if two events fall inside one tick you may get their order wrong. Event-driven simulation jumps straight to the next thing that actually happens, so it is both faster and exact about ordering. Time-stepping wins only when the state genuinely changes every instant (a moving fluid); for systems that lurch between quiet states, event-driven is the right model.
The single most common blunder in simulation is trusting a single run. One run gives one random sample, and randomness is lumpy: a quiet morning makes the system look calm, a freak burst makes it look overloaded. Without replications you cannot tell signal from noise, and without a warm-up period your averages are polluted by the empty-system start. A DES report that quotes "the average wait is 4.2 minutes" from one eight-hour run, with no interval and no warm-up, is not a result — it is an anecdote.