Approximation and Randomized Algorithms (ARA) Lecture 1, September 3, 2012

Similar documents
Copyright 2000, Kevin Wayne 1

2.1 Computational Tractability. Chapter 2. Basics of Algorithm Analysis. Computational Tractability. Polynomial-Time

1. REPRESENTATIVE PROBLEMS

1. REPRESENTATIVE PROBLEMS

COMP 355 Advanced Algorithms Algorithm Design Review: Mathematical Background

2.2 Asymptotic Order of Growth. definitions and notation (2.2) examples (2.4) properties (2.2)

Analysis of Algorithms Fall Some Representative Problems Stable Matching

COMP 355 Advanced Algorithms

Algorithm Design and Analysis

Algorithm Design and Analysis

2. ALGORITHM ANALYSIS

Copyright 2000, Kevin Wayne 1

CS320 Algorithms: Theory and Practice. Course Introduction

Matching Residents to Hospitals

1. REPRESENTATIVE PROBLEMS

Algorithms. [Knuth, TAOCP] An algorithm is a finite, definite, effective procedure, with some input and some output.

1.1 First Problem: Stable Matching. Six medical students and four hospitals. Student Preferences. s6 h3 h1 h4 h2. Stable Matching Problem

COMP 382: Reasoning about algorithms

1. STABLE MATCHING. stable matching problem Gale Shapley algorithm hospital optimality context

Creating new worlds inside the computer. COS 116: 2/10/2011 Sanjeev Arora

2.1 Computational Tractability

Review Asympto&c Bounds

COMP251: Bipartite graphs

COMP251: Bipartite graphs

cs.washington.edu/417

CSE 417, Winter Introduc6on, Examples, and Analysis. Ben Birnbaum Widad Machmouchi

Omega notation. Transitivity etc.

CSC2556. Lecture 5. Matching - Stable Matching - Kidney Exchange [Slides : Ariel D. Procaccia]

Algorithms Design & Analysis. Analysis of Algorithm

Consider a complete bipartite graph with sets A and B, each with n vertices.

Bipartite Matchings and Stable Marriage

Ma/CS 6b Class 3: Stable Matchings

What do you do when you can t use money to solve your problems?

Analysis of Algorithms Fall Basics of Algorithm Analysis Computational Tractability

CSE 421: Intro Algorithms. 2: Analysis. Winter 2012 Larry Ruzzo

Ma/CS 6b Class 3: Stable Matchings

Algorithm runtime analysis and computational tractability

Matching. Terence Johnson. April 17, University of Notre Dame. Terence Johnson (ND) Matching April 17, / 41

Matching Theory and the Allocation of Kidney Transplantations

Two-Sided Matching. Terence Johnson. December 1, University of Notre Dame. Terence Johnson (ND) Two-Sided Matching December 1, / 47

Math 301: Matchings in Graphs

CSEP 521 Applied Algorithms. Richard Anderson Winter 2013 Lecture 1

Algorithms and Theory of Computation. Lecture 2: Big-O Notation Graph Algorithms

Defining Efficiency. 2: Analysis. Efficiency. Measuring efficiency. CSE 421: Intro Algorithms. Summer 2007 Larry Ruzzo

Matchings in Graphs. Definition 3 A matching N in G is said to be stable if it does not contain a blocking pair.

Define Efficiency. 2: Analysis. Efficiency. Measuring efficiency. CSE 417: Algorithms and Computational Complexity. Winter 2007 Larry Ruzzo

Subramanian s stable matching algorithm

1 Definitions and Things You Know

Algorithms: COMP3121/3821/9101/9801

CS711008Z Algorithm Design and Analysis

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018

Stable Marriage with Ties and Bounded Length Preference Lists

An improved approximation algorithm for the stable marriage problem with one-sided ties

6. DYNAMIC PROGRAMMING I

Dynamic Matching under Preferences

Stable Matching Existence, Computation, Convergence Correlated Preferences. Stable Matching. Algorithmic Game Theory.

Growth of Functions (CLRS 2.3,3)

