Inferensys

Glossary

Traveling Salesman Problem (TSP)

A foundational combinatorial optimization problem to find the shortest possible route that visits each node exactly once and returns to the origin.
Performance engineer optimizing AI latency on laptop, latency charts visible, technical optimization session.
COMBINATORIAL OPTIMIZATION

What is Traveling Salesman Problem (TSP)?

The Traveling Salesman Problem is a foundational computational challenge in logistics and computer science focused on finding the most efficient Hamiltonian circuit.

The Traveling Salesman Problem (TSP) is a classic combinatorial optimization challenge that asks: given a list of cities and the distances between each pair, what is the shortest possible route that visits each city exactly once and returns to the origin city? It is a foundational benchmark in computer science for testing the efficiency of optimization algorithms.

TSP is classified as NP-hard, meaning the computational time required to find a provably optimal solution grows exponentially with the number of stops. For last-mile delivery with dozens of addresses, exact solvers become infeasible. Consequently, logistics systems rely on metaheuristics like Genetic Algorithms and Simulated Annealing to find near-optimal routes within operational time constraints.

COMBINATORIAL OPTIMIZATION

Key Characteristics of TSP

The Traveling Salesman Problem (TSP) is a foundational NP-hard problem in combinatorial optimization. It seeks the shortest possible Hamiltonian cycle—a route that visits each node exactly once and returns to the origin. Despite its simple formulation, TSP serves as the theoretical backbone for modern last-mile delivery optimization, where constraints like time windows and vehicle capacity are layered on top.

01

Hamiltonian Cycle Requirement

The core mathematical constraint of TSP is the Hamiltonian cycle: a closed loop that visits every vertex exactly once before returning to the start. This distinguishes TSP from general shortest-path problems. In logistics, this maps directly to a single driver completing a full delivery tour. The constraint ensures no stop is skipped and no backtracking occurs unless mathematically optimal. For n cities, the number of possible tours is (n-1)!/2, making brute-force enumeration infeasible beyond roughly 20 stops.

02

NP-Hard Complexity

TSP is classified as NP-hard, meaning no known algorithm can solve all instances to optimality in polynomial time. Computational effort grows factorially: a 50-city problem has roughly 10^62 possible tours. This intractability is why logistics platforms rely on heuristics and metaheuristics rather than exact solvers for real-world routing. The NP-hard nature of TSP directly motivates the use of Genetic Algorithms, Simulated Annealing, and Large Neighborhood Search in production systems.

03

Symmetric vs. Asymmetric TSP

In Symmetric TSP (STSP), the cost to travel from node A to B equals the cost from B to A—a valid assumption for Euclidean distance. In Asymmetric TSP (ATSP), directional costs differ due to one-way streets, turn restrictions, or time-dependent traffic. Last-mile delivery systems almost always model the ATSP variant because real road networks are directional. ATSP doubles the decision variables and is computationally harder to solve exactly.

04

Metric TSP and Triangle Inequality

Metric TSP is a constrained variant where edge costs satisfy the triangle inequality: the direct path between two nodes is never longer than a path through an intermediate node. Euclidean distances naturally obey this property. Metric TSP allows for approximation algorithms with provable guarantees—Christofides' algorithm, for example, produces a tour at most 1.5x the optimal length. Non-metric instances (e.g., airfares with arbitrary pricing) lack such guarantees.

05

Dynamic TSP with Real-Time Re-Optimization

Classical TSP assumes static inputs, but modern logistics demands dynamic re-optimization. New orders arrive mid-tour, traffic conditions shift, and delivery windows tighten. Dynamic TSP continuously resolves the problem as new information emerges, often using rolling-horizon approaches. This requires solving many small TSP instances in milliseconds rather than one large instance overnight. The algorithmic challenge shifts from pure optimality to anytime performance—returning the best solution found within a strict time budget.

06

TSP as a Subproblem in VRP

In practice, pure TSP is rarely solved in isolation for logistics. It appears as a subproblem within richer frameworks like the Vehicle Routing Problem (VRP). Once a VRP solver assigns a set of stops to a specific vehicle, a TSP solver sequences those stops optimally. This decomposition—cluster first, route second—is a common heuristic strategy. The quality of the TSP solver directly impacts the overall VRP solution, making fast, near-optimal TSP heuristics critical infrastructure.

TRAVELING SALESMAN PROBLEM

Frequently Asked Questions

The Traveling Salesman Problem (TSP) is a foundational combinatorial optimization challenge in computer science and operations research. It asks: given a list of cities and the distances between them, what is the shortest possible route that visits each city exactly once and returns to the origin city? Despite its simple formulation, TSP is NP-hard, meaning no known algorithm can solve all instances efficiently as the number of cities grows. Its solutions directly underpin modern last-mile delivery optimization, fleet routing, and autonomous supply chain intelligence.

The Traveling Salesman Problem (TSP) is a combinatorial optimization problem that seeks the shortest possible Hamiltonian cycle—a closed loop that visits every node in a graph exactly once and returns to the starting node. Formally, given a complete weighted graph G = (V, E) where V is a set of n cities and E represents edges with associated costs (distances, time, or fuel), the objective is to find a permutation π of the vertices that minimizes the total tour cost ∑ d(v_i, v_{i+1}) + d(v_n, v_1). The problem is NP-hard, meaning the solution space grows factorially as (n-1)!/2 possible tours. For a 20-city instance, this yields roughly 60 quadrillion possible routes. Exact solvers using Mixed Integer Programming (MIP) with branch-and-cut algorithms can handle instances up to tens of thousands of nodes by iteratively adding subtour elimination constraints. In practice, heuristic and metaheuristic approaches like Lin-Kernighan-Helsgaun (LKH) and Concorde TSP Solver are employed to find near-optimal solutions for massive logistics networks within operational time constraints.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.