Strong Stability in the Hospitals/Residents
Problem
Rob Irving, David Manlove and Sandy
Scott
University of GlasgowDepartment of Computing Science
Supported by EPSRC grant GR/R84597/01,Nuffield Foundation award NUF-NAL-02, and RSE / SEETLLD Personal Research Fellowship
2
Hospitals/Residentsproblem (HR): Motivation
Graduating medical students or residents seek hospital appointments
Free-for-all markets are chaotic
Centralised matching schemes are in operation
Schemes produce stable matchings of residents to hospitals
National Resident Matching Program (US) other large-scale matching schemes, both
educational and vocational
3
A set H of hospitals, a set R of residents
Each resident r ranks a subset of H in strict order of preference r finds h acceptable if h appears on r’s
preference list
Each hospital h has ph posts, and ranks in strict order those residents who find h acceptable
A matching M is a subset of R×H such that:
1. (r,h)M implies that r finds h acceptable2. Each resident r is assigned at most one hospital
3. Each hospital h is assigned at most ph residents
Hospitals/Residentsproblem (HR): Definition
4
An instance of HR
r1: h2 h3 h1
r2: h2 h1
r3: h3 h2 h1
r4: h2 h3
r5: h2 h1 h3
r6: h3
h1:3: r2 r1 r3 r5
h2:2: r3 r2 r1 r4 r5
h3:1: r4 r5 r1 r3 r6
5
A matching in HR
r1: h2 h3 h1
r2: h2 h1
r3: h3 h2 h1
r4: h2 h3
r5: h2 h1 h3
r6: h3
h1:3: r2 r1 r3 r5
h2:2: r3 r2 r1 r4 r5
h3:1: r4 r5 r1 r3 r6
6
Stable matchings in HR
Matching M is stable if M admits no blocking pair
(r,h) is a blocking pair of matching M if:
1. r finds h acceptable and
2. either r is unmatched in M or r prefers h to his assigned hospital in
M and3. either h is undersubscribed in M
or h prefers r to its worst resident assigned in M
7
A blocking pair
r1: h2 h3 h1
r2: h2 h1
r3: h3 h2 h1
r4: h2 h3
r5: h2 h1 h3
r6: h3
h1:3: r2 r1 r3 r5
h2:2: r3 r2 r1 r4 r5
h3:1: r4 r5 r1 r3 r6
(r4, h2) is a blocking pair of matching M since:
• r4 finds h2 acceptable• r4 is unmatched in M• h2 prefers r4 to its worst resident assigned in M
8
A stable matching
r1: h2 h3 h1
r2: h2 h1
r3: h3 h2 h1
r4: h2 h3
r5: h2 h1 h3
r6: h3
h1:3: r2 r1 r3 r5
h2:2: r3 r2 r1 r4 r5
h3:1: r4 r5 r1 r3 r6
Example shows that, in a stable matching,
• one or more residents may be unmatched• one or more hospitals may be undersubscribed
9
Algorithmic results for HR
Every instance of HR admits at least one stable matching
Such a matching can be found in linear time using the Gale / Shapley algorithm
Resident-oriented version finds the resident-optimal stable matching Each resident obtains the best hospital that
he could obtain in any stable matching
Hospital-oriented version finds the hospital-optimal stable matching Each hospital obtains the best set of
residents that it could obtain in any stable matching
10
The Rural Hospitals Theorem
For a given instance of HR, there may be more than one stable matching, but:
All stable matchings have the same size
The same set of residents are matched in all stable matchings
Any hospital that is undersubscribed in one stable matching has exactly same residents in all stable matchings
This is the Rural Hospitals Theorem
11
Ties in the preference lists
Participants may wish to express ties in their preferences lists:
h1 : r7 (r1 r3) r5
version of HR with ties is HRT more general form of indifference involves
partial orders version of HR with partial orders is HRP Three stability definitions are possible:
Weak stability Strong stability Super-stability
12
r1:(h2 h3) h1
r2: h2 h1
r3: h3 (h1 h2)
r4: h2 h3
r5: h2 (h1 h3)
r6: h3
h1:3: r2 (r1 r3) r5
h2:2: r3 r2 (r1 r4 r5)
h3:1:(r4 r5) (r1 r3 r6)
An instance of HRT
13
Weak stability
Matching M is weakly stable if M admits no blocking pair
(r,h) is a blocking pair of matching M if:
1. r finds h acceptable2. either r is unmatched in M or r
strictly prefers h to his assigned hospital in M3. either h is undersubscribed in M or h
strictly prefers r to its worst resident assigned in M
That is, if (r,h) joined together, both would be better off
14
A weakly stable matching in HRT
r1:(h2 h3) h1
r2: h2 h1
r3: h3 (h1 h2)
r4: h2 h3
r5: h2 (h1 h3)
r6: h3
h1:3: r2 (r1 r3) r5
h2:2: r3 r2 (r1 r4 r5)
h3:1:(r4 r5) (r1 r3 r6)
Weakly stable matching has size 5
15
r1:(h2 h3) h1
r2: h2 h1
r3: h3 (h1 h2)
r4: h2 h3
r5: h2 (h1 h3)
r6: h3
h1:3: r2 (r1 r3) r5
h2:2: r3 r2 (r1 r4 r5)
h3:1:(r4 r5) (r1 r3 r6)
Weakly stable matching has size 6
A second weakly stable matching in HRT
16
Weak stability in HRT: algorithmic results
Weakly stable matching always exists and can be found in linear time
Gusfield and Irving, 1989
Weakly stable matchings can have different sizes Problem of finding a maximum cardinality weakly
stable matching is NP-hard, even if each hospital has 1 post (i.e. instance of stable marriage problem with ties and incomplete lists)
Iwama, Manlove, Miyazaki and Morita, ICALP ’99
Result holds even if the ties occur on one side only, at most one tie per list, and each tie is of length 2
Manlove, Irving, Iwama, Miyazaki, Morita, TCS 2002 Result also holds for minimum weakly stable matchings
17
Weak stability: lower bounds
Problem of finding a maximum cardinality weakly stable matching in HRT is APX-complete, even if each hospital has 1 post
Halldórsson, Iwama, Miyazaki, Morita, LATIN 2002 Ties on both sides, ties of length 2 Ties on one side only, ties of length ≤3
Halldórsson, Iwama, Miyazaki, Yanagisawa, ESA 2003 Ties on one side only, ties of length 2 NP-hard to approximate maximum within 21/19
Halldórsson, Irving, Iwama, Manlove, Miyazaki, Morita, Scott, TCS 2003
Ties on one side only, preference lists of constant length
Result also holds for minimum weakly stable matchings
18
Weak stability: upper bounds
Problem of finding a maximum or minimum cardinality weakly stable matching is approximable within 2
Manlove, Irving, Iwama, Miyazaki, Morita, TCS 2002 If each hospital has 1 post, problem of finding a maximum cardinality
weakly stable matching is approximable within: 2/(1+L-2) – ties on one side only, ties of length ≤L 13/7 – ties on both sides, ties of length 2
Halldórsson, Iwama, Miyazaki, Yanagisawa, ESA 2003 10/7 (expected) – ties on one side only, ≤1 tie per list, ties of length
2 7/4 (expected) – ties on both sides, ≤n ties, ties of length 2
Halldórsson, Iwama, Miyazaki, Yanagisawa, COCOON 2003 Let s+ and s- denote the sizes of a maximum and minimum cardinality
weakly stable matching, and let t be the number of lists with ties. If each hospital has 1 post, any weakly stable matching M satisfies:
s+ - t ≤ |M| ≤ s- + t Halldórsson, Irving, Iwama, Manlove, Miyazaki, Morita, Scott, TCS 2003
19
Super-stability
Matching M is super-stable if M admits no blocking pair
(r,h) is a blocking pair of matching M if:
1. r finds h acceptable2. either r is unmatched in M
or r strictly prefers h to his assigned hospital in M or r is indifferent between them
3. either h is undersubscribed in M or h strictly prefers r to its worst resident assigned in M or h is indifferent between them
That is, if (r,h) joined together, neither would be worse off
20
A matching is super-stable in an instance of HRT if it is stable in every instance of HR obtained by breaking the ties
A super-stable matching is weakly stable
“Rural Hospitals Theorem” also holds for HRT under super-stability
Irving, Manlove, Scott, SWAT 2000
A super-stable matching may not exist:
r1:(h1 h2) h1:1:(r1 r2)
r2:(h1 h2) h2:1:(r1 r2)
Super-stable matchings in HRT
21
Finding a super-stable matching
Stable marriage problem with ties (i.e. HRT with |R|=|H|=n and each hospital has 1 post):
O(n2) algorithm Irving, Discrete Applied Mathematics, 1994
General HRT case O(L) algorithm, where L is total length of preference
lists Algorithm can be extended to HRP case
Irving, Manlove, Scott, SWAT 2000
22
Strong stability in HRT
A matching M is strongly stable unless there is an acceptable pair (r,h)M such that, if they joined together, one would be better off and the other no worse off
Such a pair constitutes a blocking pair
A super-stable matching is strongly stable, and a strongly stable matching is weakly stable
Ties on one side only super-stability = strong stability
An instance of HRT may admit no strongly stable matching:
r1: h1 h2 h1:1:(r1 r2)
r2: h1 h2 h2:1: r1 r2
23
A blocking pair
r1: (h2 h3) h1
r2: h2 h1
r3: h3 h2 h1
r4: h2 h3
r5: h2 (h1 h3)
r6: h3
h1:3: r2 (r1 r3) r5
h2:2: r3 r2 (r1 r4 r5)
h3:1: (r4 r5) (r1 r3) r6
r4 and h2 form a blocking pair
24
Another blocking pair
r1: (h2 h3) h1
r2: h2 h1
r3: h3 h2 h1
r4: h2 h3
r5: h2 (h1 h3)
r6: h3
h1:3: r2 (r1 r3) r5
h2:2: r3 r2 (r1 r4 r5)
h3:1: (r4 r5) (r1 r3) r6
r1 and h3 form a blocking pair
25
Finding a strongly stable matching
Stable marriage problem with ties (i.e. HRT with |R|=|H|=n and each hospital has 1 post):
O(n4) algorithm Irving, Discrete Applied Mathematics, 1994
General HRT case O(L2) algorithm, where L is total length of preference lists
HRP case Deciding whether a strongly stable matching exists is NP-
complete Irving, Manlove, Scott, STACS 2003
26
The algorithm in brief
repeatprovisionally assign all free residents to hospitals at head of listform reduced provisional assignment graphfind critical set of residents and make corresponding deletions
until critical set is emptyform a feasible matchingcheck if feasible matching is strongly stable
27
An instance of HRT
r1: (h2 h3) h1
r2: h2 h1
r3: h3 h2 h1
r4: h2 h3
r5: h2 (h1 h3)
r6: h3
h1:3: r2 (r1 r3) r5
h2:2: r3 r2 (r1 r4 r5)
h3:1: (r4 r5) (r1 r3) r6
28
A provisional assignmentand a dominated resident
r1: (h2 h3) h1
r2: h2 h1
r3: h3 h2 h1
r4: h2 h3
r5: h2 (h1 h3)
r6: h3
h1:3: r2 (r1 r3) r5
h2:2: r3 r2 (r1 r4 r5)
h3:1: (r4 r5) (r1 r3) r6
29
A deletion
r1: (h2 h3) h1
r2: h2 h1
r3: h3 h2 h1
r4: h2 h3
r5: h2 (h1 h3)
r6: h3
h1:3: r2 (r1 r3) r5
h2:2: r3 r2 (r1 r4 r5)
h3:1: (r4 r5) (r1 r3) r6
30
Another provisional assignment
r1: (h2 h3) h1
r2: h2 h1
r3: h3 h2 h1
r4: h2 h3
r5: h2 (h1 h3)
r6: h3
h1:3: r2 (r1 r3) r5
h2:2: r3 r2 (r1 r4 r5)
h3:1: (r4 r5) (r1 r3) r6
31
Several provisional assignments
r1: (h2 h3) h1
r2: h2 h1
r3: h3 h2 h1
r4: h2 h3
r5: h2 (h1 h3)
r6: h3
h1:3: r2 (r1 r3) r5
h2:2: r3 r2 (r1 r4 r5)
h3:1: (r4 r5) (r1 r3) r6
32
Provisional assignment graph with one bound resident
r2
r3
r4
r5
r1h1:(3)
h2:(2)
h3:(1)
33
Removing a bound resident
r2
r3
r4
r5
r1h1:(3)
h2:(1)
h3:(1)
34
Reduced provisional assignment graph
r3
r4
r5
r1
h2:(1)
h3:(1)
35
r3
r4
r5
r1
h2:(1)
h3:(1)
Critical set
36
Critical set
r1: (h2 h3) h1
r2: h2 h1
r3: h3 h2 h1
r4: h2 h3
r5: h2 (h1 h3)
r6: h3
h1:3: r2 (r1 r3) r5
h2:2: r3 r2 (r1 r4 r5)
h3:1: (r4 r5) (r1 r3) r6
37
Deletions from the critical set, end of loop iteration
r1: (h2 h3) h1
r2: h2 h1
r3: h3 h2 h1
r4: h2 h3
r5: h2 (h1 h3)
r6: h3
h1:3: r2 (r1 r3) r5
h2:2: r3 r2 (r1 r4 r5)
h3:1: (r4 r5) (r1 r3) r6
38
Second loop iteration, starting with a provisional assignment
r1: (h2 h3) h1
r2: h2 h1
r3: h3 h2 h1
r4: h2 h3
r5: h2 (h1 h3)
r6: h3
h1:3: r2 (r1 r3) r5
h2:2: r3 r2 (r1 r4 r5)
h3:1: (r4 r5) (r1 r3) r6
39
Several provisional assignments
r1: (h2 h3) h1
r2: h2 h1
r3: h3 h2 h1
r4: h2 h3
r5: h2 (h1 h3)
r6: h3
h1:3: r2 (r1 r3) r5
h2:2: r3 r2 (r1 r4 r5)
h3:1: (r4 r5) (r1 r3) r6
40
Final provisional assignment graph with 4 bound residents
r2
r3
r4
r5
r1h1:(3)
h2:(2)
h3:(1)
41
Removing a bound resident
r2
r3
r4
r5
r1h1:(2)
h2:(2)
h3:(1)
42
Removing a second bound resident
r2
r3
r4
r5
r1h1:(2)
h2:(1)
h3:(1)
43
Removing a third bound resident
r2
r3
r4
r5
r1h1:(2)
h2:(0)
h3:(1)
44
Removing a bound resident with an additional provisional assignment
r2
r3
r4
r5
r1h1:(1)
h2:(0)
h3:(1)
45
Final reduced provisional assignment graph
r4h3:(1)
46
A feasible matching
This consists of:
1. the bound (resident,hospital) pairs
— (r1,h1), (r2,h2), (r3,h2), (r5,h1)
unioned together with:
2. perfect matching in the final reduced provisional assignment graph
— (r4,h3)
47
A strongly stable matching
r1: (h2 h3) h1
r2: h2 h1
r3: h3 h2 h1
r4: h2 h3
r5: h2 (h1 h3)
r6: h3
h1:3: r2 (r1 r3) r5
h2:2: r3 r2 (r1 r4 r5)
h3:1: (r4 r5) (r1 r3) r6
(r1,h1), (r2,h2), (r3,h2), (r4,h3), (r5,h1)
48
repeat {
while some resident r is free and has a non-empty list
for each hospital h at the head of r’s list {
provisionally assign r to h;
if h is fully-subscribed or over-subscribed {
for each resident r' dominated on h’s list
delete the pair (r',h); } }
form the reduced provisional assignment graph;
find the critical set Z of residents;
for each hospital h N(Z)
for each resident r in the tail of h’s list
delete the pair (r,h);
} until Z = ;
The algorithm in full (1)
49
The algorithm in full (2)
let G be the final provisional assignment graph;
let M be a feasible matching in G;
if M is strongly stable
output M;
else
no strongly stable matching exists;
50
Theoretical results
Algorithm has complexity O(L2), where L is total length of preference lists
Bounded below by complexity of finding a perfect matching in a bipartite graph
Matching produced by the algorithm is resident-optimal
“Rural Hospitals Theorem” holds for HRT under strong stability
51
Strong stability in HRP
HRP under strong stability is NP-complete even if each hospital has 1 post and all pairs
are acceptable
Reduction from RESTRICTED 3-SAT: Boolean formula B in CNF where each
variable v occurs in exactly two clauses as literal v, and exactly two clauses as literal ~v
52
Conclusions
O(nL) algorithm, where n is number of residents and L is total length of preference lists Kavitha, Mehlhorn, Michail, Paluch, STACS 2004
Find a weakly stable matching with minimum number of strongly stable blocking pairs
Size of strongly stable matchings relative to possible sizes of weakly stable matchings
Hospital-oriented algorithm