Asymptotic Analysis. Slides by Carl Kingsford. Jan. 27, AD Chapter 2

CS1210 Lecture 23 March 8, 2019

STABLE MARRIAGE PROBLEM WITH TIES AND INCOMPLETE BOUNDED LENGTH PREFERENCE LIST UNDER SOCIAL STABILITY

Lecture 5: The Principle of Deferred Decisions. Chernoff Bounds

Stable matching. Carlos Hurtado. July 5th, Department of Economics University of Illinois at Urbana-Champaign

9. PSPACE 9. PSPACE. PSPACE complexity class quantified satisfiability planning problem PSPACE-complete

9. PSPACE. PSPACE complexity class quantified satisfiability planning problem PSPACE-complete

CS 781 Lecture 9 March 10, 2011 Topics: Local Search and Optimization Metropolis Algorithm Greedy Optimization Hopfield Networks Max Cut Problem Nash

Matching Problems. Roberto Lucchetti. Politecnico di Milano

CPSC 320 Sample Final Examination December 2013

CS 6901 (Applied Algorithms) Lecture 2

Lecture 2: Just married

The key is that there are two disjoint populations, and everyone in the market is on either one side or the other

CS 598RM: Algorithmic Game Theory, Spring Practice Exam Solutions

CSE 417: Algorithms and Computational Complexity

Game Theory: Lecture #5

Matching Problems. Roberto Lucchetti. Politecnico di Milano

PROBLEMS OF MARRIAGE Eugene Mukhin

1 Matchings in Non-Bipartite Graphs

A (ln 4)-Approximation Algorithm for Maximum Stable Matching with One-Sided Ties and Incomplete Lists

P, NP, NP-Complete, and NPhard

COMP 182 Algorithmic Thinking. Algorithm Efficiency. Luay Nakhleh Computer Science Rice University

CSE 202 Dynamic Programming II

CS 344 Design and Analysis of Algorithms. Tarek El-Gaaly Course website:

Matching Theory. Mihai Manea. Based on slides by Fuhito Kojima. MIT

12. LOCAL SEARCH. gradient descent Metropolis algorithm Hopfield neural networks maximum cut Nash equilibria

Asymptotic Analysis 1

Dynamic Programming: Interval Scheduling and Knapsack

Analysis of Algorithms

An analogy from Calculus: limits

Chapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

Two-Sided Matching. Terence Johnson. September 1, University of Notre Dame. Terence Johnson (ND) Two-Sided Matching September 1, / 37

Algorithms, Design and Analysis. Order of growth. Table 2.1. Big-oh. Asymptotic growth rate. Types of formulas for basic operation count

Chapter 9. PSPACE: A Class of Problems Beyond NP. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

Chapter 8. NP and Computational Intractability. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

CS 580: Algorithm Design and Analysis

Divide-and-Conquer Algorithms Part Two

CS 6783 (Applied Algorithms) Lecture 3

Analysis of Algorithms

1 Terminology and setup

Chapter 8. NP and Computational Intractability

When we use asymptotic notation within an expression, the asymptotic notation is shorthand for an unspecified function satisfying the relation:

Copyright 2000, Kevin Wayne 1

Transcription:

Approximation and Randomized Algorithms (ARA) Lecture 1, September 3, 2012

Practicalities Code: 456314.0 intermediate and optional course Previous knowledge 456305.0 Datastrukturer II (Algoritmer) Period I (weeks 36-43): 3.9-22.10.2012 Mondays and Wednesdays, 13:15-15:00 Fortran (A3058) and Cobol (B3040) Components: Lectures: 10 lectures (20h) 2 lectures per week in weeks 36,39, 42 1 lecture per week in weeks 37,38,40,41 Exercises: 5 exercise sessions in weeks 37,38,40,41,43. Exam: 26.10 (week 43), 9.11 (week 45), 1.2.2013, 12.4.2013

