Bold Stroke January 13, 2003 Advanced Algorithms CS 539/441 OR In Search Of Efficient General Solutions Joe Hoffert

Slides:



Advertisements
Similar presentations
Introduction to Algorithms
Advertisements

CS 332: Algorithms NP Completeness David Luebke /2/2017.
CS Section 600 CS Section 002 Dr. Angela Guercio Spring 2010.
 Review: The Greedy Method
Greedy Algorithms.
Algorithm Design Techniques: Greedy Algorithms. Introduction Algorithm Design Techniques –Design of algorithms –Algorithms commonly used to solve problems.
1.1 Data Structure and Algorithm Lecture 6 Greedy Algorithm Topics Reference: Introduction to Algorithm by Cormen Chapter 17: Greedy Algorithm.
Analysis of Algorithms
Greed is good. (Some of the time)
1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell ( )
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
Greedy Algorithms Basic idea Connection to dynamic programming
S. J. Shyu Chap. 1 Introduction 1 The Design and Analysis of Algorithms Chapter 1 Introduction S. J. Shyu.
Greedy Algorithms Basic idea Connection to dynamic programming Proof Techniques.
Computational problems, algorithms, runtime, hardness
Lecture 7: Greedy Algorithms II Shang-Hua Teng. Greedy algorithms A greedy algorithm always makes the choice that looks best at the moment –My everyday.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 1 (Part 3) Tuesday, 9/4/01 Greedy Algorithms.
CSE 780 Algorithms Advanced Algorithms Greedy algorithm Job-select problem Greedy vs DP.
CSE 421 Algorithms Richard Anderson Lecture 6 Greedy Algorithms.
Chapter 11: Limitations of Algorithmic Power
Algoritmi on-line e risoluzione di problemi complessi Carlo Fantozzi
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2002 Lecture 1 (Part 3) Tuesday, 1/29/02 Design Patterns for Optimization.
CS10 The Beauty and Joy of Computing Lecture #23 : Limits of Computing Thanks to the success of the Kinect, researchers all over the world believe.
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Fundamental Techniques
NP and NP- Completeness Bryan Pearsaul. Outline Decision and Optimization Problems Decision and Optimization Problems P and NP P and NP Polynomial-Time.
Lecture 7: Greedy Algorithms II
10/31/02CSE Greedy Algorithms CSE Algorithms Greedy Algorithms.
10/31/02CSE Greedy Algorithms CSE Algorithms Greedy Algorithms.
David Luebke 1 8/23/2015 CS 332: Algorithms Greedy Algorithms.
1 Introduction to Approximation Algorithms. 2 NP-completeness Do your best then.
1 CSC 421: Algorithm Design & Analysis Spring 2013 Complexity & Computability  lower bounds on problems brute force, decision trees, adversary arguments,
Computational Complexity Polynomial time O(n k ) input size n, k constant Tractable problems solvable in polynomial time(Opposite Intractable) Ex: sorting,
1 Introduction to Approximation Algorithms. 2 NP-completeness Do your best then.
Advanced Algorithm Design and Analysis (Lecture 13) SW5 fall 2004 Simonas Šaltenis E1-215b
David Luebke 1 10/24/2015 CS 332: Algorithms Greedy Algorithms Continued.
CSC 413/513: Intro to Algorithms NP Completeness.
CSC 413/513: Intro to Algorithms Greedy Algorithms.
1 Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples: b number of comparisons needed to find the.
P, NP, and Exponential Problems Should have had all this in CS 252 – Quick review Many problems have an exponential number of possibilities and we can.
Greedy Methods and Backtracking Dr. Marina Gavrilova Computer Science University of Calgary Canada.
Honors Track: Competitive Programming & Problem Solving Optimization Problems Kevin Verbeek.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
CSE373: Data Structures & Algorithms Lecture 22: The P vs. NP question, NP-Completeness Lauren Milne Summer 2015.
Greedy Algorithms. What is “Greedy Algorithm” Optimization problem usually goes through a sequence of steps A greedy algorithm makes the choice looks.
December 14, 2015 Design and Analysis of Computer Algorithm Pradondet Nilagupta Department of Computer Engineering.
CS10: The Beauty and Joy of Computing Lecture #22 Limits of Computing Warning sign posted at Stern Hall. Also, Apple releases new operating.
Limits to Computation How do you analyze a new algorithm? –Put it in the form of existing algorithms that you know the analysis. –For example, given 2.
LIMITATIONS OF ALGORITHM POWER
The Beauty and Joy of Computing Lecture #23 Limits of Computing Researchers at Facebook and the University of Milan found that the avg # of “friends” separating.
Algorithm Design Methods 황승원 Fall 2011 CSE, POSTECH.
Greedy Algorithms BIL741: Advanced Analysis of Algorithms I (İleri Algoritma Çözümleme I)1.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2010 Lecture 2 Tuesday, 2/2/10 Design Patterns for Optimization.
CSE 421 Algorithms Richard Anderson Lecture 8 Greedy Algorithms: Homework Scheduling and Optimal Caching.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 18.
Great Theoretical Ideas in Computer Science.
CSCI 58000, Algorithm Design, Analysis & Implementation Lecture 12 Greedy Algorithms (Chapter 16)
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
Lecture on Design and Analysis of Computer Algorithm
Algorithm Design Methods
Analysis and design of algorithm
Exam 2 LZW not on syllabus. 73% / 75%.
Chapter 11 Limitations of Algorithm Power
Algorithm Design Methods
Algorithm Design Techniques Greedy Approach vs Dynamic Programming
Algorithm Design Methods
Major Design Strategies
Department of Computer Science & Engineering
Major Design Strategies
Algorithm Design Methods
Presentation transcript:

