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.

× × ×

What can board game strategy tell us about the future of the car wash?

I’m increasingly convinced that Friedemann Friese‘s 2009 board game Power Grid: Factory Manager (BoardGameGeek) presents gamers with a highly-digestible model of the energy economy in a capitalist society. In Factory Manager, players aim to financially-optimise a factory over time, growing production and delivery capacity through upgrades in workflow, space, energy, and staff efficiency. An essential driving factor in the game is that energy costs will rise sharply throughout. Although it’s not always clear in advance when or by how much, this increase in the cost of energy is always at the forefront of the savvy player’s mind as it’s one of the biggest factors that will ultimately impact their profit.

Power grid's energy cost tracker
8 $money per $unit of electricity I use? That’s a rip off! Or a great deal! I don’t know!

Given that players aim to optimise for turnover towards the end of the game (and as a secondary goal, for the tie-breaker: at a specific point five rounds after the game begins) and not for business sustainability, the game perhaps-accidentally reasonably-well represents the idea of “flipping” a business for a profit. Like many business-themed games, it favours capitalism… which makes sense – money is an obvious and quantifiable way to keep score in a board game! – but it still bears repeating.

There’s one further mechanic in Factory Manager that needs to be understood: a player’s ability to control the order in which they take their turn and their capacity to participate in the equipment auctions that take place at the start of each round is determined by their manpower-efficiency in the previous round. That is: a player who operates a highly-automated factory running on a skeleton staff benefits from being in the strongest position for determining turn order and auctions in their next turn.

Empty Factory Manager staff room
My staff room is empty. How about yours?

The combination of these rules leads to an interesting twist: in the final turn – when energy costs are at their highest and there’s no benefit to holding-back staff to monopolise the auction phase in the nonexistent subsequent turn – it often makes most sense strategically to play what I call the “sweatshop strategy”. The player switches off the automated production lines to save on the electricity bill, drags in all the seasonal workers they can muster, dusts off the old manpower-inefficient machines mouldering in the basement, and gets their army of workers cranking out widgets!

With indefinitely-increasing energy prices and functionally-flat staff costs, the rules of the game would always eventually reach the point at which it is most cost-effective to switch to slave cheap labour rather than robots. but Factory Manager‘s fixed-duration means that this point often comes for all players in many games at the same predictable point: a tipping point at which the free market backslides from automation to human labour to keep itself alive.

There are parallels in the real world. Earlier this month, Tim Watkins wrote:

Abandoned automatic car wash

The demise of the automated car wash may seem trivial next to these former triumphs of homo technologicus but it sits on the same continuum. It is just one of a gathering list of technologies that we used to be able to use, but can no longer express (through market or state spending) a purpose for. More worrying, however, is the direction in which we are willingly going in our collective decision to move from complexity to simplicity. The demise of the automated car wash has not followed a return to the practice of people washing their own cars (or paying the neighbours’ kid to do it). Instead we have more or less happily accepted serfdom (the use of debt and blackmail to force people to work) and slavery (the use of physical harm) as a reasonable means of keeping the cost of cleaning cars to a minimum (similar practices are also keeping the cost of food down in the UK). This, too, is precisely what is expected when the surplus energy available to us declines.

I love Factory Manager, but after reading Watkins’ article, it’ll probably feel a little different to play it, now. It’s like that moment when, while reading the rules, I first poured out the pieces of Puerto Rico. Looking through them, I thought for a moment about what the “colonist” pieces – little brown wooden circles brought to players’ plantations on ships in a volume commensurate with the commercial demand for manpower – represented. And that realisation adds an extra message to the game.

Beneath its (fabulous) gameplay, Factory Manager carries a deeper meaning encouraging the possibility of a discussion about capitalism, environmentalism, energy, and sustainability. And as our society falters in its ability to fulfil the techno-utopian dream, that’s perhaps a discussion we need to be having.

Sorry to Bother You
Seriously, this film is awesome.

But for now, go watch Sorry to Bother You, where you’ll find further parallels… and at least you’ll get to laugh as you do so.

× × ×

An Honest Stock Market Update

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

NEW YORK — Stocks gained momentum on Monday, with the Dow Jones Industrial Average closing up 48 points, reversing losses from last week’s decline.

Experts hailed both moves as a “remarkable, textbook example of pure statistical chance,” chalking up Monday’s gains to a couple random marginal buyers being slightly more motivated than a few random marginal sellers.

“Imagine you pick 1 million random people from around the world every day,” said Toby McDade, chief investment officer of Momentum Fee Capital Management. “Some days, 51% would be in a good mood, 49% in a bad mood. The next day maybe it’s the opposite. Other days, random chance could mean 8% of people are really pissed off for no real reason. This is basically what the market is on a day-to-day basis,” he said.

