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.
Glossary
Traveling Salesman Problem (TSP)

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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
The Traveling Salesman Problem is the theoretical root of modern logistics. Master these related concepts to understand how real-world delivery fleets are optimized.
Vehicle Routing Problem (VRP)
The direct generalization of TSP for fleet management. Instead of one salesman, VRP seeks optimal routes for multiple vehicles from a central depot. It introduces the critical constraint of vehicle capacity, making it the foundational model for last-mile delivery. Solving VRP minimizes total distance traveled while ensuring no vehicle is overloaded.
VRP with Time Windows (VRPTW)
Adds the hard constraint that each customer must be visited within a specific time interval. This is the most commercially relevant variant for attended home delivery. A solution is only valid if the vehicle arrives after the ready time and before the due time. Early arrivals force the vehicle to wait, directly impacting fleet utilization.
Genetic Algorithm (GA)
A metaheuristic inspired by natural selection that evolves a population of candidate routes over generations. Key operators include:
- Crossover: Combining two parent routes to create offspring
- Mutation: Randomly perturbing a route to maintain diversity
- Selection: Keeping the fittest solutions GAs excel at escaping local optima in massive, rugged search spaces where exact methods fail.

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us