The nearest courier, every time, and the board kept getting worse
Dispatch works one order at a time. An order arrives, the service finds the nearest free courier, and offers it. Every individual decision is the best available at the moment it is made.
The board still degrades through the lunch rush: couriers cross each other carrying one bag apiece, two orders leaving the same kitchen go to two different people, and the courier who was ninety seconds from finishing next door is never offered anything because at the moment of asking they were not free.
- R1Sometimes the correct action is to offer nothing yet — because a better courier is ninety seconds from finishing, or because a second order from the same kitchen is about to be ready. Whatever makes the decision has to be able to decide to wait, and to be asked again shortly.
- R2Merchant and business preferences constrain who may be assigned what. They are edited during the day, and an edit must apply to decisions made after it — including decisions about orders that were created before the edit.
- R3An offer goes to a courier who may decline it, and a decline must feed back in time for the next decision rather than being lost or retried into the same courier. The thing carrying offers out must hold them rather than assume they were taken.
Boundaries, outermost first: ONE REGION, MANY TIMES A MINUTE: Prediction service (ready and travel times), Order service (outstanding orders), Couriers (free and finishing), an empty slot for the scores the whole board and may choose to wait, tier 1, an empty slot for the the constraints, as they are now, tier 1 Outside every boundary: Courier app (accepts or declines), an empty slot for the carries the offer and survives a decline, tier 2 Connections: Order service calls scores the whole board and may choose to wait — what is outstanding Couriers calls scores the whole board and may choose to wait — who is free scores the whole board and may choose to wait calls Prediction service — how long will it take the constraints, as they are now calls scores the whole board and may choose to wait — read now scores the whole board and may choose to wait publishes to carries the offer and survives a decline — an offer carries the offer and survives a decline publishes to Courier app Courier app publishes to scores the whole board and may choose to wait — decline, next cycle