University project · Operations research
What is the shortest road trip through 12 cities?
Solving the travelling salesman problem for 12 cities in Spain and Portugal by hand, from quick estimates to the proven shortest round trip of 2,927 km.
At a glance
- Type
- Course paper, team of two
- Period
- Feb 2022
- Problem
- Travelling salesman problem, 12 cities
- Methods
- Minimum spanning tree, s-tree relaxation, Christofides algorithm, branch and bound
- Tools
- Excel, worked through by hand
About
A paper for the course Operations Research and IT Security Risk Assessment, part of the master's programme Technology and Innovation Management at Hochschule Harz, written with a fellow student and submitted in February 2022.
The problem
A salesperson has to visit 12 cities and come back home. In which order should they travel to keep the total distance as short as possible?
It sounds like a puzzle, but it is one of the most famous problems in operations research. The same question appears when a delivery van plans its stops, a machine drills holes into a circuit board, or a robot arm moves across a chip.
The catch is the number of possibilities. With 12 cities there are almost 20 million different round trips. A fast computer could still check those in seconds, but each extra city multiplies the count, and at 20 cities the same computer would need about 1,900 years, roughly as long ago as the Roman Empire. So instead of checking every option, you need smart ways to narrow the search.

Our cities
We picked 12 cities in Spain and Portugal: Madrid, Seville, Valencia, Granada, Barcelona, Málaga, Girona, Lisbon, Porto, Bilbao, Valladolid and Jerez de la Frontera near Cádiz. For each pair we used the air distance, which gave a table of 66 distances.

Step 1: how short could it possibly be?
Before searching for the answer, it helps to know the lowest value it could ever have, a lower bound.
- Minimum spanning tree. Connect all cities with the shortest possible network of roads, without forming loops. That gave 2,256 km. A real round trip must be at least this long.
- s-tree relaxation. A sharper version: leave one city out, build the network for the rest, then connect the missing city with its two shortest links. We tried this for every city by hand. Leaving out Valencia gave the best bound, 2,726 km.
Step 2: a good trip that is not too long
Next, an upper bound, a real trip that is good but not necessarily perfect.
- Christofides algorithm. It starts from the spanning tree, adds the cheapest links between the cities with an odd number of connections, and turns the result into a tour. Our best tour was 3,194 km.
So now we knew the answer lay somewhere between 2,726 and 3,194 km.
Step 3: finding the exact answer
Branch and bound finds the optimal tour without checking every possibility. Think of searching a building for the cheapest room: if a whole floor is already more expensive than a room you have found, you skip the entire floor.
In practice, we worked with the distance table in Excel. At every step we reduced the table, picked the most promising connection, and split the problem in two: one branch with that connection and one without it. Each branch got a new lower bound. Any branch whose bound was already worse than the best trip found so far was cut off.
The result was a round trip of 2,927 km, and the search proved that no shorter trip exists:
Valladolid, Madrid, Bilbao, Girona, Barcelona, Valencia, Granada, Málaga, Jerez, Seville, Lisbon, Porto and back to Valladolid.

The results side by side
| Method | Result | What it tells you |
|---|---|---|
| Minimum spanning tree | 2,256 km | Lower bound |
| s-tree relaxation | 2,726 km | Sharper lower bound |
| Christofides algorithm | 3,194 km | A good tour, upper bound |
| Branch and bound | 2,927 km | Proven shortest tour |
Why it still matters to me
Doing it by hand made the logic stick. Branch and bound is really a planning habit: estimate the best case, find a realistic solution, and stop exploring options that cannot beat what you already have. I use the same thinking when comparing schedules or options in a project.
Sources
- Wikipedia: Travelling salesman problem ↗en.wikipedia.org
- NASA Earth Observatory: Iberian Peninsula at Night (Dec 2011) ↗earthobservatory.nasa.gov
Get in touch
Questions, ideas, or tried something similar yourself? I'd love to hear about it. Email me