Satire, obviously, but it might as well not be. I’ve long maintained that nobody, not even (and perhaps especially) economists, understand economics. It’s a fundamentally chaotic system and at best your years of training and practice on the stock market will give you the edge over a layperson; the fact that some people appear to be doing better is most-often a result of the fact that those who’ve been lucky historically are more-likely to stay in the game for long enough for you to observe how lucky they’ve been (I’m reminded of the old “tipster scam” where a scammer would send guesses as horse racing tips for free, and then to the people to whom the scammer had by chance sent good tips they’d charge for future tips, with increasing cost for the punter the more times the scammer had gotten lucky by chance).

But enough of my ranting. Go read this funny article.

Solar Power, part 1

One of the great joys of owning a house is that you can do pretty much whatever you please with it. I celebrated Ruth, JTA and I’s purchase of Greendale last year by wall-mounting not one but two televisions and putting shelves up everywhere. But honestly, a little bit of DIY isn’t that unusual nor special. We’ve got plans for a few other changes to the house, but right now we’re pushing our eco-credentials: we had cavity wall insulation added to the older parts of the building the other week and an electric car charging port added not long before that. And then… came this week’s big change.

South-facing roof.
Look at all that South-facing roof, sitting there serving no purpose except to keep the rain off our heads.

Solar photovoltaics! They’re cool, they’re (becoming) economical, and we’ve got this big roof that faces almost due-South that would otherwise be just sitting there catching rain. Why not show off our green credentials and save ourselves some money by covering it with solar cells, we thought.

Annabel watches the solar panelling team arrive.
Annabel sits at the window and supervises the parking of the structural engineer, the electrician, and the solar panel specialist.

Because it’s me, I ended up speaking to five different companies and, after removing one from the running for employing a snake for a salesman, collecting seven quotes from the remaining four, I began to do my own research. The sheer variety of panels, inverters, layouts and configurations (all of which are described in their technical sheets using terms that in turn required a little research into electrical efficiency and dusting off formulas I’d barely used since my physics GCSE exam) are mind-boggling. Monolithic, string, or micro-inverters? 250w or 327w panels? Where to run the cables that connect the inverter (in the attic) to the generation meter and fusebox (in the ground floor toilet)? Needless to say, every company had a different idea about the “best way” to do it – sometimes subtly different, sometimes dramatically – and had a clear agenda to push. So – as somebody not suckered in to a quick deal – I went and did the background reading first.

Scaffolding!
The shape of our conservatory made erecting the scaffolding (which “staddles” it) a somewhat complicated operation.

In case you’re not yet aware, let me tell you the three reasons that solar panels are a great idea, economically-speaking. Firstly, of course, they make electricity out of sunlight which you can then use: that’s pretty cool. With good discipline and a monitoring tool either in hardware or software, you can discover the times that you’re making more power than you’re using, and use that moment to run the dishwasher or washing machine or car charger or whatever. Or the tumble drier, I suppose, although if you’re using the tumble drier because it’s sunny then you lose a couple of your ‘green points’ right there. So yeah: free energy is a nice selling point.

The second point is that the grid will buy the energy you make but don’t use. That’s pretty cool, too – if it’s a sunny day but there’s nobody in the house, then our electricity meter will run backwards: we’re selling power back to the grid for consumption by our neighbours. Your energy provider pays you for that, although they only pay you about a third of what you pay them to get the energy back again if you need it later, so it’s always more-efficient to use the power (if you’ve genuinely got something to use it for, like ad-hoc bitcoin mining or something) than to sell it. That said, it’s still “free money”, so you needn’t complain too much.

The third way that solar panels make economic sense is still one of the most-exciting, though. In order to enhance uptake of solar power and thus improve the chance that we hit the carbon emission reduction targets that Britain committed to at the Kyoto Protocol (and thus avoid a multi-billion-pound fine), the government subsidises renewable microgeneration plants. If you install solar panels on your house before the end of this year (when the subsidy is set to decrease) the government will pay you 14.38p per unit of electricity you produce… whether you use it or whether you sell it. That rate is retail price index linked and guaranteed for 20 years, and as a result residential solar installations invariably “pay for themselves” within that period, making them a logical investment for anybody who’s got a suitable roof and who otherwise has the money just sitting around. (If you don’t have the cash to hand, it might be worth taking out a loan to pay for solar panels, but then the maths gets a lot more complicated.)

Dan with his solar panels.
Look ma, no carbon emissions.

