CS 312: Algorithm Analysis Lecture #33: Branch and Bound, Job Assignment This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported.

Slides:



Advertisements
Similar presentations
Review: Search problem formulation
Advertisements

Informed search algorithms
Artificial Intelligence By Mr. Ejaz CIIT Sahiwal.
A* Search. 2 Tree search algorithms Basic idea: Exploration of state space by generating successors of already-explored states (a.k.a.~expanding states).
Traveling Salesperson Problem
Techniques for Dealing with Hard Problems Backtrack: –Systematically enumerates all potential solutions by continually trying to extend a partial solution.
Problem Solving and Search Andrea Danyluk September 9, 2013.
Solving Problems by Searching Currently at Chapter 3 in the book Will finish today/Monday, Chapter 4 next.
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.
Branch & Bound Algorithms
CPSC 322, Lecture 5Slide 1 Uninformed Search Computer Science cpsc322, Lecture 5 (Textbook Chpt 3.4) January, 14, 2009.
Artificial Intelligence (CS 461D)
Uninformed Search Jim Little UBC CS 322 – Search 2 September 12, 2014
Artificial Intelligence Lecture No. 7 Dr. Asad Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Search in AI.
Review: Search problem formulation
6 - 1 § 6 The Searching Strategies e.g. satisfiability problem x1x1 x2x2 x3x3 FFF FFT FTF FTT TFF TFT TTF TTT.
MAE 552 – Heuristic Optimization Lecture 27 April 3, 2002
Using Search in Problem Solving
Informed Search CSE 473 University of Washington.
Blind Search-Part 2 Ref: Chapter 2. Search Trees The search for a solution can be described by a tree - each node represents one state. The path from.
1 Branch and Bound Searching Strategies 2 Branch-and-bound strategy 2 mechanisms: A mechanism to generate branches A mechanism to generate a bound so.
Ch 13 – Backtracking + Branch-and-Bound
CS 188: Artificial Intelligence Spring 2006 Lecture 2: Queue-Based Search 8/31/2006 Dan Klein – UC Berkeley Many slides over the course adapted from either.
5-1 Chapter 5 Tree Searching Strategies. 5-2 Breadth-first search (BFS) 8-puzzle problem The breadth-first search uses a queue to hold all expanded nodes.
Backtracking.
Review: Search problem formulation Initial state Actions Transition model Goal state (or goal test) Path cost What is the optimal solution? What is the.
Busby, Dodge, Fleming, and Negrusa. Backtracking Algorithm Is used to solve problems for which a sequence of objects is to be selected from a set such.
Problem Solving and Search Andrea Danyluk September 11, 2013.
Dr. Jouhaina Chaouachi Siala
CS 312: Algorithm Analysis
CS 312: Algorithm Design & Analysis Lecture #34: Branch and Bound Design Options for Solving the TSP: Tight Bounds This work is licensed under a Creative.
CS 312: Algorithm Analysis Lecture #4: Primality Testing, GCD This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.Creative.
CS 312: Algorithm Design & Analysis Lecture #17: Connectedness in Graphs This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported.
CS 312: Algorithm Analysis Lecture #8: Non-Homogeneous Recurrence Relations This work is licensed under a Creative Commons Attribution-Share Alike 3.0.
BackTracking CS335. N-Queens The object is to place queens on a chess board in such as way as no queen can capture another one in a single move –Recall.
Today’s Topics FREE Code that will Write Your PhD Thesis, a Best-Selling Novel, or Your Next Methods for Intelligently/Efficiently Searching a Space.
CS 312: Algorithm Analysis Lecture #32: Intro. to State-Space Search This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported.
CS 312: Algorithm Design & Analysis Lecture #23: Making Optimal Change with Dynamic Programming Slides by: Eric Ringger, with contributions from Mike Jones,
CS 312: Algorithm Design & Analysis Lecture #12: Average Case Analysis of Quicksort This work is licensed under a Creative Commons Attribution-Share Alike.
Computer Science CPSC 322 Lecture 9 (Ch , 3.7.6) Slide 1.
Search Tamara Berg CS 560 Artificial Intelligence Many slides throughout the course adapted from Dan Klein, Stuart Russell, Andrew Moore, Svetlana Lazebnik,
CS 312: Algorithm Design & Analysis Lecture #24: Optimality, Gene Sequence Alignment This work is licensed under a Creative Commons Attribution-Share Alike.
COMP261 Lecture 6 Dijkstra’s Algorithm. Connectedness Is this graph connected or not? A Z FF C M N B Y BB S P DDGG AA R F G J L EE CC Q O V D T H W E.
CS 312: Algorithm Design & Analysis Lecture #35: Branch and Bound Design Options: State Spaces Slides by: Eric Ringger, with contributions from Mike Jones,
Review: Tree search Initialize the frontier using the starting state While the frontier is not empty – Choose a frontier node to expand according to search.
Lecture 3: Uninformed Search
1 Branch and Bound Searching Strategies Updated: 12/27/2010.
Divide and Conquer Optimization problem: z = max{cx : x  S}
CS 312: Algorithm Design & Analysis Lecture #37: A* (cont.); Admissible Heuristics Credit: adapted from slides by Stuart Russell of UC Berkeley. This work.
Slides by: Eric Ringger, adapted from slides by Stuart Russell of UC Berkeley. CS 312: Algorithm Design & Analysis Lecture #36: Best-first State- space.
Ricochet Robots Mitch Powell Daniel Tilgner. Abstract Ricochet robots is a board game created in Germany in A player is given 30 seconds to find.
COSC 2007 Data Structures II
CPSC 322, Lecture 6Slide 1 Uniformed Search (cont.) Computer Science cpsc322, Lecture 6 (Textbook finish 3.5) Sept, 17, 2012.
CS 312: Algorithm Analysis Lecture #7: Recurrence Relations a.k.a. Difference Equations Slides by: Eric Ringger, with contributions from Mike Jones, Eric.
CS 312: Algorithm Analysis Lecture #31: Linear Programming: the Simplex Algorithm, part 2 This work is licensed under a Creative Commons Attribution-Share.
CS 312: Algorithm Analysis Lecture #35: Branch and Bound Design Options - State Spaces Slides by: Eric Ringger, with contributions from Mike Jones, Eric.
CSCE350 Algorithms and Data Structure Lecture 21 Jianjun Hu Department of Computer Science and Engineering University of South Carolina
CS 312: Algorithm Analysis Lecture #31: Linear Programming: the Simplex Algorithm, part 2 This work is licensed under a Creative Commons Attribution-Share.
Branch and Bound Searching Strategies
Adversarial Search 2 (Game Playing)
CPSC 322, Lecture 5Slide 1 Uninformed Search Computer Science cpsc322, Lecture 5 (Textbook Chpt 3.5) Sept, 13, 2013.
Optimization Problems The previous examples simply find a single solution What if we have a cost associated with each solution and we want to find the.
CS 312: Algorithm Design & Analysis Lecture #26: 0/1 Knapsack This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.Creative.
CS 312: Algorithm Design & Analysis Lecture #29: Network Flow and Cuts This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported.
CS 312: Algorithm Analysis Lecture #30: Linear Programming: Intro. to the Simplex Algorithm This work is licensed under a Creative Commons Attribution-Share.
Brian Williams, Fall 041 Analysis of Uninformed Search Methods Brian C. Williams Sep 21 st, 2004 Slides adapted from: Tomas Lozano Perez,
CS 312: Algorithm Analysis Lecture #27: Network Flow This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.Creative.
Traveling Salesperson Problem
BackTracking CS255.
Presentation transcript:

