Sunday, September 19, 2021
science

# Algebra: the maths working to solve the UK’s supply chain crisis

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 knuckle down and manage it in school, you probably wondered why it was important to solve an equation involving x raised to the power of 2 or why you should want to find a and b when a + b = 3 and 2a – b = 12. You might even feel that your scepticism has been vindicated: the chances are that you have never done algebra in your post-school life. But that doesn’t mean that the jumble of letters, numbers and missing things that we call algebra is useless. Whether it’s supermarket groceries, a new TV or a parcel from Aunt Emily, they all reach your home through some attempt to solve an equation and find the missing number. 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 ninth-century book on calculation, but ancient peoples in Babylon, India, China and Africa had been solving algebraic equations long before that. It is, essentially, the art of finding unknown numbers, given certain others. The sought-after 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.

See also  British-built satellite designed to remove space debris makes successful start

Early adopters of algebra didn’t have the luxury of solving equations: 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 in around AD800, called Problems to Sharpen the Young. It is not that different from the questions we all faced in maths lessons at school and 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,” says 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, but do not exceed the warehouse storage capacity and, importantly, minimise food waste.

Moss, you might not be surprised to learn, is a maths whiz. She has worked for Intel in the past and frequently publishes her mathematics 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. This is algebra where the variables (data about warehouse stock, for example) tend to be processed in ways that don’t depend on the square, the cube or any other power. So y = 4x would be an operation in linear algebra; y = 4x2 would not.

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”.

“You can think of this as computational algebra,” says 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. And, as anyone working in post-Brexit supermarkets knows, that’s never actually possible. “In every distribution centre I’ve been around, the constraints keep the operation from perfectly maximising OTIF,” Moore says.

It’s Moore’s job to maximise what is possible for a wide range of clients, including Unilever and Procter & Gamble. 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 that data changes constantly. It’s not just impractical to have analysts and people sitting in a room doing math 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: they were worried their mathematicians might say too much. 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 you ever encountered in any exam question. 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 in a store picking the products from the shelves. But they also have to factor in the time slot that you selected, the capacity of the van 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 says. “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. “We know the travel distances between all pairs of these locations,” Moss says. “The problem is to find the best van routes or the way to assign orders to vans and determine the sequence for each van in which to deliver its assigned orders.”

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. Cut to the bone, it is this: 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, strictly speaking, although linear algebra does provide one angle of attack. Others come through algebra-derived disciplines such as graph theory. However, the precise nature of the mathematics is somewhat moot, since there is no way to solve the travelling salesman problem once you are 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 for that relatively small number of deliveries.

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 is the approach known as heuristics. It is another high-powered relative of school algebra and tries to get as close as possible to optimal solutions. Although it starts with guesswork, it’s still validated by maths. “Mathematics gives us the confidence that we are close enough to the best option,” says Ravi Ahuja, founder and CEO of two logistics optimisation companies Optym and Axele.