
The Stable Marriage Problem Algorithms and Networks 2016/2017 Johan M. M. van Rooij Hans L. Bodlaender 1 A prize winning algorithm Lloyd Shapley, Nobel Prize Winner 2012 in economics. Obtained the prize for a number of contributions, one being the Gale-Shapley algorithm, discussed today. Photo Bengt Nyman http://en.wikipedia.org/wiki/File:Lloyd_Shapley_2_2012.jpg 2 The stable marriage problem There are n men and n women all unmarried. Each has a preference list on the persons of the opposite sex. Does there exist and can we find a stable marriage (stable matching): a matching between men and women, such that there is no man and woman who both prefer each other above their partner in the matching? Origin: assignment of medical students to hospitals (for internships). Students list hospitals in order of preference. Hospitals list students in order of preference. 3 Example Arie: Ann Cindy Betty Stable matching: Bert: Betty Ann Cindy (Arie, Cindy), (Bert, Ann), (Carl, Betty). Carl: Betty Ann Cindy Matching (Arie, Cindy), Ann: Bert Carl Arie (Bert, Betty), (Carl, Ann) Betty: Carl Bert Arie is not stable. Cindy: Bert Carl Arie Carl and Betty prefer each other above given partner: they form a Blocking pair. 4 Contents of this lecture Stable marriage problem. Gale-Shapley algorithm. Man-optimal and woman-optimal stable marriages. Stable roommates problem. Introduction. Next week: An algorithm for the stable roommates problem. 5 Stable Marriage & Roommates - Algorithms and Networks STABLE MARRIAGE PROBLEM 6 Problem: greedy algorithm does not need to terminate Greedy or ‘Soap-Series’ Algorithm: While there is a blocking pair Do Switch the blocking pair Greedy “local search” approach does not need to terminate: Can go on for ever! So, we need something else… 7 Result Gale-Shapley algorithm: always finds a stable matching. Input: list of men, women, and their preference list. Output: stable matching. 8 The algorithm Fix some ordering on the men. Repeat until everyone is matched. Let Y be the first unmatched man in the ordering. Now Y will ‘propose’ to the women X highest on Y’s preference list to whom he has not proposed before. If X has no partner, or feels that she is better off with Y than with her current partner, she accepts and X and Y become matched. This possibly turns a man Z to be unmatched. Otherwise X turns down Y and Y will continue proposing to the next woman on his list. Questions: Does this terminate? How fast? Does this give a stable matching? 9 A demonstration on the blackboard Example: Gale-Shapley Algorithm: Arie: Ann Cindy Betty Repeat until everyone is matched: Bert: Betty Ann Cindy Let Y be the first unmatched man. Carl: Betty Ann Cindy Y will ‘propose’ to the women X highest on Y’s preference list to whom he has not proposed before. Ann: Bert Carl Arie If X has no partner, or feels that Betty: Carl Bert Arie she is better off with Y than with her current partner, she accepts Cindy: Bert Carl Arie and X and Y become matched (possibly leaving man Z). Otherwise X turns down Y and Y will continue proposing to next woman on his list. 10 Termination and number of steps Observations: 1. Once a woman is matched, she stays matched. Her partner can change though. 2. If her partner changes, she will always get a more preferable partner. 3. The women to whom a man proposes will get worse (in his opinion) during the execution of algorithm. 4. If a man becomes free again, then there is a woman to whom he has not yet proposed. There must be a free woman due to a counting argument, and he cannot have proposed to her by the first observation. 5. The computed set is a matching. 6. The algorithm uses at most n2 steps/proposals. Each man proposes to each women at most once. Proof: the matching is stable. 11 The matching is stable Suppose the computed matching is not stable. There exist a blocking pair: (X,Y), (X’,Y’) where: • Y prefers X’ over X • X’ prefers Y over Y’. Ys last proposal was to X (by definition of the algorithm). Did Y propose to X’ during the execution of the algorithm? No? Then Y does not prefer X’ over X – contradiction. Yes? Then X’ rejected Y in favour of man Y’’. • Y’’ Y’! Otherwise, contradiction with that X’ prefers Y over Y’. Since X’ ends up with Y’ we know that she prefers Y’ over Y’’. But wait: X’ prefers Y over Y’ and Y’ over Y’’, thus Y over Y’’. • Contradiction: she rejected Y in favour of Y’’. 12 More than one stable matching? Conclusion: A stable matching always exists and can be found in polynomial time. How well are the men/women off in the stable matching produced by the Gale-Shapley algorithm? What if the woman would propose? Are there alternative stable matchings? Example : (preference lists) Arie: Ann Betty Ann: Bert Arie Bert: Betty Ann Betty: Arie Bert 13 Man-optimal stable matchings Theorem: All executions of the Gale-Shapley algorithm result in the set S = { (Y, best partner of Y in any stable matching) }. Corollaries: 1. S is a stable matching (not clear from the definition). 2. The algorithm produces a Man-optimal stable matching. 3. The algorithm produces the worst stable matching from the perspective of the women. 14 Proof of Corollary 3 Theorem: All executions of the Gale-Shapley algorithm result in the set S = { (Y, best partner of Y in any stable matching) }. Corollary: 3. The algorithm produces the worst stable matching from the perspective of the women. Suppose that in S woman X is matched to Y while Y is not her worst possible stable partner. Then there is a stable matching S’ in which she is matched to Y’ that is worse than Y (let Y have partner X’ in S’). Since X is the best stable partner of Y (in S) and X’ is a stable partner of Y (in S’), we know that Y prefers X to X’. Contradiction: S’ is not stable, blocking pair (X,Y). 15 Proof of Theorem Theorem: All executions of the Gale-Shapley algorithm result in the set S = { (Y, best partner of Y in any stable matching) }. Suppose it is not true, then some man Y is rejected by a stable partner X during the execution of the algorithm. Consider the first time this happens: X rejects Y in favour of Y’. Because men propose in order of preference, and this is the first such rejection, X is Ys best stable partner. Since X is a stable partner for Y, there is a stable matching S’ where X and Y are matched. Here Y’ is matched to X’ X. Since we consider the first rejection of a stable partner, Y’ has not been rejected yet by a stable partner: thus, Y’ prefers X over X’. Then S’ is not stable: X prefers Y’ over Y, Y’ prefers X over X’. Contradiction. 16 Stable marriage: conclusions A stable matching always exists and can be found in O(n2) time using the Gale-Shapley algorithm. The Gale-Shapley algorithm produces a stable matching where: All men have their best possible stable partner. All woman have their worst possible stable partner. 17 Stable Marriage & Roommates - Algorithms and Networks STABLE ROOMMATES PROBLEM 18 Stable roommates Given: A set of people that must share two-person rooms. Each person has a preference list with all possible roommates. Question: Does there exist (and can we find) a stable matching: an assignment of roommates, such that there are no two people who both prefer each other above their current roommate. 19 Not always a stable matching for the stable roommates problem Consider the following instance: Arie: Carl Bert Dirk Bert: Arie Carl Dirk Carl: Bert Arie Dirk Dirk: can be anything Each matching is unstable e.g., (Arie,Bert)(Carl,Dirk) has {Carl,Arie} as blocking pair. 20 The Stable Roommates Problem Algorithms and Networks 2016/2017 Johan M. M. van Rooij Hans L. Bodlaender 21 Contents of this lecture Last week: Stable marriage problem. Gale-Shapley algorithm. Man-optimal and woman-optimal stable marriages. Introduction to stable roommates problem. This week: An algorithm for the stable roommates problem. 22 Stable roommates Given: A set of people that must share two-person rooms. Each person has a preference list with all possible roommates. Question: Does there exist (and can we find) a stable matching: an assignment of roommates, such that there are no two people who both prefer each other above their current roommate. Last week, we have seen that such a stable roommates assignment does not need to exists. 23 Not always a stable matching for the stable roommates problem Consider the following instance: Arie: Carl Bert Dirk Bert: Arie Carl Dirk Carl: Bert Arie Dirk Dirk: can be anything Each matching is unstable e.g., (Arie,Bert)(Carl,Dirk) has {Carl,Arie} as blocking pair. This problem appears a bit more complicated than the stable marriage problem. 24 Testing stable roommates In the next slides, we give an algorithm to find a stable roommates assignment or decide that no such assignment exists. The algorithm will filter preference lists, removing options that will never lead to stable assignments. Some form of constraint propagation. Algorithm outline: Phase 1: proposing and filtering. Phase 2: removing all-or-nothing cycles. Phase 3: find empty preference lists, or output solution. 25 Phase 1: proposing Proposing phase: people propose to others to be roommates. During the algorithm each person: Has at most one outstanding proposal.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages49 Page
-
File Size-