CS 312: Algorithm Analysis Lecture #33: Branch and Bound, Job Assignment This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.Creative Commons Attribution-Share Alike 3.0 Unported License Slides by: Eric Ringger, with contributions from Mike Jones, Eric Mercer, and Sean Warnick

Announcements  Project #6:  Due today by 5pm  Homework #23 optional  Homework #24 due Wednesday  Project #7: TSP  Budget about 15 hours (mean)  ASAP: Read Instructions  Today: We discuss main ideas  Tuesday: Help session at 5pm in 1066 TMCB  By Wednesday: Read the helpful “B&B for TSP Notes” linked from the schedule in the reading column  Next Wednesday: Early day  Week from Friday: due

Objectives  Understand the difference between backtracking and branch and bound  Understand bounding functions  Develop a branch and bound algorithm for the Job Assignment Problem

State-space Search Backtracking Purpose:Existence, Enumeration Answer:Yes/No, Count, Set Idea:Avoid searching the entire state-space Main tool:Feasibility function

State-space Search BacktrackingBranch and Bound Purpose:Existence, EnumerationOptimization Answer:Yes/No, Count, Set(Good, better,) best Idea:Both avoid searching the entire state-space Main tool:Feasibility functionBounding function

Bounding Function “From this state s, I can do no better than B(s).” better worse bound B(s) cost of actual solution is somewhere in here Given some state s in the search space, compute a bound B(s) on the cost/goodness of all solutions that descend from that state.

