700 likes | 717 Views
Explore the Stable Roommates (SR) problem, its definitions, instances, and stability criteria, including connections to the Gale/Shapley algorithm and Stable Marriage (SM) problem. Discover efficient matching algorithms.
E N D
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/M13329 and GR/R84597/01 Nuffield Foundation award NUF-NAL-02 RSE/Scottish Executive Personal Research Fellowship
Stable Roommates (SR): definition • Input:2n persons; each person ranks all 2n-1 • other persons in strict order • Output: a stable matching • Definitions • A matchingis a set of n disjoint pairs of persons • A blocking pair of a matching M is a pair of persons {p,q}Msuch 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
Stable Roommates (SR): definition • Input:2n persons; each person ranks all 2n-1 • other persons in strict order • Output: a stable matching • Definitions • A matchingis a set of n disjoint pairs of persons • A blocking pair of a matching M is a pair of persons {p,q}Msuch 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 I1:1: 3 2 4 • 2: 4 3 1 • 3: 2 1 4 • 4: 1 3 2
Stable Roommates (SR): definition • Input:2n persons; each person ranks all 2n-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}Msuch that: • p prefers q to his partner in M, and • q prefers p to his partner in M • A matching is stableif it admits no blocking pair • Example SR instance I1:1: 3 2 4 • 2: 4 3 1 • 3: 2 1 4 • 4: 1 3 2
Stable Roommates (SR): definition • Input:2n persons; each person ranks all 2n-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}Msuch that: • p prefers q to his partner in M, and • q prefers p to his partner in M • A matching is stableif it admits no blocking pair • Example SR instance I1:1: 3 2 4 • 2: 4 3 1 • 3: 2 1 4 • 4: 1 3 2 • The matching is not stable as {1,3} blocks.
Stable matching in I1:1: 3 2 4 2: 4 3 1 3: 2 1 4 4: 1 3 2
Stable matching in I1:1: 3 2 4 2: 4 3 1 3: 2 1 4 4: 1 3 2 Example SR instance I2:1: 3 2 4 2: 1 3 4 3: 2 1 4 4: 1 2 3
Stable matching in I1:1: 3 2 4 2: 4 3 1 3: 2 1 4 4: 1 3 2 Example SR instance I2:1: 3 2 4 2: 1 3 4 3: 2 1 4 4: 1 2 3
Stable matching in I1:1: 3 2 4 2: 4 3 1 3: 2 1 4 4: 1 3 2 Example SR instance I2:1: 3 2 4 2: 1 3 4 3: 2 1 4 4: 1 2 3
Stable matching in I1:1: 3 2 4 2: 4 3 1 3: 2 1 4 4: 1 3 2 Example SR instance I2:1: 3 2 4 2: 1 3 4 3: 2 1 4 4: 1 2 3 1: 3 2 4 2: 1 3 4 3: 2 1 4 4: 1 2 3
Stable matching in I1:1: 3 2 4 2: 4 3 1 3: 2 1 4 4: 1 3 2 Example SR instance I2:1: 3 2 4 2: 1 3 4 3: 2 1 4 4: 1 2 3 1: 3 2 4 2: 1 3 4 3: 2 1 4 4: 1 2 3
Stable matching in I1:1: 3 2 4 2: 4 3 1 3: 2 1 4 4: 1 3 2 Example SR instance I2:1: 3 2 4 2: 1 3 4 3: 2 1 4 4: 1 2 3 1: 3 2 4 1: 3 2 4 2: 1 3 4 2: 1 3 4 3: 2 1 4 3: 2 1 4 4: 1 2 3 4: 1 2 3
Stable matching in I1:1: 3 2 4 2: 4 3 1 3: 2 1 4 4: 1 3 2 Example SR instance I2:1: 3 2 4 2: 1 3 4 3: 2 1 4 4: 1 2 3 1: 3 2 4 1: 3 2 4 2: 1 3 4 2: 1 3 4 3: 2 1 4 3: 2 1 4 4: 1 2 3 4: 1 2 3
Stable matching in I1:1: 3 2 4 • 2: 4 3 1 • 3: 2 1 4 • 4: 1 3 2 • Example SR instance I2:1: 3 2 4 • 2: 1 3 4 • 3: 2 1 4 • 4: 1 2 3 • 1: 3 2 4 1: 3 2 4 • 2: 1 3 4 2: 1 3 4 • 3: 2 1 4 3: 2 1 4 • 4: 1 2 3 4: 1 2 3 • 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 I2 has no stable matching. SR was first studied in 1962 by Gale and Shapley
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/Shapleyalgorithm
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={m1, m2,...,mn} is the set of men, and W={w1, w2,...,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?
Efficient algorithm for SR • Knuth (1976): is there an efficient algorithm • for deciding whether there 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 instanceof SR, decides whether a stable matching exists; if so, finds one • Algorithm is in two phases • Phase 1: similar to GS algorithm for SM • Phase 2: elimination of “rotations” • 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: • if some list becomes empty during Phase 2 • no stable matching exists • else Phase 2 finds a stable matching
Stable Roommates with Ties (SRT) • Ties are permitted in any preference list • Example SRT instance: 1: (2 3) 4 • 2: 1 3 4 • 3: (1 4) 2 • 4: 3 1 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
Stable Roommates with Ties (SRT) • Ties are permitted in any preference list • Example SRT instance: 1: (2 3) 4 • 2: 1 3 4 • 3: (1 4) 2 • 4: 3 1 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
Stable Roommates with Ties (SRT) • Ties are permitted in any preference list • Example SRT instance: 1:(2 3) 4 • 2: 1 3 4 • 3:(1 4) 2 • 4: 3 1 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
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
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 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
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; /* qis 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: assigned to/from 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
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; /* qis 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: assigned to/from 1: (6 4) 2 5 3 6 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 1
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; /* qis 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: assigned to/from 1: (6 4) 2 5 3 6 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 1
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; /* qis 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: assigned to/from 1: (6 4) 2 5 3 6 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 1
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; /* qis 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: assigned to/from 1: (6 4) 2 5 3 6,4 2: 6 3 5 1 4 3: (5 4) 1 6 2 4: 2 6 5 (1 3) 1 5: 4 2 3 6 1 6: 5 1 4 2 3 1
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; /* qis 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: assigned to/from 1: (6 4) 2 5 3 6,4 2: 6 3 5 1 4 3 3: (5 4) 1 6 22 4: 2 6 5 (1 3) 1 5: 4 2 3 6 1 6: 5 1 4 2 3 1
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; /* qis 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: assigned to/from 1: (6 4) 2 5 3 6,4 2: 6 3 5 1 4 3 3: (5 4) 1 6 2 5 2 4: 2 6 5 (1 3) 1 5: 4 2 3 6 1 3 6: 5 1 4 2 3 1
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; /* qis 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: assigned to/from 1: (6 4) 2 5 3 6,4 2: 6 3 5 1 4 3 3: (5 4) 1 6 2 5 2 4: 2 6 5 (1 3) 1 5: 4 2 3 6 1 3 6: 5 1 4 2 3 1
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; /* qis 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: assigned to/from 1: (6 4) 2 5 3 6,4 2: 6 3 5 1 4 3 3: (5 4) 1 6 2 5 2 4: 2 6 5 (1 3) 1 5: 4 2 3 6 1 3 6: 5 1 4 2 3 1
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; /* qis 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: assigned to/from 1: (6 4) 2 5 3 6,4 2: 6 3 5 1 4 3 3: (5 4) 1 6 2 5,4 2 4: 2 6 5 (1 3) 1,3 5: 4 2 3 6 1 3 6: 5 1 4 2 3 1
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; /* qis 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: assigned to/from 1: (6 4) 2 5 3 6,4 2: 6 3 5 1 4 3 3: (5 4) 1 6 2 5,4 2 4: 2 6 5 (1 3) 5: 4 2 3 6 1 3 6: 5 1 4 2 3 1
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; /* qis 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: assigned to/from 1: (6 4) 2 5 3 6 2: 6 3 5 1 4 3 3: (5 4) 1 6 2 5 2 4: 2 6 5 (1 3) 5: 4 2 3 6 1 3 6: 5 1 4 2 3 1
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; /* qis 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: assigned to/from 1: (6 4) 2 5 3 6 2: 6 3 5 1 4 3 4 3: (5 4) 1 6 2 5 2 4:2 6 5 (1 3) 2 5: 4 2 3 6 1 3 6: 5 1 4 2 3 1
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; /* qis 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: assigned to/from 1: (6 4) 2 5 3 6 2: 6 3 5 1 4 3 4 3: (5 4) 1 6 2 5 2 4: 2 6 5 (1 3) 2 5 5:4 2 3 6 1 4 3 6: 5 1 4 2 3 1
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; /* qis 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: assigned to/from 1: (6 4) 2 5 3 6 6 2: 6 3 5 1 4 3 4 3: (5 4) 1 6 2 5 2 4: 2 6 5 (1 3) 2 5 5: 4 2 3 6 1 4 3 6: 5 1 4 2 3 1 1
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; /* qis 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: assigned to/from 1: (6 4) 2 5 3 6 6 2: 6 3 5 1 4 3 4 3: (5 4) 1 6 2 5 2 4: 2 6 5 (1 3) 2 5 5: 4 2 3 6 1 4 3 6: 5 1 4 2 3 1 1
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; /* qis 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: assigned to/from 1: (6 4) 2 5 3 6 6 2: 6 3 5 1 4 3 4 3: (5 4) 1 6 2 5 2 4: 2 6 5 (1 3) 2 5 5: 4 2 3 6 1 4 3 6: 5 1 4 2 3 1 1
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; /* qis 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: assigned to/from 1: 6 6 6 2: 3 5 4 3 4 3: 5 2 5 2 4: 2 5 2 5 5: 4 2 3 4 3 6: 1 1 1
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: 6 • 2: 3 5 4 • 3: 52 • 4: 25 • 5: 4 2 3 • 6: 1
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: 6 • 2: 3 5 4 • 3: 52 • 4: 25 • 5: 4 2 3 • 6: 1 • 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
• Let person 2 be rejected by person 3 • 1: 6 • 2: 3 5 4 • 3: 5 2 • 4: 25 • 5: 4 2 3 • 6: 1
Let person 2 be rejected by person 3 • 1: 6 • 2: 3 54 • 3: 5 2 • 4: 25 • 5: 423 • 6: 1
Let person 2 be rejected by person 3 • 1: 6 • 2: 3 5 4 • 3: 5 2 • 4: 2 5 • 5: 4 2 3 • 6: 1
Let person 2 be rejected by person 3 • 1: 6 • 2: 3 5 4 • 3: 5 2 • 4: 2 5 • 5: 4 2 3 • 6: 1 • Person 3’s list is empty
Let person 2 be rejected by person 3 • 1: 6 • 2: 3 5 4 • 3: 5 2 • 4: 2 5 • 5: 4 2 3 • 6: 1 • Person 3’s list is empty • Reinstate the preference lists to their • status after original Phase 1 • 1: 6 • 2: 3 5 4 • 3: 52 • 4: 25 • 5: 4 2 3 • 6: 1
Let person 2 be rejected by person 3 • 1: 6 • 2: 3 5 4 • 3: 5 2 • 4: 2 5 • 5: 4 2 3 • 6: 1 • 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: 6 • 2: 3 5 4 • 3: 5 2 • 4: 2 5 • 5: 4 2 3 • 6: 1
Let person 2 be rejected by person 3 • 1: 6 • 2: 3 5 4 • 3: 5 2 • 4: 2 5 • 5: 4 2 3 • 6: 1 • 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: 6 • 2: 3 5 4 • 3: 5 2 • 4: 2 5 • 5: 4 2 3 • 6: 1
Let person 2 be rejected by person 3 • 1: 6 • 2: 3 5 4 • 3: 5 2 • 4: 2 5 • 5: 4 2 3 • 6: 1 • 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: 6 • 2: 3 5 4 • 3: 5 2 • 4: 2 5 • 5: 4 2 3 • 6: 1