Branch and bound Pasi Fränti 30.9.2014. Explore all alternatives Solution constructed by stepwise choices Decision tree Guarantees optimal solution Exponential.

Slides:



Advertisements
Similar presentations
Algorithm Design Methods (I) Fall 2003 CSE, POSTECH.
Advertisements

Algorithm Design Methods Spring 2007 CSE, POSTECH.
 Review: The Greedy Method
Traveling Salesperson Problem
Knapsack Problem: Greedy vs. Brute Force pp (Section 7.6)
Lecture 24 Coping with NPC and Unsolvable problems. When a problem is unsolvable, that's generally very bad news: it means there is no general algorithm.
Greedy Algorithms Pasi Fränti Greedy algorithm 1.Coin problem 2.Minimum spanning tree 3.Generalized knapsack problem 4.Traveling salesman problem.
Techniques for Dealing with Hard Problems Backtrack: –Systematically enumerates all potential solutions by continually trying to extend a partial solution.
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
AI – Week 5 Implementing your own AI Planner in Prolog – part II : HEURISTICS Lee McCluskey, room 2/09
CS 206 Introduction to Computer Science II 11 / 07 / 2008 Instructor: Michael Eckmann.
Artificial Intelligence Lecture No. 7 Dr. Asad Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Search in AI.
Search Strategies.  Tries – for word searchers, spell checking, spelling corrections  Digital Search Trees – for searching for frequent keys (in text,
Merge Sort 4/15/2017 6:09 PM The Greedy Method The Greedy Method.
Algorithm Strategies Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Branch and Bound Searching Strategies
6 - 1 § 6 The Searching Strategies e.g. satisfiability problem x1x1 x2x2 x3x3 FFF FFT FTF FTT TFF TFT TTF TTT.
Toy Problem: Missionaries and Cannibals
Directed Graph Algorithms CSE 373 Data Structures Lecture 14.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Graphs.
MAE 552 – Heuristic Optimization Lecture 27 April 3, 2002
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
Review Best-first search uses an evaluation function f(n) to select the next node for expansion. Greedy best-first search uses f(n) = h(n). Greedy best.
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.
Ch 13 – Backtracking + Branch-and-Bound
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.
1 The Greedy Method CSC401 – Analysis of Algorithms Lecture Notes 10 The Greedy Method Objectives Introduce the Greedy Method Use the greedy method to.
TK3043 Analysis and Design of Algorithms Introduction to Algorithms.
For Friday Finish chapter 3 Homework: –Chapter 3, exercise 6 –May be done in groups. –Clarification on part d: an “action” must be running the program.
Solving Problems by Searching
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.
Introduction to search Chapter 3. Why study search? §Search is a basis for all AI l search proposed as the basis of intelligence l inference l all learning.
Design and Analysis of Algorithms - Chapter 111 How to tackle those difficult problems... There are two principal approaches to tackling NP-hard problems.
Chapter 12 Coping with the Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
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.
Online Algorithms By: Sean Keith. An online algorithm is an algorithm that receives its input over time, where knowledge of the entire input is not available.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Graphs.
5-1-1 CSC401 – Analysis of Algorithms Chapter 5--1 The Greedy Method Objectives Introduce the Brute Force method and the Greedy Method Compare the solutions.
For Wednesday No reading No homework There will be homework for Friday, as well the program being due – plan ahead.
Honors Track: Competitive Programming & Problem Solving Optimization Problems Kevin Verbeek.
December 14, 2015 Design and Analysis of Computer Algorithm Pradondet Nilagupta Department of Computer Engineering.
Search Techniques CS480/580 Fall Introduction Trees: – Root, parent, child, sibling, leaf node, node, edge – Single path from root to any node Graphs:
Ch22.Branch and Bound.
CSCE350 Algorithms and Data Structure Lecture 21 Jianjun Hu Department of Computer Science and Engineering University of South Carolina
Approximation Algorithms
Breadth-first and depth-first traversal CS1114
Branch and Bound Algorithm: Scheduling Problem Input of the problem:  A number of tasks  A number of resources ABC Output of the problem:  A.
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.
Ch3 /Lecture #4 Brute Force and Exhaustive Search 1.
Brute Force and Exhaustive Search Brute Force and Exhaustive Search Traveling Salesman Problem Knapsack Problem Assignment Problem Selection Sort and Bubble.
MA/CSSE 473 Day 11 Knuth interview Amortization (growable Array) Brute Force Examples.
Brute Force and Exhaustive Search Brute Force and Exhaustive Search Traveling Salesman Problem Knapsack Problem Assignment Problem Selection Sort and Bubble.
Artificial Intelligence Solving problems by searching.
Data Structures Lab Algorithm Animation.
BackTracking CS255.
Lecture on Design and Analysis of Computer Algorithm
Major Design Strategies
Chapter 1 Introduction Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Analysis and design of algorithm
Heuristics Definition – a heuristic is an inexact algorithm that is based on intuitive and plausible arguments which are “likely” to lead to reasonable.
Merge Sort 11/28/2018 2:21 AM The Greedy Method The Greedy Method.
Trevor Brown DC 2338, Office hour M3-4pm
Backtracking and Branch-and-Bound
Unit –VII Coping with limitations of algorithm power.
Major Design Strategies
Major Design Strategies
Chapter 1 Introduction Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Presentation transcript:

Branch and bound Pasi Fränti

Explore all alternatives Solution constructed by stepwise choices Decision tree Guarantees optimal solution Exponential time (slow) Depth-first search Implement as stack (push, pop, isempty) Linear time memory Breadth-first search Implemented by queue (enqueue, dequeue, isempty) General search strategies Backtracking

Traveling salesman problem Input: graph (V,E) Problem: Find shortest path via all nodes and returning to start node.

Traveling salesman problem Solution= A-B-C-F-H-E-D-G-A Length= 22 Input: graph (V,E) Output: path (p 1, p 2,..., p n, p n+1 )

Traveling salesman problem Exercise task

Input:Weight of N items {w 1, w 2,..., w n } Cost of N items {c 1, c 2,..., c n } Knapsack limit S Output:Selection for knapsack: {x 1,x 2,…x n } where x i  {0,1}. Sample input: w i ={1,1,2,4,12} c i = {1,2,2,10,4} S=15 Knapsack problem Problem definition Real example?

Max 15 Input:Weight of N items {w 1, w 2,..., w n } Knapsack limit S Output:Selection for knapsack: {x 1,x 2,…x n } where x i  {0,1}. Sample input: w i ={2,3,5,7,11} S=15 Knapsack problem Simplified

Max Knapsack problem Branch-and-bound w i ={2,3,5,7,11}

Something here When time Plus the same for sorting decreasing order w i ={2,3,5,7,11} S=15 To be done...

Graph algorithms

A B C

Empty space for notes

Branch and Bound Algorithm: Scheduling Problem Input of the problem:  A number of tasks  A number of resources ABC Output of the problem:  A sequence of feeding the tasks to resources to minimize the required processing time Material by A.Mirhashemi

Application 1 Digital processing: Each resource is a processor. All tasks need to pass trough all processors in the fix sequence A,B,C but depending on the task it takes different time for each processor to process them. For example : Processor A:Scanning Processor B:Making a PDF Processor C:Exporting a PDF Task 1:A one page plain text document Task 2:A 10 page document with pictures Task 3:A 5 page html document. Task 4:…

Production line: Each product (task) need to pass trough all machines (resources) in the production line but, the time depends on what kind of customization the customer has ordered for that production. For example: Machine A:Solding Machine B:Painting Machine C:Packaging Task 1:A black car with airbag Task 2:A red car without airbag with CD player Task 3:A white car with leather seats Task 4:… Application 2

Different tasks take different time to be processed in each resource ABC

Tasks can be done in any order N! Possible different sequences NP

For part 1 and 2 Start For part 3 and 4 Decision tree (Brute force)

Greedy Algorithm A possible greedy algorithm might start with selecting the fastest tasks for processor A ABC A :

Greedy solution T(4,2,3,1) = ABC

ABC Optimal solution T(4,1,2,3) = 26

Branch and bound Algorithm Define a bounding criteria for a minimum time required by each branch of the decision tree For level 1: For level 2:

ABC b(1)= 7+( )+1=27 b(2)= 5+( )+1=25 b(3)= 6+( )+2=27 b(4)= 3+( )+1=23 Level 1 Start 1234 T ≥ 23T ≥27 T ≥ 25 Bounds: Minimum This next

b(4,1)= (3+7)+(6+5+4)+1=26 b(4,2)= (3+5)+(6+5+4)+1=24 b(4,3)= (3+6)+(6+5+4)+2= ABC Bounds: Level 2 T ≥26T ≥24T ≥26 Minimum This next

ABC T(4,2,1,3) = 29 T(4,2,3,1) = 34 T min (4,2,x,x)= 29 Solve the branch 4-2-x-x T ≥26 T ≥24T ≥26 Bounds: Actual:

ABC Bounds: T ≥26T ≥24T ≥26 T min (4,3,x,x)= 29 T min (4,1,x,x)= 26 T min (4,2,x,x)= 29 Solve the branch 4-2-x-x T(4,1,2,3) = 26 T(4,1,3,2) = 28 T(4,3,1,2) = 29 T(4,3,2,1) = 34 Actual:

ABC Start 1234 Actual Time: T = 26 Bounds:T ≥27T ≥25T ≥23T ≥27 Must be solved Can be skipped Solve the other branches

b(2,1)= (5+7)+(6+4+4)+1=27 b(2,3)= (5+6)+(6+4+4)+3=28 b(2,4)= (5+3)+(6+4+4)+1= ABC The only candidate that can outperform T(4,1,2,3) is T(2,4,…) so we calculate it: Actual T(2,4,1,3) = 29 Actual T(2,4,3,1) = 34

ABC Start 1234 Actual Time: So the best time is T(4,1,2,3) and we don’t need to solve the problem for any other branch because we now their minimum time, already. Bounds: T = 26T = 29 T ≥27T ≥25T ≥23T ≥27 Bounds greater than 26!

Using only the first level criteria we reduce the problem by 50% (omitting 2 main branches). Using the second level criteria we can reduce even more. Summary

Empty space for notes