The Guardian Weekly

Science The algebra in your grocery delivery

The calculations behind filling our supermarket shelves are dizzyingly complex – but it all starts with the x and y problems you remember from school

By Michael Brooks MICHAEL BROOKS IS THE AUTHOR OF THE ART OF MORE: HOW MATHEMATICS CREATED CIVILISATION

There are trillions of possible routes for a driver delivering 60 to 70 parcels

Nando’s put it succinctly on its Twitter feed last month: “The UK supply chain is having a bit of a mare right now.” Getting things on to supermarket shelves, through your letterbox or into a restaurant kitchen has certainly become problematic of late. It’s hard to know exactly where to pin the blame, though Covid and Brexit have surely played a part. What we can do is give thanks for algebra, because things would be so much worse without it.

It’s likely that you have mixed feelings about algebra. Even if you could manage it in school, you probably wondered why it was important. You might even feel that your scepticism has been vindicated: chances are you have never used algebra in your post-school life. But that doesn’t mean algebra is useless. Whether it’s supermarket groceries, a new TV or a parcel, they all reach your home through some attempt to solve an equation. Algebra is the maths that delivers.

Algebra has been around for millennia. The word comes from the Arabic word al-jabr in the title of a ninthcentury book on calculation. It is, essentially, the art of finding unknown numbers, given certain others. The hidden factor was usually referred to in Latin as the cossa , or “thing”, and so algebra was often known as the “cossick art”: the art of the thing.

Until the 16th century, everything was written out in words. An early student of the cossick art might find themselves face to face with something like the following: two men are leading oxen along a road and one says to the other: “Give me two oxen and I’ll have as many as you have.” Then the other said: “Now you give me two oxen and I’ll have double the number you have.” How many oxen were there and how many did each have?

This poser comes from a compendium of puzzles, published circa AD800, called Problems to Sharpen the Young. A prime use of algebra today is still about calculating numbers of oxen on the road – for stocking the butcher’s counter at your supermarket.

“Stocking warehouses is a complicated problem,” said Anna Moss, principal data scientist at Ocado Technology. Moss’s role involves ensuring that the amounts of stock ordered from suppliers are sufficient to satisfy customer demand for the online grocery business, but do not exceed the warehouse storage capacity and, importantly, minimise food waste.

Moss (no surprise) is a maths whiz. She has worked for Intel and frequently publishes her research in academic journals. Applying such expertise to grocery delivery might seem like overkill, but the logistical puzzles involved are every bit as challenging as anything she has faced elsewhere.

The maths of logistics starts with algebra – linear algebra, to be precise. Linear algebra explores solutions for sets of equations that together contain all you need to find out the relationships between the variables. Its equations are, essentially, mathematical spreadsheets where a single operation can process a huge array of data, expose the relationships between them all and allow the mathematician to optimise one particular chosen outcome. The same trick lies behind Google searches,

flight scheduling and parcel delivery; even the way your virtual shopping basket is delivered to your computer screen involves linear algebra in the logistics of routing information through the internet.

Logistics hasn’t stood still with linear algebra, however. It has been developed into algorithms for “linear programming” and “mixed integer programming” and various other odd-sounding mathematical routines, such as “combinatorial optimisation”, “greedy heuristics” and “simulated annealing”.

“Think of this as computational algebra,” said Keith Moore of US logistics software company Autoscheduler.AI. And it’s all done with just one purpose: to deliver to every customer, on time and in full – OTIF as it’s known in the trade. But, as anyone working in post-Brexit supermarkets knows, that’s never actually possible. “In every distribution centre, the constraints keep the operation from perfectly maximising OTIF,” Moore said.

It’s Moore’s job to maximise what is possible for clients. He doesn’t use paper and pen or a calculator. “Even at a single distribution centre, they are collecting gigabytes of data every minute and it changes constantly. It’s not just impractical to have analysts sitting in a room doing maths to make decisions, it’s completely unfeasible.”

Instead, the necessary algebra is programmed into software. The exact nature of the algorithm at work is, of course, a trade secret. That’s why numerous companies refused to speak to me for this article: Sainsbury’s, DPD and Hermes all declined an interview request on the basis that the mathematical tricks used to improve their service are, as DPD’s PR put it, “not something they want their competitors to know about”.

What we do know is that delivery is a terrifying algebraic challenge, with far more variables than any exam question. The UK online supermarket Ocado’s optimisation algorithms, for instance, consider how to pack ordered items in the smallest possible number of bags, as well as the best path to be travelled by a robot in a warehouse or by a personal shopper picking the products from the shelves.

But they also have to factor in the time slot that you selected, van capacity and myriad other factors, such as achieving minimal environmental impact. “All these criteria are given weights based on their relative importance and this weighted combination serves as a single value to be optimised,” Moss said. “In addition, our problem keeps changing all the time, as customers place new orders and edit the existing ones. Our algorithms have to cope with these on-the-fly changes.”

Then there are the optimal delivery routes, given the location of warehouses and stores relative to your home address. Assuming you can find drivers and fuel, the mathematics of delivering goods efficiently is actually an instance of a long-standing problem for mathematicians: the travelling salesman problem. How do you find the shortest path that allows you to visit a number of locations only once?

You don’t have to treat this as an algebra problem, although linear algebra is one angle of attack. Others come through algebra-derived disciplines such as graph theory. However, the precise nature of the maths is moot: there is no way to solve the travelling salesman problem once dealing with a realistic number of destinations.

While there are six options for travelling from a distribution centre to three destinations, there are 479m possible ways to deliver to just 12 destinations. A single parcel delivery driver might deliver 60 or 70 parcels a day and there are trillions of possible routes.

No one expects even a computer to work through them all, so software, such as UPS’s Orion, makes a guess at a best route, examines its issues and then improves on it. This approach is known as heuristics and it tries to get as close as possible to optimal solutions. Although it starts with guesswork, it’s still validated by maths. “Maths gives us the confidence that we are close enough to the best option,” said Ravi Ahuja, a logistics software expert who is CEO and founder of Optym, and founder of Axele.

Nowhere is this more important than in the airline industry. Here, variables include what routes to fly, how many flights per route and at what times, plus the best way to schedule each plane, crew member and passenger for maximum profit. “Timing is everything for airlines, as that enables inbound planes to connect with outbound, crews to go from one flight to another, passengers to fly when they want to and make flight connections,” Ahuja said. “For a large passenger airline, it is a massive and tremendously complex mathematical problem.”

And you solve it with algebra. “We use several techniques, including greedy heuristics – take one decision at a time but the best one – or mixed integer programming, which relies on linear algebra,” Ahuja said. His algebra skills once allowed him to find an optimal solution for a hideous set of equations on behalf of an airline and it saw its profitability suddenly surge by hundreds of millions of dollars a year.

So learning algebra wasn’t a waste of time – for Ahuja and the others who keep our deliveries coming in these trying times, at least. Not that these mathematicians all keep things strictly professional. “I sleep pretty well every night knowing that we’re helping companies reduce costs and run greener operations,” Moore said. “But building an algorithmic fantasy football team that absolutely destroyed the 2019 NFL season was pretty great, too.” Observer

A Week In The Life Of The World/Inside

en-gb

2021-09-17T07:00:00.0000000Z

2021-09-17T07:00:00.0000000Z

https://theguardianweekly.pressreader.com/article/282050510192520

Guardian/Observer