CSCI 256 Data Structures and Algorithm Analysis Lecture 2 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some.

Slides:



Advertisements
Similar presentations
Piyush Kumar (Lecture 3: Stable Marriage) Welcome to COT5405.
Advertisements

Prof. Swarat Chaudhuri COMP 482: Design and Analysis of Algorithms Spring 2013 Lecture 2.
CSCI 256 Data Structures and Algorithm Analysis Lecture 22 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some.
Five Problems CSE 421 Richard Anderson Winter 2009, Lecture 3.
Combinatorial Algorithms
CSE 421 Algorithms Richard Anderson Lecture 2. Announcements Office Hours –Richard Anderson, CSE 582 Monday, 10:00 – 11:00 Friday, 11:00 – 12:00 –Yiannis.
The max flow problem
1 Bipartite Matching Polytope, Stable Matching Polytope x1 x2 x3 Lecture 10: Feb 15.
CSE 421 Algorithms Richard Anderson Autumn 2006 Lecture 2.
Inefficiency of equilibria, and potential games Computational game theory Spring 2008 Michal Feldman.
Lecture 8 CSE 331 Sep 17, HW 1 due today Place Q1 and Q2 in separate piles I will not accept HWs after 1:15pm.
1.1 Chapter 1: Introduction What is the course all about? Problems, instances and algorithms Running time v.s. computational complexity General description.
Piyush Kumar (Lecture 1: Introduction) Welcome to COT5405.
The Stable Marriage Problem
1 Chapter 1 Introduction: Some Representative Problems Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
1 Stable Matching Problem Goal. Given n men and n women, find a "suitable" matching. n Participants rate members of opposite sex. n Each man lists women.
Prof. Swarat Chaudhuri COMP 482: Design and Analysis of Algorithms Spring 2013.
Lecture 3 CSE 331. Stable Matching Problem Problem Statement Algorithm Problem Definition Implementation Analysis.
Stable Matchings a.k.a. the Stable Marriage Problem
CSE 331: Review. Main Steps in Algorithm Design Problem Statement Algorithm Real world problem Problem Definition Precise mathematical def “Implementation”
1 The Stable Marriage Problem Algorithms and Networks 2014/2015 Hans L. Bodlaender Johan M. M. van Rooij.
CSCI 256 Data Structures and Algorithm Analysis Lecture 6 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some.
Graph Colouring L09: Oct 10. This Lecture Graph coloring is another important problem in graph theory. It also has many applications, including the famous.
1 Chapter 1 Introduction: Some Representative Problems Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
CSE 421 Algorithms Richard Anderson Winter 2009 Lecture 1.
CSEP 521 Applied Algorithms Richard Anderson Winter 2013 Lecture 1.
Bipartite Matching. Unweighted Bipartite Matching.
CSE 421 Algorithms Richard Anderson (for Anna Karlin) Winter 2006 Lecture 2.
The Stable Marriage Problem
Matching Lecture 19: Nov 23.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 29.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 25.
CSCI 256 Data Structures and Algorithm Analysis lecture 1 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some.
Graph Algorithms Maximum Flow - Best algorithms [Adapted from R.Solis-Oba]
CSCI 256 Data Structures and Algorithm Analysis Lecture 20 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some.
Market Design and Analysis Lecture 2 Lecturer: Ning Chen ( 陈宁 )
Market Design and Analysis Lecture 1 Lecturer: Ning Chen ( 陈宁 )
Approximation Algorithms by bounding the OPT Instructor Neelima Gupta
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 3.
Data Structures and Algorithm Analysis Lecture 24
Matching Boys Girls A B C D E
Stable Matching.
Chapter 1 Introduction: Some Representative Problems
Chapter 10 Iterative Improvement
CSE 421: Introduction to Algorithms
Lecture 6 CSE 331 Sep 11, 2017.
Richard Anderson (for Anna Karlin) Winter 2006 Lecture 1
S. Raskhodnikova; based on slides by K. Wayne
Richard Anderson Autumn 2006 Lecture 1
CSE 421 Richard Anderson Autumn 2016, Lecture 3
CSE 421: Introduction to Algorithms
1.1 A First Problem: Stable Matching
CSE 421 Richard Anderson Autumn 2015, Lecture 3
Richard Anderson Autumn 2015 Lecture 1
Chapter 1 Introduction: Some Representative Problems
Richard Anderson Autumn 2016 Lecture 2
Richard Anderson Autumn 2006 Lecture 1
Lecture 6 CSE 331 Sep 12, 2011.
Lecture 6 CSE 331 Sep 12, 2016.
Richard Anderson Winter 2009 Lecture 2
Lecture 7 CSE 331 Sep 10, 2014.
Richard Anderson Winter 2019 Lecture 1
Piyush Kumar (Lecture 3: Stable Marriage)
CSE 421, University of Washington, Autumn 2006
Lecture 7 CSE 331 Sep 11, 2013.
CSE 421 Richard Anderson Winter 2019, Lecture 3
Richard Anderson Winter 2019 Lecture 2
Richard Anderson Autumn 2015 Lecture 2
Richard Anderson Autumn 2019 Lecture 2
CSE 421 Richard Anderson Autumn 2019, Lecture 3
Presentation transcript:

