# LAW February 20071 A 5/3 approximation algorithm for a hard case of stable marriage Rob Irving Computing Science Department University of Glasgow (joint.

## Presentation on theme: "LAW February 20071 A 5/3 approximation algorithm for a hard case of stable marriage Rob Irving Computing Science Department University of Glasgow (joint."— Presentation transcript:

LAW February 20071 A 5/3 approximation algorithm for a hard case of stable marriage Rob Irving Computing Science Department University of Glasgow (joint work with David Manlove )

LAW February 20072 The stable marriage problem an example m 1 : w 2 w 4 w 1 w 3 w 1 : m 2 m 1 m 4 m 2 : w 3 w 1 w 4 w 2 : m 4 m 3 m 1 m 3 : w 2 w 3 w 3 : m 1 m 4 m 3 m 2 m 4 : w 4 w 1 w 3 w 2 w 4 : m 2 m 1 m 4 mens preferences womens preferences It's an unstable matching - ( m 1, w 4 ) is a blocking pair An example matching - {( m 1, w 1 ), ( m 2, w 3 ), ( m 3, w 2 ), ( m 4, w 4 )}

LAW February 20073 The stable marriage problem an example m 1 : w 2 w 4 w 1 w 3 w 1 : m 2 m 1 m 4 m 2 : w 3 w 1 w 4 w 2 : m 4 m 3 m 1 m 3 : w 2 w 3 w 3 : m 1 m 4 m 3 m 2 m 4 : w 4 w 1 w 3 w 2 w 4 : m 2 m 1 m 4 mens preferenceswomens preferences {( m 1, w 4 ), ( m 2, w 1 ), ( m 3, w 2 ), ( m 4, w 3 )} - a stable matching

LAW February 20074 Stable marriage facts § There is always at least one stable matching l The Gale-Shapley algorithm finds such a matching [Gale & Shapley 1962] § There may be many stable matchings § exponentially many in some cases [Knuth 1976] § All stable matchings have the same size and involve the same people [Gale & Sotomayor 1985] § The version of stable marriage described here is usually called "Stable Marriage with Incomplete Lists" (SMI)

LAW February 20075 The Hospitals / Residents problem an example r 1 : h 4 h 2 h 1 h 1 : 2: r 2 r 7 r 1 r 5 r 4 r 6 r 3 r 2 : h 3 h 1 h 4 h 2 : 2: r 8 r 1 r 3 r 6 r 3 : h 2 h 3 h 1 h 3 : 2: r 3 r 5 r 2 r 6 r 8 r 7 r 4 r 4 : h 3 h 4 h 1 h 4 : 3: r 5 r 8 r 2 r 4 r 7 r 1 r 5 : h 1 h 4 h 3 r 6 : h 2 h 3 h 1 r 7 : h 4 h 1 h 3 r 8 : h 3 h 4 h 2 residents preferences hospitals quotas and preferences It's unstable - (r 3,h 2 ) is a blocking pair so is (r 5,h 1 ) An example matching - {(r 1,h 2 ),(r 2,h 3 ),(r 3,h 3 ),(r 4,h 4 ),(r 5,h 4 ),(r 6,h 2 ),(r 7,h 1 ),(r 8,h 4 )}

LAW February 20076 The Hospitals / Residents problem an example r 1 : h 4 h 2 h 1 h 1 : 2: r 2 r 7 r 1 r 5 r 4 r 6 r 3 r 2 : h 3 h 1 h 4 h 2 : 2: r 8 r 1 r 3 r 6 r 3 : h 2 h 3 h 1 h 3 : 2: r 3 r 5 r 2 r 6 r 8 r 7 r 4 r 4 : h 3 h 4 h 1 h 4 : 3: r 5 r 8 r 2 r 4 r 7 r 1 r 5 : h 1 h 4 h 3 r 6 : h 2 h 3 h 1 r 7 : h 4 h 1 h 3 r 8 : h 3 h 4 h 2 residents preferences hospitals capacities and preferences A stable matching {(r 1,h 2 ),(r 2,h 3 ),(r 3,h 2 ),(r 4,h 4 ),(r 5,h 1 ),(r 6,h 3 ),(r 7,h 4 ),(r 8,h 4 )}

LAW February 20077 Stable matching in practice §The National Resident Matching Program (NRMP) l a scheme that each year matches over 30,000 graduating medical students (residents) to hospitals in the US l Since the early 1950s, the NRMP has used essentially the Gale-Shapley algorithm [Roth 1984] l Owes its success to the stability of its matching §Similar matching schemes in other countries and other contexts l including the SFAS scheme in Scotland [Irving 1998]

