10 · Rank a technician queue
Choose which facilities work order gets the next technician, then replay the shift to see which repairs actually make their deadlines.
One technician, two repairs
You are at the Facilities Helpdesk. On the severity-rule schedule, an electrical fault in a public area arrives while a higher-severity job is still waiting. Both jobs are due by the same slot. Each takes one slot to finish, and the public-area sensor reading is higher. Which repair gets the electrician who is free now?
Facilities Helpdesk · Dispatch board
Severity-rule queue · Shift 56 · Slot 5
queue-56-16- Trade
- Electrical
- Finish by
- Slot 7
- Repair time
- 1 slot
- Severity
- 2
- Sensor index
- 0.931
queue-56-00- Trade
- Electrical
- Finish by
- Slot 7
- Repair time
- 1 slot
- Severity
- 4
- Sensor index
- 0.505
Tech 1 · BusyElectrical / HVAC
Tech 2 · FreeElectrical / plumbing
Tech 3HVAC / plumbing
Check who can take either work order
Only Tech 2 can start an electrical job now. Tech 1 already has a job until slot 6. Tech 3 lacks the electrical qualification even when free.
Two work orders waiting at slot 5 in the saved severity-rule replay. A slot lasts 30 minutes.
Change one fact. Suppose you want to send the free electrician to the public-area job. Change only Tech 2’s availability in this snapshot. Can you still start that repair now?
| Tech 2 at slot 5 | Can the top-ranked electrical job start? |
|---|---|
| Free, as recorded | Yes. Assign Tech 2 if the policy selects that job. |
| Busy, for the thought experiment | No. Tech 1 is still busy and Tech 3 lacks the qualification. |
The rank tells you what to prefer. The staffing state tells you what you can do. The pair above shows the difference. The experiment asks whether a better preference changes which jobs finish on time.
The learned score raised ranking quality and moved five high-impact repairs inside deadline
Same 12 held-out shifts and 264 tickets under both dispatch policies
1Ranking quality
Mean NDCG@10 per shift, a score from 0 to 1
aDeadline misses
Tickets late, including high-impact tickets in orange
bScore impact, then assign the work
The severity rule ranks by the severity recorded at intake. Learned impact estimates the eventual impact from severity, slack at intake, expected duration, the sensor reading and whether the repair is in a public area. Both sort equal scores by deadline and then ticket identifier. The simulated grade is the historical outcome used to train the regressor. A held-out ticket’s grade stays with the evaluator.
The simulator generates that grade from severity, sensor reading and public-area status, adds Gaussian noise, then bins the result. The learned method receives sensor and public-area information that the severity rule leaves out. The comparison asks whether it can use those extra signals to improve the replay under this impact definition.
# Lab 10: the three cut-offs produce four ordered impact grades.
impact = 0.60 * severity + 2.30 * sensor + 0.65 * public_area
impact += float(rng.normal(0, 0.38))
impact_grade = int(np.digitize(impact, [1.8, 2.9, 4.0]))UPS separated two layers when introducing ORION. It changed stop sequencing while keeping its existing van assignments, and added route consistency to the optimiser. The UPS authors reported 55,000 drivers using ORION in 2016. Changing one layer in the replay isolates the effect of the new priority score. UPS engineering paper, company-reported.
The solver gets the same eligibility rules under both policies. Bring forward tickets that have arrived, collect technicians who are free, and give the solver one eligible edge for each skill match. The dummy columns let a technician idle when the queue has no suitable work. This is the decision inside staffing_matches:
# A free technician can always choose an idle column.
bonus = len(waiting) * len(free_technicians) + 1
utility = np.zeros((len(free_technicians), len(waiting) + len(free_technicians)))
utility[:, :len(waiting)] = -1
for row, tech in enumerate(free_technicians):
for column, ticket in enumerate(waiting):
if ticket["skill"] in TECHNICIANS[tech]:
utility[row, column] = bonus + ranks[column]
rows, columns = linear_sum_assignment(utility, maximize=True)For an eligible pair, starting an extra job earns the bonus, which exceeds any possible difference in the total rank reward. The solver therefore starts as many feasible jobs as it can, then maximises their summed queue priority:
Each binary assignment connects a technician from the free set to a ticket from the waiting set, with the right trade. The technician stays busy until the repair’s finish slot. Deadlines break tied scores and contribute to evaluation. The solver can still start an eligible repair that will finish late.
Uber describes the same distinction at marketplace scale. Its matching system considers who is online, the requested trip and vehicle type, and local constraints. It weighs the effects across trips, including waiting and empty travel. Uber’s account of production matching.
queue-56-16 · Electrical · Public area · Severity 2 · Sensor 0.931 · Arrives at 5, due at 7 · Takes one slot
- Expected service
- Start by slot 6 with an electrical technician and finish by slot 7.
- Severity rule
- tech-1 · start 10 · finish 11 · missed_deadline = true
- Learned impact
- tech-2 · start 5 · finish 6 · missed_deadline = false
The severity rule starts queue-56-00 at slot 5. Learned impact started that job at slot 4 and finished it at slot 5, freeing Tech 2 for the public-area job. Both policies replayed the shift from the start. Only the evaluator sees the public-area job’s impact grade of 3.
The electrical job waited five slots under the severity rule
queue-56-16 · One slot of work, due by slot 7 · each policy replays the shift from the start
2Measure the ordering and the shift separately
Ranking chooses which work should come first; allocation chooses what fits the available people and time. A better priority score does not automatically produce a feasible shift.
NDCG@10 gives more credit for placing higher-grade tickets near the top. The notebook uses scikit-learn with linear gain: the grade itself is the gain. Each item’s contribution is discounted by its position, then divided by the score for ideal ordering of the same grades.
The ranking includes the whole shift and evaluates how well the model estimates impact. The dispatch replay admits each ticket at its arrival slot and checks whether it finishes after its deadline. A job can move up the list and still finish late. In shift 48, for example, NDCG rose from 0.925 to 1.000 while late repairs rose from 9 to 11.
The better ranking increased total misses in three shifts
Change in late tickets per shift · Learned impact minus severity rule · Negative is better
3Both policies face the same arrivals, skills and durations, so the comparison is paired. For a difference in deadline misses, compute learned minus severity on each shift and average those differences. The derived interval draws whole paired shifts with replacement. Tickets within a shift share technicians, so resampling tickets would treat competing jobs as independent.
| Mean difference, learned minus rule | Estimate | Derived 95% shift-bootstrap interval |
|---|---|---|
| NDCG@10 | +0.103 | +0.082 to +0.125 |
| Total misses per shift | −0.42 | −1.17 to +0.33 |
| High-impact misses per shift | −0.42 | −0.67 to −0.17 |
The interval for total misses spans zero. The high-impact drop holds across the resamples, within this synthetic workload. The training and replay are generated from the same impact recipe, so the comparison says little about a site with different skills, travel times, demand or impact definitions.
Find the jobs that lost time
Across both schedules, 38 tickets moved from late to on time and 33 moved in the opposite direction. The net drop of five hides both groups. Grade-1 tickets carried the largest increase in misses, while the highest-impact group finished within deadline on every held-out job under learned impact.
Grades 2 and 3 missed fewer deadlines while the lowest grades missed more
Late tickets by held-out impact grade · Grade 3 is high impact
4| Grade | Tickets | Severity rule | Learned impact | Change |
|---|---|---|---|---|
| 0 | 40 | 32 | 33 | +1 |
| 1 | 87 | 41 | 49 | +8 |
| 2 | 89 | 31 | 22 | −9 |
| 3 | 48 | 5 | 0 | −5 |
queue-48-09 · Electrical · Non-public area · Severity 4 · Sensor 0.425 · Arrives at 3, due at 9 · Takes four slots
- Expected service
- Start by slot 5 with an electrical technician and finish by slot 9.
- Severity rule
- tech-1 · start 4 · finish 8 · missed_deadline = false
- Learned impact
- tech-1 · start 8 · finish 12 · missed_deadline = true
The learned policy used Tech 1 at slot 4 for queue-48-20, a shorter electrical job that it completed at slot 6 before its slot-7 deadline. Under the severity rule that job finished at slot 13.
The lesson follows one simulation. DoorDash compared its replacement dispatch platform against live traffic in shadow mode. The existing dispatcher still made the assignments. DoorDash then used controlled switchback experiments with fallbacks to assess live fulfilment. That sequence gives a way to check whether a measured replay gain survives changes in actual demand and behaviour. DoorDash engineering write-up.
Time the whole replay
The timed boundary includes calculating scores and solving each slot’s assignment through the end of a shift. It excludes fitting, notebook startup and any external service. The code alternates policy order between shifts and records a first pass and two warm repeats for each policy. On this CPU the median warm replay takes about 47 times as long with learned impact, a derived ratio. The absolute numbers cover a small in-memory simulation.
The learned policy took longer to replay even after warm-up
CPU milliseconds per complete shift replay · Point is the median, line is the observed range · Log scale
5What to keep
| Decision measure | Severity rule | Learned impact |
|---|---|---|
| Mean NDCG@10 | 0.871 | 0.974 |
| Total missed deadlines | 109 / 264 | 104 / 264 |
| High-impact missed deadlines | 5 / 48 | 0 / 48 |
| Median peak waiting backlog | 11 jobs | 10.5 jobs |
| Assignment constraint violations | 0 | 0 |
| Model fit | — | 489 ms |
| Median warm replay per shift | 0.101 ms | 4.772 ms |
| Recorded failure | The public-area electrical job in shift 56 missed its deadline | The four-slot electrical job in shift 48 missed its deadline |
- Keep eligibility in the solver. Let the scoring method express preference. Check skills, arrival, capacity and duration where assignments are made.
- Compare both schedules on the same shifts. Track all misses, high-impact misses and the specific jobs that become late.
- Require live evidence before changing dispatch. Compare in shadow mode and define which service measures must hold before a live trial.
Next to try, not tested here
- Add electrical coverage to Tech 3, then compare shifts where both scorers compete for the same eligible technician.
- Rank by latest feasible start first and use learned impact to break ties. Check whether high-impact gains survive.
- Replay on a different mix of trades and arrival times. Check whether the same grades bear the missed deadlines.
How it was built
| Item | Setting |
|---|---|
| Data | Synthetic Facilities Helpdesk work orders. Seed 7010, 48 train shifts and 12 evaluation shifts, 22 tickets per shift. |
| Course contract | This dispatch lab uses its own shift split and impact labels inside the shared helpdesk domain. No equipment-family tickets from the frozen release split are used to train or evaluate its ranker. |
| Model | HistGradientBoostingRegressor, max_iter=75, max_leaf_nodes=15, random_state=7010. No language model. |
| Incumbent | Severity descending, deadline ascending, ticket identifier ascending. |
| Shared matching | scipy.optimize.linear_sum_assignment with idle options and hard skill checks. |
| Evaluation | Shift-level NDCG@10. Finish slot > deadline counts as late. The simulator checks trade compatibility, arrival, duration, overlaps, duplicates and missing assignments. Derived percentile intervals use 10,000 paired shift resamples, seed 7010. |
| Hardware and recorded runtime | CPU on macOS, Python 3.12.8, NumPy 1.26.4, scikit-learn 1.7.2, Matplotlib 3.10.9. The receipt omits the SciPy version. |
| Saved evidence | Summary JSON, ticket and timing records, runtime receipt. |
Time and cost. The saved cell timestamps span 4.78 seconds from first code input to last code completion, excluding kernel startup and dependency installation. Model fit took 489 ms. The experiment ran locally on CPU without Colab credits or API fees.
Run it yourself
Download the executed CPU notebook to see the baseline outputs or run it in a Python environment with NumPy, scikit-learn, SciPy and Matplotlib. The saved code-cell span was under five seconds on the recorded CPU.
| Find this in the notebook | Read it alongside |
|---|---|
The cells that define make_episode, policy_order and staffing_matches | Score impact, then assign the work |
| Inspect one staffing decision | One technician, two repairs |
| Compare both policies on the same episodes | Measure the ordering and the shift separately and Time the whole replay |
| Read the result | What to keep |
Change one input at a time and write your prediction before replaying.
- Add
"electrical"toTECHNICIANS["tech-3"]. Willqueue-56-16finish by slot 7 under both policies? Filterrecords.jsonfor the ticket ID and comparestart,finishandtechnician. - Change
policy_orderfor Learned impact only. Sort first bydeadline - duration, then use the learned score to break ties. Leave Severity rule as it is. Willqueue-48-09finish on time? Read both its outcome and the high-impact miss count. - Remove
"sensor"fromFEATURESand refit. Predict which changes more, NDCG@10 or the number of high-impact misses. Compare both summary fields with the saved values.
Lesson 11, Benchmark inference serving, turns from the time it takes to assign a simulated shift to the time an inference service takes under load. Back to the course outline.
How is this page?
Last updated on