CSE 421: Introduction to Algorithms

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.
Matching problems Toby Walsh NICTA and UNSW. Motivation Agents may express preferences for issues other than a collective decision  Preferences for a.
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.
Lecture 4 CSE 331 Sep 9, Blog posts for lectures Starts from today See Sep 8 post on the blog.
Lecture 5 CSE 331 Sep 11, HW 1 out today Will be handed out at the END of the lecture Read the homework policy document carefully START EARLY! ©ehow.com.
Lecture 8 CSE 331 Sep 18, Homeworks Hand in your HW 1 HW 2 and solutions to HW 1 out at the end of class Not naming your collaborators is same as.
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.
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 5 CSE 331 Sep 11, Submit the form I’ll need confirmation in writing. No graded material will be handed back till I get this signed form.
1 Chapter 1 Introduction: Some Representative Problems Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
The Stable Marriage Problem
CSCI 256 Data Structures and Algorithm Analysis lecture 1 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some.
CSCI 256 Data Structures and Algorithm Analysis Lecture 2 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some.
COMP9007: Algorithms Stable Matching. What's in an algorithm? Algorithms can have huge impact For example – A report to the White House from 2010 includes.
Matching Boys Girls A B C D E
Cybernetica AS & Tartu University
Stable Matching.
Chapter 1 Introduction: Some Representative Problems
Lower bound for the Stable Marriage Problem
Stable Marriage Problem
Lecture 4 CSE 331 Sep 7, 2016.
Introduction to the Design and Analysis of Algorithms
The Stable Marriage Problem
Lecture 8 CSE 331 Sep 14, 2011.
Lecture 5 CSE 331 Sep 8, 2017.
Lecture 6 CSE 331 Sep 9, 2013.
Lecture 5 CSE 331 Sep 10, 2010.
Lecture 7 CSE 331 Sep 15, 2010.
Lecture 4 CSE 331 Sep 6, 2017.
Lecture 7 CSE 331 Sep 14, 2016.
Lecture 6 CSE 331 Sep 11, 2017.
Lecture 6 CSE 331 Sep 13, 2010.
Richard Anderson (for Anna Karlin) Winter 2006 Lecture 1
S. Raskhodnikova; based on slides by K. Wayne
Richard Anderson Autumn 2006 Lecture 1
Lecture 7 CSE 331 Sep 13, 2017.
Lecture 9 CSE 331 Sep 19, 2012.
CSE 421: Introduction to Algorithms
1.1 A First Problem: Stable Matching
Discrete Math for CS CMPSC 360 LECTURE 9 Last time: Strong induction
Lecture 5 CSE 331 Sep 6, 2013.
Lecture 5 CSE 331 Sep 7, 2012.
Blah blah blah.
Chapter 1 Introduction: Some Representative Problems
Lecture 8 CSE 331 Sep 16, 2016.
Lecture 7 CSE 331 Sep 13, 2011.
Lecture 10 CSE 331 Sep 21, 2011.
Richard Anderson Autumn 2016 Lecture 2
Lecture 8 CSE 331 Sep 15, 2017.
Lecture 10 CSE 331 Sep 21, 2012.
Lecture 6 CSE 331 Sep 12, 2011.
Lecture 8 CSE 331 Sep 15, 2011.
Lecture 9 CSE 331 Sep 15, 2014.
Lecture 9 CSE 331 Sep 20, 2010.
Lecture 5 CSE 331 Sep 5, 2014.
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)
Lecture 5 CSE 331 Sep 9, 2011.
Lecture 7 CSE 331 Sep 11, 2013.
Lecture 5 CSE 331 Sep 9, 2016.
Richard Anderson Winter 2019 Lecture 2
Lecture 11 CSE 331 Sep 20, 2013.
Richard Anderson Autumn 2019 Lecture 2
Presentation transcript:

CSE 421: Introduction to Algorithms Stable Matching Yin-Tat Lee

Administrativia Stuffs HW1 is out! It is due Wednesday Apr 04 before class. Please submit to Canvas How to submit? Submit a separate file for each problem Double check your submission before the deadline!! For hand written solutions, take a picture, turn it into pdf and submit Guidelines: Always prove your algorithm halts and outputs correct answer You can collaborate, but you must write solutions on your own Your proofs should be clear, well-organized, and concise. Spell out main idea. Sanity Check: Make sure you use assumptions of the problem You CANNOT search the solution online.

Last Lecture (summary) Stable matching problem: Given n men and n women, and their preferences, find a stable matching. Gale-Shapley algorithm: Guarantees always finds a stable matching by running at most 𝑛 2 proposals. Main properties: Men go down their lists Women trade up! For a perfect matching M, a pair m-w is unstable if they prefer each other to their match in M.

Questions Q: How to implement GS algorithm efficiently? Q: If there are multiple stable matchings, which one does GS find? Q: How many stable matchings are there?