BSSF = Best Solution So Far better worse Cost of BSSFbound B(s) cost of actual solution is somewhere in here

Pruning Scenario #1 better worse Cost of BSSF Would you explore this state s with bound B(s)? bound B(s) BSSF = “Best Solution So Far” cost of actual solution is somewhere in here

Pruning Scenario #2 better worse Cost of BSSF Would you explore this state s’ with bound B(s’)? BSSF = “Best Solution So Far” cost of actual solution is somewhere in here bound B(s’)

Job Assignment Problem  Given n tasks and n agents.  Each agent has a cost to complete each task  Assign each agent one task; each task one agent;  A 1:1 mapping  Minimize cost

Minimization  The cost of the BSSF  Is an Upper Bound on the optimal solution  B(): Bounding function for evaluating any state s  Is a Lower Bound on potential solutions reachable from s  Usually involves solving a relaxed form of the problem  s 0 : Initial state  LB = B(s 0 )  Is a Lower Bound on all potential solutions reachable from the initial state  Tight bounds:  Why would you want the upper and lower bounds to be tight? better worse Cost of BSSF LB

Example

How to represent a state?

Example First, generate a solution (not necessarily optimal) and call that your best solution so far (BSSF). How?

Hint First, generate a solution (not necessarily optimal) and call that your best solution so far (BSSF). How?

BSSF BSSF: 73 First, generate a solution (not necessarily optimal) and call that your best solution so far (BSSF). How? One possible way: Assign jobs along the diagonals – take the lower one. Something quick (at worst linear?).

Lower Bound BSSF: 73 Next, compute a lower bound on all solutions. How?

Hint BSSF: 73 Next, compute a lower bound on all solutions. How? Bounding function: Easy to evaluate True bound

Lower Bound BSSF: 73 Next, compute a lower bound on all solutions. How? Add the smallest entry in each column LB = 58 Other alternatives?

Lower Bound BSSF: 73 Next, compute a lower bound on all solutions. How? Add the smallest entry in each column LB = 58 Our situation:

Lower Bound BSSF: 73 Next, compute a lower bound on all solutions. How? Add the smallest entry in each column LB = 58 Initial questions: What if the LB == BSSF? What if the assignment underlying the LB is a solution? What if LB > BSSF?

Search A:1 BSSF: 73 Now, make an assignment to agent A  (58)

A:1 (60) Then apply the bounding function: add the smallest values in each column. This is a lower bound on the cost of any solution with job 1 assigned to A. It’s not a solution! BSSF: 73 Example  (58)

A:1 (60) A:2 (58) same for assigning job 2 to A. BSSF: 73 Example  (58)

A:1 (60) A:2 (58) A:3 (65) BSSF: 73 Example  (58)

A:1 (60) A:2 (58) A:3 (65) A:4 (78) BSSF: 73 What can we say about the last option? Example  (58)

