Download presentation
Presentation is loading. Please wait.
Published byΛέων Σαμαράς Modified over 6 years ago
1
Discrete Math for CS CMPSC 360 LECTURE 9 Last time: Strong induction
Well ordering principle Induction and recursion Today: Application: Stable Matching CMPSC 360 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
2
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, and y prefers x to one of its admitted students Stable assignment: no unstable pairs. Individual self-interest will prevent any applicant/hospital deal from being made. 2012 Nobel prize in economics for work on matching algorithms (“mechanisms”) 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
3
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 1st 2nd 3rd 1st 2nd 3rd Xavier Amy Bertha Clare Amy Yancey Xavier Zeus Yancey Bertha Amy Clare Bertha Xavier Yancey Zeus Zeus Amy Bertha Clare Clare Xavier Yancey Zeus Men’s Preference Profile Women’s Preference Profile 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
4
Stable Matching Problem
Unstable pair: man m and woman w are unstable if m prefers w to his assigned match, and w prefers m to her assigned match Unstable pairs have an incentive to elope Stable matching: no unstable pairs. favorite least favorite favorite least favorite 1st 2nd 3rd 1st 2nd 3rd Xavier Amy Bertha Clare Amy Yancey Xavier Zeus Yancey Bertha Amy Clare Bertha Xavier Yancey Zeus Zeus Amy Bertha Clare Clare Xavier Yancey Zeus Men’s Preference Profile Women’s Preference Profile 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
5
Stable Matching Problem
Input: preference lists of n men and n women Goal: find a stable matching if one exists favorite least favorite favorite least favorite 1st 2nd 3rd 1st 2nd 3rd Xavier Amy Bertha Clare Amy Yancey Xavier Zeus Yancey Bertha Amy Clare Bertha Xavier Yancey Zeus Zeus Amy Bertha Clare Clare Xavier Yancey Zeus Men’s Preference Profile Women’s Preference Profile 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
6
I-clicker question (frequency: BC)
Q. Is assignment X-C, Y-B, Z-A stable? Stable. Unstable. favorite least favorite favorite least favorite 1st 2nd 3rd 1st 2nd 3rd Xavier Amy Bertha Clare Amy Yancey Xavier Zeus Yancey Bertha Amy Clare Bertha Xavier Yancey Zeus Zeus Amy Bertha Clare Clare Xavier Yancey Zeus Men’s Preference Profile Women’s Preference Profile 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
7
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 1st 2nd 3rd 1st 2nd 3rd Xavier Amy Bertha Clare Amy Yancey Xavier Zeus Yancey Bertha Amy Clare Bertha Xavier Yancey Zeus Zeus Amy Bertha Clare Clare Xavier Yancey Zeus Men’s Preference Profile Women’s Preference Profile 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
8
I-clicker question (frequency: BC)
Q. Is assignment X-A, Y-B, Z-C stable? Stable. Unstable. favorite least favorite favorite least favorite 1st 2nd 3rd 1st 2nd 3rd Xavier Amy Bertha Clare Amy Yancey Xavier Zeus Yancey Bertha Amy Clare Bertha Xavier Yancey Zeus Zeus Amy Bertha Clare Clare Xavier Yancey Zeus Men’s Preference Profile Women’s Preference Profile 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
9
Stable Matching Problem
Q. Is assignment X-A, Y-B, Z-C stable? A. Yes. X and Y got their first choice; Z is the last choice for every woman. No man can participate in an unstable pair. favorite least favorite favorite least favorite 1st 2nd 3rd 1st 2nd 3rd Xavier Amy Bertha Clare Amy Yancey Xavier Zeus Yancey Bertha Amy Clare Bertha Xavier Yancey Zeus Zeus Amy Bertha Clare Clare Xavier Yancey Zeus Men’s Preference Profile Women’s Preference Profile 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
10
Existence of Stable Matching
Q. Do stable matchings always exist? A. Not obvious a priori. Suffixes to check all 3 possible matchings: {A-B, C-D}, {A-C, B-D}, {A-D, B-C} 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
11
Stable Roommate Problem
2n people; each person ranks others from 1 to 2n-1. Assign roommate pairs so that no unstable pairs. Observation. Stable matchings do not always exist for stable roommate problem. 1st 2nd 3rd Adam B C D A-B, C-D B-C unstable A-C, B-D A-B unstable A-D, B-C A-C unstable Bob C A D Chris A B D Doofus A B C Suffixes to check all 3 possible matchings: {A-B, C-D}, {A-C, B-D}, {A-D, B-C} 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
12
An Algorithm for Stable Matching
Propose-and-reject algorithm. [Gale-Shapley 1962] Input: tables of preferences for men and women while (there are rejected suitors) { Start a new day. Morning: Every man proposes to 1st women remaining on his list. Afternoon: Every woman says ``Maybe’’ to the man she likes best among the proposals (she now has him on a string) and rejects the rest. Evening: Each rejected suitor crosses off the woman that rejected him from his list. } Each woman marries the man she has on the string. Output: The set of married couples. 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
13
Example: Execution of the Algorithm
Men’s preferences Women’s preferences Wyatt Victor 1st B D 2nd A 3rd Zeus Yancey Xavier C E 4th 5th Bertha Amy Z X W Y V Erika Diane Clare stable matching is unique for worst-case instance 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
14
Day 1: Morning Men’s preferences Women’s preferences
Wyatt Victor 1st B D 2nd A 3rd Zeus Yancey Xavier C E 4th 5th Bertha Amy Z X W Y V Erika Diane Clare Victor proposes to Bertha. Wyatt proposes to Diane. Xavier proposes to Bertha. Yancey proposes to Amy. Zeus proposes to Bertha. stable matching is unique for worst-case instance 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
15
Day 1: Afternoon Men’s preferences Women’s preferences
Wyatt Victor 1st B D 2nd A 3rd Zeus Yancey Xavier C E 4th 5th Bertha Amy Z X W Y V Erika Diane Clare Amy says ``Maybe’’ to Yancey. Bertha says ``Maybe’’ to Xavier, rejects Victor and Zeus. Diane says ``Maybe’’ to Wyatt. stable matching is unique for worst-case instance 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
16
Day 1: Evening Men’s preferences Women’s preferences
Wyatt Victor 1st B D 2nd A 3rd Zeus Yancey Xavier C E 4th 5th Bertha Amy Z X W Y V Erika Diane Clare Victor and Zeus cross off Bertha. stable matching is unique for worst-case instance 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
17
Day 2: Morning Men’s preferences Women’s preferences
Wyatt Victor 1st B D 2nd A 3rd Zeus Yancey Xavier C E 4th 5th Bertha Amy Z X W Y V Erika Diane Clare Victor proposes to Amy. Wyatt proposes to Diane. Xavier proposes to Bertha. Yancey proposes to Amy. Zeus proposes to Diane. stable matching is unique for worst-case instance 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
18
Day 2: Afternoon Men’s preferences Women’s preferences
Wyatt Victor 1st B D 2nd A 3rd Zeus Yancey Xavier C E 4th 5th Bertha Amy Z X W Y V Erika Diane Clare Amy says ``Maybe’’ to Victor, rejects Yancey. Bertha says ``Maybe’’ to Xavier. Diane says ``Maybe’’ to Zeus, rejects Wyatt. stable matching is unique for worst-case instance 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
19
Day 2: Evening Men’s preferences Women’s preferences
Wyatt Victor 1st B D 2nd A 3rd Zeus Yancey Xavier C E 4th 5th Bertha Amy Z X W Y V Erika Diane Clare Wyatt crosses off Diane. Yancey crosses off Amy. stable matching is unique for worst-case instance 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
20
Day 3: Morning Men’s preferences Women’s preferences
Wyatt Victor 1st B D 2nd A 3rd Zeus Yancey Xavier C E 4th 5th Bertha Amy Z X W Y V Erika Diane Clare Victor proposes to Amy. Wyatt proposes to Bertha. Xavier proposes to Bertha. Yancey proposes to Diane. Zeus proposes to Diane. stable matching is unique for worst-case instance 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
21
Day 3: Afternoon Men’s preferences Women’s preferences
Wyatt Victor 1st B D 2nd A 3rd Zeus Yancey Xavier C E 4th 5th Bertha Amy Z X W Y V Erika Diane Clare Amy says ``Maybe’’ to Victor.. Bertha says ``Maybe’’ to Xavier, rejects Wyatt. Diane says ``Maybe’’ to Zeus, rejects Yancey. stable matching is unique for worst-case instance 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
22
Day 3: Evening Men’s preferences Women’s preferences
Wyatt Victor 1st B D 2nd A 3rd Zeus Yancey Xavier C E 4th 5th Bertha Amy Z X W Y V Erika Diane Clare Wyatt crosses off Bertha. Yancey crosses off Diane. stable matching is unique for worst-case instance 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
23
Day 4: Morning Men’s preferences Women’s preferences
Wyatt Victor 1st B D 2nd A 3rd Zeus Yancey Xavier C E 4th 5th Bertha Amy Z X W Y V Erika Diane Clare Victor proposes to Amy. Wyatt proposes to Amy. Xavier proposes to Bertha. Yancey proposes to Clare. Zeus proposes to Diane. stable matching is unique for worst-case instance 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
24
Day 4: Afternoon Men’s preferences Women’s preferences
Wyatt Victor 1st B D 2nd A 3rd Zeus Yancey Xavier C E 4th 5th Bertha Amy Z X W Y V Erika Diane Clare Amy says ``Maybe’’ to Victor., rejects Wyatt. Bertha says ``Maybe’’ to Xavier. Clare says ``Maybe’’ to Yancey. Diane says ``Maybe’’ to Zeus. stable matching is unique for worst-case instance 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
25
Day 4: Evening Men’s preferences Women’s preferences
Wyatt Victor 1st B D 2nd A 3rd Zeus Yancey Xavier C E 4th 5th Bertha Amy Z X W Y V Erika Diane Clare Wyatt crosses off Amy. stable matching is unique for worst-case instance 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
26
Day 5: Morning Men’s preferences Women’s preferences
Wyatt Victor 1st B D 2nd A 3rd Zeus Yancey Xavier C E 4th 5th Bertha Amy Z X W Y V Erika Diane Clare Victor proposes to Amy. Wyatt proposes to Clare. Xavier proposes to Bertha. Yancey proposes to Clare. Zeus proposes to Diane. stable matching is unique for worst-case instance 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
27
Day 5: Afternoon Men’s preferences Women’s preferences
Wyatt Victor 1st B D 2nd A 3rd Zeus Yancey Xavier C E 4th 5th Bertha Amy Z X W Y V Erika Diane Clare Amy says ``Maybe’’ to Victor. Bertha says ``Maybe’’ to Xavier. Clare says ``Maybe’’ to Wyatt, rejects Yancey. Diane says ``Maybe’’ to Zeus. stable matching is unique for worst-case instance 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
28
Day 5: Evening Men’s preferences Women’s preferences
Wyatt Victor 1st B D 2nd A 3rd Zeus Yancey Xavier C E 4th 5th Bertha Amy Z X W Y V Erika Diane Clare Yancey crosses off Clare. stable matching is unique for worst-case instance 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
29
Day 6: Morning Men’s preferences Women’s preferences
Wyatt Victor 1st B D 2nd A 3rd Zeus Yancey Xavier C E 4th 5th Bertha Amy Z X W Y V Erika Diane Clare Victor proposes to Amy. Wyatt proposes to Clare. Xavier proposes to Bertha. Yancey proposes to Bertha. Zeus proposes to Diane. stable matching is unique for worst-case instance 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
30
Day 6: Afternoon Men’s preferences Women’s preferences
Wyatt Victor 1st B D 2nd A 3rd Zeus Yancey Xavier C E 4th 5th Bertha Amy Z X W Y V Erika Diane Clare Amy says ``Maybe’’ to Victor. Bertha says ``Maybe’’ to Xavier, rejects Yancey. Clare says ``Maybe’’ to Wyatt. Diane says ``Maybe’’ to Zeus. stable matching is unique for worst-case instance 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
31
Day 6: Evening Men’s preferences Women’s preferences
Wyatt Victor 1st B D 2nd A 3rd Zeus Yancey Xavier C E 4th 5th Bertha Amy Z X W Y V Erika Diane Clare Yancey crosses off Bertha. stable matching is unique for worst-case instance 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
32
Day 7: Morning Men’s preferences Women’s preferences
Wyatt Victor 1st B D 2nd A 3rd Zeus Yancey Xavier C E 4th 5th Bertha Amy Z X W Y V Erika Diane Clare Victor proposes to Amy. Wyatt proposes to Clare. Xavier proposes to Bertha. Yancey proposes to Erika. Zeus proposes to Diane. stable matching is unique for worst-case instance 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
33
Day 7: Afternoon Men’s preferences Women’s preferences
Wyatt Victor 1st B D 2nd A 3rd Zeus Yancey Xavier C E 4th 5th Bertha Amy Z X W Y V Erika Diane Clare Amy says ``Maybe’’ to Victor. Bertha says ``Maybe’’ to Xavier. Clare says ``Maybe’’ to Wyatt. Diane says ``Maybe’’ to Zeus. Erika says ``Maybe’’ to Yancey. stable matching is unique for worst-case instance 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
34
Day 7: Evening (Happy End)
Men’s preferences Women’s preferences Wyatt Victor 1st B D 2nd A 3rd Zeus Yancey Xavier C E 4th 5th Bertha Amy Z X W Y V Erika Diane Clare Output of our algorithm. The following couples get married: Victor and Amy, Wyatt and Clare, Xavier and Bertha, Yancey and Erika, Zeus and Diane. stable matching is unique for worst-case instance 1/17/2019 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith, K. Wayne
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.