Material Algorithm Design, by J. Kleinberg and Éva Tardos, Pearson International Edition, Addison-Wesley, 2006 A few copies in the ICT-library Basically chapters 11 and 13; but first chapters 1, 2, 8, 9, 10 (briefly) Other Approximation Algorithms, by V. Vazirani, Springer, 2001 Randomized Algorithms, by R. Motwani and P. Raghavan, Cambridge University Press, 1995 Algorithmics for Hard Problems, by J. Hromkovic, Springer- Verlag, 2 nd edition, 2004 (more theoretical) http://users.abo.fi/lpetre/ara12/

Algorithms... The core of computer business Computer science Computer/software engineering Information systems Some problems are simple Simple methods to solve Efficient (fast) Some problems are not simple No known algorithm

Algorithms... The core of computer business Computer science Computer/software engineering Information systems Some problems are simple Simple methods to solve Efficient (fast) Some problems are not simple No known exact algorithm Not efficient

Today Algorithm Revision Algorithms for the stable matching problem Five illustrative algorithm problems Efficiency of algorithms

Stable matching problem 1962 David Gale and Lloyd Shapley -> mathematical economists Could one design a college admission system or a job recruiting process that is self-enforcing? 1950s National Resident Matching Program Given Set of preferences among employers and applicants Can we assign applicants to employers so that for every employer E and every applicant A who is not scheduled to work for E, we have at least one of: E prefers every one of its accepted applicants to A A prefers the current situation over working at E

Matching Residents to Hospitals Goal. Given a set of preferences among hospitals and medical school students, design a self-reinforcing admissions process. Unstable pair: applicant x and hospital y are unstable if: x prefers y to its assigned hospital. y prefers x to one of its admitted students. Stable assignment. Assignment with no unstable pairs. Natural and desirable condition. Individual self-interest will prevent any applicant/hospital deal from being made. 8

Stable Matching Problem Goal. Given n men and n women, find a "suitable" matching. Participants rate members of opposite sex. Each man lists women in order of preference from best to worst. Each woman lists men in order of preference from best to worst. favorite least favorite favorite least favorite 1 st 2 nd 3 rd Xavier Amy Bertha Clare Yancey Bertha Amy Clare Zeus Amy Bertha Clare Men s Preference Profile 1 st 2 nd 3 rd Amy Yancey Xavier Zeus Bertha Xavier Yancey Zeus Clare Xavier Yancey Zeus Women s Preference Profile 9

Stable Matching Problem Perfect matching: everyone is matched monogamously. Each man gets exactly one woman. Each woman gets exactly one man. Stability: no incentive for some pair of participants to undermine assignment by joint action. In matching M, an unmatched pair m-w is unstable if man m and woman w prefer each other to current partners. Unstable pair m-w could each improve by eloping. Stable matching: perfect matching with no unstable pairs. Stable matching problem. Given the preference lists of n men and n women, find a stable matching if one exists. 10

Questions 1. Does there exist a stable matching for every set of preference lists? 2. Given a set of preference lists, can we efficiently construct a stable matching if one exists?

Stable Matching Problem Q. Is assignment X-C, Y-B, Z-A stable? favorite least favorite favorite least favorite 1 st 2 nd 3 rd Xavier Amy Bertha Clare Yancey Bertha Amy Clare Zeus Amy Bertha Clare Men s Preference Profile 1 st 2 nd 3 rd Amy Yancey Xavier Zeus Bertha Xavier Yancey Zeus Clare Xavier Yancey Zeus Women s Preference Profile 12

Stable Matching Problem Q. Is assignment X-C, Y-B, Z-A stable? A. No. Bertha and Xavier will hook up. favorite least favorite favorite least favorite 1 st 2 nd 3 rd 1 st 2 nd 3 rd Xavier Amy Bertha Clare Yancey Bertha Amy Clare Zeus Amy Bertha Clare Men s Preference Profile Amy Yancey Xavier Zeus Bertha Xavier Yancey Zeus Clare Xavier Yancey Zeus Women s Preference Profile 13

