Stream: show and tell

Topic: Seattle Delivery (Clarke/Wright algorithm)


view this post on Zulip Steve Howell (Nov 22 2026 at 15:44):

I worked a couple years at Amazon in the late 2000's on the AmazonFresh team. We were the first team to ever write software that allowed Amazon to route its own truck fleet. The AmazonFresh grocery delivery service never really took off, but it laid a lot of groundwork for the ubiquitous trucks that you see on the road now (at least in the US).

I never worked specifically on the truck routing algorithms, but this year I felt a fit of nostalgia and tried to see what Claude could come up with. This is it: https://roc.lynrummy.com/delivery/

view this post on Zulip Steve Howell (Nov 22 2026 at 15:46):

It runs a slightly tweaked version of the Clarke/Wright savings algorithm. It has some hacks for Bellevue and Medina related to racing variations of the algorithm against each other. For those not familiar with the Seattle Area (where we piloted the service), they are two suburbs that were near the fulfillment center (aka warehouse). The grocery delivery manager had to often re-route our algorithm's results (Seattle has a lot of water!), and he used certain neighborhoods for overflow.

view this post on Zulip Steve Howell (Nov 22 2026 at 15:47):

This is written mostly in Roc, of course. The UI is a little raw, but you can read the key in the top right corner. It's obviously a very simplified version of the actual problem, but I think any Seattle residents will recognize the geography! If you have Seattle connections, DM me here!

view this post on Zulip Steve Howell (Nov 22 2026 at 15:49):

The map is still drawn with TypeScript, but all the heavy lifting is in Roc. The original Claude-written version was pure TypeScript.

view this post on Zulip Steve Howell (Nov 22 2026 at 15:50):

Here's a taste of the code:

## An edge's speed factor (lower is faster), in roadgraph.ts's order of
## checks: 520's lake span, Montlake and I-5, the 405 bypass, bridges, the
## city, the suburbs.
factor : { a : U8, b : U8 }, [Surface, Bridge] -> F64
factor = |{ a, b }, kind| {
    montlake = Seattle.node_of("Montlake")
    issaquah = Seattle.node_of("Issaquah")
    redmond = Seattle.node_of("Redmond")
    medina = Seattle.medina
    if (a == montlake and b == medina) or (a == medina and b == montlake) {
        speed_bridge520
    } else if a == montlake or b == montlake {
        speed_i5
    } else if Seattle.is_i5_exit(a) or Seattle.is_i5_exit(b) {
        speed_i5
    } else if (a == issaquah and b == redmond) or (a == redmond and b == issaquah) {
        speed_fast
    } else {
        match kind {
            Bridge => speed_bridge
            Surface => if Seattle.is_west(a) or Seattle.is_west(b) {
                speed_city
            } else {
                speed_suburb
            }
        }
    }
}

view this post on Zulip Steve Howell (Nov 22 2026 at 15:51):

image.png


Last updated: Nov 26 2026 at 20:35 UTC