A:1 (60) A:2 (58) A:3 (65) A:4 (78) BSSF: 73 Example  (58) How to proceed from here? Many options: Breadth-first Depth-first Most promising first

A:1 (60) A:2 (58) A:3 (65) A:4 (78) BSSF: 73 Example  (58) How to proceed from here? Many options: Breadth-first Depth-first Most promising first – we’ll try this one today Other possibilities

A:1 (60) A:2 (58) A:3 (65) A:4 (78) BSSF: 73 Example  (58)

A:1 (60) A:2 (58) A:3 (65) A:4 (78) A:2, B:1 (68) BSSF: 73 Example  (58)

A:1 (60) A:2 (58) A:3 (65) A:4 (78) A:2, B:1 (68) A:2, B:3 (59) A:2, B:4 (64) Example  (58) BSSF: 73

A:1 (60) A:2 (58) A:3 (65) A:4 (78) A:2, B:1 (68) A:2, B:3 (59) A:2, B:4 (64) A:2, B:3, C:1, D:4 (64) A:2, B:3, C:4, D:1 (65) When you reach a solution, update the BSSF if better. Example  (58) BSSF: 73

A:1 (60) A:2 (58) A:3 (65) A:4 (78) A:2, B:1 (68) A:2, B:3 (59) A:2, B:4 (64) BSSF: 64 A:2, B:3, C:1, D:4 (64) A:2, B:3, C:4, D:1 (65) When you reach a solution, update the BSSF if better. Then what? Example  (58)

A:1 (60) A:2 (58) A:3 (65) A:4 (78) A:2, B:1 (68) A:2, B:3 (59) A:2, B:4 (64) BSSF: 64 A:2, B:3, C:1, D:4 (64) A:2, B:3, C:4, D:1 (65) Example  (58) Prune!

A:1 (60) A:2 (58) A:3 (65) A:4 (78) A:2, B:1 (68) A:2, B:3 (59) A:2, B:4 (64) BSSF: 64 A:2, B:3, C:1, D:4 (64) A:2, B:3, C:4, D:1 (65) Example  (58)

That’s the basic idea. Many details have been left out. Let’s add a few. Example

Details  What should each state contain?  Just as for backtracking state-space search, we need enough information in each state to generate its children in the state space  The value of the bound on this state  How to store the set of states visited but remaining to be explored (i.e., “frontier of the search”)?  A set, sometimes called the “agenda” or “open list”  DFS: use a stack  BFS: use a queue  Most Promising First: use a priority queue  Other possibilities (e.g., hybrids)

function DFS(v) P  empty-stack visited(v)  true P.push(v) while !P.empty() do while there exists w adjacent to P.top() (in ascending order) such that !visited(w) do visited(w)  true P.push(w) // w is the new P.top() P.pop() Recall: Iterative DFS

Recall: Breadth First Search function BFS(v) Q  empty-queue visited(v)  true Q.enqueue(v) while !Q.empty() do u  Q.first() Q.dequeue() for each w adjacent to u (in ascending order) do if !visited(w) then visited(w)  true Q.enqueue(w)

B&B using a Priority Queue: Work in Progress function BandB-draft(v) Q  empty-priority-queue visited(v)  true Q.enqueue(v) while !Q.empty() do u  Q.first() Q.dequeue() for each w adjacent to u (in ascending order) do if !visited(w) then visited(w)  true Q.enqueue(w) What’s missing? Remember: a priority queue is not the only possible representation of the agenda.

Use Bound as Priority function BandB-draft(v) Q  empty-priority-queue visited(v)  true v.b  bound(v) // LB Q.enqueue(v, v.b) while !Q.empty() do u  Q.first() Q.dequeue() for each w adjacent to u (in ascending order) do if !visited(w) then visited(w)  true w.b  bound(w) Q.enqueue(w, w.b) What’s missing?

Adapt for On-the-fly State-Space Search function BandB-draft(v) Q  empty-priority-queue // visited(v)  true v.b  bound(v) Q.enqueue(v, v.b) while !Q.empty() do u  Q.first() Q.dequeue() children = generate_children_ascending(u) for each w in children do // if !visited(w) then // visited(w)  true w.b  bound(w) Q.enqueue(w, w.b) What’s missing?

