Method and checks
Shift Rehearsal is a small discrete-event simulation that runs in your browser. It's written to be checked: the rules are below, the code is public, and the results are compared with the textbook formula every week.
The model
- Arrivals: random, at the average rate you give for each hour (a Poisson process whose rate changes on the hour).
- Service: one line, first come first served. Service times are random around your average, with the variability you choose (a gamma distribution; "high" is exponential).
- Staff: the number on duty can change every hour. Someone going off duty finishes the customer they're serving first.
- Giving up: each customer has a random patience (exponential, around your average). If service hasn't started by then, they leave.
- Closing: no one new arrives after closing; people already in line are served, and that time is paid as overtime.
- Paired days: both plans see exactly the same customers on each simulated day, so differences come from staffing, not luck.
- Same inputs, same results: the random numbers are seeded from the scenario, so a link always reproduces the same numbers.
The weekly check against the textbook
For steady arrivals, exponential service and nobody giving up, queueing theory gives an exact long-run answer (Erlang C). Each week the self-test runs these cases through the simulator for 100 simulated 24-hour days and fails if they drift apart. Results from this build:
| Case | Formula: average wait | Simulated | Formula: served within 1 min | Simulated |
|---|---|---|---|---|
| One server, 80% busy (48/h, 1 min) | 4.00 min | 4.01 min | 34.5% | 34.8% |
| Four servers, 75% busy (180/h, 1 min) | 0.51 min | 0.51 min | 81.3% | 81.5% |
| Café-like: five staff, 83% busy (100/h, 2.5 min) | 1.86 min | 1.95 min | 55.6% | 55.3% |
| Desk-like: five staff, 80% busy (30/h, 8 min) | 4.43 min | 4.17 min | 51.1% | 52.7% |
Simulated days start with an empty shop, so at high utilisation they wait slightly less than the long-run formula, which assumes a line that's been running forever. Little's law (average line = arrival rate × average wait) holds in every case to within 0.02 people.
What it doesn't know
- Your real arrival pattern, service times and patience: they're your assumptions, and the results are only as good as they are.
- Several lines, priority customers, staff doing other work between customers, breaks, or customers who come back later.
- Anything about demand: more staff may bring more customers, or none.
That's why results are labelled simulations, not forecasts, and why the tool has a reality check: write down what happened after a real shift and see how far off the simulation was.