Backtracking And Branch And Bound

Slides:



Advertisements
Similar presentations
Artificial Intelligence
Advertisements

Review: Search problem formulation
State Space 3 Chapter 4 Heuristic Search. Three Algorithms Backtrack Depth First Breadth First All work if we have well-defined: Goal state Start state.
Problem Solving Agents A problem solving agent is one which decides what actions and states to consider in completing a goal Examples: Finding the shortest.
5-1 Chapter 5 Tree Searching Strategies. 5-2 Satisfiability problem Tree representation of 8 assignments. If there are n variables x 1, x 2, …,x n, then.
UNINFORMED SEARCH Problem - solving agents Example : Romania  On holiday in Romania ; currently in Arad.  Flight leaves tomorrow from Bucharest.
Sum of Subsets and Knapsack
CSE332: Data Abstractions Lecture 9: B Trees Dan Grossman Spring 2010.
Backtracking.
Review: Search problem formulation
UnInformed Search What to do when you don’t know anything.
DAST 2005 Week 4 – Some Helpful Material Randomized Quick Sort & Lower bound & General remarks…
Solving Problems by Searching
Review: Search problem formulation Initial state Actions Transition model Goal state (or goal test) Path cost What is the optimal solution? What is the.
CSCE350 Algorithms and Data Structure Lecture 17 Jianjun Hu Department of Computer Science and Engineering University of South Carolina
Applications of Dynamic Programming and Heuristics to the Traveling Salesman Problem ERIC SALMON & JOSEPH SEWELL.
For Monday Read chapter 4, section 1 No homework..
Priority Queues and Heaps. October 2004John Edgar2  A queue should implement at least the first two of these operations:  insert – insert item at the.
1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;
Basic Problem Solving Search strategy  Problem can be solved by searching for a solution. An attempt is to transform initial state of a problem into some.
Ch22.Branch and Bound.
CSCE350 Algorithms and Data Structure Lecture 21 Jianjun Hu Department of Computer Science and Engineering University of South Carolina
Chapter 3 Solving problems by searching. Search We will consider the problem of designing goal-based agents in observable, deterministic, discrete, known.
Priority Queues and Heaps. John Edgar  Define the ADT priority queue  Define the partially ordered property  Define a heap  Implement a heap using.
Chapter 6 Branch & Bound (B & B).
Lecture 3: Uninformed Search
Adversarial Search and Game-Playing
Optimization Problems
"Teachers open the door, but you must enter by yourself. "
Trees Chapter 15.
Integer Programming An integer linear program (ILP) is defined exactly as a linear program except that values of variables in a feasible solution have.
BackTracking CS255.
For Monday Chapter 6 Homework: Chapter 3, exercise 7.
Problems with Linked List (as we’ve seen so far…)
i206: Lecture 13: Recursion, continued Trees
Binary Tree and General Tree
Artificial Intelligence (CS 370D)
Backtracking And Branch And Bound
Artificial Intelligence Problem solving by searching CSC 361
Map interface Empty() - return true if the map is empty; else return false Size() - return the number of elements in the map Find(key) - if there is an.
Analysis and design of algorithm
Types of Algorithms.
Multi-Way Search Trees
CS 188: Artificial Intelligence Fall 2008
Problem Solving and Searching
Optimization Problems
Heaps and the Heapsort Heaps and priority queues
Tree Representation Heap.
What to do when you don’t know anything know nothing
Searching for Solutions
Analysis & Design of Algorithms (CSCE 321)
"Teachers open the door, but you must enter by yourself. "
Trees CMSC 202, Version 5/02.
Problem Solving and Searching
Principles of Computing – UFCFA3-30-1
CMSC 202 Trees.
Branch and Bound Searching Strategies
Topic 5: Heap data structure heap sort Priority queue
CS 261 – Data Structures Trees.
Backtracking and Branch-and-Bound
Backtracking And Branch And Bound
UNINFORMED SEARCH -BFS -DFS -DFIS - Bidirectional
ICS 353: Design and Analysis of Algorithms
The Rich/Knight Implementation
Major Design Strategies
CS 416 Artificial Intelligence
CMSC 471 Fall 2011 Class #4 Tue 9/13/11 Uninformed Search
Major Design Strategies
Lecture 4: Tree Search Strategies
The Rich/Knight Implementation
Presentation transcript:

Backtracking And Branch And Bound

Subset & Permutation Problems Subset problem of size n. Nonsystematic search of the space for the answer takes O(p2n) 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.

Reminder: Complexity Source: http://bigocheatsheet.com/

