Travelling Salesman Problem: Using Branch and Bound Method
Travelling Salesman Problem: Using Branch and Bound Method
Travelling
Salesman Problem
Using Branch and Bound method
Department: SE-DS | Roll No: 23DS30 | 23DS23 | 23DS41 | 24DDS03
What is TSP?
Algorithm….
The Traveling Salesman Problem (TSP) is a classic
optimization problem where the goal is to find the
shortest possible route that visits each city exactly once
and returns to the starting point.
ALGORITHM
A
1. Perform row and column reduction on
1
the cost matrix.
2. Calculate the cost of the first node
(e.g., A):
Cost = sum of reductions
3. Choose the next node (e.g., A → B): Path
○ Set row A, column B, and B C D
path B → A to ∞.
2 3 4
○ Perform reduction again.
○ Compute:
Cost = parent cost + reduction cost
+ cost from A to B C D B D B C
4. After exploring all children of a node, 5 6 7 8 9 10
expand the node with the least total
cost, and repeat.
Department: SE-DS | Roll No: 23DS30 | 23DS23 | 23DS41 | 24DDS03
Let’s Learn 1. Perform row and column reduction on the cost matrix.
Q. Find the Minimum Cost for following Travelling Salesman using Branch & Bound.
20
∞ 20 30 10 11 A B
Reduction: 15
Subtracting min element of a row/column 5
15 ∞ 16 4 2 from the same row/column only. 16 16
4 30
11
2 3
3 5 ∞ 2 4 Reduced matrix:
All the row or column have atleast one 4
19 6
10
ZERO element.
19 6 18 ∞ 3 E 7
C
4
16 4 7 16 ∞ 1 3 3 2
16
18
10 ∞ 10 20 0 1 ∞ 10 17 0 1 D
2 13 ∞ 14 2 0 12 ∞ 11 2 0
2 1 3 ∞ 0 2 0 3 ∞ 0 2
3 16 3 15 ∞ 0 15 3 12 ∞ 0
4 12 0 3 12 ∞ 11 0 0 12 ∞
Department: SE-DS | Roll No: 23DS30 | 23DS23 | 23DS41 | 24DDS03
Let’s Learn
Cost = 25
A→B
No reduction required!
Cost = 25 + 0 + 10
Cost(AB) = 35
Department: SE-DS | Roll No: 23DS30 | 23DS23 | 23DS41 | 24DDS03
Let’s Learn
3. Choose the next node (e.g., A → C):
A→C
11
Cost = 25 + 11 + 17
Cost(AC) = 53
Department: SE-DS | Roll No: 23DS30 | 23DS23 | 23DS41 | 24DDS03
Let’s Learn
A→D
No reduction required!
Cost = 25 + 0 + 0
Cost(AD) = 25
A→E
Cost = 25 + (2 + 3) + 1
3 Cost(AE) = 31
Department: SE-DS | Roll No: 23DS30 | 23DS23 | 23DS41 | 24DDS03
Let’s Learn
4.After exploring all children of a node, expand the node with the least total
cost, and repeat.
Hence A → D selected. Cost= 25.
D→B
No reduction required!
Cost = 25 + 0 + 3
Cost(DB) = 28
Cost = 25 + 13 + 12
2
Cost(DC) = 50
11
Department: SE-DS | Roll No: 23DS30 | 23DS23 | 23DS41 | 24DDS03
Let’s Learn
Now, Set row D, column E, and path E → A to ∞.
Cost(DE) = 36
Cost = 25 + (2+11) + 11
2
Cost(BC) = 49
11
Department: SE-DS | Roll No: 23DS30 | 23DS23 | 23DS41 | 24DDS03
Let’s Learn
Now, Set row B, column E, and path E → A to ∞.
B→E
No reduction required!
A
Cost = 28 + 0 + 0
Cost(BE) = 28
B C D E
Since cost of B → E is smallest we select path A → D → B → E with Cost = 28
And,
Finally E → C with the cost,
B C E
Cost = Cost(BE) + cost from B to C
28 + 0
C E
Cost = 28;
PATH = A → D → B → E → C → A
C
A
Department: SE-DS | Roll No: 23DS30 | 23DS23 | 23DS41 | 24DDS03
A B
3
6
2
7
E C
10
D
Real World
Application
● Delivery Route Optimization: Scheduling Algorithms;
TSP helps delivery companies find the most efficient routes for their
vehicles to visit multiple customers, minimizing fuel consumption, travel
time, and overall costs.
● Order-Picking in Warehouses:
Finding the shortest route for a vehicle to pick up orders from multiple
locations in a warehouse can be modeled as a TSP.
Why we Learn TSP ?
● In OS:
TSP principles can help find the most efficient sequence for executing tasks,
minimizing context switching overhead and improving overall system
performance.
▶
Conclusion
TSP is a computationally challenging problem with n! permutations,
but crucial in fields like logistics, planning, and routing.
Bye…..
THANK YOU
23DS30
23DS41
23DS23
24DDS03