A classic M/M/c queue implemented as a pure discrete event simulation in Mesa.
Customers arrive according to a Poisson process (rate λ) and join a single FIFO queue. c servers each draw from the queue independently, with exponentially distributed service times (rate μ per server). This is the standard multi-server queuing model from operations research, with well-known analytical solutions for validation.
| Feature | Usage |
|---|---|
schedule_recurring |
Stochastic customer arrivals (exponential inter-arrival times) |
schedule_event(after=...) |
Scheduling service completions |
run_until |
Running a pure event-driven simulation to a target time |
| Dynamic agent lifecycle | Customers created on arrival, remove()d after service |
The model disables Mesa's default step schedule (_default_schedule.stop()) and is driven entirely by events.
Servers are active agents. When a server completes service, it checks the queue and pulls the next customer itself — a natural ABM pattern, in contrast to the system-centric routing common in traditional DES.
python model.pyRuns the simulation for 10,000 time units and prints simulated vs. analytical steady-state metrics.
| File | Description |
|---|---|
agents.py |
Customer and Server agents |
model.py |
MMcQueue model |
analytical_mmc.py |
Erlang C closed-form solutions for validation |
For a stable M/M/c system (traffic intensity analytical_mmc() to compute these, so simulation output can be compared directly:
M/M/3 Queue (λ=2.0, μ=1.0, T=10000.0)
Customers served: 19992
Metric Simulated Analytical
---------------------------------------------------
Server utilization 0.6672 0.6667
Avg wait time 0.3716 0.3750
Avg system time 1.3716 1.3750
Results converge to analytical values as simulation time increases.
There's no visualization yet, but an app.py implementation would be appreciated!