Encyclopedia of Algorithms

Living Edition
| Editors: Ming-Yang Kao

The Hospitals/Residents Problem

  • David F. ManloveEmail author
Living reference work entry
DOI: https://doi.org/10.1007/978-3-642-27848-8_180-2

Keywords

Matching Stability 

Synonyms

Years and Authors of Summarized Original Work

1962; Gale, Shapley

Problem Definition

An instance I of the Hospitals/Residents problem (HR) [6, 7, 18] involves a set \(R =\{ r_{1},\ldots,r_{n}\}\) of residents and a set \(H =\{ h_{1},\ldots,h_{m}\}\) of hospitals. Each hospital h j H has a positive integral capacity, denoted by c j . Also, each resident r i R has a preference list in which he ranks in strict order a subset of H. A pair \((r_{i},h_{j}) \in R \times H\) is said to be acceptable if h j appears in r i ’s preference list; in this case r i is said to find hj acceptable. Similarly each hospital h j H has a preference list in which it ranks in strict order those residents who find h j acceptable. Given any three agents \(x,y,z \in R \cup H\), x is said to prefer y to z if x finds each of y and z acceptable, and y precedes z on x’s preference list. Let \(C =\sum _{h_{j}\in H}c_{j}\).

Let A denote the set of acceptable pairs in I, and let L = | A |. An assignment M is a subset of A. If (r i , h j ) ∈ M, r i is said to be assigned to h j , and h j is assigned r i . For each \(q \in R \cup H\), the set of assignees of q in M is denoted by M(q). If r i R and M(r i ) = , r i is said to be unassigned; otherwise r i is assigned. Similarly, any hospital h j H is under-subscribed, full, or over-subscribed according as | M(h j ) | is less than, equal to, or greater than c j , respectively.

A matching M is an assignment such that \(\vert M(r_{i})\vert \leq 1\) for each r i R and \(\vert M(h_{j})\vert \leq c_{j}\) for each h j H (i.e., no resident is assigned to an unacceptable hospital, each resident is assigned to at most one hospital, and no hospital is over-subscribed). For notational convenience, given a matching M and a resident r i R such that \(M(r_{i})\neq \varnothing \), where there is no ambiguity, the notation M(r i ) is also used to refer to the single member of M(r i ).

A pair \((r_{i},h_{j}) \in A\setminus M\) blocks a matching M or is a blocking pair for M, if the following conditions are satisfied relative to M:
  1. 1.

    r i is unassigned or prefers h j to M(r i );

     
  2. 2.

    h j is under-subscribed or prefers r i to at least one member of M(h j ) (or both).

     

A matching M is said to be stable if it admits no blocking pair. Given an instance I of HR, the problem is to find a stable matching in I.

Key Results

HR was first defined by Gale and Shapley [6] under the name “College Admissions Problem.” In their seminal paper, the authors’ primary consideration is the classical Stable Marriage problem (SM; see Entries “Stable Marriage” and “Optimal Stable Marriage”), which is a special case of HR in which n = m, A = R × H, and c j = 1 for all h j H – in this case, the residents and hospitals are more commonly referred to as the men and women, respectively. Gale and Shapley showed that every instance I of HR admits at least one stable matching. Their proof of this result is constructive, i.e., an algorithm for finding a stable matching in I is described. This algorithm has become known as the Gale/Shapley algorithm.

An extended version of the Gale/Shapley algorithm for HR is shown in Fig. 1. The algorithm involves a sequence of apply and delete operations. At each iteration of the while loop, some unassigned resident r i with a nonempty preference list applies to the first hospital h j on his list and becomes provisionally assigned to h j (this assignment could subsequently be broken). If h j becomes over-subscribed as a result of this assignment, then h j rejects its worst assigned resident r k . Next, if h j is full (irrespective of whether h j was over-subscribed earlier in the same loop iteration), then for each resident r l that h j finds less desirable than its worst assigned resident r k , the algorithm deletes the pair (r l , h j ), which comprises deleting h j from r l ’s preference list and vice versa.

Fig. 1

Gale/Shapley algorithm for HR

Given that the above algorithm involves residents applying to hospitals, it has become known as the Resident-oriented Gale/Shapley algorithm, or RGS algorithm for short [7, Section 1.6.3]. The RGS algorithm terminates with a stable matching, given an instance of HR [6] [7, Theorem 1.6.2]. Using a suitable choice of data structures (extending those described in [7, Section 1.2.3]), the RGS algorithm can be implemented to run in O(L) time. This algorithm produces the unique stable matching that is simultaneously best possible for all residents [6] [7, Theorem 1.6.2]. These observations may be summarized as follows:

Theorem 1.

Given an instance of HR, the RGS algorithm constructs, in O(L) time, the unique stable matching in which each assigned resident obtains the best hospital that he could obtain in any stable matching, while each unassigned resident is unassigned in every stable matching.

