# Branch and Bound
- The branch-and-bound algorithm developed here is an improvement on the backtracking algorithm.
- The B&B design strategy is very similar to backtracking in that a state space tree is used to solve a problem.
- B&B vs. Backtracking
- B&B does not limit us to any particular way of traversing the tree and
- B&B is used only for optimization problems
- A B&B algorithm computes a number (bound) at a node to determine whether the node is promising.
- If that bound is no better than the value of the best solution found so far, the node is nonpromising.
- Otherwise, it is promising.
# 0-1 Knapsack Example
# Best-First Search with Branch-and-Bound Pruning
- In general, the breadth-first search strategy has no advantage over a DFS (backtracking).
- However, we can improve our search by using our bound to do more than just determine whether a node is promising.
- After visiting all the children of a given node, we can look at all the promising, unexpanded nodes and expand beyond the one with the best bound.
- In this way, we often arrive at an optimal solution more quickly than if we simply proceeded blindly in a predetemined order.
# Traveling Salesperson Problem
Find the shortest path in a directed graph that starts at a given vertex, visits each vertex exactly once, and ends up back at the starting vertex.
Such a tour is called an optimal tour.
# B&B Approach
- A lower bound should be determined on the length of any tour that can be obtained by expanding beyond a given node. (In 0-1 Knapsack problem, we need an upper bound.)
- A node is promising only if its
bound < current minimum tour length
. - In any tour, the length of the edge taken when leaving a vertex must be at least as great as the length of the shortest edge emanating from that vertex.
- If the graph of a TSP is represented by Adjacency Matrix, then the lower bound on the cost of leaving vertex vi is the minimum of all the nonzero entries in row i.
- Because a tour must leave every vertex exactly once, a lower bound on the length of a tour is the sum of these minimums.
- Therefore, a lower bound on the length of a tour is
4 + 7 + 4 + 2 + 4 = 21
. - This is not to say that there is a tour with this length. Rather, it says that there can be no tour with a shorter length.
If we have visited the node containing [1, 2], then the cost of getting from v1 to v2 is the weight on the edge from v1 to v2 (14), and any tour obtained by expanding beyond v2 has the following lower bounds.
- For v1: lower bound is determined.
- For v2: edge to v1 should not be included.
- For other vertices: edge to v2 is not included.
Now, a lower bound on the length of a tour is 14 + 7 + 4 + 2 + 4 = 31