LAW February 20078 Ties in the preference lists Stable Marriage with Ties and Incomplete Lists (SMTI) Hospitals / Residents with Ties (HRT) Each preference list can contain one or more ties arguably a more realistic model in practical applications large hospitals cannot reasonably differentiate among all of their many applicants Now, a pair blocks a matching only if both members of the pair would be better off if matched together sometimes called weak stability To find a stable matching, break the ties arbitrarily and apply the Gale-Shapley algorithm But now – stable matchings can have different sizes

LAW February 20079 SMTI - an illustration m 1 : w 3 (w 1 w 2 ) w 4 w 1 : m 1 m 2 m 3 m 4 m 2 : w 1 w 3 w 2 : m 1 m 4 m 3 : w 3 w 1 w 3 : m 4 m 3 m 1 m 2 m 4 : w 1 (w 3 w 4 ) w 2 w 4 : m 4 m 1 mens preferenceswomens preferences A stable matching of size 4: {( m 1, w 2 ), ( m 2, w 1 ), ( m 3, w 3 ), ( m 4, w 4 )} A stable matching of size 2: {( m 1, w 1 ), ( m 4, w 3 )}

LAW February 200710 A hard stable matching problem For Stable Marriage (and therefore Hospitals Residents) with incomplete lists and ties It's NP-hard to find a maximum cardinality stable matching even if all the ties are on one side, and a tie occurs only at the end of a list, and all ties are of length 2 [Iwama, Manlove et al 1999] [Manlove, Irving et al 2002] Question: what about polynomial-time approximation? Can we decide on a 'good' way to break the ties?

LAW February 200711 Approximating maximum cardinality SMTI Trivially 2-approximable max cardinality 2 * min cardinality But APX-complete [HIIMMMS 2003] And not approximable within 21/19 (unless P = NP) 13/7-approximable if all ties are of length 2 8/5-approximable if all ties are of length 2 and on just one side 10/7 approximable (randomised) if, in addition, 1 tie per list [Halldórsson et al 2003] 15/8 approximable in the general case [Iwama et al, SODA 2007]

LAW February 200712 A case of practical interest 'Special' HRT (SHRT) residents' preference lists are strict hospitals' lists can contain one tie, of arbitrary length, at the end reflects the situation where hospitals are asked to rank as many candidates as they reasonably can, then place all others in a single tie at the end of their list 'Special' SMTI (SSMTI) men's preference lists are strict women's lists can contain one tie, of arbitrary length, at the end MAX-SSMTI is NP-hard (and so MAX-SHRT is too)

LAW February 200713 Approximating Max-SSMTI and MAX-SHRT There is a polynomial-time approximation algorithm for maximum cardinality SSMTI ( and for SHRT) with an approximation guarantee of 5/3. Algorithm is quite different from the approach used by previous approximation algorithms for variants of MAX-SMTI Consists of three phases: Phase 1 : apply a tailored version of the Gale-Shapley algorithm Phase 2 : find a maximum cardinality matching of selected subsets Phase 3 : break the ties according to a particular rule, then apply standard Gale-Shapley

LAW February 200714 Algorithm SSMTI-APPROX: Phase 1 assign each person to be free; /* free = not engaged */ while (some woman w is free) and (w has a non-empty list) and (w has an untied man m at the head of her list) { w proposes, and becomes engaged to m; /* m can never have a 'worse' mate than w; in particular, m is matched in every stable matching */ for each successor w' of w on m's list { if w' is engaged to m break the engagement; delete the pair (m,w') from the preference lists; } } Fact: engaged men are matched in every stable matching

LAW February 200715 Algorithm SSMTI-APPROX: Phase 1 m 1 : w 6 w 1 w 2 w 10 w 5 w 8 w 1 : m 2 m 3 (m 1 m 6 m 9 ) m 2 : w 7 w 10 w 3 w 1 w 6 w 2 : m 1 (m 3 m 5 m 7 ) m 3 : w 6 w 2 w 8 w 9 w 1 w 3 : m 2 (m 4 m 6 m 8 ) m 4 : w 7 w 9 w 8 w 3 w 4 w 5 w 4 : m 4 m 9 (m 5 m 8 m 10 ) m 5 : w 2 w 6 w 4 w 5 w 10 w 5 : m 4 m 1 m 5 m 7 m 6 : w 1 w 3 w 6 : m 2 (m 1 m 3 m 5 ) m 7 : w 2 w 5 w 7 : (m 2 m 4 m 10 ) m 8 : w 3 w 4 w 8 : m 1 (m 3 m 4 ) m 9 : w 1 w 4 w 9 : (m 3 m 4 ) m 10 : w 7 w 10 w 4 w 10 : m 5 (m 1 m 2 m 10 ) mens preferenceswomens preferences

