Inspiration

1.05 billion tonnes of food were wasted in 2022, over a billion meals a day, while 783 million people went hungry. Food waste also produces 8–10% of global greenhouse gas emissions. In the US alone, 91 million tons of food went unsold or uneaten in 2021, and less than 2% of that surplus was donated.

Those numbers aren't abstract to me. I used to work at a place where, every single night, we threw out gallons of rice, daal, chicken and more: perfectly good food, straight into the bin. Nobody wanted to waste it. There was just no one to call, no time to figure out where it could go, and no way to get it there before closing.

The food and the hungry are often in the same city on the same night, sometimes two miles apart. What's missing is the last hour. At closing time, nobody has time to find a shelter that's still open, check whether the food is still safe, and find a driver who can get it there before it isn't. An hour later, the food is trash.

Last Call is built for that hour.

What it does

  1. It calls the restaurant. At closing time, a voice agent phones the manager and has a normal conversation: what's left, how much, how it was stored, how long it's been out. No forms, no app.
  2. Food-safety rules decide. Every answer runs through fixed rules written in code, not left to an AI's judgment, so the system can never be talked into donating unsafe food.
  3. The optimizer plans the night. Every new donation re-plans every driver, pickup and shelter against each pickup's food-safety deadline, in milliseconds.
  4. The driver gets one clear text. The chosen volunteer gets an iMessage saying what, where and deliver by when, and replies in plain words: "yes", "running 10 min late", "picked up".
  5. The garden grows. Every delivered meal counts toward tonight's CO₂ avoided, and a garden on the dashboard grows from seed to flower as the night goes on.

How it works: the technical core

1. Food safety as a hard deadline