Keep & Check BSSF function BandB-draft(v) BSSF  quick-solution(v) // BSSF.cost holds cost Q  empty-priority-queue v.b  bound(v) Q.enqueue(v, v.b) while !Q.empty() do u  Q.first() Q.dequeue() children = generate_children_ascending(u) for each w in children do w.b  bound(w) if (w.b < BSSF.cost) then if criterion(w) then BSSF  w else if partial_criterion(w) then Q.enqueue(w, w.b) return BSSF What’s missing?

V1: Prune Unpromising Nodes Lazily function BandB(v) BSSF  quick-solution(v) // BSSF.cost holds cost Q  empty-priority-queue v.b  bound(v) Q.enqueue(v, v.b) while !Q.empty() do u  Q.first() Q.dequeue() if u.b < BSSF.cost then children = generate_children_ascending(u) for each node w in children do w.b  bound(w) if (w.b < BSSF.cost) if criterion(w) then BSSF  w else if partial_criterion(w) then Q.enqueue(w, w.b) return BSSF What’s missing? Remember: this version only works for best-first; i.e., when a priority queue is the agenda.

Know when to Stop! function BandB(v) BSSF  quick-solution(v) // BSSF.cost holds cost Q  empty-priority-queue v.b  bound(v) Q.enqueue(v, v.b) while !Q.empty() do u  Q.first() Q.dequeue() if u.b < BSSF.cost then children = generate_children_ascending(u) for each node w in children do w.b  bound(w) if (w.b < BSSF.cost) if criterion(w) then BSSF  w else if partial_criterion(w) then Q.enqueue(w, w.b) else break return BSSF What’s missing? Remember: this version only works for best-first; i.e., when a priority queue is the agenda.

V2: Prune Early when BSSF is updated function BandB(v) BSSF  quick-solution(v) // BSSF.cost holds cost Q  empty-priority-queue v.b  bound(v) Q.enqueue(v, v.b) while !Q.empty() do u  Q.first() Q.dequeue() children = generate_children_ascending(u) for each w in children do w.b  bound(w) if (w.b < BSSF.cost) then if criterion(w) then BSSF  w Q.prune(BSSF.cost) else if partial_criterion(w) then Q.enqueue(w, w.b) return BSSF What’s missing?

Generalize: Arbitrary Agenda function BandB(v) BSSF  quick-solution(v) // BSSF.cost holds cost Agenda.clear() v.b  bound(v) Agenda.add(v, v.b) while !Agenda.empty() do u  Agenda.first() Agenda.remove_first() children = generate_children_ascending(u) for each w in children do w.b  bound(w) if (w.b < BSSF.cost) then if criterion(w) then BSSF  w Agenda.prune(BSSF.cost) else if partial_criterion(w) then Agenda.add(w, w.b) return BSSF

Critical Elements of a B&B Algorithm  BSSF  Bounding function  Representation of the frontier on an agenda  Select state from the agenda  Generate children  By copying parent and making one more decision  Calculate the bound  Handle children that are solutions  Place promising children on the agenda  Prune the losers  Repeat until  Agenda is empty Required for Project #7

B&B for Minimization BSSF Minimization Maximization ? HighLow B(s) is lower bound True solution’s actual cost could be lower than BSSF.

B&B for Maximization B(s) is upper bound B(s) is lower bound BSSF Minimization Maximization HighLow True solution’s actual cost could be lower than BSSF. True solution’s actual cost could be higher than BSSF. B(s) must always be optimistic.

Completeness and Optimality Important properties of search:  Completeness:  Is your search guaranteed to find a solution when one exists?  Optimality:  Does your search find the optimal (i.e., minimum or maximum cost) solution?  Does your search only prune sub-optimal states?

Assignment  Homework #24  B&B  due Wednesday  Required: Read B&B Notes & Project #7 instructions!  Then you’re ready to solve Project #7