LAW February 200716 Algorithm SSMTI-APPROX: Phase 1 outcome m 1 : w 6 w 1 w 2 w 1 : m 3 (m 1 m 6 m 9 ) m 2 : w 7 w 10 w 3 w 2 : m 1 (m 3 m 5 m 7 ) m 3 : w 6 w 2 w 8 w 9 w 1 w 3 : m 2 (m 4 m 6 m 8 ) m 4 : w 7 w 9 w 8 w 3 w 4 w 4 : m 4 m 9 (m 5 m 8 m 10 ) m 5 : w 2 w 6 w 4 w 5 w 5 : m 5 m 7 m 6 : w 1 w 3 w 6 : (m 1 m 3 m 5 ) m 7 : w 2 w 5 w 7 : (m 2 m 4 m 10 ) m 8 : w 3 w 4 w 8 : (m 3 m 4 ) m 9 : w 1 w 4 w 9 : (m 3 m 4 ) m 10 : w 7 w 10 w 4 w 10 : (m 2 m 10 ) red people are engaged, black people are free

LAW February 200717 Algorithm SSMTI-APPROX: Phase 2 Find a maximum cardinality matching F of free men and women; for each pair (m,w) F promote m from the tie to the head of w's list; reactivate phase 1; /* essentially extends the sets of engaged men and women */

LAW February 200718 Algorithm SSMTI-APPROX: Phase 2 m 1 : w 6 w 1 w 2 w 1 : m 3 (m 1 m 6 m 9 ) m 2 : w 7 w 10 w 3 w 2 : m 1 (m 3 m 5 m 7 ) m 3 : w 6 w 2 w 8 w 9 w 1 w 3 : m 2 (m 4 m 6 m 8 ) m 4 : w 7 w 9 w 8 w 3 w 4 w 4 : m 4 m 9 (m 5 m 8 m 10 ) m 5 : w 2 w 6 w 4 w 5 w 5 : m 5 m 7 m 6 : w 1 w 3 w 6 : (m 1 m 3 m 5 ) m 7 : w 2 w 5 w 7 : (m 2 m 4 m 10 ) m 8 : w 3 w 4 w 8 : (m 3 m 4 ) m 9 : w 1 w 4 w 9 : (m 3 m 4 ) m 10 : w 7 w 10 w 4 w 10 : (m 2 m 10 ) red people are engaged, black people are free

LAW February 200719 Algorithm SSMTI-APPROX: Phase 2 m 1 : w 6 w 1 w 2 w 1 : m 3 (m 1 m 6 m 9 ) m 2 : w 7 w 10 w 3 w 2 : m 1 (m 3 m 5 m 7 ) m 3 : w 6 w 2 w 8 w 9 w 1 w 3 : m 2 (m 4 m 6 m 8 ) m 4 : w 7 w 9 w 8 w 3 w 4 w 4 : m 4 m 9 (m 5 m 8 m 10 ) m 5 : w 2 w 6 w 4 w 5 w 5 : m 5 m 7 m 6 : w 1 w 3 w 6 : (m 1 m 3 m 5 ) m 7 : w 2 w 5 w 7 : (m 2 m 4 m 10 ) m 8 : w 3 w 4 w 8 : (m 3 m 4 ) m 9 : w 1 w 4 w 9 : (m 3 m 4 ) m 10 : w 7 w 10 w 4 w 10 : m 10 m 2 red people are engaged, black people are free

LAW February 200720 Algorithm SSMTI-APPROX: Phase 2 outcome m 1 : w 6 w 1 w 2 w 1 : m 3 (m 1 m 6 m 9 ) m 2 : w 7 w 10 w 3 w 2 : m 1 (m 3 m 5 m 7 ) m 3 : w 6 w 2 w 8 w 9 w 1 w 3 : m 2 (m 4 m 6 m 8 ) m 4 : w 7 w 9 w 8 w 3 w 4 w 4 : m 4 m 9 (m 5 m 8 ) m 5 : w 2 w 6 w 4 w 5 w 5 : m 5 m 7 m 6 : w 1 w 3 w 6 : (m 1 m 3 m 5 ) m 7 : w 2 w 5 w 7 : (m 2 m 4 m 10 ) m 8 : w 3 w 4 w 8 : (m 3 m 4 ) m 9 : w 1 w 4 w 9 : (m 3 m 4 ) m 10 : w 7 w 10 w 10 : m 10 m 2 red people are engaged, black people are free

LAW February 200721 Algorithm SSMTI-APPROX: Phase 3 for each woman w break the tie (if any) in w's list, placing the free men ahead of the engaged men; reactivate phase 1; /* now just classical Gale-Shapley */ return the set of engaged pairs; This is obviously a stable matching All we have done is decide how to break the ties and then apply Gale-Shapley

