TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Member-only story

Modern Route Optimization with Python

Shortest Path, Traveling Salesman Problem, Vehicle Routing Problem, Plotting Maps and Animations

Mauro Di Pietro
TDS Archive
Published in
13 min readJun 7, 2023

--

In this article, I will use Python to address the following problem: what is the optimal route for 1 or more vehicles in order to deliver to a set of customers?

Photo by Robert Anasch on Unsplash

Summary

Route Optimization is the process of determining the most cost-efficient route. It doesn’t necessarily mean finding the shortest path between two points, as it includes all relevant factors (i.e. profit, number of locations, time windows).

This topic was first addressed mathematically in the 1930s to solve a school bus routing problem. It was called the Traveling Salesman Problem, which consists of finding the shortest way for a driver to visit all the locations, given the distances between them.

The Traveling Salesman Problem can be generalized into the Vehicle Routing Problem: the issue of mapping routes for vehicles while minimizing an objective function composed of operating costs and user preferences. It’s the main problem in logistics transportation. For instance, if at night there is a lot of traffic (or high tolls) on the shortest path, it might not be the optimal route for dinner deliveries.

--

--

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Mauro Di Pietro
Mauro Di Pietro

Responses (9)