Showcases 6: A Grocery Store With Shifts and Self-Checkout
Requires Pro (ProcessFlow, declare)
Problem statement
The checkout-lanes episode asks one question about a grocery store: how many lanes to open. Its answer, five or six, is right for that store, but that store is a simplification. Every cashier works all day, every lane is staffed, and nobody scans their own groceries.
A real store manager has more levers. Cashiers work shifts, so the number on the floor can follow the crowd. And many stores now have a bank of self-checkout kiosks with one employee watching over them, who walks over when a kiosk wants an age check or complains about an unexpected item in the bagging area.
This showcase puts both into the same store, with the same customers, and asks the questions a manager would:
- Can shifts that follow the crowd beat five cashiers all day, without paying for more hours?
- What does a self-checkout bank with one attendant save, and who pays for the saving?
- When does that one attendant become the bottleneck?
Every rate and time in the model is an assumption made for illustration, not a measurement from a real store. The results are real runs of the model on SpiceGrinder 1.0.
The model
<dataset columns="time, customer, station, type, queue, busy, inSystem, items, self, freeKiosks, servers" seed="20261020">
<definitions>
<declare name="tillPlan" value="0:2, 120:3, 180:4, 360:5, 420:4, 480:3, 540:4, 720:3, 780:2"/>
<declare name="kiosks" value="6"/>
<declare name="selfShare" value="0.7"/>
<declare name="selfMax" value="20"/>
<declare name="helpP" value="0.25"/>
<declare name="noHelpP" value="0.75"/>
<declare name="helpScale" value="0.6"/>
<declare name="rateScale" value="1"/>
<declare name="output" value="events"/>
</definitions>
<root node="Store"/>
<nodes>
<Exponential name="Gap" lambda="1"/>
<NegativeBinomial name="ExtraItems" r="2" p="0.1"/>
<Uniform name="Choice" min="0" max="1"/>
<Append name="Draws">
<input name="ExtraItems"/>
<input name="Choice"/>
</Append>
<Calculate name="Shopper" expression="let items = x[0] + 1; y[0] = items; y[1] = if(items <= ${selfMax}, x[1] < ${selfShare}, 0)">
<input name="Draws"/>
</Calculate>
<Gamma name="ShopFactor" shape="4" rate="4"/>
<Gamma name="CheckoutFactor" shape="4" rate="4"/>
<Gamma name="ScanFactor" shape="4" rate="4"/>
<Gamma name="HelpTime" shape="2" scale="${helpScale}"/>
<ProcessFlow name="Store" stations="Shop:inf, Till:1, Scan:inf, Help:1" entry="Shop"
routing="Shop[self=1]>Scan:1; Shop>Till:1; Scan>Help:${helpP}, Scan>exit:${noHelpP}"
attributes="items, self"
serviceScale="Shop: 4 + 0.7 * items; Till: 0.6 + 0.06 * items; Scan: 1.0 + 0.1 * items"
schedule="Till: ${tillPlan}"
resources="Kiosk:${kiosks}" needs="Scan: Kiosk" keeps="Scan: Kiosk"
output="$output" closes="840" rateScale="$rateScale"
rate="0:1, 60:1.5, 120:1.8333333, 180:2.1666667, 240:2.5, 300:2, 360:1.5, 420:1.6666667, 480:2.3333333, 540:3.3333333, 600:3.1666667, 660:2.3333333, 720:1.6666667, 780:1, 840:1">
<input name="Gap" role="arrival"/>
<input name="Shopper" role="entity"/>
<input name="ShopFactor" role="service.Shop"/>
<input name="CheckoutFactor" role="service.Till"/>
<input name="ScanFactor" role="service.Scan"/>
<input name="HelpTime" role="service.Help"/>
</ProcessFlow>
</nodes>
</dataset>
Ten nodes, one of them the ProcessFlow that is the store. The customers are the same as in the episode’s store: the same arrival rates hour by hour, from 1 a minute at 08:00 to 3.3 a minute at 17:00, the same baskets (1 plus a NegativeBinomial, 19 items on average) and the same shopping and checkout times. The Append and Calculate give each customer two attributes: items, and self, which is 1 for a customer who has at most 20 items and picks self-checkout (7 in 10 of them do).
What is new is in the ProcessFlow:
- Shifts.
schedule="Till: ${tillPlan}"makes the number of cashiers follow the clock.tillPlanis a list ofminute:cashierspoints. When a cashier goes off shift they finish the customer in front of them first. The staffed tills share one line (“next cashier, please”). - The kiosks.
resources="Kiosk:${kiosks}"is a pool of 6 kiosks, andneeds="Scan: Kiosk"withkeeps="Scan: Kiosk"means a self-checkout customer takes a kiosk, scans at their own (slower) pace, and keeps the kiosk until they leave. - The attendant. One customer in four then needs help (
Scan>Help:${helpP}). They wait at their kiosk, still holding it, for the one attendant atHelp. While the attendant is busy elsewhere, that kiosk is out of action for everyone else.
Run it with grind --seed 101 --count 2000000 samples/pro/process-flow-grocery-store.xml. The run stops by itself once the doors have closed and the last customer has left. The first rows are the first two customers walking in and starting to shop:
1.7242327074211339,1,0,0,1,0,1,49.0,0.0,6,2147483647
1.7242327074211339,1,0,1,0,1,1,49.0,0.0,6,2147483647
2.2720194012711206,2,0,0,1,1,2,16.0,0.0,6,2147483647
Each row is one event: the time (minutes after 08:00), the customer, the station (0 is the shopping floor), the event type (0 arrive, 1 start), the line and the busy servers there, the customers in the store, then the customer’s items and self flag, the free kiosks, and the servers at that station (the shopping floor has no limit, which prints as the largest integer). Use --declare output=entities for one row per customer instead, with their time in the store and their wait.
samples/pro/process-flow-grocery-store.xml ships with the samples. learn/figures/s101-06-make.py runs every plan below for the same 30 simulated days the episode used (seeds 101 to 130), so each comparison is between plans facing exactly the same customers.
Four ways to staff the same day
| Plan | Staff-hours | Average wait | 95% of customers wait less than | Wait over 5 min |
|---|---|---|---|---|
| Five lanes all day (the episode’s store) | 70 | 3.4 min | 15.4 min | 22% |
| Five cashiers all day, one shared line | 70 | 3.1 min | 14.2 min | 22% |
| Shifts that follow the crowd | 68 | 0.8 min | 3.9 min | 3% |
| Shifts plus self-checkout (6 kiosks, 1 attendant) | 62 | 0.9 min | 5.4 min | 5% |
Means of 30 days; the standard errors are about a tenth of each value. The first row reproduces the episode’s figures exactly (3.41 minutes, the same 30 days).
Five all day is the wrong shape. Five cashiers are plenty in the morning and too few from 17:00 to 20:00, when customers come in faster than five can serve them. The average of 3.4 minutes hides an evening where the wait reaches 12.3 minutes.
One line, on its own, helps only a little. Putting the same five cashiers behind one shared line takes the average from 3.4 to 3.1 minutes. Customers choosing the shortest lane already do almost as well as one line; the problem is the number of cashiers in the evening, not the layout.
Shifts fix the evening. The shift plan is three 8-hour openers (08:00 to 16:00), three 8-hour closers (14:00 to 22:00), and four 4-hour part-timers who cover lunch (10:00 to 14:00 and 11:00 to 15:00) and the evening rush (two from 16:00 to 20:00, one from 17:00 to 21:00). That is 68 hours, two fewer than five all day, and the average wait falls from 3.4 to 0.8 minutes. No hour of the day averages more than 1.7 minutes.
Self-checkout saves hours, and the big baskets pay for it. Swapping one opener, one closer and one evening part-timer (20 cashier-hours) for 6 kiosks and one attendant (14 hours, all day) brings the day to 62 staff-hours. The overall average barely moves (0.9 minutes), but it splits in two: self-checkout customers wait 0.14 minutes on average, and the customers with full carts, who still need a cashier, wait 1.5 minutes, nearly twice as long as with the all-cashier shifts.
The kiosks are carrying real weight. With the same 48 cashier-hours and no kiosks, the average wait would be 31 minutes.
The attendant is the part to watch
The attendant is busy only 27% of the day, so the obvious question is whether one attendant could watch more kiosks. More kiosks change little: with 8 kiosks instead of 6 the self-checkout wait goes from 0.14 to 0.10 minutes, while with 4 it rises to 0.89, because in the evening customers queue for a free kiosk.
What matters is how often customers need help, and how long each fix takes:
When two customers in five need help instead of one in four, the attendant’s day goes from 27% busy to 43%, and the self-checkout wait quadruples (0.14 to 0.55 minutes). At 11 in 20 the attendant is still idle 41% of the day, yet the wait is 2.44 minutes, 17 times the starting point, and on average two-thirds of a kiosk is out of action at any moment because its customer is waiting for the attendant. A slower fix does the same: at 2.4 minutes per call instead of 1.2, the wait rises to 1.72 minutes.
An average utilization well under 100% does not mean there is slack. The calls for help bunch up in the evening rush, and each one that waits also takes a kiosk out of service, so the line for kiosks grows too. That knock-on effect is exactly what a spreadsheet of averages misses and what a simulation of each customer catches.
Checks
- Same store, same answer. With five lanes the model of the episode gives 3.41 minutes over these 30 days, the figure the episode reports.
- Who picks self-checkout. The chance that a basket has at most 20 items is 0.635, so 0.7 × 0.635 = 44.5% of customers should use the kiosks. The runs give 44.6% (of 1,680 customers a day). On the first day (seed 101) their baskets average 10.9 items, against 10.96 in theory.
- How busy the attendant is. 1,680 customers × 44.6% × 1 in 4 × 1.2 minutes a call is 225 minutes of help in the 840-minute day, or 27%. The runs give 27.2%.
What the model leaves out
These are choices, and each could be added: cashiers’ breaks (a dip in tillPlan), customers who switch to the other line when theirs is long, customers who abandon a full cart (timeouts), and the attendant stepping in as a cashier during a rush. A store with separate staffed lanes and shifts would also need customers to skip a lane that has closed; in 1.0 a customer choosing the shortest lane counts only the people in it, so this example uses one shared line for the cashiers.
What this gives you: a store you can reshape with a few declares: move a shift, add kiosks, change how often a kiosk calls for help, and see what each change does to the evening rush before you change the rota.