Optimizing deliveries in the real world is thornier than the traveling-salesman problem on several levels. First, distances between locations need to be calculated, and as anyone who’s used Google Maps will know, there’s always more than one way to make a journey. Will Salter, managing director at Paragon, which provides routing and scheduling software in 60 countries for clients like the U.K. supermarket giant Tesco, says path-finding algorithms used in delivery planning are “highly customized” compared with a Google Maps algorithm. They’ll take into account road conditions, changing traffic flows at different times of day—even the marginal benefits of making a right turn at a junction.

Then hundreds of constraints must be taken into account. You might calculate an amazing route that hits all your deliveries, but can you fit everything in the back of the van? How much longer will it take to unload the frozen food than the staples? Is it worth dropping off heavy items first to save fuel?

But James Lohr, head of planning and delivery systems at Ocado, the world’s largest online-only grocery retailer (see “The Robotic Grocery Store of the Future Is Here”), explains that its system starts by randomly allocating deliveries to vans for a certain geographic area, then works out how long those deliveries will take. Then it makes a combination of small and large changes, from switching the order of two drop-offs to switching entire chunks of deliveries between vehicles—each time evaluating whether it’s an improvement. Making four million moves a second and keeping track of the best solutions, it slowly approaches the most optimal route it can find.

Away from the heavy computational weight of planning for large organizations, some firms are developing systems targeted at small businesses, too. Routific’s Kuo, for instance, explains that his company hopes to provide route-planning power using cloud-based services that drivers access via a smartphone. “It’s kind of a shocker, but many drivers still plan routes with pen and paper,” he says. His firm’s algorithm also makes incremental changes to routes, but when a small change makes a big difference, attention is focused around that drop-off to maximize improvement, and then the algorithm moves on. Routific claims its service reduces the length of delivery routes by 40 percent.

There’s a decent chance that you’ve already interacted with these algorithms without realizing it. Paragon (working on behalf of Ikea and catalogue retailer Argos) and Ocado both suck data from their analyses when offering up delivery windows to customers on their websites. It proposes only routes that fit well with its current plans for the days ahead.

That’s a courtesy to drivers that hasn’t, perhaps, always existed. Paragon, Ocado, and Routific have all experienced cultural problems when it comes to convincing experienced delivery drivers that their algorithms know better than they do. “At one point, if you went to the place where drivers ate lunch and said you were a route planner, you’d be scared for your life,” says Ocado’s Lohr. “I’m exaggerating slightly, of course, but it can be politically difficult.”

Meanwhile, more layers of difficulty keep being added to the optimization problem itself—and there looks to be no end in sight. Paragon’s Salter explains that clients keep asking for new features to be added. Routes that minimize carbon dioxide emissions. for instance, have become a favorite. “Every year we’re taking into account more and more constraints,” he says. “I don’t think it’s possible to truly optimize [the routes] we’re planning.”