Mathematics of Mid-Journey Refuelling

I love my electric car, but sometimes – like when I need to transport five people and a week’s worth of their luggage 250 miles and need to get there before the kids’ bedtime! – I still use our big ol’ diesel-burning beast. And it was while preparing for such a journey that I recently got to thinking about the mathematics of refuelling.

Car display showing "Please refuel. Range: 40ml"
I don’t know why you’d measure range in millilitres in the first place, but I’m hearing that I ought to fill up the car before we go.

It’s rarely worth travelling out-of-your-way to get the best fuel prices. But when you’re on a long road trip anyway and you’re likely to pass dozens of filling stations as a matter of course, you might as well think at least a little about pulling over at the cheapest.

You could use one of the many online services to help with this, of course… but assuming you didn’t do this and you’re already on the road, is there a better strategy than just trusting your gut and saying “that’s good value!” when you see a good price?

It turns out this is an application for the Secretary Problem (and probably a little more sensible than the last time I talked about it!).

A woman's hand reaches for one of four fuel pump nozzles. Photo by Gustavo Fring, used under the Pexels License.
If you can’t decide which nozzle is best, mix up a cocktail of them all. #TerribleProTip

Here’s how you do it:

  1. Estimate your outstanding range R: how much further can you go? Your car might be able to help you with this. Let’s say we’ve got 82 miles in the tank.
  2. Estimate the average distance between filling stations on your route, D. You can do this as-you-go by counting them over a fixed distance and continue from step #4 as you do so, and it’ll only really mess you up if there are very few. Maybe we’re on a big trunk road and there’s a filling station about every 5 miles.
  3. Divide R by D to get F: the number of filling stations you expect to pass before you completely run out of fuel. Round down, obviously, unless you’re happy to push your vehicle to the “next” one when it breaks down. In our example above, that gives us 16 filling stations we’ll probably see before we’re stranded.
  4. Divide F by e to get T (use e = 2.72 if you’re having to do this in your head). Round down again, for the same reason as before. This gives us T=5.
  5. Drive past the next T filling stations and remember the lowest price you see. Don’t stop for fuel at any of these.
  6. Keep driving, and stop at the first filling station where the fuel is the same price or cheaper than the cheapest you’ve seen so far.
Dan sitting in the driving seat of a car, doing maths on a portable whiteboard.
Obviously you should take care doing maths on the road. Don’t drink and derive!

This is a modified variant of the Secretary Problem because it’s possible for two filling stations to have the same price, and that’s reflected in the algorithm above by the allowance for stopping for fuel at the same price as the best you saw during your sampling phase. It’s probably preferable to purchase sub-optimally than to run completely dry, right?

Of course, you’re still never guaranteed a good solution with this approach, but it maximises your odds. Your own risk-assessment might rank “not breaking down” over pure mathematical efficiency, and that’s on you.

Car display showing "Please refuel. Range: 40ml"× A woman's hand reaches for one of four fuel pump nozzles. Photo by Gustavo Fring, used under the Pexels License.× Dan sitting in the driving seat of a car, doing maths on a portable whiteboard.×

Note #20099

Adapted version of XKCD comic #927. Titled: How WP plugins proliferate (see: authentication, crossposting, galleries, etc.). Situation: there are 14 competing WordPress plugins. Engineers in conversation agree that 14 is ridiculous and commit to developing a unified plugin that covers everybody's use cases. Result: there are now 15 competing WordPress plugins.

Almost nerdsniped myself when I discovered several #WordPress plugins that didn’t quite do what I needed. Considered writing an overarching one to “solve” the problem. Then I remembered @xkcd comic 927

Adapted version of XKCD comic #927. Titled: How WP plugins proliferate (see: authentication, crossposting, galleries, etc.). Situation: there are 14 competing WordPress plugins. Engineers in conversation agree that 14 is ridiculous and commit to developing a unified plugin that covers everybody's use cases. Result: there are now 15 competing WordPress plugins.×

Note #20096

Dan with a towel.

Time is an illusion. School drop-off time doubly so. #towelday

Dan with a towel.×

Dan Q archived GC7Q96B Oxford’s Long-Lost Zoo

This checkin to GC7Q96B Oxford's Long-Lost Zoo reflects a geocaching.com log entry. See more of Dan's cache logs.

