20 floors · 4 elevators · 1000 passengers · SCAN vs LOOK vs Random · M/M/c queueing model
Elevator Dispatching models a 20-story building with 4 elevators serving 1000 passengers per day. Three dispatching algorithms are compared: SCAN (elevator algorithm), LOOK (directional SCAN), and random assignment. The results show that LOOK reduces average wait time by 40% versus random, and 15% versus SCAN.
I built this at 16, after waiting 3 minutes for an elevator in a 20-story building. The building had 4 elevators — plenty of capacity — yet the wait was long. The problem wasn't the number of elevators; it was how they were dispatched.
Elevator dispatching is a queueing theory problem (M/M/c: Poisson arrivals, exponential service, c servers). The SCAN algorithm moves elevators in one direction until no more calls exist, then reverses. LOOK is a refinement that reverses early if no calls remain in the current direction. Random assignment is the baseline. The question: how much does the algorithm matter?
| Parameter | Value |
|---|---|
| Floors | 20 |
| Elevators | 4 |
| Passengers | 1000/day |
| Floor travel time | 2 seconds |
| Arrival distribution | Poisson (λ = 1000/3600) |
| Service model | M/M/c |
| Algorithm | Mean wait (s) | Std dev (s) | Improvement vs Random |
|---|---|---|---|
| SCAN | 28.4 | 12.1 | 35% |
| LOOK | 22.7 | 9.8 | 48% |
| Random | 43.2 | 18.5 | — |
LOOK is 15% faster than SCAN and 48% faster than random. The variance reduction is equally important — passengers experience more predictable wait times.
- Generate 1000 passengers with Poisson arrivals over 1 hour
- Simulate SCAN — elevators move in one direction, then reverse
- Simulate LOOK — elevators reverse immediately when no calls remain ahead
- Simulate Random — assign passengers to random elevators
- Compare mean wait time and variance
git clone https://github.com/Vitalcheffe/over-engineer-elevator.git
cd over-engineer-elevator
pip install numpy matplotlib
python3 model.py
python3 visualize.py| Layer | Technology |
|---|---|
| Language | Python 3.11+ |
| Simulation | Custom M/M/c model |
| Visualization | Matplotlib |
- Simplified physics. Real elevators have acceleration/deceleration profiles, door open/close times, and capacity constraints. The model uses constant 2s per floor.
- No peak hours. Arrival rate is uniform. Real buildings have morning/evening rush hours with 10× higher demand.
- No capacity limits. Elevators can hold unlimited passengers. Real elevators have weight limits that create secondary wait times.
- No destination dispatch. Modern buildings use destination dispatch (assign passengers before they board). This is not modeled.
- Single simulation run. No Monte Carlo analysis across multiple random seeds.
MIT — see LICENSE.
"The problem wasn't the number of elevators. It was how they were dispatched."
