Algorithms

Carlo Varrasi
Humdrum explores: Food Delivery
3 min readSep 29, 2018

There is a set of drivers, in different areas, with different modes of transport. Some are already busy, some will free up soon, some just turned on the app. There is a set of orders from different customers, at different addresses, for different restaurants. Often all at the same time, at peak hours. The algorithm has to match them effectively and that is often the thing that can distinguish a successful platform from a failed one.

Of course, we can’t find out a lot about the specific algorithms of different food delivery services, it’s their secret sauce. But in a way, food delivery algorithms try to solve for a modified version of a famous and fascinating mathematical conundrum: the Travelling Salesman problem. A salesman has to visit a certain number of cities. What is the shortest route passing once through each city and coming back home? The problem is you can’t really each possible route as you will find that with just 16 cities you have already trillions of options. So, yes, the algorithms work mostly by approximation, searching a close-enough optimal solution within a reasonable amount of time and use machine-learning to continuously get better at it.

Great, all great. But question: what are we optimizing for, exactly? It’s not a trivial question as we have multiple goals at the same time. We want to keep customers waiting as little as possible, as they are hungry for their orders. We want to keep food as warm as possible. We want to keep drivers idle as little as possible. We would also like drivers to travel as little as possible, to consume the least amount of time and gas.

Reality is, these goals are not always aligned, so that our algorithms inevitably need to privilege one side over the other. No way around it. Take a look at case 1 on the right.

Will the food stay there at the counter getting cold? Will Rick be forced to be there waiting for the food to get ready? Will Dave be deprioritized again and wait out there, idle in the cold? Will the customer have to be hungry much longer?

Or take case 2. Will you spend more money and waste drivers’ time to get the food faster to the customer? Or do you want to risk that the ravioli gets there ice-cold and that the guy angrily calls customer service asking for a refund?

There is not a right answer, now do we really know how different delivery services manage these choices and who they decide to put first or second. Sometimes they don’t even know themselves, as machine learning is not very transparent in its workings. But these decisions have very practical implications for everyone involved. And, since all services inevitably need to take a side from time to time, it is really hard for them to be as impartial as they claim to be.

BE THE ALGORITHM!

An order for 1x Salami Madness pizza is going to be ready for pickup in 7 minutes at Gino’s. You have three drivers ready to be dispatched to the restaurant. Which one do you choose, mr. algorithm?

▢ Chris

8 minutes away. Just finished a previous
delivery nearby.

▢ Dave

10 minutes away. Has
been waiting quite a bit
for a new delivery.

▢ Rick

1 minute away. Will be waiting for the food to be ready for the remaining 6.

BE THE ALGORITHM!

Another order for a Salami Madness pizza! What the hell is wrong with these people? Gino’s is incredibly overpriced and tastes nothing like that place next to it. God, I love that place. What’s its name? Mmm.. Sam’s, yes! So good. Wait, there is also a third order at Gino’s for some meat ravioli. What will you do now, mr. algorithm?

▢ Get 1 driver to deliver both orders

Customer addresses are close. You will save money to the company and make
the most of the driver’s trip.

▢ Get 2 separate drivers instead

Addresses are close, yes. But this will
get the ravioli to the second address
much earlier than the other option.

--

--