This has been muggled hard. I no longer live very close, so I’m removing the cache: I’ve extracted the remnants of the container from the GZ.

Shame to lose such a beautiful container, but it had a good long life and told many people the unusual story of this site, so it’s all good.

Will swapping out electric car batteries catch on?

This article is a repost promoting content originally published elsewhere. See more things Dan's reposted.

Without even a touch of the steering wheel, the electric car reverses autonomously into the recharging station

Underside of a car with a removable battery.

I won’t be plugging it in though, instead, the battery will be swapped for a fresh one, at this facility in Norway belonging to Chinese electric carmaker, Nio.

The technology is already widespread in China, but the new Power Swap Station, just south of Oslo, is Europe’s first.

This is what I’ve been saying for years would be a better strategy for electric vehicles. Instead of charging them (the time needed to charge is their single biggest weakness compared to fuelled vehicles) we should be doing battery swaps. A decade or two ago I spoke hopefully for some kind of standardised connector and removal interface, probably below the vehicle, through which battery cells could be swapped-out by robots operating in a pit. Recovered batteries could be recharged and reconditioned by the robots at their own pace. People could still charge their cars in a plug-in manner at their homes or elsewhere.

You’d pay for the difference in charge between the old and replacement battery, plus a service charge for being part of the battery-swap network, and you’d be set. Car manufacturers could standardise on battery designs, much like the shipping industry long-ago standardised on container dimensions and whatnot, to take advantage of compatibility with the wider network.

Rather than having different sizes of battery, vehicles could be differentiated by the number of serial battery units installed. A lorry might need four or five units; a large car two; a small car one, etc. If the interface is standardised then all the robots need to be able to do is install and remove them, however many there are.

This is far from an unprecedented concept: the centuries-old idea of stagecoaches (and, later, mail coaches) used the same idea, but with the horses being changed at coaching inns rather. Did you know that the “stage” in stagecoach refers to the fact that their journey would be broken into stages by these quick stops?

Anyway: I dismayed a little when I saw every EV manufacturer come up with their own battery standards, co=operating only as far as the plug-in charging interfaces (and then, only gradually and not completely!). But I’m given fresh hope by this discovery that China’s trying to make it work, and Nio‘s movement in Norway is exciting too. Maybe we’ll get there someday.

Incidentally: here’s a great video about how AC charging works (with a US/type-1 centric focus), which briefly touches upon why battery swaps aren’t necessarily an easy problem to solve.

Underside of a car with a removable battery.×

Dan Q found GC49ERR #5 Billy Wynt – Up Top

This checkin to GC49ERR #5 Billy Wynt - Up Top reflects a geocaching.com log entry. See more of Dan's cache logs.

Wow, definitely had to go off the beaten track for this one. I took a route up and tightly alongside the fence, and only after getting to the GZ did I discover the easier way. Still a tough thing to find with the foliage so verdant. TFTC and thanks for the walk and the view, too!

From the top of the folly I can just make out my hotel in the distance (see photo)! Better go get some breakfast!

Dan, on a hilltop, points down into the valley between this and the next hill over. Where he's pointing is a white-and-brown-brick building with a grey slate roof in the iconic shape of a Travelodge hotel.

Dan, on a hilltop, points down into the valley between this and the next hill over. Where he's pointing is a white-and-brown-brick building with a grey slate roof in the iconic shape of a Travelodge hotel.×

Dan Q couldn’t find GC49EQW #3 Billy Wynt – Feeling Peckish

This checkin to GC49EQW #3 Billy Wynt - Feeling Peckish reflects a geocaching.com log entry. See more of Dan's cache logs.

Had to give up on this one. 😢
Between a great fix, a clear clue, and CO maintenance only last week I figured this was a sure thing. But somehow it wasn’t to be, no matter how many nettle stings I endured in the hunt.

Dan Q found GC49AEB #1 Billy Wynt – Cattle Grid

This checkin to GC49AEB #1 Billy Wynt - Cattle Grid reflects a geocaching.com log entry. See more of Dan's cache logs.

Woke earlier than my friends who’d been to a wedding last night, and used that as an excuse for a quick walk up the hill. Easy find: second place I looked! TFTC. Greetings from Oxfordshire!

Dan stands on a rough muddy forest trail ad waves at the camera.

Dan stands on a rough muddy forest trail ad waves at the camera.×