Stable Matching Problem Q. Is assignment X-A, Y-B, Z-C stable? A. Yes. favorite least favorite favorite least favorite 1 st 2 nd 3 rd 1 st 2 nd 3 rd Xavier Amy Bertha Clare Yancey Bertha Amy Clare Zeus Amy Bertha Clare Men s Preference Profile Amy Yancey Xavier Zeus Bertha Xavier Yancey Zeus Clare Xavier Yancey Zeus Women s Preference Profile 14

Propose-And-Reject Algorithm Propose-and-reject algorithm. [Gale-Shapley 1962] Intuitive method that guarantees to find a stable matching. Initialize each person to be free. while (some man is free and hasn't proposed to every woman) { Choose such a man m w = 1 st woman on m's list to whom m has not yet proposed if (w is free) assign m and w to be engaged else if (w prefers m to her fiancé m') assign m and w to be engaged, and m' to be free else w rejects m } 15

Proof of Correctness: Termination Observation 1. Men propose to women in decreasing order of preference. Observation 2. Once a woman is matched, she never becomes unmatched; she only "trades up." Claim. Algorithm terminates after at most n 2 iterations of while loop. Pf. Each time through the while loop a man proposes to a new woman. There are only n 2 possible proposals. 1 st 2 nd 3 rd 4 th 5 th 1 st 2 nd 3 rd 4 th 5 th Victor A B C D E Amy W X Y Z V Wyatt B C D A E Bertha X Y Z V W Xavier C D A B E Clare Y Z V W X Yancey D A B C E Diane Z V W X Y Zeus A B C D E Erika V W X Y Z n(n-1) + 1 proposals required 16

Proof of Correctness: Perfection Claim. All men and women get matched. Pf. (by contradiction) Suppose, for sake of contradiction, that Zeus is not matched upon termination of algorithm. Then some woman, say Amy, is not matched upon termination. By Observation 2, Amy was never proposed to. But, Zeus proposes to everyone, since he ends up unmatched. 17

Proof of Correctness: Stability Claim. No unstable pairs. Pf. (by contradiction) Suppose A-Z is an unstable pair: each prefers each other to partner in Gale-Shapley matching S*. Case 1: Z never proposed to A. Z prefers his GS partner to A. A-Z is stable. Case 2: Z proposed to A. A rejected Z (right away or later) A prefers her GS partner to Z. A-Z is stable. men propose in decreasing order of preference women only trade up In either case A-Z is stable, a contradiction. S* Amy-Yancey Bertha-Zeus... 18

Summary Stable matching problem. Given n men and n women, and their preferences, find a stable matching if one exists. Gale-Shapley algorithm. Guarantees to find a stable matching for any problem instance. Q. If there are multiple stable matchings, which one does GS find? 19

Extensions: Matching Residents to Hospitals Ex: Men hospitals, Women med school residents. Variant 1. Some participants declare others as unacceptable. Variant 2. Unequal number of men and women. resident A unwilling to work in Cleveland Variant 3. Limited polygamy. hospital X wants to hire 3 residents Def. Matching S unstable if there is a hospital h and resident r such that: h and r are acceptable to each other; and either r is unmatched, or r prefers h to her assigned hospital; and either h does not have all its places filled, or h prefers r to at least one of its assigned residents. 20

Stable matching problem Enough precision to ask concrete questions start thinking about an algorithm to solve the problem Design algorithm for problem Analyze algorithm Correctness Bound on running time Fundamental design techniques

Five representative problems Interval scheduling Weighted interval scheduling Bipartite matching Independent set Competitive facility location

Interval Scheduling Input. Set of jobs with start times and finish times. Goal. Find maximum cardinality subset of mutually compatible jobs. jobs don't overlap a b c d e f g 0 1 2 3 4 5 6 7 8 9 10 11 h Time 23

Weighted Interval Scheduling Input. Set of jobs with start times, finish times, and weights. Goal. Find maximum weight subset of mutually compatible jobs. 23 12 20 26 13 20 11 0 1 2 3 4 5 6 7 8 9 10 11 16 Time 24

Bipartite Matching Input. Bipartite graph. Goal. Find maximum cardinality matching. A 1 B 2 C 3 D 4 E 5 25

Independent Set Input. Graph. Goal. Find maximum cardinality independent set. subset of nodes such that no two joined by an edge 1 2 3 4 5 6 7 26

Competitive Facility Location Input. Graph with weight on each node. Game. Two competing players alternate in selecting nodes. Not allowed to select a node if any of its neighbors have been selected. Goal. Select a maximum weight subset of nodes. 10 1 5 15 5 1 5 1 15 10 Second player can guarantee 20, but not 25. 27

Five Representative Problems Variations on a theme: independent set. Interval scheduling: n log n greedy algorithm. Weighted interval scheduling: n log n dynamic programming algorithm. Bipartite matching: n k max-flow based algorithm. Independent set: NP-complete. Competitive facility location: PSPACE-complete. 28

Algorithm analysis How do resource requirements change when input size increases? Time, space Notational machinery Problems of discrete nature Implicit searching over large space of possibilities Goal: efficiently find solution satisfying conditions Focus on running time

Algorithm efficiency 1. An algorithm is efficient if, when implemented, it runs quickly on real-input instances

Worst-Case Analysis Worst case running time. Obtain bound on largest possible running time of algorithm on input of a given size N. Generally captures efficiency in practice. Draconian view, but hard to find effective alternative. Average case running time. Obtain bound on running time of algorithm on random input as a function of input size N. Hard (or impossible) to accurately model real instances by random distributions. Algorithm tuned for a certain distribution may perform poorly on other inputs. 31

Algorithm efficiency 1. An algorithm is efficient if, when implemented, it runs quickly on real-input instances 2. An algorithm is efficient if it achieves a better worst-case performance, at an analytical level, then brute-force search Brute-force search provides no insight into the structure of the problem we are studying!

Polynomial-Time Brute force. For many non-trivial problems, there is a natural brute force search algorithm that checks every possible solution. Typically takes 2 N time or worse for inputs of size N. Unacceptable in practice. n! for stable matching with n men and n women Desirable scaling property. When the input size doubles, the algorithm should only slow down by some constant factor C. There exists constants c > 0 and d > 0 such that on every input of size N, its running time is bounded by c N d steps. Def. An algorithm is poly-time if the above scaling property holds. choose C = 2 d 33

Worst-Case Polynomial-Time Def. An algorithm is efficient if its running time is polynomial. Justification: It really works in practice! Although 6.02 10 23 N 20 is technically poly-time, it would be useless in practice. In practice, the poly-time algorithms that people develop almost always have low constants and low exponents. Breaking through the exponential barrier of brute force typically exposes some crucial structure of the problem. Exceptions. Some poly-time algorithms do have high constants and/or exponents, and are useless in practice. Some exponential-time (or worse) algorithms are widely used because the worst-case instances seem to be rare. simplex method Unix grep 34

Why It Matters 35

More on the definition of efficiency in terms of poly-time This definition is negatable: we can say when there is no efficient algorithm for a particular problem Previous definitions were subjective First definition turned efficiency into a moving target The poly-time definition is more absolute Promotes the idea that problems have an intrinsic level of computational tractability Some admit efficient solutions, some do not

Asymptotic Order of Growth Upper bounds. T(n) is O(f(n)) if there exist constants c > 0 and n 0 0 such that for all n n 0 we have T(n) c f(n). Lower bounds. T(n) is Ω(f(n)) if there exist constants c > 0 and n 0 0 such that for all n n 0 we have T(n) c f(n). Tight bounds. T(n) is Θ(f(n)) if T(n) is both O(f(n)) and Ω(f(n)). Ex: T(n) = 32n 2 + 17n + 32. T(n) is O(n 2 ), O(n 3 ), Ω(n 2 ), Ω(n), and Θ(n 2 ). T(n) is not O(n), Ω(n 3 ), Θ(n), or Θ(n 3 ). 37

Properties Transitivity. If f = O(g) and g = O(h) then f = O(h). If f = Ω(g) and g = Ω(h) then f = Ω(h). If f = Θ(g) and g = Θ(h) then f = Θ(h). Additivity. If f = O(h) and g = O(h) then f + g = O(h). If f = Ω(h) and g = Ω(h) then f + g = Ω(h). If f = Θ(h) and g = O(h) then f + g = Θ(h). 38

Asymptotic Bounds for Some Common Functions Polynomials. a 0 + a 1 n + + a d n d is Θ(n d ) if a d > 0. Polynomial time. Running time is O(n d ) for some constant d independent of the input size n. Logarithms. O(log a n) = O(log b n) for any constants a, b > 0. can avoid specifying the base Logarithms. For every x > 0, log n = O(n x ). log grows slower than every polynomial Exponentials. For every r > 1 and every d > 0, n d = O(r n ). every exponential grows faster than every polynomial 39

Linear Time: O(n) Linear time. Running time is at most a constant factor times the size of the input. Computing the maximum. Compute maximum of n numbers a 1,, a n. max a 1 for i = 2 to n { if (a i > max) max a i } 40

Linear Time: O(n) Merge. Combine two sorted lists A = a 1,a 2,,a n with B = b 1,b 2,,b n into sorted whole. i = 1, j = 1 while (both lists are nonempty) { if (a i b j ) append a i to output list and increment i else(append b j to output list and increment j } append remainder of nonempty list to output list Claim. Merging two lists of size n takes O(n) time. Pf. After each comparison, the length of output list increases by 1. 41

O(n log n) Time O(n log n) time. Arises in divide-and-conquer algorithms. also referred to as linearithmic time Sorting. Mergesort and heapsort are sorting algorithms that perform O(n log n) comparisons. Largest empty interval. Given n time-stamps x 1,, x n on which copies of a file arrive at a server, what is largest interval of time when no copies of the file arrive? O(n log n) solution. Sort the time-stamps. Scan the sorted list in order, identifying the maximum gap between successive time-stamps. 42

Quadratic Time: O(n 2 ) Quadratic time. Enumerate all pairs of elements. Closest pair of points. Given a list of n points in the plane (x 1, y 1 ),, (x n, y n ), find the pair that is closest. O(n 2 ) solution. Try all pairs of points. min (x 1 - x 2 ) 2 + (y 1 - y 2 ) 2 for i = 1 to n { for j = i+1 to n { d (x i - x j ) 2 + (y i - y j ) 2 if (d < min) min d } } don't need to take square roots Remark. Ω(n 2 ) seems inevitable, but this is just an illusion. 43

Cubic Time: O(n 3 ) Cubic time. Enumerate all triples of elements. Set disjointness. Given n sets S 1,, S n each of which is a subset of 1, 2,, n, is there some pair of these which are disjoint? O(n 3 ) solution. For each pairs of sets, determine if they are disjoint. foreach set S i { foreach other set S j { foreach element p of S i { determine whether p also belongs to S j } if (no element of S i belongs to S j ) report that S i and S j are disjoint } } 44

Polynomial Time: O(n k ) Time Independent set of size k. Given a graph, are there k nodes such that no two are joined by an edge? O(n k ) solution. Enumerate all subsets of k nodes. foreach subset S of k nodes { check whether S in an independent set if (S is an independent set) report S is an independent set } } k is a constant Check whether S is an independent set = O(k 2 ). Number of k element subsets = n O(k 2 n k / k!) = O(n k ). n (n 1) (n 2) (n k +1) = k k (k 1) (k 2) (2) (1) poly-time for k=17, but not practical nk k! 45

Exponential Time Independent set. Given a graph, what is maximum size of an independent set? O(n 2 2 n ) solution. Enumerate all subsets. S* φ foreach subset S of nodes { check whether S in an independent set if (S is largest independent set seen so far) update S* S } } 46

Summing up Finding algorithms for practical problems Depends on the problem The efficiency of the algorithm varies Next time There is (some) hope for NP-completeness