Bold Stroke January 13, 2003 Advanced Algorithms CS 539/441 OR In Search Of Efficient General Solutions Joe Hoffert

Bold Stroke January 13, 2003 Outline General Techniques For Polynomial Time Solutions –Greedy Algorithms –Dynamic Programming –Linear Programming Problems w/ unlikely Poly-time Solutions (NP Complete) Next best solutions (e.g., Approximation Algorithms) Lower Bound Techniques On-Line/Dynamic Algorithms

Bold Stroke January 13, 2003 Greedy Algorithms Locally optimal choice leads to globally optimal solution. Will not often yield optimal solution. Framework –Prove Greedy Choice Property Holds: first step “g” made by greedy algorithm is part of some optimal solution (i.e., using “g” does no worse than an arbitrary optimal solution) –Prove Optimal Substructure Property Holds We need subproblem P’ of P left after g is chosen P’ is optimally solved in S. That is, the solution to P’ contained within S is optimal for P’. Examples: Earliest Deadline First (EDF) scheduling, Huffman coding

Bold Stroke January 13, 2003 Greedy Algorithm Example EDF scheduling: sort jobs by deadline – O(n log n) Job 1 Job 2 Job 3 Job 4 Job 5 Schedule job with shortest deadline first Subproblem P’ is to schedule remaining jobs must prove this choice is at least as good as any other Maximize # of jobs that meet deadlines Job 5 Job 3 Job 2 Job 1 Job 4 must prove this subproblem is independent of first choice made Job 1 Job 2 Job 3 Job 4 Job 5

Bold Stroke January 13, 2003 Dynamic Programming Locally optimal choice doesn’t lead to a globally optimal solution but there is still optimal substructure Framework –Try all possible first choices: One of these must be the correct first choice –Prove Optimal Substructure Property Holds We need subproblem P’ of P left after first choice P’ is optimally solved in S. That is, the solution S’ to P’ contained within S is optimal for P’. –Use bottom up approach to efficiently compute optimal cost for all subproblems (a.k.a. overlapping subproblems) Examples: assembly line scheduling, longest common subsequence

Bold Stroke January 13, 2003 Dynamic Programming Example Assembly line scheduling: find minimal cost through stations chassis enters e1 e2 a 1,1 a 2,1 a 2,2 a 2,3 a 1,2 a 1,3 assembly line 1 a 1,n-1 a 1,n a 2,n-1 a 2,n assembly line 2 x1 x2 completed auto exits t 2,1 t 1,1 t 2,2 t 1,2 t 2,n-1 t 1,n-1 … chassis enters assembly line assembly line completed auto exits

