Docsity

Backtracking, Branch and Bound - Algorithms and Applications in Java - Lecture Slides, Slides of Computer Science

Partial preview of the text

Download Backtracking, Branch and Bound - Algorithms and Applications in Java - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

Backtracking And Branch And Bound

Subset & Permutation Problems

  • Subset problem of size n.

 Nonsystematic search of the space for the answer takes O(p2 n^ ) time, where p is the time needed to evaluate each member of the solution space.

  • Permutation problem of size n.

 Nonsystematic search of the space for the answer takes O(pn!) time, where p is the time needed to evaluate each member of the solution space.

  • Backtracking and branch and bound perform a systematic search; often taking much less time than taken by a nonsystematic search.
 - Subset Tree For n = - x 1 =1 x^1 = 
  • x 2 =1 x 2 = 0 x^2 =1 x^2 =
  • x 3 =1 x 3 = - x 4 =1 x 4 =

Permutation Tree For n = 3

x 1 =1 (^) x 1 =^

x 1 = 3

x 2 = 2 x 2 = 3 x 2 = 1 x 2 = 3 x 2 = 1 x 2 = 2

x 3 =3 x 3 =2 x 3 =3 x 3 =1 x 3 =2 x 3 =

123 132 213 231 312 321

Backtracking Depth-First Search

x 1 =1 x^1 = 0

x 2 =1 x 2 = 0 x^2 =1^ x^2 = 0

Backtracking Depth-First Search

x 1 =1 x^1 = 0

x 2 =1 x 2 = 0 x^2 =1^ x^2 = 0

Backtracking Depth-First Search

x 1 =1 x^1 = 0

x 2 =1 x 2 = 0 x^2 =1^ x^2 = 0

Backtracking Depth-First Search

x 1 =1 x^1 = 0

x 2 =1 x 2 = 0 x^2 =1^ x^2 = 0

Backtracking

  • Space required is O(tree height).
  • With effective bounding functions, large instances can often be solved.
  • For some problems (e.g., 0/1 knapsack), the answer (or a very good solution) may be found quickly but a lot of additional time is needed to complete the search of the tree.
  • Run backtracking for as much time as is feasible and use best solution found up to that time.

Branch And Bound

  • Search the tree using a breadth-first search (FIFO branch and bound).
  • Search the tree as in a bfs, but replace the FIFO queue with a stack (LIFO branch and bound).
  • Replace the FIFO queue with a priority queue (least-cost (or max priority) branch and bound). The priority of a node p in the queue is based on an estimate of the likelihood that the answer node is in the subtree whose root is p.

Branch And Bound

 FIFO branch and bound finds solution closest to root.  Backtracking may never find a solution because tree depth is infinite (unless repeating configurations are eliminated).

  • Least-cost branch and bound directs the search to parts of the space most likely to contain the answer. So it could perform better than backtracking.