CSCI 256 Data Structures and Algorithm Analysis Lecture 2 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some by Iker Gondra

Stable Matching Problem (Recall) Perfect matching Preference lists (ranking is strictly increasing) Stability –Following is not stable m1m1 w1w1 m2m2 w2w2

Propose-And-Reject Algorithm (Recall) Propose-and-reject algorithm [Gale-Shapley 1962]: Intuitive method that guarantees output which is 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 }

Does this Work? Does it terminate? Is the result a stable matching? Is there a unique solution? What is the complexity Begin analysis by identifying measures of progress and invariants –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.”

Proof of Correctness: Termination Denote a Gale-Shapely marching by S* Claim: Algorithm terminates after at most n 2 iterations of while loop. Why? –Pf: Each time through the while loop a man proposes to a new woman. There are only n 2 possible proposals ▪

Proof of Correctness: Perfection Claim: All men and women get matched. Why? –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 – contradiction!▪ Hence, the algorithm finds a perfect matching

Proof of Correctness: Stability Claim: There are no unstable pairs in S* Pf: (by contradiction) –Suppose A-Z is an unstable pair: each prefers each other to the 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 –In either case A-Z is stable, a contradiction ▪ Bertha-Zeus Amy-Yancey S*... men propose in decreasing order of preference –Obs 1 women only trade up

Result Simple, O(n 2 ) algorithm to compute a stable matching Corollary –A stable matching always exists

Understanding the Solution For a given problem instance, there may be several stable matchings: m 1 : w 1 w 2 w 3 m 2 : w 2 w 3 w 1 m 3 : w 3 w 1 w 2 w 1 : m 2 m 3 m 1 w 2 : m 3 m 1 m 2 w 3 : m 1 m 2 m 3 m1m1 m2m2 m3m3 w1w1 w2w2 w3w3 How many stable matchings can you find?

Understanding the Solution Q: Do all executions of Gale-Shapley yield the same stable matching? If so, which one? m 1 : w 1 w 2 w 3 m 2 : w 1 w 3 w 2 m 3 : w 1 w 2 w 3 w 1 : m 2 m 3 m 1 w 2 : m 3 m 1 m 2 w 3 : m 3 m 1 m 2 m1m1 m2m2 w2w2 w1w1 m3m3 w3w3

Understanding the Solution Stable matchings are not necessarily fair Many different ways of picking m’s to propose Surprising result: –All executions (orderings of picking free m’s) in G-S approach give the same result

