Travelling Salesman Problem
Multiple Salesmen
Optimization
Operations Research
Computational Mathematics

Travelling Salesman with multiple salesmen?

Data Structures & Algorithms practice on Codemia

Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.

Practice algorithms

Introduction

The Travelling Salesman Problem (TSP) is a classic problem in optimization and logistics. The objective is to find the shortest possible route for a salesman to visit a set of cities exactly once and return to the starting city. A practical variant is the Multiple Travelling Salesmen Problem (mTSP), which involves more than one salesman. This variant adds complexity and real-world applicability, especially in fleet routing, delivery logistics, and operations research.

Problem Definition

Classic TSP

The classic TSP can be represented using a graph where:

  • Nodes (cities): The locations that need to be visited.
  • Edges (paths): The connections between cities, each with an associated cost or distance.

The goal is to find a Hamiltonian cycle (a loop visiting each node exactly once) with the minimum total cost. Given nn cities, there are (n1)!2\frac{(n-1)!}{2} possible tours for an undirected graph, making brute-force infeasible for even moderate nn.

Multiple Travelling Salesmen Problem (mTSP)

The mTSP introduces mm salesmen into the scenario:

  • Each salesman starts and ends at a common depot.
  • The set of cities is partitioned among the salesmen so that each city is visited exactly once by exactly one salesman.
  • The objective is to minimize the total cost across all salesmen's routes.

Mathematical Formulation

Classic TSP

Given cities c1,c2,,cn{c_1, c_2, \ldots, c_n} and a cost matrix D=[dij]D = [d_{ij}] where dijd_{ij} is the travel cost from city ii to city jj, the objective is:

mini=1nj=1ndijxij\min \sum_{i=1}^{n} \sum_{j=1}^{n} d_{ij} x_{ij}

Subject to:

  • j=1nxij=1\sum_{j=1}^{n} x_{ij} = 1 for all ii (leave each city exactly once)
  • i=1nxij=1\sum_{i=1}^{n} x_{ij} = 1 for all jj (enter each city exactly once)
  • xij0,1x_{ij} \in {0, 1}
  • Sub-tour elimination constraints (e.g., Miller-Tucker-Zemlin or Dantzig-Fulkerson-Johnson)

mTSP Formulation

For mm salesmen servicing nn cities, introduce a superscript tt for each salesman:

mint=1mi=1nj=1ndijxij(t)\min \sum_{t=1}^{m} \sum_{i=1}^{n} \sum_{j=1}^{n} d_{ij} x_{ij}^{(t)}

Subject to:

  • Each city visited exactly once: t=1mj=1nxij(t)=1\sum_{t=1}^{m} \sum_{j=1}^{n} x_{ij}^{(t)} = 1 for all ii
  • Each salesman departs from and returns to the depot
  • Sub-tour elimination constraints for each salesman
  • xij(t)0,1x_{ij}^{(t)} \in {0, 1}

Additional constraints can bound the minimum and maximum number of cities per salesman to ensure balanced workloads.

Solution Approaches

Exact Methods

  1. Branch and Bound: Systematically explores the solution space by computing lower bounds and pruning branches that cannot improve on the best known solution. Guarantees optimality but has exponential worst-case time.
  2. Mixed Integer Linear Programming (MILP): Formulates the problem as a linear program with integer constraints. Solvers like Gurobi and CPLEX can handle instances with up to a few hundred cities.

Heuristics

  1. Nearest Neighbor: A greedy approach where each salesman always visits the closest unvisited city. Fast (O(n2)O(n^2) per salesman) but often produces suboptimal tours.
  2. Cluster-First, Route-Second: Partition cities into mm clusters (using k-means or geographic partitioning), then solve a single-salesman TSP within each cluster.
  3. Route-First, Cluster-Second: Solve one large TSP tour, then split it into mm segments.

Metaheuristics

  1. Genetic Algorithms (GA): Evolve a population of solutions through crossover and mutation. Good at exploring diverse solutions.
  2. Ant Colony Optimization (ACO): Simulates ants depositing pheromones on paths, reinforcing shorter routes over time.
  3. Simulated Annealing: Accepts worse solutions with decreasing probability, helping escape local optima.
  4. Tabu Search: Uses a memory structure to avoid revisiting recent solutions.

Example Scenario

Consider n=5n = 5 cities and m=2m = 2 salesmen with the following assignment:

SalesmanRouteCost
1Depot - City 1 - City 2 - Depot15
2Depot - City 3 - City 4 - City 5 - Depot20

Total cost: 35. A different partition might yield a lower total, so the optimization lies in both the assignment of cities to salesmen and the ordering within each route.

Applications

  • Logistics and Distribution: Optimizing multi-vehicle delivery routes to minimize fuel consumption and time.
  • Field Service Scheduling: Deploying technicians to customer sites across a region.
  • Manufacturing: Coordinating robotic arms or tool heads visiting multiple positions on an assembly line.
  • Drone Delivery: Splitting delivery targets among multiple drones with limited battery life.

Challenges

  • Scalability: The mTSP is NP-hard, inheriting the intractability of the classic TSP. The additional partitioning dimension makes it even harder.
  • Dynamic Environments: Real-time changes in traffic, new orders, or vehicle breakdowns require adaptive re-optimization.
  • Heterogeneous Fleets: Different vehicles may have different speeds, capacities, or operating costs, adding constraints to the formulation.

Summary

The Multiple Travelling Salesmen Problem extends the classic TSP by partitioning cities among multiple agents. The mathematical formulation adds assignment variables for each salesman, and solution methods range from exact MILP solvers (for small instances) to metaheuristics like genetic algorithms and ant colony optimization (for large-scale problems). The choice of method depends on problem size, solution quality requirements, and available computation time.


Related reading
Course
Intermediate
27 lessons
15 hours
DSA Fundamentals

Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Data Structures & Algorithms practice on Codemia

Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.

Practice algorithms

All Rights Reserved.