Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 COMP9007: Algorithms Stable Matching

2 What's in an algorithm? Algorithms can have huge impact For example – A report to the White House from 2010 includes the following.  Professor Martin Grotschel A benchmark production planning model solved using linear programming would have taken 82 years to solve in 1988, using the computers and the linear programming algorithms of the day. Fifteen years later, in 2003, this same model could be solved in roughly 1 minute, an improvement by a factor of roughly 43 million! [Extreme case, but even the average factor is very high.]

3 In 2003 there were examples of problems that we can solve 43 million times faster than in 1988  This is because of better hardware and better algorithms What's in an algorithm?

4 In 1988  Intel 386 and 386SX About 275,000 transistors clock speeds of 16MHz, 20MHz, 25MHz, and 33MHz  MSDOS 4.0 and windows 2.0  VGA In 2003  Pentium M About 140 million transistors Up to 2.2 GHz  AMD Athlon 64  Windows XP What's in an algorithm?

5 In a report to the White House from 2010 includes the following.  Professor Martin Grotschel: A benchmark production planning model solved using linear programming would have taken 82 years to solve in 1988, using the computers and the linear programming algorithms of the day. Fifteen years later, in 2003, this same model could be solved in roughly 1 minute, an improvement by a factor of roughly 43 millions Observation: Hardware: 1,000 times improvement Algorithms: 43,000 times improvement What's in an algorithm?

6 Efficient algorithms produce results within available resource limits In practice  Low polynomial time algorithms behave well  Exponential running times are infeasible except for very small instances, or carefully designed algorithms Performance depends on many obvious factors  Hardware  Software  Algorithm  Implementation of the algorithm This unit: Algorithms Efficient algorithms

7 Efficient algorithms “do the job” the way you want them to...  Do you need the exact solution?  Are you dealing with some special case and not with a general problem?  Is it ok if you miss the right solution sometimes? Efficient algorithms

8 Complex, highly sophisticated algorithms can greatly improve performance But... Reasonably good algorithmic solutions that avoid simple, or “lazy” mistakes, can have a much bigger impact! Efficient algorithms

9 List of topics Greedy algorithms Divide and conquer Dynamic programming Network flows Mincut theorems Approximation (?) Optimization problems (?)

10 10 Chapter 1 Introduction: Some Representative Problems

11 11 First Problem: Stable Matching ›Goal. Given a set of preferences among hospitals and medical school students, design a self-reinforcing admissions process. ›Definition. Self-reinforcement is a process whereby individuals control their own behavior by rewarding themselves when a certain standard of performance has been attained or surpassed ›2nd version (a.k.a Stable marriage problem): -Suppose we have an equal number of men M={m1,m2,…,mn} and women W={w1,w2,…,wn} -Every man lists the women in order of his preference, and every woman lists the men in order of her preference. -We would like to arrange marriages between the men and women so that there is not a man and a woman who prefer one another to their spouses

12 Stable Matching … ›A matching is a mapping from the elements of one set to the elements of the other set. ›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. ›In other words, a matching is stable when there does not exist any match (A, B) by which both A and B would be individually better off than they are with the element to which they are currently matched. ›Economics language: the set exhibits Pareto Efficiency. 12

13 Stable marriage problem ›Given n men and n women, where each person has ranked all members of the opposite sex in order of preference, marry the men and women together such that there are no two people of opposite sex who would both rather have each other than their current partners. ›When there are no such pairs of people, the set of marriages is deemed stable 13

14 14 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. ZeusAmyClareBertha YanceyBerthaClareAmy XavierAmyClareBertha 1 st 2 nd 3 rd Men’s Preference Profile favoriteleast favorite ClareXavierZeusYancey BerthaXavierZeusYancey AmyYanceyZeusXavier 1 st 2 nd 3 rd Women’s Preference Profile favoriteleast favorite

15 15 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.

16 16 Stable Matching Problem ›Question: Is assignment X-C, Y-B, Z-A stable? ZeusAmyClareBertha YanceyBerthaClareAmy XavierAmyClareBertha 1 st 2 nd 3 rd Men’s Preference Profile ClareXavierZeusYancey BerthaXavierZeusYancey AmyYanceyZeusXavier 1 st 2 nd 3 rd Women’s Preference Profile favoriteleast favoritefavorite least favorite