Understanding the Solution Proposal Algorithm (G-S algorithm) finds the best possible solution for M (i.e., there is no stable matching in which any of the men could have hoped to do better) Formalize the notion of best possible solution –(m, w) is valid if (m, w) is in some stable matching –best(m): the highest ranked w for m, such that (m, w) is valid (i.e., there is no w ' such that w ' ranks higher than w and (m, w ') is valid) –S* = {(m, best(m)} –Every execution of the proposal algorithm computes S* (proof in page 11 of the book) uniqueness

Understanding the Solution Related result: Proposal algorithm yields the worst valid partner for the W’s ( i.e., for each w, (w,m) is valid (i.e. there is a stable matching containing the pair (w,m) ) and no m’ that w ranks lower is a valid partner) Algorithm is the M-optimal algorithm Proposal algorithms where w’s propose is W- optimal

Let’s prove that the algorithm gives the worst valid partner for each w Lemma: In the stable matching S*, each woman is paired with her worst valid partner. Proof in class –Sketch -- do by contradiction; assume there is a pair (m,w) in S* such that m is not the worst valid partner –Then there is a stable matching S’ in which w is paired with a man m’, whom she likes less than m –What can we say about m in S’ ( he must be paired with a woman w’, (m,w’) is valid and since (m,w) is in S*, w is the best valid partner for m; consequently m prefers w to w’) –We can see that S’ is unstable --- Why??? –Contradiction --- Why??

Key Ideas/Steps in Algorithm Design as exemplified in this sample problem: Formalize real world problem –Model: graph and preference lists –Mechanism: stability condition Specify an algorithm with a natural operation –e.g. Proposal in G-S Establish termination of process through invariants and progress measure Underspecify an algorithm –e.g. in G-S as long as there is a free man one can choose any free man) Establish uniqueness of solution

A Landscape of Representative Problems Show the types of problems we will consider We’ll see that similar looking problems can have very different characteristics and require different methods Problems –Interval Scheduling –Weighted Interval Scheduling –Bipartite Matching –Maximum Independent Set –Competitive Facility Location

Interval Scheduling Input: Set of jobs with start and finish times Goal: Find maximum cardinality subset of mutually compatible jobs ( nlogn greedy algorithm) Time f g h e a b c d h e b jobs don't overlap

Weighted Interval Scheduling Input: Set of jobs with start, finish, and weights Goal: Find maximum weight subset of mutually compatible jobs Time n log n dynamic programming algorithm

Bipartite Graph A graph G = (V, E) is bipartite if V can be partitioned into sets X and Y such that every edge in E has one end in X and the other end in Y

Bipartite Graph C A E 3 B D4

Many relationships are expressed by a bipartite graph C A E 3 B D4 professors courses can teach

Bipartite Matching Input: Bipartite graph Goal: Find maximum cardinality matching –A matching is M  E with property that each node in V appears in at most one edge of M

Find a Maximum Matching Solutions use max-flow based algorithms (Polynomial time)

Independent Set Problem Input: Graph Goal: Find maximum cardinality independent set subset of nodes such that no two joined by an edge

Find a Maximum Independent Set NP-complete No efficient algorithm is known, and it is conjectured that no such algorithm exists

Key characteristics of the Independent Set Problem Hard to find a solution Easy to verify a solution once you have one Can encode interval scheduling and bipartite matching problems as Independent Set problems Other problems like this –Hamiltonian cycle –Traveling salesman –3-Sat –Graph coloring

NP-Completeness Theory of Hard Problems (like the independent set problem) A large number of problems are known to be equivalent Very elegant theory

Are There Even Harder Problems? Simple game: –Players alternating selecting nodes in a graph Score points associated with node Once node is picked, remove node’s neighbors –When neither can move, player with most points wins

Another Game: Competitive Facility Location For a particular player P i, is there a strategy so that, no matter how the other players play, P i will be able to select a set of nodes with a total value of at least X? Hard to convince someone of the answer to this question (i.e., no short proof, lengthy case-by-case analysis), compare with Independent Set Problem PSPACE-complete

Competitive Facility Location PSPACE-complete problems are believed to be strictly harder than NP-complete problems as there does not appear to be a short proof if there is a solution For many problems that involve game playing and planning, it seems that one must do a lengthy case-by- case analysis of the set of possible moves.

Theorem: Output of G-S Algorithm is S* {(m,best(m)) for all m} Proof Sketch: By contradiction – (what do we say??)

Assume in output of G-S there is some man who is not paired with his best valid partner – (What does this imply?)

(Because men propose in decreasing order of preference) some man m is rejected by a valid partner; Consider the first time in execution this happens; let m be this man who is rejected by a valid partner, w Then w must be best(m) (Why – again because m proposes in order of preference.) Now focus on w

w now forms or continues an engagement with m’, who she prefers to m Also there is a stable matching S’ containing the pair (m,w) ( since w is a valid partner of m) Who is m’ paired with in this S’? It can’t be w, so let it be w’ not equal to w We can show that (m’,w’) is unstable –m’ prefers w to w’ (m’ proposed in order of preference) –and w prefers m’ to m (see above) Conclude that S’ is not a stable matching A contradiction!!! Conclude in output of G-S: for all men m, m is paired with best(m)