The scaffolding went up on the afternoon of day one, and I took the opportunity to climb up myself and give the gutters a good cleaning-out, because it’s a lot easier to do that from a fixed platform than it is from our wobbly “community ladder”. On day two, a team of electricians and a solar expert appeared at breakfast time and by 3pm they were gone, leaving behind a fully-functional solar array. On day three, we were promised that the scaffolding company would reappear and remove the climbing frame from our garden, but it’s now dark and they’ve not been seen yet, which isn’t ideal but isn’t the end of the world either: not least because Ruth’s been unwell and thus hasn’t had the chance to get up and see the view from the top of it, yet.

Greendale energy usage for the last four months.
Because that’s the kind of nerd I am, I have a process in place already to monitor our energy use fluctuations: note the jump in gas usage as we turned on the central heating for the winter!

We made about 4 units of electricity on our first day, which didn’t seem bad for an overcast afternoon about a fortnight away from the shortest day of the year. That’s about enough to power every light bulb in the house for the duration that the sun was in the sky, plus a little extra (we didn’t opt to commemorate the occasion by leaving the fridge door open in order to ensure that we used every scrap of the power we generated).

Because I’m a bit of a data nerd these years, I’ve been monitoring our energy usage lately anyway and as a result I’ve got an interesting baseline against which to compare the effectiveness of this new addition. And because there’s no point in being a data nerd if you don’t get to share the data love, I will of course be telling you all about it as soon as I know more.

× × × × ×

Buying a House, Part 3

This blog post is the third in a series about buying our first house. If you haven’t already, you might like to read the first part. In the second post in the series, we’d put an offer on a house which had been accepted… but of course that’s still early days in the story of buying a house…

We hooked up with Truemans, a local solicitor, after discovering that getting our conveyancing services from a local solicitor is only marginally more-expensive than going with one of the online/phone/post based national ones, and you get the advantage of being able to drop in and harass them if things aren’t going as fast as you’d like. Truemans were helpful from day one, giving us a convenient checklist of all of the steps in the process of buying a house. I’m sure we could have got all the same information online, but by the time I was thinking about offers and acceptance and moving and mortgages and repayments and deposits and everything else, it was genuinely worth a little extra money just to have somebody say “next, this needs to happen,” in a reassuring voice.

A 22-page form; each page is double-sided for added insanity.
This gargantuan beast is our mortgage application form. All of those pages are double-sided, by the way.

Meanwhile, we got on with filling out our mortgage application form. Our choice of lenders – which Stefan, who I’d mentioned in the last post, had filtered for us – was limited slightly by the fact that we wanted a mortgage for three people, not for one or two; but it wasn’t limited by as much as you might have thought. In practice, it was only the more-exotic mortgage types (e.g. Option ARMs, some varieties of interest-only mortgage) that we were restricted from, and these weren’t particularly appealing to us anyway. One downside of there being three of us, though, was that while our chosen lender had computerised their application process, the computerised version wasn’t able to handle more than two applicants, so we instead had to fill out a mammoth 22-page paper form in order to apply. At least it weeds out people who aren’t serious, I suppose.

A front door with a hole, boarded up with plywood.
The front door of our intended new home had recently sustained some… damage. That didn’t bode well.

I revisited the house to check out a few things from the outside: in particular, I was interested in the front door, which had apparently been broken during a… misunderstanding… by the current owners, who are in the middle of what seems like a complicated divorce. The estate agent had promised that it would be repaired before the sale, but when I went to visit I found that this hadn’t happened yet. Of course, now we had lawyers on our side, so it was a quick job to ask them to send a letter to the seller’s solicitor, setting the repair of the door as a condition upon which the sale was dependent.

A page from our Environmental Search, indicating some of the past uses of the land around the house we hope to buy.
The results of our Environmental Search were perhaps the most-interesting. But I’ll understand if you don’t think it’s as interesting as I do.

Our solicitors had also gotten started with the requisite local searches. One of the first things a conveyancing solicitor will do for you is do a little research to ensure that the property really is owned by the people who are selling it, that there’s no compulsory purchase order so that a motorway can be built through the middle of it, that it’s actually connected to mains water and sewers, that planning permission was correctly obtained for any work that’s been done on it, and that kind of thing. One of the first of these searches to produce results was the environmental search.

A map of the area around our new house, as it was about a century ago.
A map of the area around our new house, as it was about a century ago, unearthed by our convenient tame librarian.

One of the things that was revealed be the environmental search was that the area was at a significantly higher-than-average risk of subsidence, had the construction not been done in a particular way – using subsidence-proof bricks, or something, I guess? I theorised that this might be related to the infill activities that (the environmental search also reported) had gone on over the last hundred and fifty years. The house is near a major waterway, in an area that was probably once lower-lying and wetter, but many of the small ponds in the area were filled in in the early part of the 20th century (and then, of course, the area was developed as the suburbs of central Oxfordshire expanded, in the 1980s). Conveniently, we have a librarian on our house-buying team, and he was able to pull up a stack of old OS maps showing the area, and we were able to find our way around this now almost-unidentifiable landscape.