Food left at room temperature is only safe for 4 hours (the FDA's time-as-a-control rule). For a donation i that has already been out hᵢ hours, the call gives a hard deadline:

dᵢ = now + (4 h − hᵢ), and the food is declined if hᵢ > 4 h.

Hot food is served tonight only if a late-serving shelter that accepts hot food is open, with dᵢ = now + 4 h. Otherwise it's chilled for a morning pickup, as are refrigerated and shelf-stable food, with dᵢ = tomorrow 6 PM. Food already served to the public is declined. These rules are pure functions, fully unit-tested, with no model in the loop.

2. Routing as a pickup-and-delivery problem with time windows

Every evening is an instance of the Pickup and Delivery Problem with Time Windows (PDPTW), which is NP-hard. Each donation i has mᵢ meals, a ready time rᵢ and a deadline dᵢ. Each driver k has car capacity Qₖ and a free-until time Tₖ. Each shelter s has receiving hours [aₛ, bₛ] and a capacity Cₛ. Road travel times are τ(u, v). Last Call picks a route Rₖ for each driver that solves:

maximize Σᵢ mᵢ · 𝟙[ dropoffᵢ ≤ dᵢ ] then minimize Σₖ Σ₍ᵤ,ᵥ₎ ∈ Rₖ τ(u, v)

The objective is lexicographic: first save as many meals as possible, and only then minimize driving. It is subject to:

$$r_i \le \text{pickup}_i < \text{dropoff}_i \le d_i, \qquad a_s \le \text{dropoff}_i \le b_s, \qquad \text{load}_k(t) \le Q_k, \qquad \text{every stop} \le T_k$$

plus shelter capacity, each driver's limit on open pickups, and pickups a driver has already accepted staying with that driver.

3. The algorithm

  • Deadline-ordered insertion. Donations are taken in order of their deadline dᵢ (most urgent first). Each one is tried in every driver's route at every pickup position and every dropoff position. The whole route is re-simulated to check every constraint, and the feasible slot with the smallest added driving wins:

$$\Delta_k(p, q) = \text{drive}\big(R_k \oplus_{p,q} i\big) - \text{drive}(R_k)$$

  • Local search. Starting from that plan, it repeatedly relocates a pickup to another driver or position, exchanges pickups between drivers, and retries anything left unassigned. A move is accepted only if it improves the lexicographic objective. It stops when nothing improves or 300 ms run out; a typical evening plans in about 4 ms.
  • Real roads. Travel times τ(u, v) come from the Mapbox Matrix API (actual road routing), cached in Postgres.
  • Two windows at once: tonight (late shelters, hot food) and tomorrow 8 AM–12 PM (chilled food), planned side by side.

4. Explainable by design

Every re-plan also runs the obvious baseline, send the nearest available driver, on the exact same input. When the two disagree, the dashboard says why: "Nearest driver would arrive 4 min late: 18 meals lost. Last Call sends Maya: 4 min to spare." A 4-stage view on the map walks through every candidate driver, their pickup and delivery times, the deadline check, and the final choice.

5. Does it actually matter? The benchmark

We ran both planners on 200 simulated Ann Arbor evenings (seed 42; 3–8 donations and 2–4 drivers each, with mixed hot, chilled and bakery food), using the same drivers, food and travel times:

Nearest driver Last Call
Meals expired per evening 8.2 1.3 (84% fewer)
Meals delivered on time 114.9 123.2 (+7%)
Drive time per evening 29.8 min 26.9 min (−10%)
Evenings better / equal / worse 161 / 39 / 0

On average Last Call saves 8.2 more meals per evening (95% CI 5.3–11.1) while driving less, and it was never worse on a single evening. It wins because the nearest driver is often still busy with another pickup, while hot food waits and the clock runs out.

6. Impact, and the garden

Every delivered meal is counted as roughly 0.4 kg of food, and each kilogram of food waste avoided saves about 2.5 kg of CO₂-equivalent:

CO₂e avoided ≈ Σ meals delivered × 0.4 kg/meal × 2.5 kg CO₂e/kg = 1 kg CO₂e per meal

That number grows the garden: seed, then sprout at 5 kg, two leaves at 15, a small plant at 30, and a flower at 45. A full demo night delivers 46 meals, so by the end of the night it's in bloom.

How we built it

  • Voice: an ElevenLabs conversational agent with a save_donation tool that posts structured answers to a FastAPI backend, with push-to-talk so a noisy room can't interrupt the call.
  • Backend: Python and FastAPI, with the rules engine and planners written from scratch, on Neon Postgres. 255 tests.
  • Dispatch: a Bun service on Photon Spectrum that sends and receives real iMessages.
    • Offers go to one driver at a time, expire if unanswered, and are never repeated to the same driver.
    • Replies are parsed for intent: accept, decline, running late, picked up, delivered.
  • Command center: React, TypeScript, Vite, Tailwind and Motion on a Mapbox 3D satellite map. Cars drive their real road routes on a demo clock that can run at 30×.

Challenges we ran into

  • Making the optimizer visible. A plan that's correct but invisible convinces nobody. Showing why each driver was chosen took as much work as choosing them.
  • One demo, many live services: a voice agent, iMessage, a cloud database and maps, all on hotel and venue Wi-Fi.
  • Food safety can't be "mostly right." A wrong answer feeds someone spoiled food, so the rules are deterministic code with tests, not a model's guess.
  • Building it solo in 24 hours.

Accomplishments that we're proud of

  • The whole loop is real. A live voice call, real safety rules, a real planner, a real text to a real phone, and a real reply that moves the night forward.
  • Never worse than the obvious approach on any of 200 evenings, and it plans in milliseconds.
  • You can watch it think: every decision on the map comes with its reason.

What we learned

  • Food rescue isn't short of donors. It's short of time, and the last hour is where the food is lost.
  • Classic optimization ideas (insertion, local search, lexicographic objectives) solve a deeply human problem when they're aimed at the right constraint: a deadline.
  • Explaining why an algorithm made a choice matters as much as making it.

What's next for Last Call

  • Scheduled calls at every restaurant's real closing time, across a whole city.
  • Driver sign-up by text: pick your nights, done.
  • Shelters confirm deliveries, generating an automatic donation receipt for the restaurant's tax deduction.
  • A garden that keeps growing, night after night and city after city, until throwing good food away at closing feels as strange as it should.

Built With

Share this project:

Updates

Submission history