L26 Travelling Salesman Problem Using B and B
L26 Travelling Salesman Problem Using B and B
L26 Travelling Salesman Problem Using B and B
By
Dr. Ratnesh Litoriya
Medi-Caps University, Indore (M.P.)
5/6/2023
Branch and Bound Algorithm
In computer science, there is a large number of optimization
problems which has a finite but extensive number of feasible
solutions. Among these, some problems like finding the
shortest path in a graph or Minimum Spanning Tree can be
solved in polynomial time.
A significant number of optimization problems like production
planning, crew scheduling can’t be solved in polynomial time,
and they belong to the NP-Hard class. These problems are
the example of NP-Hard combinatorial optimization problem.
Branch and bound (B&B) is an algorithm paradigm widely
used for solving such problems.
2
Branch and Bound Algorithm
Branch and bound is one of the algorithm design
techniques used for problem solving.
It is similar to the backtracking since it also uses the
state space tree.
It is used for solving the optimization problems and
minimization problems.
If we have given a maximization problem then we can
convert it using the Branch and bound technique by
simply converting the problem into a maximization
problem.
3
Branch and Bound Algorithm
Branch and bound is generally used for solving
combinatorial optimization problems.
These problems are typically exponential in terms of time
complexity and may require exploring all possible
permutations in worst case.
The Branch and Bound Algorithm technique solves these
problems relatively quickly.
4
Travelling Salesman Problem | Branch & Bound
5
Travelling Salesman Problem | Branch & Bound
Example
working example
7
Solution
Step-01:
Write the initial cost matrix and reduce it-
Rules
To reduce a matrix, perform the row reduction and column reduction of
the matrix separately.
A row or a column is said to be reduced if it contains at least one entry
‘0’ in it.
Solution
Row reduction
Now,
We reduce this matrix.
Then, we find out the cost of node-02.
Solution
Cost(2)
= Cost(1) + Sum of reduction
elements + M[A,B]
= 18 + (13 + 5) + 0
= 36
Solution
Choosing To Go To Vertex-C: Node-3 (Path A → C)
Now,
We reduce this matrix.
Then, we find out the cost of node-03.
Solution
Cost(3)
= Cost(1) + Sum of reduction
elements + M[A,C]
= 18 + 0 + 7
= 25
Solution
Choosing To Go To Vertex-D: Node-4 (Path A → D)
Now,
We reduce this matrix.
Then, we find out the cost of node-04.
Solution
Cost(4)
= Cost(1) + Sum of reduction
elements + M[A,D]
= 18 + 5 + 3
= 26
Solution
Thus, we have-
Cost(2) = 36 (for Path A → B)
Cost(3) = 25 (for Path A → C)
Cost(4) = 26 (for Path A → D)
Now,
We reduce this matrix.
Then, we find out the cost of node-5.
Solution
Cost(5)
= cost(3) + Sum of reduction elements
+ M[C,B]
= 25 + (13 + 8) + ∞
=∞
Solution
Choosing To Go To Vertex-D: Node-6
(Path A → C → D)
Now,
We reduce this matrix.
Then, we find out the cost of node-6.
Solution
Thus, the matrix is already reduced.
Now, we calculate the cost of node-6.
Cost(6)
= cost(3) + Sum of reduction elements +
M[C,D]
= 25 + 0 + 0
= 25
Solution
Thus, we have-
Cost(5) = ∞ (for Path A → C → B)
Cost(6) = 25 (for Path A → C → D)
Now,
We reduce this matrix.
Then, we find out the cost of node-6.
Solution
Finally, the matrix is already completely reduced.
All the entries have become ∞.
Now, we calculate the cost of node-7.
Cost(7)
= cost(6) + Sum of reduction elements + M[D,B]
= 25 + 0 + 0
= 25
Thus,
Optimal path is: A → C → D → B → A
Cost of Optimal path = 25 units
Time Complexity
Traveling salesman problem is a NP-hard problem.
Until now, researchers have not found a polynomial
time algorithm for traveling salesman problem.
Among the existing algorithms, dynamic
programming algorithm can solve the problem in
time O(n^2*2^n) where n is the number of nodes in
the graph.
The branch-and-bound algorithm has been applied
to solve the problem with a large number of nodes.
However, branch-and-cut algorithm also has an
exponential worst-case running time.