A map showing a field, hedgerows, water course and - highlighted in blue - a pond. The second highlighting in blue (bottom left) is a letter 'O', not a pond. I got carried away highlighting things, okay?
A map showing a field, hedgerows, water course and – highlighted in blue – a pond. The second highlighting in blue (bottom left) is a letter ‘O’, not a pond. I got carried away highlighting things, okay?

Sure enough, there were ponds there, once, but that’s as far as our research took us. Better, we thought, to just pass on the environmental search report to a qualified buildings surveyor, and have them tell us whether or not it was made out of subsidence-proof bricks or shifting-ready beams or whatever the hell it is that you do when you’re building a house to make it not go wonky. Seriously, I haven’t a clue, but I know that there are experts who do.

Three-panel diagram, showing a low-lying lake being pumped to allow house construction, but in the third panel - OH NOES! - the houses have gone lop-sided because without the water in it, the ground becomes unstable.
In this highly-realistic diagram, which wouldn’t look out of place in a geography textbook, houses go wonky because they’re built on ground that became more-compressible after it was drained. This is what I want to avoid.

Given that the house we’re looking at is relatively new, I don’t anticipate there being any problems (modern building regulations are a lot more stringent than their historical counterparts), but when you’re signing away six-figures, you learn to pay attention to these kinds of things.

Hopefully, the fourth blog post in this series will be about exchanging contracts and getting ready to move in to our new home: fingers crossed!

× × × × × ×

Pay To Post

I see that Facebook is experimenting with allowing you to pay a nominal fee to make sure that your posts end up “highlighted” over those of your friends’ other friends. That’s a whole new level of crazy… or is it?

A screenshot of Facebook's new "Highlight" feature.
A screenshot of Facebook's new "Highlight" feature. For about a quid, you can push your wall posts to the top of everybody's list.

I’m not on Facebook, but I think that this is a really interesting piece of news. The biggest thing that makes Facebook unusable (and which also affects Twitter) is that people will post every little banal thing that comes to their mind. I don’t care what you’re eating for your lunch. I don’t want to read the lyrics of some song that must have been written for you. I really can’t stand your chain messages (for a while there, after I hadn’t received any by email for a few years, I hoped that they’d died out… but it turns out that they just moved to Facebook instead). If you’re among my friends, I know that you have some pretty smart and interesting things to say… but unless I’m willing to spend hours sifting through the detritus it’s buried in, I’ll never find it.

Social Media Citation. The littering fine tickets of the digital generation.
Social Media Citation. The littering fine tickets of the digital generation.

But this might work. If the price sweet spot can be found, and it’s marketed right, then this kind of feature might make services like Facebook more tolerable. When you’re writing about a cute picture of the cat you’ve seen, that’s fine. And when you write something I might care about, you can tick the “this is actually relevant” box. You’ll have to pay a few pence, but at least you know I’ll see it. And if I want to churn through reams of “X likes Chocolate” (who doesn’t?) and “Y is… in a queue for the bus” then I can turn off the “only relevant things” mode and waste some time.

The problem is that the sweet spot will vary from person to person, and there’s no way to work around that. Big Bucks Bob can probably afford to pay a couple of pounds every time he wants to push some meme photo to the top of your feed, but Poor Penniless Penny can’t even justify ten pence to make sure that all of her friends hear about her birthday party.

Google+ tries to use heuristics to show you "top" content you might be interested in.
Google+ tries to use heuristics to show you "top" content you might be interested in. It feels less insidious than charging you, as Facebook will, but it still doesn't quite work.

It’s a pity that it won’t work, because a part of me is drawn to the idea that economic theory can help to improve the signal-to-noise ratio in our information-saturated lives. Turning my attention to email: of all the cost-based anti-spam systems, I was always quite impressed with Hashcash (which Microsoft seem to be reinventing with their Penny Black project). The idea is that your computer does some hard-to-do (but easy-to-verify) computational work for each and every email that it sends. But in its own way, Hashcash has a similar problem to Facebook’s new system: the ability to pay of a sender is not directly proportional to their relevance to the recipient. If my mother wants to send me an email from her aging smartphone, should she have to wait for several minutes while it processes and generates an “e-stamp”, just because – if it were made any faster – spammers with zombie networks of computers could do so too easily?

Yes, I just equated your social network status, about what you ate for your lunch, with spam. If you don’t like it, don’t share this blog post with your friends.

hashcash token: 1:20:120511:https://danq.me/2012/05/11/pay-to-post/::UVHo081pj6bSDWkI:00000000000001sxI

× ×