17 17 Stable Matching Problem ›Question: Is assignment X-C, Y-B, Z-A stable? ›Answer: No. Bertha and Xavier will form a relationship if find a chance. ZeusAmyClareBertha YanceyBerthaClareAmy XavierAmyClareBertha ClareXavierZeusYancey BerthaXavierZeusYancey AmyYanceyZeusXavier 1 st 2 nd 3 rd 1 st 2 nd 3 rd favoriteleast favoritefavorite least favorite Men’s Preference ProfileWomen’s Preference Profile

18 18 Stable Matching Problem ›Question: Is assignment X-A, Y-B, Z-C stable? ›Answer: Yes. ZeusAmyClareBertha YanceyBerthaClareAmy XavierAmyClareBertha ClareXavierZeusYancey BerthaXavierZeusYancey AmyYanceyZeusXavier 1 st 2 nd 3 rd 1 st 2 nd 3 rd favoriteleast favoritefavorite least favorite Men’s Preference ProfileWomen’s Preference Profile

19 19 Stable Roommate Problem ›Question: Do stable matchings always exist? ›Answer: Not obvious a priori. ›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. B Bob Chris Adam C A B D D Doofus ABC D C A 1 st 2 nd 3 rd A-B, C-D  B-C unstable A-C, B-D  A-B unstable A-D, B-C  A-C unstable

20 20 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 }

21 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile

22 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Victor proposes to Bertha. Victor Bertha

23 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Victor proposes to Bertha. - Bertha accepts since previously unmatched. Victor Bertha

24 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Wyatt proposes to Diane. Victor Bertha Diane Wyatt

25 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Wyatt proposes to Diane. - Diane accepts since previously unmatched. Victor Bertha Diane Wyatt

26 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Xavier proposes to Bertha. Victor Bertha Diane Wyatt Bertha Xavier

27 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Xavier proposes to Bertha. - Bertha dumps Victor and accepts Xavier. Victor Bertha Diane Wyatt Bertha Xavier

28 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Diane Wyatt Bertha Xavier Victor proposes to Amy. Amy Victor Bertha

29 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Diane Wyatt Bertha Xavier Amy Victor Victor proposes to Amy. - Amy accepts since previously unmatched. Victor Bertha

30 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Diane Wyatt Bertha Xavier Amy Victor Yancey proposes to Amy. Amy Yancey Victor Bertha

31 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Diane Wyatt Bertha Xavier Amy Victor Amy Yancey Yancey proposes to Amy. - Amy rejects since she prefers Victor. Victor Bertha

32 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Diane Wyatt Bertha Xavier Amy Victor Yancey proposes to Diane. Diane Yancey Amy Yancey Victor Bertha

33 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Diane Wyatt Bertha Xavier Amy Victor Diane Yancey Yancey proposes to Diane. - Diane dumps Wyatt and accepts Yancey. Amy Yancey Victor Bertha

34 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Bertha Xavier Amy Victor Diane Yancey Wyatt proposes to Bertha. Bertha Wyatt Diane Wyatt Amy Yancey Victor Bertha

35 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Victor Bertha Diane Wyatt Bertha Xavier Amy Victor Amy Yancey Diane Yancey Bertha Wyatt Wyatt proposes to Bertha. - Bertha rejects since she prefers Xavier.

36 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Bertha Xavier Amy Victor Diane Yancey Wyatt proposes to Amy. Amy Wyatt Victor Bertha Diane Wyatt Amy Yancey Bertha Wyatt

37 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Bertha Xavier Amy Victor Diane Yancey Wyatt proposes to Amy. - Amy rejects since she prefers Victor. Victor Bertha Diane Wyatt Amy Yancey Bertha Wyatt Amy Wyatt

38 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Victor Bertha Diane Wyatt Bertha Xavier Amy Victor Amy Yancey Diane Yancey Bertha Wyatt Amy Wyatt Wyatt proposes to Clare. Clare Wyatt

39 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Bertha Xavier Amy Victor Diane Yancey Clare Wyatt Wyatt proposes to Clare. - Clare accepts since previously unmatched. Victor Bertha Diane Wyatt Amy Yancey Bertha Wyatt Amy Wyatt

40 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Bertha Xavier Amy Victor Diane Yancey Clare Wyatt Zeus proposes to Bertha. Bertha Zeus Victor Bertha Diane Wyatt Amy Yancey Bertha Wyatt Amy Wyatt