A counterpart of the RGS algorithm, known as the Hospital-oriented Gale/Shapley algorithm, or HGS algorithm for short [7, Section 1.6.2], gives the unique stable matching that similarly satisfies an optimality property for the hospitals [7, Theorem 1.6.1].

Although there may be many stable matchings for a given instance I of HR, some key structural properties hold regarding unassigned residents and under-subscribed hospitals with respect to all stable matchings in I, as follows.

Theorem 2.

For a given instance of HR:
  • The same residents are assigned in all stable matchings;

  • Each hospital is assigned the same number of residents in all stable matchings;

  • Any hospital that is under-subscribed in one stable matching is assigned exactly the same set of residents in all stable matchings.

These results are collectively known as the “Rural Hospitals Theorem” (see [7, Section 1.6.4] for further details). Furthermore, the set of stable matchings in I forms a distributive lattice under a natural dominance relation [7, Section 1.6.5].

Applications

Practical applications of HR are widespread, most notably arising in the context of centralized automated matching schemes that assign applicants to posts (e.g., medical students to hospitals, school leavers to universities, and primary school pupils to secondary schools). Perhaps the largest and best-known example of such a scheme is the National Resident Matching Program (NRMP) in the USA [8], which annually assigns around 31,000 graduating medical students (known as residents) to their first hospital posts, taking into account the preferences of residents over hospitals and vice versa and the hospital capacities. Counterparts of the NRMP are in existence in other countries, including Canada [9] and Japan [10]. These matching schemes essentially employ extensions of the RGS algorithm for HR.

Centralized matching schemes based largely on HR also occur in other practical contexts, such as school placement in New York [1], university faculty recruitment in France [3], and university admission in Spain [16]. Further applications are described in [15, Section 1.3.7].

Indeed, the Nobel Prize in Economic Sciences was awarded in 2012 to Alvin Roth and Lloyd Shapley, partly for their theoretical work on HR and its variants [6, 18] and partly for their contribution to the widespread deployment of algorithms for HR in practical settings such as junior doctor allocation as noted above.

Extensions of HR

One key extension of HR that has considerable practical importance arises when an instance may involve a set of couples, each of which submits a joint preference list over pairs of hospitals (typically in order that the members of the couple can be located geographically close to one another). The extension of HR in which couples may be involved is denoted by HRC; the stability definition in HRC is a natural extension of that in HR (see [15, Section 5.3] for a formal definition of HRC). It is known that an instance of HRC need not admit a stable matching (see [4]). Moreover, the problem of deciding whether an HRC instance admits a stable matching is NP-complete [17].

HR may be regarded as a many-one generalization of SM. A further generalization of SM is to a many-many stable matching problem, in which both residents and hospitals may be multiply assigned subject to capacity constraints. In this case, residents and hospitals are more commonly referred to as workers and firms, respectively. There are two basic variations of the many-many stable matching problem according to whether workers rank (i) individual acceptable firms in order of preference and vice versa or (ii) acceptable subsets of firms in order of preference and vice versa. Previous work relating to both models is surveyed in [15, Section 5.4].

Other variants of HR may be obtained if preference lists include ties. This extension is again important from a practical perspective, since it may be unrealistic to expect a popular hospital to rank a large number of applicants in strict order, particularly if it is indifferent among groups of applicants. The extension of HR in which preference lists may include ties is denoted by HRT. In this context three natural stability definitions arise, the so-called weak stability, strong stability, and super-stability (see [15, Section 1.3.5] for formal definitions of these concepts). Given an instance I of HRT, it is known that weakly stable matchings may have different sizes, and the problem of finding a maximum cardinality weakly stable matching is NP-hard (see entry “Stable Marriage with Ties and Incomplete Lists” for further details). On the other hand, in contrast to the case for weak stability, a super-stable matching in I need not exist, though there is an O(L) algorithm to find such a matching if one does [11]. Analogous results hold in the case of strong stability – in this case, an O(L2) algorithm [13] was improved by an O(CL) algorithm [14] and extended to the many-many case [5]. Furthermore, counterparts of the Rural Hospitals Theorem hold for HRT under each of the super-stability and strong stability criteria [11, 19].

A further generalization of HR arises when each hospital may be split into several departments, where each department has a capacity, and residents rank individual departments in order of preference. This variant is modeled by the Student-Project Allocation problem [15, Section 5.5]. Finally, the Hospitals/Residents problem under Social Stability [2] is an extension of HR in which an instance is augmented by a social network graph G (a bipartite graph whose vertices correspond to residents and hospitals and whose edges form a subset of A) such that a blocking pair must additionally satisfy the property that it forms an edge of G. Edges in G correspond to resident–hospital pairs that are acquainted with one another and therefore more likely to block a matching in practice.

