Docsity

Backtracking and Branch and Bound Algorithms: Solving Constrained Sequence Problems, Study notes of Digital & Analog Electronics

Partial preview of the text

Download Backtracking and Branch and Bound Algorithms: Solving Constrained Sequence Problems and more Study notes Digital & Analog Electronics in PDF only on Docsity!

Backtracking

Branch and Bound

Backtracking Algorithm

  • (^) Is used to solve problems for which a sequence of objects is to be selected from a set such that the sequence satisfies some constraint
  • (^) Traverses the state space using a depth-first search with pruning

Example: N-Queens Problem

  • (^) Given an N x N sized chess board
  • (^) Objective: Place N queens on the board so that no queens are in danger
  • One option would be to generate a tree of every possible board layout
  • This would be an expensive way to find a solution

Backtracking

8 queens problem

Basic idea of solution:

  1. Start with one queen in the first column, first row.
  2. Start with another queen in the second column, first row.
  3. Go down with the second queen until you reach a permissible situation.

Backtracking

8 queens problem

  1. Advance to the next column, first row, and do the same thing.
  2. If you cannot find a permissible situation in one column and reach the bottom of it, then you have to go back to the previous column and move one position down there. (This is the backtracking step.)

Backtracking

8 queens problem

Backtracking

8 queens problem

Efficiency of Backtracking

  • (^) This given a significant advantage over an exhaustive search of the tree for the average problem
  • (^) Worst case: Algorithm tries every path, traversing the entire search space as in an exhaustive search

The Branch and Bound

Algorithm

  • (^) Starting by considering the root node and applying a lower-bounding and upper-bounding procedure to it
  • (^) If the bounds match, then an optimal solution has been found and the algorithm is finished
  • (^) If they do not match, then algorithm runs on the child nodes

Example:

The Traveling Salesman

Problem

Branch and bound can be used to solve the TSP using a priority queue as an auxiliary data structure An example is the problem with a directed graph given by this adjacency matrix:

Traveling Salesman Problem

  • (^) Next, the bound for the node for the partial tour from 1 to 2 is calculated using the formula: Bound = Length from 1 to 2 + sum of min outgoing edges for vertices 2 to 5 = 14 + (7 + 4 + 2 + 4) = 31

Traveling Salesman Problem

  • (^) The node is added to the priority queue
  • (^) The node with the lowest bound is then removed
  • (^) This calculation for the bound for the node of the partial tours is repeated on this node
  • (^) The process ends when the priority queue is empty