LAW February 200722 Algorithm SSMTI-APPROX: Phase 3 m 1 : w 6 w 1 w 2 w 1 : m 3 (m 1 m 6 m 9 ) m 2 : w 7 w 10 w 3 w 2 : m 1 (m 3 m 5 m 7 ) m 3 : w 6 w 2 w 8 w 9 w 1 w 3 : m 2 (m 4 m 6 m 8 ) m 4 : w 7 w 9 w 8 w 3 w 4 w 4 : m 4 m 9 (m 5 m 8 ) m 5 : w 2 w 6 w 4 w 5 w 5 : m 5 m 7 m 6 : w 1 w 3 w 6 : (m 1 m 3 m 5 ) m 7 : w 2 w 5 w 7 : (m 2 m 4 m 10 ) m 8 : w 3 w 4 w 8 : (m 3 m 4 ) m 9 : w 1 w 4 w 9 : (m 3 m 4 ) m 10 : w 7 w 10 w 10 : m 10 m 2

LAW February 200723 Algorithm SSMTI-APPROX: Phase 3 m 1 : w 6 w 1 w 2 w 1 : m 3 m 6 m 9 m 1 m 2 : w 7 w 10 w 3 w 2 : m 1 m 7 m 3 m 5 m 3 : w 6 w 2 w 8 w 9 w 1 w 3 : m 2 m 6 m 8 m 4 m 4 : w 7 w 9 w 8 w 3 w 4 w 4 : m 4 m 9 m 8 m 5 m 5 : w 2 w 6 w 4 w 5 w 5 : m 5 m 7 m 6 : w 1 w 3 w 6 : m 1 m 3 m 5 m 7 : w 2 w 5 w 7 : m 2 m 4 m 10 m 8 : w 3 w 4 w 8 : m 3 m 4 m 9 : w 1 w 4 w 9 : m 3 m 4 m 10 : w 7 w 10 w 10 : m 10 m 2

LAW February 200724 Algorithm SSMTI-APPROX: Phase 3 m 1 : w 6 w 1 : m 6 m 9 m 2 : w 7 w 2 : m 7 m 3 m 5 m 3 : w 6 w 2 w 8 w 3 : m 8 m 4 : w 7 w 9 w 4 : m 9 m 5 m 5 : w 2 w 6 w 4 w 5 w 5 : m 5 m 6 : w 1 w 6 : m 1 m 3 m 5 m 7 : w 2 w 7 : m 2 m 4 m 10 m 8 : w 3 w 8 : m 3 m 9 : w 1 w 4 w 9 : m 4 m 10 : w 7 w 10 w 10 : m 10 A stable matching of size 10

LAW February 200725 Visualising the performance guarantee Engaged men Free men Extra men Extra women M A A Men Women M = maximum cardinality stable matching A = stable matching found by algorithm SSMTI-APPROX Extra men are matched in M but not in A Extra women must also be matched in A

LAW February 200726 Visualising the performance guarantee Engaged men Free men Extra men Extra women M A A Men Women M = maximum cardinality stable matching A = stable matching found by algorithm SSMTI-APPROX M s r-s s s s A These women must be matched in A x

LAW February 200727 Visualising the performance guarantee Extra men Extra women M A A Men Women Inequalities: (i)|A| |M| - r (ii)|A| |M| - x (a consequence of Phase 2) (iii)|A| x + r – s (iv)|A| r + s Algebra gives |M| 5|A|/3 M s r-s s s s A These women must be matched in A x

LAW February 200728 Further observations The algorithm extends in a (fairly) straightforward way to SHRT with the same performance guarantee of 5/3 We have no example where the 5/3 bound is realised The worst case we have is 8/5 so maybe a sharper analysis could improve the bound Open question Can these or similar techniques give good approximation algorithms for more general cases? e.g. when men also can have a tie at the end of their list

LAW February 200729 A bad case for Algorithm SSMTI-APPROX m 1 : w 5 w 2 w 1 : m 3 (m 8 m 5 ) m 2 : w 6 w 3 w 2 : m 1 m 6 m 3 : w 5 w 7 w 8 w 1 w 3 : m 2 m 7 m 4 : w 6 w 8 w 7 w 4 w 4 : m 4 m 8 m 5 : w 1 w 5 : (m 3 m 1 ) m 6 : w 2 w 6 : (m 4 m 2 ) m 7 : w 3 w 7 : (m 4 m 3 ) m 8 : w 1 w 4 w 8 : (m 3 m 4 ) Algorithm can return the red matching – size 5 The blue matching – size 8 – is also stable

Similar presentations