Implementation of GS Algorithm Problem size N=2n2 words 2n people each with a preference list of length n 2n2log n bits specifying an ordering for each preference list takes nlog n bits Q. Why do we care? A. Usually, the running time is lower-bounded by input length.

Propose-And-Reject Algorithm [Gale-Shapley’62] Initialize each person to be free. while (some man is free and hasn't proposed to every woman) { Choose such a man m w = 1st 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 }

Efficient Implementation We describe O(n2) time implementation. Representing men and women: Assume men are named 1, …, n. Assume women are named n+1, …, 2n. Engagements. Maintain a list of free men, e.g., in a queue. Maintain two arrays wife[m], and husband[w]. set entry to 0 if unmatched if m matched to w then wife[m]=w and husband[w]=m Men proposing: For each man, maintain a list of women, ordered by preference. Maintain an array count[m] that counts the number of proposals made by man m.

A Preprocessing Idea Women rejecting/accepting. Does woman w prefer man m to man m'? For each woman, create inverse of preference list of men. Constant time access for each query after O(n) preprocessing per woman. O(n2) total reprocessing cost. Pref 1st 8 2nd 7 3rd 3 4th 4 5th 1 5 2 6 6th 7th 8th Inverse Amy for i = 1 to n inverse[pref[i]] = i Amy prefers man 3 to 6 since 𝐢𝐧𝐯𝐞𝐫𝐬𝐞[𝟑]=𝟐 < 𝟕=𝐢𝐧𝐯𝐞𝐫𝐬𝐞[𝟔]

Questions How to implement GS algorithm efficiently? We can implement GS algorithm in O(n2) time. Q: If there are multiple stable matchings, which one does GS find? Q: How many stable matchings are there?

Understanding the Solution Q. For a given problem instance, there may be several stable matchings. Do all executions of Gale-Shapley yield the same stable matching? If so, which one? An instance with two stable matchings: A-X, B-Y. A-Y, B-X. Yuri Xavier B A 1st 2nd X Brenda Amy Y 1st 2nd

Man Optimal Assignments Definition: Man m is a valid partner of woman w if there exists some stable matching in which they are matched. Man-optimal matching: Each man receives the best valid partner (according to his preferences). Simultaneously best for each and every man. Claim: All executions of GS yield a man-optimal matching, which is a stable matching! No reason a priori to believe that man-optimal matching is perfect, let alone stable.

Man Optimality Claim: GS matching S* is man-optimal. m’-w’ m-w S . . . Claim: GS matching S* is man-optimal. Proof: (by contradiction) Suppose some man is paired with someone other than his best partner. Men propose in decreasing order of preference  some man is rejected by a valid partner. Let m be the man who is the first such rejection, and let w be the women who is first valid partner that rejects him. Let S be a stable matching where w and m are matched. In building S*, when m is rejected, w forms (or reaffirms) engagement with a man, say m’, whom she prefers to m. Let w’ be the partner of m’ in S. In building S*, m’ is not rejected by any valid partner at the point when m is rejected by w. Thus, m’ prefers w to w’. But w prefers m’ to m. Thus w-m’ is unstable in S. since this is the first rejection by a valid partner

Man Optimality Summary Man-optimality: In version of GS where men propose, each man receives the best valid partner. Q: Does man-optimality come at the expense of the women? w is a valid partner of m if there exist some stable matching where m and w are paired

Woman Pessimality Woman-pessimal assignment: Each woman receives the worst valid partner. Claim. GS finds woman-pessimal stable matching S*. Proof. Suppose m-w matched in S*, but m is not worst valid partner for w. There exists stable matching S in which w is paired with a man, say m’, whom she likes less than m. Let w’ be the partner of m’ in S. m prefers w to w’. Thus, m-w is an unstable in S. man-optimality of S*

Questions Q: How to implement GS algorithm efficiently? We can implement GS algorithm in O(n2) time. Q: If there are multiple stable matchings, which one does GS find? It finds the man-optimal woman-pessimal matching. Q: How many stable matchings are there?

How many stable Matchings? We already show every instance has at least 1 stable matchings. There are instances with about 2.28 𝑛 stable matchings. There are at most 131072 𝑛 stable matchings. [Research-Question]: Is there an “efficient” algorithm that chooses a uniformly random stable matching of a given instance.

More realistic Let 𝐹⊂𝑀×𝑊 be the set of relationship (possible marriage). Can we find a perfect stable matching in 𝐹? No. Consider w prefers m’ to m, m’ prefers w to w’. There is no perfect stable matching even there’s prefect matching in 𝐹. What can we find? Same algorithm gives a (non-perfect) matching that is stable. m’ w m w’ Gale-Shapley algorithm is very robust to variations! For a matching M, a pair m-w is unstable if (m,w)∈𝑭 and they prefer each other to their match in M. (They prefer not to be alone.)