Open Problems

As noted in Section “Applications,” ties in the hospitals’ preference lists may arise naturally in practical applications. In an HRT instance, weak stability is the most commonly-studied stability criterion, due to the guaranteed existence of such a matching. Attempting to match as many residents as possible motivates the search for large weakly stable matchings. Several approximation algorithms for finding a maximum cardinality weakly stable matching have been formulated (see “Stable Marriage with Ties and Incomplete Lists” and [15, Section 3.2.6] for further details). It remains open to find tighter upper and lower bounds for the approximability of this problem.

URL to Code

Ada implementations of the RGS and HGS algorithms for HR may be found via the following URL: http://www.dcs.gla.ac.uk/research/algorithms/stable.

Cross-References

Recommended Reading

  1. 1.
    Abdulkadiroǧlu A, Pathak PA, Roth AE (2005) The New York city high school match. Am Econ Rev 95(2):364–367CrossRefGoogle Scholar
  2. 2.
    Askalidis G, Immorlica N, Kwanashie A, Manlove DF, Pountourakis E (2013) Socially stable matchings in the Hospitals/Residents problem. In: Proceedings of the 13th Algorithms and Data Structures Symposium (WADS’13), London, Canada. Lecture Notes in Computer Science, vol 8037. Springer, pp 85–96Google Scholar
  3. 3.
    Baïou M, Balinski M (2004) Student admissions and faculty recruitment. Theor Comput Sci 322(2):245–265zbMATHCrossRefGoogle Scholar
  4. 4.
    Biró P, Klijn F (2013) Matching with couples: a multidisciplinary survey. Int Game Theory Rev 15(2):Article number 1340008Google Scholar
  5. 5.
    Chen N, Ghosh A (2010) Strongly stable assignment. In: Proceedings of the 18th annual European Symposium on Algorithms (ESA’10), Liverpool, UK. Lecture Notes in Computer Science, vol 6347. Springer, pp 147–158Google Scholar
  6. 6.
    Gale D, Shapley LS (1962) College admissions and the stability of marriage. Am Math Mon 69:9–15zbMATHMathSciNetCrossRefGoogle Scholar
  7. 7.
    Gusfield D, Irving RW (1989) The Stable Marriage Problem: Structure and Algorithms. MIT Press, Cambridge, USAzbMATHGoogle Scholar
  8. 8.
    http://www.nrmp.org (National Resident Matching Program website)
  9. 9.
    http://www.carms.ca (Canadian Resident Matching Service website)
  10. 10.
    http://www.jrmp.jp (Japan Resident Matching Program website)
  11. 11.
    Irving RW, Manlove DF, Scott S (2000) The Hospitals/Residents problem with Ties. In: Proceedings of the 7th Scandinavian Workshop on Algorithm Theory (SWAT’00), Bergen, Norway. Lecture Notes in Computer Science, vol 1851. Springer, pp 259–271Google Scholar
  12. 12.
    Irving RW, Manlove DF, Scott S (2002) Strong stability in the Hospitals/Residents problem. Technical report TR-2002-123, Department of Computing Science, University of Glasgow. Revised May 2005Google Scholar
  13. 13.
    Irving RW, Manlove DF, Sott S (2003) Strong stability in the Hospitals/Residents problem. In: Proceedings of the 20th Annual Symposium on Theoretical Aspects of Computer Science (STACS’03), Berlin, Germany. Lecture Notes in Computer Science, vol 2607. Springer, pp 439–450. Full version available as [12]Google Scholar
  14. 14.
    Kavitha T, Mehlhorn K, Michail D, Paluch KE (2007) Strongly stable matchings in time O(nm) and extension to the Hospitals-Residents problem. ACM Trans Algorithms 3(2):Article number 15Google Scholar
  15. 15.
    Manlove DF (2013) Algorithmics of matching under preferences. World Scientific, Hackensack, SingaporezbMATHCrossRefGoogle Scholar
  16. 16.
    Romero-Medina A (1998) Implementation of stable solutions in a restricted matching market. Rev Econ Des 3(2):137–147Google Scholar
  17. 17.
    Ronn E (1990) NP-complete stable matching problems. J Algorithms 11:285–304zbMATHMathSciNetCrossRefGoogle Scholar
  18. 18.
    Roth AE, Sotomayor MAO (1990) Two-sided matching: a study in game-theoretic modeling and analysis. Econometric society monographs, vol 18. Cambridge University Press, Cambridge/New York, USAGoogle Scholar
  19. 19.
    Scott S (2005) A study of stable marriage problems with ties. PhD thesis, Department of Computing Science, University of GlasgowGoogle Scholar

Copyright information

© Springer Science+Business Media New York 2015

Authors and Affiliations

  1. 1.School of Computing ScienceUniversity of GlasgowGlasgowUK