The Stable Roommates Problem with Ties David Manlove
The Stable Roommates Problem with Ties David Manlove Joint work with Rob Irving University of Glasgow Department of Computing Science Supported by: EPSRC grants GR/M 13329 and GR/R 84597/01 Nuffield Foundation award NUF-NAL-02 RSE/Scottish Executive Personal Research Fellowship #1
Stable Roommates (SR): definition Input: 2 n persons; each person ranks all 2 n-1 other persons in strict order Output: a stable matching Definitions A matching is a set of n disjoint pairs of persons A blocking pair of a matching M is a pair of persons {p, q} M such that: • p prefers q to his partner in M, and • q prefers p to his partner in M A matching is stable if it admits no blocking pair #2
Stable Roommates (SR): definition Input: 2 n persons; each person ranks all 2 n-1 other persons in strict order Output: a stable matching Definitions A matching is a set of n disjoint pairs of persons A blocking pair of a matching M is a pair of persons {p, q} M such that: • p prefers q to his partner in M, and • q prefers p to his partner in M A matching is stable if it admits no blocking pair Example SR instance I 1: 2: 4 3 1 3: 2 1 4 4: 1 3 2 1: 3 2 4 #3
Stable Roommates (SR): definition Input: 2 n persons; each person ranks all 2 n-1 other persons in strict order Output: a stable matching Definitions A matching is a set of n disjoint pairs of persons A blocking pair of a matching M is a pair of persons {p, q} M such that: • p prefers q to his partner in M, and • q prefers p to his partner in M A matching is stable if it admits no blocking pair Example SR instance I 1: 2: 4 3 1 3: 2 1 4 4: 1 3 2 1: 3 2 4 #4
Stable Roommates (SR): definition Input: 2 n persons; each person ranks all 2 n-1 other persons in strict order Output: a stable matching Definitions A matching is a set of n disjoint pairs of persons A blocking pair of a matching M is a pair of persons {p, q} M such that: • p prefers q to his partner in M, and • q prefers p to his partner in M A matching is stable if it admits no blocking pair Example SR instance I 1: 2: 4 3 1 3: 2 1 4 4: 1 3 2 1: 3 2 4 The matching is not stable as {1, 3} blocks. #5
Stable matching in I 1: 2: 3: 4: 3 4 2 1 2 3 1 3 4 1 4 2 #6
Stable matching in I 1: 2: 3: 4: Example SR instance I 2: 1: 2: 3: 4: 3 4 2 1 3 1 2 3 1 3 2 3 1 2 4 1 4 2 4 4 4 3 #7
Stable matching in I 1: 2: 3: 4: Example SR instance I 2: 1: 2: 3: 4: 3 4 2 1 3 1 2 3 1 3 2 3 1 2 4 1 4 2 4 4 4 3 #8
Stable matching in I 1: 2: 3: 4: Example SR instance I 2: 1: 2: 3: 4: 3 4 2 1 3 1 2 3 1 3 2 3 1 2 4 1 4 2 4 4 4 3 #9
Stable matching in I 1: 2: 3: 4: Example SR instance I 2: 1: 2: 3: 4: 3 1 2 3 4 2 1 3 1 2 3 1 3 2 3 1 2 4 1 4 2 4 4 4 3 #10
Stable matching in I 1: 2: 3: 4: Example SR instance I 2: 1: 2: 3: 4: 3 1 2 3 4 2 1 3 1 2 3 1 3 2 3 1 2 4 1 4 2 4 4 4 3 #11
Stable matching in I 1: 2: 3: 4: Example SR instance I 2: 1: 2: 3: 4: 3 1 2 1 2 3 1 2 4 4 4 3 1: 2: 3: 4: 3 1 2 4 4 4 3 3 4 2 1 2 3 1 3 4 1 4 2 #12
Stable matching in I 1: 2: 3: 4: Example SR instance I 2: 1: 2: 3: 4: 3 1 2 1 2 3 1 2 4 4 4 3 1: 2: 3: 4: 3 1 2 4 4 4 3 3 4 2 1 2 3 1 3 4 1 4 2 #13
Stable matching in I 1: 2: 3: 4: Example SR instance I 2: 1: 2: 3: 4: 3 1 2 1 2 3 1 2 4 4 4 3 1: 2: 3: 4: 3 1 2 4 4 4 3 3 4 2 1 2 3 1 3 4 1 4 2 The three matchings containing the pairs {1, 4}, {2, 4}, {3, 4} are blocked by the pairs {1, 2}, {2, 3}, {3, 1} respectively. instance I 2 has no stable matching. SR was first studied in 1962 by Gale and Shapley#14
Stable marriage (SM) problem SM is a special case of SR Input: n men and n women; each person ranks all n members of the opposite sex in order Output: a stable matching Definitions: A matching is a set of n disjoint (man, woman) pairs A blocking pair of a matching M is an unmatched (man, woman) pair (m, w) such that: • m prefers w to his partner in M, and • w prefers m to her partner in M A matching is stable if it admits no blocking pair • Every instance of SM admits a stable matching • Such a matching can be found by an efficient algorithm known as the Gale/Shapley algorithm #15
Reduction from SM to SR An instance I of SM can be reduced to an instance J of SR such that set of stable matchings in I = set of stable matchings in J SM instance I: U={m 1, m 2, . . . , mn} is the set of men, and W={w 1, w 2, . . . , wn} is the set of women SR instance J: People comprise men in U and women in W mi’s list in J is his list in I together with the men in U{mi} appended in arbitrary order. wi’s list in J is her list in I together with the women in W{wi} appended in arbitrary order. Proposition: Set of stable matchings in I = set of stable matchings in J Open question: can we reduce SR to SM? #16
Efficient algorithm for SR • Knuth (1976): is there an efficient algorithm for deciding whethere exists a stable matching, given an instance of SR? • Irving (1985) “An efficient algorithm for the ‘Stable Roommates’ Problem”, Journal of Algorithms, 6: 577 -595 Ø given an instance of SR, decides whether a stable matching exists; if so, finds one • Algorithm is in two phases Ø Phase 1: similar to GS algorithm for SM • if some list becomes empty during Phase 1 Ø no stable matching exists • if all lists are of length 1 after Phase 1 Ø we have a stable matching, else: Ø Phase 2: elimination of “rotations” • if some list becomes empty during Phase 2 Ø no stable matching exists • else Phase 2 finds a stable matching #17
Stable Roommates with Ties (SRT) • Ties are permitted in any preference list Example SRT instance: 1: (2 2: 1 3: (1 4: 3 3) 3 4) 1 4 4 2 2 • More than one stability definition is possible Super-stability A matching M in instance J of SRT is super-stable if there is no pair {p, q} M such that • p strictly prefers q to his partner in M or is indifferent between them • q strictly prefers p to his partner in M or is indifferent between them In any instance of SRT with no ties, super-stability is the same as classical stability Recall: an SR instance can have no stable matching #18
Stable Roommates with Ties (SRT) • Ties are permitted in any preference list Example SRT instance: 1: (2 2: 1 3: (1 4: 3 3) 3 4) 1 4 4 2 2 • More than one stability definition is possible Super-stability A matching M in instance J of SRT is super-stable if there is no pair {p, q} M such that • p strictly prefers q to his partner in M or is indifferent between them • q strictly prefers p to his partner in M or is indifferent between them In any instance of SRT with no ties, super-stability is the same as classical stability Recall: an SR instance can have no stable matching #19
Stable Roommates with Ties (SRT) • Ties are permitted in any preference list Example SRT instance: 1: (2 2: 1 3: (1 4: 3 3) 3 4) 1 4 4 2 2 • More than one stability definition is possible Super-stability A matching M in instance J of SRT is super-stable if there is no pair {p, q} M such that • p strictly prefers q to his partner in M or is indifferent between them • q strictly prefers p to his partner in M or is indifferent between them In any instance of SRT with no ties, super-stability is the same as classical stability Recall: an SR instance can have no stable matching #20
SRT: super-stability (cont) • Algorithm for finding a super-stable matching if one exists, given an SRT instance Ø Irving and Manlove (2002) “The Stable Roommates Problem with Ties”, Journal of Algorithms, 43: 85 -105 #21
SRT: super-stability (cont) • Algorithm for finding a super-stable matching if one exists, given an SRT instance Ø Irving and Manlove (2002) “The Stable Roommates Problem with Ties”, Journal of Algorithms, 43: 85 -105 • Algorithm is in two phases Phase 1: similar to SR case – sequence of proposals and deletions – persons become provisionally assigned to / assigned from other persons Example SRT instance: 1: (6 2: 6 3: (5 4: 2 5: 4 6: 5 4) 3 4) 6 2 1 2 5 5 1 1 6 5 (1 3 6 4 2 3) 1 3 #22
Phase 1 of Algorithm SRT-Super while (some person p has a non-empty list and p is not assigned to anyone) { for (each q at the head of p's list) { assign p to q; /* q is assigned from p */ for (each strict successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q, r}; } if ( 2 persons are assigned to q) { break all assignments to q; for (each r tied with p in q's list) delete the pair {q, r}; } } } Example SRT instance: 1: (6 2: 6 3: (5 4: 2 5: 4 6: 5 4) 3 4) 6 2 1 2 5 5 1 1 6 5 (1 3 6 4 2 assigned to/from 3 4 2 3) 1 3 #23
Phase 1 of Algorithm SRT-Super while (some person p has a non-empty list and p is not assigned to anyone) { for (each q at the head of p's list) { assign p to q; /* q is assigned from p */ for (each strict successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q, r}; } if ( 2 persons are assigned to q) { break all assignments to q; for (each r tied with p in q's list) delete the pair {q, r}; } } } Example SRT instance: 1: (6 2: 6 3: (5 4: 2 5: 4 6: 5 4) 3 4) 6 2 1 2 5 5 1 1 6 5 (1 3 6 4 2 assigned to/from 3 4 2 3) 1 3 6 1 #24
Phase 1 of Algorithm SRT-Super while (some person p has a non-empty list and p is not assigned to anyone) { for (each q at the head of p's list) { assign p to q; /* q is assigned from p */ for (each strict successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q, r}; } if ( 2 persons are assigned to q) { break all assignments to q; for (each r tied with p in q's list) delete the pair {q, r}; } } } Example SRT instance: 1: (6 2: 6 3: (5 4: 2 5: 4 6: 5 4) 3 4) 6 2 1 2 5 5 1 1 6 5 (1 3 6 4 2 assigned to/from 3 4 2 3) 1 3 6 1 #25
Phase 1 of Algorithm SRT-Super while (some person p has a non-empty list and p is not assigned to anyone) { for (each q at the head of p's list) { assign p to q; /* q is assigned from p */ for (each strict successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q, r}; } if ( 2 persons are assigned to q) { break all assignments to q; for (each r tied with p in q's list) delete the pair {q, r}; } } } Example SRT instance: 1: (6 2: 6 3: (5 4: 2 5: 4 6: 5 4) 3 4) 6 2 1 2 5 3 5 1 4 1 6 2 5 (1 3) 3 6 1 4 2 3 assigned to/from 6 1 #26
Phase 1 of Algorithm SRT-Super while (some person p has a non-empty list and p is not assigned to anyone) { for (each q at the head of p's list) { assign p to q; /* q is assigned from p */ for (each strict successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q, r}; } if ( 2 persons are assigned to q) { break all assignments to q; for (each r tied with p in q's list) delete the pair {q, r}; } } } Example SRT instance: 1: (6 4) 2 5 3 2: 6 3 5 1 4 3: (5 4) 1 6 2 4: 2 6 5 (1 3) 5: 4 2 3 6 1 6: 5 1 4 2 3 assigned to/from 6, 4 1 1 #27
Phase 1 of Algorithm SRT-Super while (some person p has a non-empty list and p is not assigned to anyone) { for (each q at the head of p's list) { assign p to q; /* q is assigned from p */ for (each strict successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q, r}; } if ( 2 persons are assigned to q) { break all assignments to q; for (each r tied with p in q's list) delete the pair {q, r}; } } } Example SRT instance: 1: (6 4) 2 5 3 2: 6 3 5 1 4 3: (5 4) 1 6 2 4: 2 6 5 (1 3) 5: 4 2 3 6 1 6: 5 1 4 2 3 assigned to/from 6, 4 3 2 1 1 #28
Phase 1 of Algorithm SRT-Super while (some person p has a non-empty list and p is not assigned to anyone) { for (each q at the head of p's list) { assign p to q; /* q is assigned from p */ for (each strict successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q, r}; } if ( 2 persons are assigned to q) { break all assignments to q; for (each r tied with p in q's list) delete the pair {q, r}; } } } Example SRT instance: 1: (6 4) 2 5 3 2: 6 3 5 1 4 3: (5 4) 1 6 2 4: 2 6 5 (1 3) 5: 4 2 3 6 1 6: 5 1 4 2 3 assigned to/from 6, 4 3 5 2 1 3 1 #29
Phase 1 of Algorithm SRT-Super while (some person p has a non-empty list and p is not assigned to anyone) { for (each q at the head of p's list) { assign p to q; /* q is assigned from p */ for (each strict successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q, r}; } if ( 2 persons are assigned to q) { break all assignments to q; for (each r tied with p in q's list) delete the pair {q, r}; } } } Example SRT instance: 1: (6 2: 6 3: (5 4: 2 5: 4 6: 5 4) 3 4) 6 2 1 2 5 3 5 1 4 1 6 2 5 (1 3) 3 6 1 4 2 3 assigned to/from 6, 4 3 5 2 1 3 1 #30
Phase 1 of Algorithm SRT-Super while (some person p has a non-empty list and p is not assigned to anyone) { for (each q at the head of p's list) { assign p to q; /* q is assigned from p */ for (each strict successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q, r}; } if ( 2 persons are assigned to q) { break all assignments to q; for (each r tied with p in q's list) delete the pair {q, r}; } } } Example SRT instance: 1: (6 4) 2 2: 6 3 5 3: (5 4) 1 4: 2 6 5 5: 4 2 3 6: 5 1 4 5 3 1 4 6 2 (1 3) 6 1 2 3 assigned to/from 6, 4 3 5 2 1 3 1 #31
Phase 1 of Algorithm SRT-Super while (some person p has a non-empty list and p is not assigned to anyone) { for (each q at the head of p's list) { assign p to q; /* q is assigned from p */ for (each strict successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q, r}; } if ( 2 persons are assigned to q) { break all assignments to q; for (each r tied with p in q's list) delete the pair {q, r}; } } } Example SRT instance: 1: (6 4) 2 2: 6 3 5 3: (5 4) 1 4: 2 6 5 5: 4 2 3 6: 5 1 4 5 3 1 4 6 2 (1 3) 6 1 2 3 assigned to/from 6, 4 3 5, 4 2 1, 3 3 1 #32
Phase 1 of Algorithm SRT-Super while (some person p has a non-empty list and p is not assigned to anyone) { for (each q at the head of p's list) { assign p to q; /* q is assigned from p */ for (each strict successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q, r}; } if ( 2 persons are assigned to q) { break all assignments to q; for (each r tied with p in q's list) delete the pair {q, r}; } } } Example SRT instance: 1: (6 2: 6 3: (5 4: 2 5: 4 6: 5 4) 3 4) 6 2 1 2 5 3 5 1 4 1 6 2 5 (1 3) 3 6 1 4 2 3 assigned to/from 6, 4 3 5, 4 2 3 1 #33
Phase 1 of Algorithm SRT-Super while (some person p has a non-empty list and p is not assigned to anyone) { for (each q at the head of p's list) { assign p to q; /* q is assigned from p */ for (each strict successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q, r}; } if ( 2 persons are assigned to q) { break all assignments to q; for (each r tied with p in q's list) delete the pair {q, r}; } } } Example SRT instance: 1: (6 4) 2 5 3 2: 6 3 5 1 4 3: (5 4) 1 6 2 4: 2 6 5 (1 3) 5: 4 2 3 6 1 6: 5 1 4 2 3 assigned to/from 6 3 5 2 3 1 #34
Phase 1 of Algorithm SRT-Super while (some person p has a non-empty list and p is not assigned to anyone) { for (each q at the head of p's list) { assign p to q; /* q is assigned from p */ for (each strict successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q, r}; } if ( 2 persons are assigned to q) { break all assignments to q; for (each r tied with p in q's list) delete the pair {q, r}; } } } Example SRT instance: 1: (6 4) 2: 6 3 3: (5 4) 4: 2 6 5: 4 2 6: 5 1 2 5 1 5 3 4 5 1 6 (1 6 2 assigned to/from 3 4 2 3) 1 3 6 3 5 2 4 2 3 1 #35
Phase 1 of Algorithm SRT-Super while (some person p has a non-empty list and p is not assigned to anyone) { for (each q at the head of p's list) { assign p to q; /* q is assigned from p */ for (each strict successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q, r}; } if ( 2 persons are assigned to q) { break all assignments to q; for (each r tied with p in q's list) delete the pair {q, r}; } } } Example SRT instance: 1: (6 2: 6 3: (5 4: 2 5: 4 6: 5 4) 2 3 5 4) 1 6 5 2 3 1 4 5 1 6 (1 6 2 assigned to/from 3 4 2 3) 1 3 6 3 5 2 4 4 2 5 3 1 #36
Phase 1 of Algorithm SRT-Super while (some person p has a non-empty list and p is not assigned to anyone) { for (each q at the head of p's list) { assign p to q; /* q is assigned from p */ for (each strict successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q, r}; } if ( 2 persons are assigned to q) { break all assignments to q; for (each r tied with p in q's list) delete the pair {q, r}; } } } Example SRT instance: 1: (6 2: 6 3: (5 4: 2 5: 4 6: 5 4) 2 3 5 4) 1 6 5 2 3 1 4 5 1 6 (1 6 2 assigned to/from 3 4 2 3) 1 3 6 3 5 2 4 1 6 4 2 5 3 1 #37
Phase 1 of Algorithm SRT-Super while (some person p has a non-empty list and p is not assigned to anyone) { for (each q at the head of p's list) { assign p to q; /* q is assigned from p */ for (each strict successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q, r}; } if ( 2 persons are assigned to q) { break all assignments to q; for (each r tied with p in q's list) delete the pair {q, r}; } } } Example SRT instance: 1: (6 2: 6 3: (5 4: 2 5: 4 6: 5 4) 2 3 4) 6 2 1 5 5 1 1 6 5 (1 3 6 4 2 assigned to/from 3 4 2 3) 1 3 6 3 5 2 4 1 6 4 2 5 3 1 #38
Phase 1 of Algorithm SRT-Super while (some person p has a non-empty list and p is not assigned to anyone) { for (each q at the head of p's list) { assign p to q; /* q is assigned from p */ for (each strict successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q, r}; } if ( 2 persons are assigned to q) { break all assignments to q; for (each r tied with p in q's list) delete the pair {q, r}; } } } Example SRT instance: 1: (6 2: 6 3: (5 4: 2 5: 4 6: 5 5 5 1 1 6 5 (1 3 6 4 2 assigned to/from 4) 2 3 3 4) 6 2 1 4 2 3) 1 3 6 3 5 2 4 1 6 4 2 5 3 1 #39
Phase 1 of Algorithm SRT-Super while (some person p has a non-empty list and p is not assigned to anyone) { for (each q at the head of p's list) { assign p to q; /* q is assigned from p */ for (each strict successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q, r}; } if ( 2 persons are assigned to q) { break all assignments to q; for (each r tied with p in q's list) delete the pair {q, r}; } } } Example SRT instance: 1: 2: 3: 4: 5: 6: 6 3 5 2 4 1 5 2 4 3 assigned to/from 6 3 5 2 4 1 6 4 2 5 3 1 #40
After Phase 1: • Lemma: if some person’s list is empty then no super-stable matching exists • Lemma: if every person’s list has length 1 then the lists specify a super-stable matching • If nobody’s list is empty and some person’s list has length >1 then we move on to Phase 2 1: 2: 3: 4: 5: 6: 6 3 5 2 4 1 5 2 4 3 #41
After Phase 1: • Lemma: if some person’s list is empty then no super-stable matching exists • Lemma: if every person’s list has length 1 then the lists specify a super-stable matching • If nobody’s list is empty and some person’s list has length >1 then we move on to Phase 2 1: 2: 3: 4: 5: 6: 6 3 5 2 4 1 5 2 4 3 Phase 2: “reject and reactivate Phase 1” – select a person p whose list is of length >1 – let p be rejected by first person on his list – reactivate Phase 1 #42
• Let person 2 be rejected by person 3 1: 2: 3: 4: 5: 6: 6 3 5 2 4 1 5 4 2 5 2 3 #43
• Let person 2 be rejected by person 3 1: 2: 3: 4: 5: 6: 6 3 5 2 4 1 5 4 2 5 2 3 #44
• Let person 2 be rejected by person 3 1: 2: 3: 4: 5: 6: 6 3 5 2 4 1 5 4 2 5 2 3 #45
• Let person 2 be rejected by person 3 1: 2: 3: 4: 5: 6: 6 3 5 2 4 1 5 4 2 5 2 3 – Person 3’s list is empty #46
• Let person 2 be rejected by person 3 1: 2: 3: 4: 5: 6: 6 3 5 2 4 1 5 4 2 5 2 3 – Person 3’s list is empty – Reinstate the preference lists to their status after original Phase 1 1: 2: 3: 4: 5: 6: 6 3 5 2 4 1 5 2 4 3 #47
• Let person 2 be rejected by person 3 1: 2: 3: 4: 5: 6: 6 3 5 2 4 1 5 4 2 5 2 3 – Person 3’s list is empty – Reinstate the preference lists to their status after original Phase 1 – Let p reject the last person on his list – Reactivate Phase 1 • Let person 2 reject person 4 1: 2: 3: 4: 5: 6: 6 3 5 2 4 1 5 2 4 3 #48
• Let person 2 be rejected by person 3 1: 2: 3: 4: 5: 6: 6 3 5 2 4 1 5 4 2 5 2 3 – Person 3’s list is empty – Reinstate the preference lists to their status after original Phase 1 – Let p reject the last person on his list – Reactivate Phase 1 • Let person 2 reject person 4 1: 2: 3: 4: 5: 6: 6 3 5 2 4 1 5 2 4 3 #49
• Let person 2 be rejected by person 3 1: 2: 3: 4: 5: 6: 6 3 5 2 4 1 5 4 2 5 2 3 – Person 3’s list is empty – Reinstate the preference lists to their status after original Phase 1 – Let p reject the last person on his list – Reactivate Phase 1 • Let person 2 reject person 4 1: 2: 3: 4: 5: 6: 6 3 5 2 4 1 5 2 5 2 4 3 #50
• Let person 2 be rejected by person 3 1: 2: 3: 4: 5: 6: 6 3 5 2 4 1 5 4 2 5 2 3 – Person 3’s list is empty – Reinstate the preference lists to their status after original Phase 1 – Let p reject the last person on his list – Reactivate Phase 1 • Let person 2 reject person 4 1: 2: 3: 4: 5: 6: 6 3 5 4 5 2 2 5 4 2 3 1 #51
• Let person 2 be rejected by person 3 1: 2: 3: 4: 5: 6: 6 3 5 2 4 1 5 4 2 5 2 3 – Person 3’s list is empty – Reinstate the preference lists to their status after original Phase 1 – Let p reject the last person on his list – Reactivate Phase 1 • Let person 2 reject person 4 1: 2: 3: 4: 5: 6: 6 3 5 2 4 1 5 4 2 5 2 3 #52
• Let person 2 be rejected by person 3 1: 2: 3: 4: 5: 6: 6 3 5 2 4 1 5 4 2 5 2 3 – Person 3’s list is empty – Reinstate the preference lists to their status after original Phase 1 – Let p reject the last person on his list – Reactivate Phase 1 • Let person 2 reject person 4 1: 2: 3: 4: 5: 6: 6 3 5 5 2 2 5 4 2 1 4 3 – Reactivation of Phase 1 terminates #53
1: 2: 3: 4: 5: 6: 6 3 2 5 4 1 • All lists now have length 1 • This corresponds to the matching {1, 6}, {2, 3}, {4, 5} 1: (6 2: 6 3: (5 4: 2 5: 4 6: 5 4) 3 4) 6 2 1 2 5 5 1 1 6 5 (1 3 6 4 2 3) 1 3 • The matching is super-stable with respect to the original lists #54
Phase 2 of Algorithm SRT-Super T : = preference lists generated by Phase 1; while (some person p’s list in T is of length > 1) { let q be the person assigned from p ; let r be the person assigned to p; form T 1 from T by letting p be rejected by q; form T 2 from T by letting p reject r; reactivate Phase 1 on T 1; reactivate Phase 1 on T 2; if (no list in T 1 is empty) T : = T 1; else if (no list in T 2 is empty) T : = T 2; else output “no super-stable matching exists”; } output T; /* which is a super-stable #55
Correctness of Algorithm SRT-Super Lemma 1: if T contains an embedded superstable matching then either T 1 or T 2 contains an embedded super-stable matching Corollary 1: if T contains an embedded superstable matching and T 1 has an empty list then T 2 contains an embedded super-stable matching Corollary 2: if each of T 1 and T 2 has an empty list then T contains no embedded super-stable matching Lemma 2: if T contains an embedded superstable matching and T 1 has no empty list then T 1 contains an embedded super-stable matching T T 1 T 2 #56
Analysis of Algorithm SRT-Super • Assume standard data structures: Ø preference lists represented as doublylinked lists embedded in an array Ø ranking lists: for each person p, rankp(q) gives the position of q in p’s list • These may be initialised in O(n 2) time at outset • With these data structures each deletion may be carried out in constant time • Maintain a pointer to the last element in each person’s preference list • Maintain a stack of persons waiting to propose • Phase 1 is O(n+d) where d is the number of pairs deleted #57
Analysis of Algorithm SRT-Super (cont) • Computation of T 1 and T 2 during iteration i of main loop in Phase 2 is O(di 1+di 2) where dij is number of pairs deleted during each reactivation of Phase 1 Ø Maintain two copies of the reduced lists at each iteration Ø Initially make two copies, T 1 and T 2, of the preference lists - O(n 2) time Ø Thereafter, simulate parallel applications of Phase 1 on each of T 1 and T 2 Ø Ensure that number of deletions from T 1 never exceeds number of deletions from T 2 by >1 (and vice versa) Ø Maintain a stack of deletions from each Ø E. g. if a list in T 1 becomes empty, undo deletions of T 1 and apply deletions of T 2 • Hence Phase 2 is O(n+d) where d is the total number of (non-redundant) pairs deleted • Overall Algorithm SRT-Super has O(n 2) complexity #58
SRT: strong stability A matching M in instance J of SRT is strongly stable if there is no pair {p, q} M such that • p strictly prefers q to his partner in M • q strictly prefers p to his partner in M or is indifferent between them Example SRT instance: 1: 4 2 2: (1 3) 3: 1 (4 4: 2 3 3 4 2) 1 The matching is strongly stable. • Polynomial-time algorithm for finding a strongly stable matching, or reporting that none exists, given an instance of SRT Ø Scott (2004), Ph. D thesis (in preparation) #59
SRT: weak stability A matching M in instance J of SRT is weakly stable if there is no pair {p, q} M such that • p strictly prefers q to his partner in M • q strictly prefers p to his partner in M Example SRT instance: 1: 3 2: (1 3: 2 4: 1 2 3) 1 2 4 4 4 3 The matching is weakly stable. • The problem of deciding whether an instance of SRT admits a weakly stable matching is NP-complete Ø Ronn (1990) “NP-complete Stable Matching Problems”, Journal of Algorithms, 11: 285 -304 Ø Irving and Manlove (2002) “The Stable Roommates Problem with Ties”, Journal of Algorithms, 43: 85 -105 #60
Other extensions of SR • Stable Crews Problem (SC) – Each person p can have one of two roles, e. g. (A) Captain (p. A) or (B) Navigator (p. B) 1: 2: 3: 4: 4 B 1 B 1 A 2 A 3 A 4 A 2 A 1 B 2 A 3 B 2 B 2 B 2 B 4 B 4 A 3 B 3 B 1 A 4 A 3 A 1 B 3 A E. g. person 2 prefers person 1 as a navigator to person 4 as a captain #61
Other extensions of SR • Stable Crews Problem (SC) – Each person p can have one of two roles, e. g. (A) Captain (p. A) or (B) Navigator (p. B) 1: 2: 3: 4: role B A A B 4 B 1 B 1 A 2 A 3 A 4 A 2 A 1 B 2 A 3 B 2 B 2 B 2 B 4 B 4 A 3 B 3 B 1 A 4 A 3 A 1 B 3 A E. g. person 2 prefers person 1 as a navigator to person 4 as a captain – A matching M is a disjoint set of pairs of persons with roles – each person is in exactly one pair – each pair has exactly one Captain (A) and exactly one Navigator (B) – e. g. {1 B, 3 A}, {2 A, 4 B} #62
– {XA, YB} is a blocking pair of M if (1) X prefers YB to his partner in M (2) Y prefers XA to his partner in M – A matching is stable if it admits no blocking pair E. g. {2 A, 3 B} blocks the previous matching 1: 2: 3: 4: role B A A B 4 B 1 B 1 A 2 A 3 A 4 A 2 A 1 B 2 A 3 B 2 B 2 B 2 B 4 B 4 A 3 B 3 B 1 A 4 A 3 A 1 B 3 A 1: 2: 3: 4: role B A 4 B 1 B 1 A 2 A 3 A 4 A 2 A 1 B 2 A 3 B 2 B 2 B 2 B 4 B 4 A 3 B 3 B 1 A 4 A 3 A 1 B 3 A – The above matching is stable #63
– An instance I of SR can be reduced to an instance J of SC such that every stable matching in I corresponds to a stable matching in J and vice versa – Some instances of SC do not admit a stable matching – There is an efficient algorithm to find a stable matching, if one exists, given an instance of SC – If crews are of size 3, the problem of deciding whether a stable matching exists is NP-complete Cechlárová and Ferková (2004) “The Stable Crews Problem”, Discrete Applied Mathematics, 140 (1 -3): 1 -17 #64
• Stable Fixtures Problem (SF) – Choose a schedule of fixtures based on teams having preferences over each other – Two given teams can play each other at most once – Each team i has a capacity ci , indicating the maximum number of fixtures it can play – A fixture allocation A is a set of unordered pairs of teams {i, j} such that, for each i, team i is scheduled to play at most ci fixtures – Example SF instance: team capacity 1: 2 2: 2 3: 2 4: 2 preferences 2 3 4 1 2 3 #65
• Stable Fixtures Problem (SF) – Choose a schedule of fixtures based on teams having preferences over each other – Two given teams can play each other at most once – Each team i has a capacity ci , indicating the maximum number of fixtures it can play – A fixture allocation A is a set of unordered pairs of teams {i, j} such that, for each i, team i is scheduled to play at most ci fixtures – Example SF instance: team capacity 1: 2 2: 2 3: 2 4: 2 preferences 2 3 4 1 2 3 – The above fixture allocation is: {1, 2}, {1, 4}, {2, 3}, {3, 4} #66
– A blocking pair of a fixture allocation A is a pair of teams {i , j} A such that: Ø i is assigned fewer than ci teams in A or i prefers j to at least one of its assignees and Ø j is assigned fewer than cj teams in A or j prefers i to at least one of its assignees – A fixture allocation is stable if it admits no blocking pair – Example SF instance: team capacity 1: 2 2: 2 3: 2 4: 2 preferences 2 3 4 1 2 3 – The above fixture allocation is not stable as {1, 3} is a blocking pair #67
– Example SF instance: team capacity 1: 2 2: 2 3: 2 4: 2 preferences 2 3 4 1 2 3 – The above fixture allocation is stable – SR is a special case of SF (in which each team has capacity 1) – There is an efficient algorithm to find a stable fixtures allocation, if one exists, given an instance of SF Ø Irving and Scott (2004), “The Stable Fixtures Problem”, to appear in Discrete Applied Mathematics #68
• Stable Activities Problem (SA) – Generalization of SC in which number of roles (“activities”) is arbitrary – Problem is formulated in terms of a multigraph Ø vertex for each person Ø edge e. A={u, v} indicates that u finds acceptable activity A with v Ø u has a linear order over N(u) • Stable Multiple Activities Problem (SMA) – Generalization of SA in which each vertex v has a bound b(v) – In any matching v is incident to at most b(v) edges – In both cases we seek a stable matching – Each of SA and SMA is reducible to SR Ø Cechlárová and Fleiner (2003) “On a generalization of the stable roommates problem”, EGRES Technical Report No. 2003 -03 #69
Summary • Stable Roommates problem (SR) • Stable Roommates problem with Ties (SRT) – super-stability – strong stability – weak stability • Other extensions: – Stable Crews problem (SC) – Stable Fixtures problem (SF) – Stable Activities problem (SA) – Stable Multiple Activities problem (SMA) Open questions • Reduction from SR to SM? • Characterise Algorithm SRT-Super in terms of rotations, as in the SR case • SA / SMA with ties #70
- Slides: 70