Picnic logo

Computational Logistics at Picnic

Written by Regan KoopmansDec 9, 2020 16:126 min read
1 7iMaogehwpx1E9eV 7NniA

Logistics is the science of efficiently moving items from one place to another. This sounds simple at first, but it serves as the gateway to some of the most exciting frontiers in the mathematics and computer science. The world of logistics is fundamentally one of algorithms and optimisation. It is, therefore, no surprise that algorithmic thinking is so deeply integrated into the culture of engineering at Picnic. In this piece I would like to illustrate this by highlighting some of the most interesting problems that we are solving, and why a career in logistics should be on your radar.





“The line between disorder and order lies in logistics” — Sun Tzu.





Places and Pathways





Supply-chains can be casually described as combinations of two building blocks, namely “places” and “pathways”. Places are where things need to go, and pathways are how they get there. With these two concepts, we have enough to model complex distribution models in the real world. You might notice that this is a formulation of a network or graph, where “places” are nodes, and “pathways” are the connections between them. This means that any algorithm that applies to a graph will also generally apply to a complex supply chain.





Image for post
An illustration of a graph.




One famous problem of this kind is the Traveling Salesman Problem (TSP), which is concerned with finding the optimal round-trip in a graph. This maps directly to a business-case within Picnic. Our delivery vehicles require their routes to be carefully planned to ensure deliveries are made efficiently and on time. The Picnic routing algorithm uses a heuristic-driven solution to the Traveling Salesman Problem to achieve this on a daily basis.





Another graph theory principle is Metcalfe’s Law, which states that the value of a network is the square of the number of nodes. This means that a supply-chain becomes exponentially more valuable as it grows. Intuitively this makes sense. Larger, more established supply-chains are able to reach more customers and support resource load between warehouses. This principle also applies to internet and telephone infrastructure. Which is to say that all these things benefit from economies of scale. Picnic understands this, which is why we are the fastest-growing supermarket in Europe.





Machine Learning





We are currently in a renaissance of machine learning. Many of the recent improvements in machine learning have found applications within Picnic. We have an entire team dedicated to actively exploring learning-based solutions to promote business interests. This team is aptly named the Advanced Analytics & Algorithms Team.





One such application is the prediction of demand. Using neural networks we are able to make reasonable estimations about what demand an item might have on a given day. The models used for such predictions draw on features such as previous demand, weather, and the occurrence of public holidays. This allows preemptive stock keeping and minimises the regional unavailability of items.





Predicting demand in this way allows for some protection from the Bullwhip Effect. The Bullwhip Effect is an interesting observation from supply-chain management, that states that “demand becomes more abstract the further away you are from a customer”. If there is a spike in demand for a specific product, a warehouse will generally not know whether this is an outlier or represents genuine growth. Forecasting at Picnic, therefore, has the corollary effect of helping distinguish between these steady increases in demand and exceptional cases (such as holidays and sporting events).





Image for post
An illustration of the Bullwhip Effect.




Similar estimations can be made for how many deliveries are required for a given day. The daily delivery capacity within a region is finite, like any other resource in the supply chain. It is therefore extremely valuable to have a rough idea of what deliveries might look like in the coming days. This ensures that we do not over-promise to customers and have sufficient drivers allocated to shifts.





Monte Carlo Simulation





Monte Carlo simulation is a technique for forecasting repeated probabilistic processes. Successful deliveries in the real world are dependent on many haphazard external factors. This is particularly true of last-mile deliveries (those being the ones going to customers). Challenging factors include (but are not limited to) traffic, weather, and the size of individual orders. We cannot let the randomness of these factors prevent analysis and planning. To this end, Monte Carlo simulation has found great use in establishing risk and reliability of supply-chains.





Such simulations were recently run to approximate how an increase in average order size would impact the delivery network. Answers to these types of questions are imperative to Picnic in preventing growing pains and informing higher-level projections and planning.





Unexplored Territories





Quantum computers are no longer a theoretical concept, and not even limited to academics. There exist public APIs that you can use right now to run programs remotely on real quantum computers. You might have heard it said that quantum computers will only find use in a very limited number of special domains. Logistics is one of those domains.





In 2015 a group of academics developed the Quantum Approximate Optimization Algorithm (QAOA), which is a general-purpose optimisation algorithm for quantum computers. This algorithm allows many classical optimisation problems to be translated into the quantum realm. Chief among these is the Traveling Salesman Problem mentioned earlier. Although we do not currently leverage quantum computing at Picnic, it is possible that quantum algorithms will one day play a key role in route optimisation, model training and forecasting.





Results from logistics research have strangely found use in other industries. The theory of optimal transport has been used in biology to describe the genetic expression of single cells. Linear programming, which was at first a logistics technique, has been leveraged in agriculture and manufacturing. There does not seem to be any reason why the contrary would not be true. I, therefore, suspect that some breakthroughs in logistics could be made by transposing findings in the domains of physics, chemistry and mathematics.





Conclusion





As I see it, the number of businesses doing truly novel things in software is extremely small. Logistics is one of the industries that demand academic rigour and allows developers to experience the algorithms that they might have studied in university. Working at Picnic is interesting in this way, and that is the highest praise I can give it.


Recent blog posts

We're strong believers in learning from each other, so
our employees write about what interests them.