41 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Bertha Xavier Amy Victor Diane Yancey Clare Wyatt Zeus proposes to Bertha. - Bertha rejects since she prefers Xavier. Victor Bertha Diane Wyatt Amy Yancey Bertha Wyatt Amy Wyatt Bertha

42 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Bertha Xavier Amy Victor Diane Yancey Clare Wyatt Zeus proposes to Diane. Diane Zeus Victor Bertha Diane Wyatt Amy Yancey Bertha Wyatt Amy Wyatt Bertha

43 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Victor Bertha Diane Wyatt Bertha Xavier Amy Victor Amy Yancey Diane Yancey Bertha Wyatt Amy Wyatt Clare Wyatt Bertha Zeus Diane Zeus Zeus proposes to Diane. - Diane rejects Yancey and accepts Zeus.

44 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Bertha Xavier Amy Victor Clare Wyatt Diane Zeus Yancey proposes to Clare. Clare Yancey Victor Bertha Diane Wyatt Amy Yancey Diane Yancey Bertha Wyatt Amy Wyatt Bertha Zeus

45 BerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Victor Bertha Diane Wyatt Bertha Xavier Amy Victor Amy Yancey Diane Yancey Bertha Wyatt Amy Wyatt Clare Wyatt Bertha Zeus Diane Zeus Clare Yancey Yancey proposes to Clare. - Clare rejects since she prefers Wyatt.

46 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Bertha Xavier Amy Victor Clare Wyatt Diane Zeus Yancey proposes to Bertha. Bertha Yancey Victor Bertha Diane Wyatt Amy Yancey Diane Yancey Bertha Wyatt Amy Wyatt Bertha Zeus Clare Yancey

47 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Victor Bertha Diane Wyatt Bertha Xavier Amy Victor Amy Yancey Diane Yancey Bertha Wyatt Amy Wyatt Clare Wyatt Bertha Zeus Diane Zeus Clare Yancey Bertha Yancey Yancey proposes to Bertha. - Bertha rejects since she prefers Xavier.

48 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Bertha Xavier Amy Victor Clare Wyatt Diane Zeus Yancey proposes to Erika. Erika Yancey Victor Bertha Diane Wyatt Amy Yancey Diane Yancey Bertha Wyatt Amy Wyatt Bertha Zeus Clare Yancey Bertha Yancey

49 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Bertha Xavier Amy Victor Clare Wyatt Diane Zeus Erika Yancey Yancey proposes to Erika. - Erika accepts since previously unmatched. Victor Bertha Diane Wyatt Amy Yancey Diane Yancey Bertha Wyatt Amy Wyatt Bertha Zeus Clare Yancey Bertha Yancey

50 ZeusBerthaAmyDianeErikaClare YanceyAmyClareDianeBerthaErika XavierBerthaClareErikaDianeAmy WyattDianeAmyBerthaClareErika VictorBerthaDianeAmyErikaClare 0 th 1 st 2 nd 3 rd 4 th Men’s Preference Profile ErikaYanceyZeusWyattXavierVictor DianeVictorYanceyZeusXavierWyatt ClareWyattYanceyXavierZeusVictor BerthaXavierYanceyWyattVictorZeus AmyZeusWyattVictorYanceyXavier 0 th 1 st 2 nd 3 rd 4 th Women’s Preference Profile Bertha Xavier Amy Victor Clare Wyatt Diane Zeus Erika Yancey STOP - Everyone matched. - Stable matching! Victor Bertha Diane Wyatt Amy Yancey Diane Yancey Bertha Wyatt Amy Wyatt Bertha Zeus Clare Yancey Bertha Yancey

51 51 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. Proof: Each time through the while loop a man proposes to a new woman. There are only n 2 possible proposals. ▪ Wyatt Victor 1 st A B 2 nd C D 3 rd C B AZeus Yancey XavierC D A B B A D C 4 th E E 5 th A D E E D C B E Bertha Amy 1 st W X 2 nd Y Z 3 rd Y X VErika Diane ClareY Z V W W V Z X 4 th V W 5 th V Z X Y Y X W Z

