TSP
Branch and Bound
Optimization Algorithms
Traveling Salesman Problem
Computational Mathematics

TSP - Branch and bound

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 Traveling Salesman Problem (TSP) is a classic problem in combinatorial optimization that seeks the shortest possible route for a salesman to visit a set of cities and return to the origin city. It's a well-known NP-hard problem, meaning there is no known polynomial-time algorithm to solve it for all cases. One of the methods used to tackle this problem is the "Branch and Bound" technique, which is a systematic way of solving optimization problems, cutting away large portions of the search space that cannot contain the optimal solution.

Branch and Bound Technique

Branch and Bound is an algorithmic method for solving optimization problems. It involves identifying feasible solutions by branching out, and then bounding these solutions by employing bounds to eliminate parts of the search space.

Key Components

  • Branching: This step involves dividing a problem into smaller subproblems. For TSP, this typically means choosing a city to visit next, thereby reducing the number of cities remaining to be visited.
  • Bounding: Calculate a bound on the smallest possible solution that can be obtained from a particular node, which helps in eliminating suboptimal paths.
  • Pruning: When a bound for a node exceeds the cost of the best-known solution, that node along with its descendants is pruned, reducing the search space.

Application in TSP

The Branch and Bound technique involves exploring all possible solutions but discards paths that are unlikely to produce a better solution than the current best one. Below is a step-by-step approach:

  1. Initialization: Start with an initial upper bound which can be obtained using simple heuristics like the greedy method.
  2. Node Selection: Choose a node for expansion among promising nodes identified via bounding criteria.
  3. Branching: Select a city to travel next, reducing the problem size.
  4. Bounding: Calculate the lower bound for each branch. If this bound is higher than the current best solution, prune the branch.
  5. Solution Update: If a complete tour is found with a lower cost than the best-known solution, update the best-known solution.
  6. Repeat: Continue the branching, bounding, and pruning process until all branches have been explored or pruned.

Example

Let's consider a TSP with four cities: A, B, C, and D, and the following distance matrix.

ABCD
A0101520
B1003525
C1535030
D2025300

Step-by-Step

  1. Initial Bound Calculation: Apply a simple heuristic to get a bound, say through the nearest neighbor algorithm.
  2. Branching from A: Consider paths that start from A, such as A to B, A to C, and A to D.
  3. Bounding: Compute a bound for each path. For example, choose A -> B (with remaining nodes C, D). Calculate the minimum spanning tree for remaining nodes combined with the direct path B -> A and set this as the bound for node B.
  4. Pruning: If the bound for any path exceeds the current best path length, prune it.
  5. Explore more nodes: Continue the process by selecting the next promising node until all possibilities are exhausted.

Advantages and Limitations

Advantages

  • Effectiveness for Small to Medium Instances: Branch and bound can efficiently solve small to medium-sized instances of TSP through the bounded restriction of search space.
  • Exact Solution: Provides an exact solution rather than an approximation.

Limitations

  • Scalability: When node numbers increase, the computational complexity increases, limiting its practical use for very large instances.
  • Memory Usage: Requires significant memory for storing the branching tree.

Summary Table

ComponentDescription
BranchingDivides the problem into smaller subproblems through systematic selection of cities to visit.
BoundingCalculates lower bounds to help identify non-promising nodes early.
PruningEliminates paths that cannot yield better solutions than the current best-known solution.
ScalabilitySuitable for small to medium-sized instances but struggles with larger ones due to exponential growth

Conclusion

The Branch and Bound technique is a powerful algorithmic approach to solving the TSP by focusing computational effort on promising areas of the solution space. While it provides exact solutions, it's primarily suitable for instances where the size is manageable due to its reliance on exhaustive exploration. As technology advances, hybrid methods and improvements on bounding techniques may unlock further potential in exploiting branch and bound methods for TSP.


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.