Chahira Mourad
@Zalando
Aug 26, 2024
Planning Your Dream Europe Trip? Here’s the Math That Could Make It Perfect
Sofia is finally planning her dream Europe trip, visiting must-see cities like Paris, Rome, Berlin, Barcelona, and Athens. But as she maps it out, she wonders: What’s the best order to visit them? Should she go from west to east, or north to south?
It’s not just about minimizing travel time—Sofia wants to maximize her experience.
What she doesn’t know is that her travel dilemma is actually a classic mathematical optimization problem known as the Traveling Salesman Problem (TSP). It’s a problem that businesses, from logistics companies to tech giants, face every day.
What is the Traveling Salesman Problem (TSP)?The TSP asks a simple yet challenging question: Given a list of locations, what’s the shortest possible route that visits each location exactly once and then returns to the starting point?
In Sofia’s case, the locations are Paris, Rome, Berlin, Barcelona, and Athens. While finding the shortest route may seem straightforward, the complexity grows exponentially with each added city. With just five cities, there are already 120 possible routes.
Imagine how complicated it gets with more cities! The Traveling Salesman Problem isn't just for travelers like Sofia. It's widely used across industries. Logistics companies optimize delivery routes to minimize costs, while tech companies use TSP to improve network routing, design circuits, and even tackle DNA sequencing.
Solving Sofia’s dilemma taps into the same optimization techniques that power industries worldwide. A High-Level Model of the TSPNow, let’s take a closer look at how Sofia’s travel problem can be modeled using the principles of the Traveling Salesman Problem.
Picture Sofia’s Europe trip as a network of cities connected by roads—like dots connected by lines on a map. Each city she wants to visit represents a node, and the roads between them represent the edges.
Graph showing Sofia's Europe trip cities and the distances between them in kilometers

Cities (Nodes): Sofia's cities—Paris, Rome, Berlin, Barcelona, and Athens—are the nodes in the network.
Distances (Edges): The roads connecting the cities are represented by the edges. Each edge has a distance, or “cost,” associated with it. For example, the distance between Paris and Rome is 1100 km, and the distance between Athens and Berlin is 2000 km.
Objective: Sofia’s main goal is to find the route that minimizes the total distance traveled. This means choosing a path that allows her to visit each city once and return to the starting point, with the least amount of time spent traveling.
For instance, if Sofia starts her journey in Paris, the model will calculate and compare possible routes such as
Paris → Berlin → Rome → Barcelona → Athens → Paris, or
Paris → Athens → Barcelona → Berlin → Rome → Paris
The TSP model evaluates all possible combinations, ultimately finding the optimal route that minimizes the total distance. With this solution, Sofia can embark on her journey, confident she has found the most efficient path.
How Can You Solve the Traveling Salesman Problem?
Sofia’s Europe trip presents us with a classic Traveling Salesman Problem: finding the shortest possible route that visits all cities and returns to the starting point. After evaluating all possible routes based on this specific instance, Sofia's most efficient Europe trip is:
Paris → Berlin → Athens → Rome → Barcelona → Paris
Here’s what the optimized route looks like:
Optimized route for Sofia’s Europe trip, minimizing total travel distance between Paris, Berlin, Athens, Rome, and Barcelona.

But distances aren’t the only factor you can optimize for! We could just as easily replace the distances with the cost of travel—whether by train or by plane—between these cities. In this case, the optimization would be focused on minimizing the cost of travel rather than the physical distance. This flexibility is one of the key strengths of the Traveling Salesman Problem: it adapts to the specific goals of the situation, whether it’s saving time, money, or even fuel.
Now that we’ve explored the idea of optimizing for both distance and cost, let’s take a look at the solvers that can help tackle these kinds of problems...
Concorde TSP Solver: The leading solver for exact TSP solutions, known for consistently finding optimal routes. Concorde is highly efficient and capable of solving even very large instances of TSP, making it the gold standard for exact optimization problems.
Google OR-Tools: A versatile open-source optimization library by Google. It supports solving TSP using both heuristic and exact methods, is highly accessible, integrates well with Python, and is a popular choice for flexibility and ease of use.
Gurobi: A commercial solver known for its exceptional speed and efficiency. Gurobi offers powerful optimization for both exact and heuristic methods, with extensive commercial support.
Hexaly: Hexaly is a highly scalable solver, capable of handling thousands of nodes efficiently. It’s known for its flexibility and rapid solutions, often outperforming other solvers in large-scale industrial applications.
Conclusion
Sofia’s Europe trip may seem like a fun vacation plan, but the math behind it shows how optimization techniques like the Traveling Salesman Problem (TSP) are deeply embedded in our everyday lives. From planning the most efficient travel routes to optimizing complex networks, TSP demonstrates the power of mathematical thinking in solving real-world problems.
As you reflect on Sofia’s journey, what other optimization problems do you think are hiding in plain sight in our everyday life?
More Articles For You
Operational planning and campaign optimization
Cristina Radu
(Supply Chain Optimization)

Strategic planning and network design
Cristina Radu
(Supply Chain Optimization)

A Brief History of Linear and Mixed-Integer Programming Computation
Robert E. Bixby
(Technical knowledge)

Sudoku
Julian Hall
(Technical knowledge)