52 52 Proof of Correctness: Perfection Claim. All men and women get matched. Proof: (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. ◄

53 53 Proof of Correctness: Stability Claim: No unstable pairs. Proof: (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 current partner to A.  A-Z is stable. -Case 2: Z proposed to A.  A rejected Z (right away or later)  A prefers her current partner to Z.  A-Z is stable. -In both cases A-Z is stable, a contradiction! ▪ Bertha-Zeus Amy-Yancey S*... men propose in decreasing order of preference women only trade up

54 54 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. ›Question: How to implement GS algorithm efficiently? ›Question: If there are multiple stable matchings, which one does GS find?

55 55 Efficient Implementation ›Efficient implementation. We describe O(n 2 ) time implementation. ›Representing men and women. -Assume men are named 1, …, n. -Assume women are named 1', …, n'. ›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.

56 56 Efficient Implementation ›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. for i = 1 to n inverse[pref[i]] = i Pref 1 st 8 2 nd 7 3 rd 3 4 th 4 5 th 1 526 6 th 7 th 8 th Inverse4 th 2 nd 8 th 6 th 5 th 7 th 1 st 3 rd 12345 678 Amy Amy prefers man 3 to 6 since inverse[3] < inverse[6] 2 7

57 57 Understanding the Solution ›Question: 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, C-Z. -A-Y, B-X, C-Z. Zeus Yancey Xavier A B A 1 st B A B 2 nd C C C 3 rd Clare Bertha Amy X X Y 1 st Y Y X 2 nd Z Z Z 3 rd

58 58 Understanding the Solution ›Question: 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? ›Definition: Man m is a valid partner of woman w if there exists some stable matching in which they are matched. ›Man-optimal assignment. Each man receives best valid partner. ›Claim. All executions of GS yield man-optimal assignment, which is a stable matching! -No reason a priori to believe that man-optimal assignment is perfect, let alone stable. -Simultaneously best for each and every man.

59 59 Man Optimality ›Claim: GS matching S* is man-optimal. ›Proof: (by contradiction) -Suppose some man is paired with someone other than best partner. Men propose in decreasing order of preference  some man is rejected by valid partner. -Let Y be first such man, and let A be first valid woman that rejects him. -When Y is rejected, A forms (or reaffirms) engagement with a man, say Z, whom she prefers to Y. -Let S be a stable matching where A and Y are matched. -Let B be Z's partner in S. -Z has not been rejected by any valid partner at the point when Y is rejected by A. Thus, Z prefers A to B. -But A prefers Z to Y. -Thus A-Z is unstable in S. ▪ Bertha-Zeus Amy-Yancey S... since this is first rejection by a valid partner

60 60 Stable Matching Summary ›Stable matching problem. Given preference profiles of n men and n women, find a stable matching. ›Gale-Shapley algorithm. Finds a stable matching in O(n 2 ) time. ›Man-optimality. In version of GS where men propose, each man receives best valid partner. ›Question: 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

61 61 Woman Pessimality ›Woman-pessimal assignment. Each woman receives worst valid partner. ›Claim: GS finds woman-pessimal stable matching S*. ›Proof: -Suppose A-Z matched in S*, but Z is not worst valid partner for A. -There exists stable matching S in which A is paired with a man, say Y, whom she likes less than Z. -Let B be Z's partner in S. -Z prefers A to B. -Thus, A-Z is an unstable in S. ▪ Bertha-Zeus Amy-Yancey S... man-optimality

62 62 Extensions: Matching Residents to Hospitals ›Example: Men  hospitals, Women  med school residents. ›Variant 1. Some participants declare others as unacceptable. ›Variant 2. Unequal number of men and women. ›Variant 3. Limited polygamy. ›Definition: 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. resident A unwilling to work in Canberra hospital X wants to hire 3 residents

63 63 Application: Matching Residents to Hospitals ›NRMP. (National Resident Matching Program) -Original use just after WWII. -23,000+ residents. ›Rural hospital dilemma. -Certain hospitals (mainly in rural areas) were unpopular and declared unacceptable by many residents. -Rural hospitals were under-subscribed in NRMP matching. -How can we find stable matching that benefits "rural hospitals"? ›Rural Hospital Theorem. Rural hospitals get exactly same residents in every stable matching!

64 64 Lessons Learned ›Powerful ideas learned in course. -Isolate underlying structure of problem. -Create useful and efficient algorithms. ›Potentially deep social ramifications. [legal disclaimer] -Historically, men propose to women. Why not vice versa? -Men: propose early and often. -Men: be more honest. -Women: ask out the guys. -Theory can be socially enriching and fun!


Download ppt "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."

Similar presentations


Ads by Google