Bold Stroke January 13, 2003 Linear Programming Problem defined by set of linear equations (equalities or inequalities) –Poly-time but high exponent on time complexity (e.g., n 8 to n 10 ) –Proves poly-time solution, more efficient solutions might be found Example: 2 dimensional constraints, minimum cost flow x 2 >= 0 x1x1 x2x2 x 1 >= 0 2x 1 + x 2 <= 10 4x 1 - x 2 <= 8 5x 1 - 2x 2 >= -2 x1x1 x2x2 x 1 + x 2 = 4 x 1 + x 2 = 0 x 1 + x 2 = 8 s x t y capacity = 5 cost = 2 capacity = 1 cost = 3 capacity = 2 cost = 5 capacity = 2 cost = 7 capacity = 4 cost = 1 s x t y 2 of 5 cost = 2 1 of 1 cost = 3 2 of 2 cost = 5 1 of 2 cost = 7 3 of 4 cost = 1 Minimize cost for flow of 4 units from s to t Maximize x 1 + x 2 given constraints below

Bold Stroke January 13, 2003 NP-Complete Problems NP complete problems are: –Complexity class Non-deterministic Polynomial (NP), i.e., solution to NP problem can be verified in polynomial time –NP-hard, i.e., reducible from all other NP problems in poly-time Unlikely to have poly-time solutions, not (yet) proven Example: MP-Scheduling problem Job 3 Job 2 Job 1 Job n-1 Job n … Processor 2 … Processor 1 Processor m Processor 2 … Processor 1 Processor m Is there a schedule in which all jobs are processed by specified time? Job 3 Job 2 Job 1 Job n-1 Job n Processor m-1

Bold Stroke January 13, 2003 Next Best Solutions What to do when problem shown to be NP-complete: –Is problem a special case? For instance, vertex-cover is NP- complete but if graph is a tree there exists a poly time algorithm for this case –Input size may be small enough not to be a problem –Use a heuristic and hope it gets something good enough –Use approximation algorithms (can be proven to be “good enough” or not “good enough”) LP relaxation (IP is NP-complete, LP may give a good enough answer) 0-1 Knapsack relaxation to fractional knapsack Non-preempted schedule relaxed to have preemption

Bold Stroke January 13, 2003 Approximation Algorithms Poly-time algorithms with provable bounds relative to optimal solution –If approximation bound is some constant n then the algorithm is said to be an n-approximation Example: 2-approximation 0-1 Knapsack problem Item 4 Item 3 Item 5 Item 1 Item 2 Item 4Item 3 Item 5 Item 1 Item 2 Sort items by value per unit quantity (i.e., total value/amount) and start filling up the knapsack Take the larger of the first item that won’t completely fit and the sum of all the previous items in the knapsack. This must be at least ½ of optimal solution which is a 2 approximation.

Bold Stroke January 13, 2003 Lower Bound Techniques Determine minimum number of operations needed for any solution –Use decision-tree lower bound algorithm when applicable All possibilities are enumerated as leaves in a decision tree Traverse the depth of the tree Example: lower bound for median among two sorted arrays –Adversary strategy Devise a strategy that makes it “hard” for any algorithm to find a solution (i.e., maximize the number of steps needed for any solution) Example: merging two sorted arrays Provides guidance for how good an algorithm can be

Bold Stroke January 13, 2003 Adversary Strategy Example Example: merging two sorted arrays –How many comparisons must be made before any algorithm has the arrays sorted? a1a1 a2a2 a3a3 a4a4 a n-1 anan … b1b1 b2b2 b3b3 b4b4 b n-1 … bnbn a1a1 a2a2 a3a3 a4a4 a n-1 anan b1b1 b2b2 b3b3 b4b4 b n-1 … bnbn If < 2n – 1 comparisons are made  more than one possible answer left (i.e., adversary can switch the elements that have not been compared) aiai bibi aiai bibi aiai bibi a i-1 b i-1 a i+1 b i+1 a i-1 b i-1 a i-1 b i-1 a i+1 b i+1 a i+1 b i+1 ………… …… Adversary strategy

Bold Stroke January 13, 2003 On-Line/Dynamic Algorithms Algorithms that don’t have knowledge of future requests/input –Compare to off-line algorithms that have complete knowledge of input –Provable bound compared to off-line solution Examples: Ski rental vs. purchase, scheduling jobs with deadlines using EDF, B = cost to buy Can have 2-competitive algorithm, i.e., provable 2B bound on cost R = cost to rent

Bold Stroke January 13, 2003 Conclusion Techniques exist for: –Provable poly-time algorithms –Determining unlikely poly-time algorithms –Next best solutions with provable bounds When to use what technique –Mostly developed through practice and intuition What does it matter? –Provable solutions