Tree Organization Of Solution Space Set up a tree structure such that the leaves represent members of the solution space. For a size n subset problem, this tree structure has 2n leaves. For a size n permutation problem, this tree structure has n! leaves. The tree structure is too big to store in memory; it also takes too much time to create the tree structure. Portions of the tree structure are created by the backtracking and branch and bound algorithms as needed. Tree organizations in which nonleaf nodes represent members of the solution space are also possible.

Subset Problem Use a full binary tree that has 2n leaves. At level i the members of the solution space are partitioned by their xi values. Members with xi = 1 are in the left subtree. Members with xi = 0 are in the right subtree. Could exchange roles of left and right subtree.

Subset Tree For n = 4 x1= 0 x1=1 x2= 0 x2=1 x2=1 x2= 0 x3=1 x3= 0 x4=1 0001 0111 1110 1011

Permutation Problem Use a tree that has n! leaves. At level i the members of the solution space are partitioned by their xi values. Members (if any) with xi = 1 are in the first subtree. Members (if any) with xi = 2 are in the next subtree. And so on.

Permutation Tree For n = 3 x1= 3 x1=1 x1=2 x2= 2 x2= 3 x2= 1 x2= 3 x2= 1 x2= 2 x3=3 x3=2 x3=3 x3=1 x3=2 x3=1 123 132 213 231 312 321

Backtracking Search the solution space tree in a depth-first manner. May be done recursively or use a stack to retain the path from the root to the current node in the tree. The solution space tree exists only in your mind, not in the computer.

Backtracking The backtracking algorithm enumerates a set of partial candidates that, in principle, could be completed in various ways to give all the possible solutions to the given problem. Backtracking is a Swiss army knife Most problems where you can't find another solution for, are solved by backtracking Sources: http://moritz.faui2k3.org/en/backtracking https://www.cis.upenn.edu/~matuszek/cit594-2012/Pages/backtracking.html https://en.wikipedia.org/wiki/Backtracking

Backtracking Depth-First Search x1= 0 x1=1 x2= 0 x2=1 x2=1 x2= 0

Backtracking Depth-First Search x1= 0 x1=1 x2= 0 x2=1 x2=1 x2= 0 “Conceptually, you start at the root of a tree; the tree probably has some good leaves and some bad leaves, though it may be that the leaves are all good or all bad. You want to get to a good leaf. At each node, beginning with the root, you choose one of its children to move to, and you keep this up until you get to a leaf. Suppose you get to a bad leaf. You can backtrack to continue the search for a good leaf by revoking your most recent choice, and trying out the next option in that set of options. If you run out of options, revoke the choice that got you here, and try another choice at that node. If you end up at the root with no options left, there are no good leaves to be found.”

Backtracking Depth-First Search x1= 0 x1=1 x2= 0 x2=1 x2=1 x2= 0

Backtracking Depth-First Search x1= 0 x1=1 x2= 0 x2=1 x2=1 x2= 0

Backtracking Depth-First Search x1= 0 x1=1 x2= 0 x2=1 x2=1 x2= 0

O(2n) Subet Sum & Bounding Functions x1=1 x1= 0 x2=1 x2= 0 When you move forward on an x =1 branch, add to a variable that keeps track of the sum of the subset represented by the node. When you move back on an x = 1 branch, subtract. Moving in either direction along an x = 0 branch requires no add/subtract. When you reach a node with the desired sum, terminate. When you reach a node whose sum exceeds the desired sum, backtrack; do not move into this nodes subtrees. When you make a right child move see if the desired sum is attainable by adding in all remaining integers; for this keep another variable that gives you the sum of the remaining integers. Each forward and backward move takes O(1) time.

Bounding Functions When a node that represents a subset whose sum equals the desired sum c, terminate. When a node that represents a subset whose sum exceeds the desired sum c, backtrack. I.e., do not enter its subtrees, go back to parent node. Keep a variable r that gives you the sum of the numbers not yet considered. When you move to a right child, check if current subset sum + r >= c. If not, backtrack.

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 Space required is O(number of leaves). For some problems, solutions are at different levels of the tree (e.g., 16 puzzle). 1 3 2 4 5 6 13 14 15 12 11 10 9 7 8 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

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.

Branch And Bound maintain provable lower and upper bounds on global objective value terminate with certificate proving epsilon–sub optimality rely on two subroutines that (efficiently) compute a lower and an upper bound on the optimal value over a given region of search space often slow; exponential worst case performance Source: http://stanford.edu/class/ee364b/lectures/bb_slides.pdf