Skip to article frontmatterSkip to article content

Matching Games

Motivating Example: Stable peer review assignment at a research conference

The Social Perspectives Research Symposium receives five paper submissions and recruits five expert reviewers. Each paper must be assigned to exactly one reviewer.

To promote high-quality reviews, both authors and reviewers submit ranked preference lists:

The participants are:

For example:

“R3’s expertise would be invaluable for my analysis.”
“A4’s topic fits directly with my current research.”
“R5’s previous reviews have been extremely helpful.”

The preferences of the authors are given in Table 1 and the preferences of the reviewers are given in Table 2.

Table 1:Preference table for the authors

Author1st2nd3rd4th5th
A1R3R1R4R5R2
A2R2R4R3R5R1
A3R5R2R3R1R4
A4R2R3R5R1R4
A5R5R3R4R2R1

The organizers aim to compute a stable matching: an assignment where no author-reviewer pair exists who would both prefer to be assigned to each other over their current assignments.

Table 2:Preference table for the reviewers

Reviewer1st2nd3rd4th5th
R1A3A1A5A4A2
R2A4A2A5A1A3
R3A1A5A2A3A4
R4A2A5A3A1A4
R5A5A3A4A1A2

Theory

Definition: Matching Game

A matching game of size NN is defined by two disjoint sets SS and RR or proposers and reviewers of size NN. Associated to each element of SS and RR is a preference map:

f:SRN and g:RSNf:S\to R^N\text{ and }g:R\to S^N

A matching MM is any bijection between SS and RR. If sSs\in S and rRr\in R are matched by MM we denote:

M(s)=rM(s)=r

Example: Author Reviewer as a Matching Game

For Motivating Example: Stable peer review assignment at a research conference the matching game has size N=5N=5, the set of proposers S=(A1,A2,A3,A4,A5)S=(A1, A2, A3, A4, A5) the set of reviewers R=(R1,R2,R3,R4,R5)R=(R1, R2, R3, R4, R5) and the preference maps:

f(A1)=(R3,R1,R4,R5,R2)f(A2)=(R2,R4,R3,R5,R1)f(A3)=(R5,R2,R3,R1,R4)f(A4)=(R2,R3,R5,R1,R4)f(A5)=(R5,R3,R4,R2,R1)g(R1)=(A3,A1,A5,A4,A2)g(R2)=(A4,A2,A5,A1,A3)g(R3)=(A1,A5,A2,A3,A4)g(R4)=(A2,A5,A3,A1,A4)g(R5)=(A5,A3,A4,A1,A2)\begin{align*} f(A1)&=(R3, R1, R4, R5, R2)\\ f(A2)&=(R2, R4, R3, R5, R1)\\ f(A3)&=(R5, R2, R3, R1, R4)\\ f(A4)&=(R2, R3, R5, R1, R4)\\ f(A5)&=(R5, R3, R4, R2, R1)\\ g(R1)&=(A3, A1, A5, A4, A2)\\ g(R2)&=(A4, A2, A5, A1, A3)\\ g(R3)&=(A1, A5, A2, A3, A4)\\ g(R4)&=(A2, A5, A3, A1, A4)\\ g(R5)&=(A5, A3, A4, A1, A2) \end{align*}

One potential mapping is given by:

M(A1)=R3M(A2)=R2M(A3)=R5M(A4)=R1M(A5)=R4\begin{align*} M(A1) &= R3\\ M(A2) &= R2\\ M(A3) &= R5\\ M(A4) &= R1\\ M(A5) &= R4 \end{align*}

Definition: a blocking pair

A pair (s,r)(s,r) is said to block a matching MM if M(s)rM(s)\ne r but ss prefers rr to M(s)M(s) and rr prefers ss to M1(r)M^{-1}(r).

Example: Blocking pair for the author reviewer game

In (4) the pair (A4,R2)(A4, R2) is a blocking pair as A4A4 prefer R2R2 to M(A4)M(A4) and R2R2 prefers A4A4 to M1(R2)M^{-1}(R2).

Definition: a stable matching

A matching MM with no blocking pair is said to be stable.

Example: A stable matching for the author reviewer game

The following is a stable matching for Motivating Example: Stable peer review assignment at a research conference:

M(A1)=R3M(A2)=R4M(A3)=R1M(A4)=R2M(A5)=R5\begin{align*} M(A1) &= R3\\ M(A2) &= R4\\ M(A3) &= R1\\ M(A4) &= R2\\ M(A5) &= R5 \end{align*}

Definition: The Gale-Shapley algorithm

Here is the Gale-Shapley algorithm, which gives a stable matching for a matching game:

  1. Assign every sSs\in S and rRr\in R to be unmatched
  2. Pick some unmatched sSs\in S, let rr be the top of ss’s preference list:
    • If rr is unmatched set M(s)=rM(s)=r
    • If rr is matched:
      • If rr prefers ss to M1(r)M^{-1}(r) then set M(r)=sM(r)=s
      • Otherwise ss remains unmatched and remove rr from ss’s preference list.
  3. Repeat step 2 until all sSs\in S are matched.

Theorem: Unique matching as output of the Gale Shapley algorithm

All possible executions of the Gale-Shapley algorithm yield the same stable matching and in this stable matching every suitor has the best possible partner in any stable matching.

Proof

Suppose that an arbitrary execution α\alpha of the algorithm gives MM and that another execution β\beta gives MM' such that \exists sSs\in S such that ss prefers r=M(s)r'=M'(s) to r=M(s)r=M(s).

Without loss of generality this implies that during α\alpha rr' must have rejected ss. Suppose, again without loss of generality that this was the first occasion that a rejection occured during α\alpha and assume that this rejection occurred because r=M(s)r'=M(s'). This implies that ss' has no stable match that is higher in ss''s preference list than rr' (as we have assumed that this is the first rejection).

Thus ss' prefers rr' to M(s)M'(s') so that (s,r)(s',r') blocks MM'. Each suitor is therefore matched in MM with his favorite stable reviewer and since α\alpha was arbitrary it follows that all possible executions give the same matching.

Example: Application of the Gale-Shapley algorithm to the author reviewer game

We start by assigning A1,A2,A3,A4,A5A1, A2, A3, A4, A5 and R1,R2,R3,R4,R5R1, R2, R3, R4, R5 to be unmatched.

We pick A1A1 which has f(A1)=(R3,R1,R4,R5,R2)f(A1)=(R3, R1, R4, R5, R2), the top of the preference list is R1R1 so we set:

M(A1)=R3\begin{align*} M(A1) &= R3 \end{align*}

We now pick A2A2 which has f(A2)=(R2,R4,R3,R5,R1)f(A2)=(R2, R4, R3, R5, R1), the top of the preference list is R2R2 so we set:

M(A1)=R3M(A2)=R2\begin{align*} M(A1) &= R3\\ M(A2) &= R2\\ \end{align*}

We now pick A3A3 which has f(A3)=(R5,R2,R3,R1,R4)f(A3)=(R5, R2, R3, R1, R4), the top of the preference list is R5R5 so we set:

M(A1)=R3M(A2)=R2M(A3)=R5\begin{align*} M(A1) &= R3\\ M(A2) &= R2\\ M(A3) &= R5\\ \end{align*}

We now pick A4A4 which has f(A4)=(R2,R3,R5,R1,R4)f(A4)=(R2, R3, R5, R1, R4), the top of the preference list is R2R2 but R2R2 is matched (M(A2)=R2M(A2)=R2). We have g(R2)=(A4,A2,A5,A1,A3)g(R2)=(A4, A2, A5, A1, A3) so R2R2 prefers A2A2 then their current matching. So we set:

M(A1)=R3M(A3)=R5M(A4)=R2\begin{align*} M(A1) &= R3\\ M(A3) &= R5\\ M(A4) &= R2\\ \end{align*}

We now pick A2A2 (for the second time) which has f(A2)=(R2,R4,R3,R5,R1)f(A2)=(R2, R4, R3, R5, R1), the top of the preference list is R2R2 but R2R2 is matched and prefers their current matching so we remove it from A2A2’s preference list:

f(A2)=(R4,R3,R5,R1)f(A2)=(R4, R3, R5, R1)

We could pick any unmatched reviewer, we will pick A2A2 again (for the third time), A2A2 has preference list f(A)=(R4,R3,R5,R1)f(A)=(R4, R3, R5, R1), the top of the preference list is R4R4 so we set:

M(A1)=R3M(A2)=R4M(A3)=R5M(A4)=R2\begin{align*} M(A1) &= R3\\ M(A2) &= R4\\ M(A3) &= R5\\ M(A4) &= R2\\ \end{align*}

We now pick A5A5, the final unmatched reviewer, which has f(A5)=(R5,R3,R4,R2,R1)f(A5)=(R5, R3, R4, R2, R1), the top of the preference list is R5R5 so we set:

M(A1)=R3M(A2)=R4M(A3)=R5M(A4)=R2M(A5)=R5\begin{align*} M(A1) &= R3\\ M(A2) &= R4\\ M(A3) &= R5\\ M(A4) &= R2\\ M(A5) &= R5\\ \end{align*}

Theorem: Reviewer sub optimality of the Gale Shapley Algorithm

In a suitor-optimal stable matching each reviewer has the worst possible matching.

Proof

Assume that the result is not true. Let M0M_0 be a suitor-optimal matching and assume that there is a stable matching MM' such that \exists rr such that rr prefers s=M01(r)s=M_0^{-1}(r) to s=M1(r)s'=M'^{-1}(r). This implies that (r,s)(r,s) blocks MM' unless ss prefers M(s)M'(s) to M0(s)M_0(s) which contradicts the fact the ss has no stable match that they prefer in M0M_0.

Exercises

Exercise: Application of the Gale Shapley Algorithm

Obtain stable suitor optimal and reviewer optimal matchings for the games shown:

  1. f(A1)=(R2,R1,R3)f(A2)=(R1,R3,R2)f(A3)=(R1,R3,R2)g(R1)=(A1,A2,A3)g(R2)=(A2,A1,A3)g(R3)=(A2,A3,A1)\begin{align*} f(A1)&=(R2, R1, R3)\\ f(A2)&=(R1, R3, R2)\\ f(A3)&=(R1, R3, R2)\\ g(R1)&=(A1, A2, A3)\\ g(R2)&=(A2, A1, A3)\\ g(R3)&=(A2, A3, A1)\\ \end{align*}
  2. f(A1)=(R1,R3,R2)f(A2)=(R2,R3,R1)f(A3)=(R1,R3,R2)g(R1)=(A1,A2,A3)g(R2)=(A2,A3,A1)g(R3)=(A2,A3,A1)\begin{align*} f(A1)&=(R1, R3, R2)\\ f(A2)&=(R2, R3, R1)\\ f(A3)&=(R1, R3, R2)\\ g(R1)&=(A1, A2, A3)\\ g(R2)&=(A2, A3, A1)\\ g(R3)&=(A2, A3, A1)\\ \end{align*}
  3. f(A1)=(R1,R4,R2,R3)f(A2)=(R2,R1,R3,R4)f(A3)=(R4,R1,R3,R2)f(A4)=(R1,R4,R3,R2)g(R1)=(A1,A4,A2,A3)g(R2)=(A1,A3,A4,A2)g(R3)=(A4,A1,A3,A2)g(R4)=(A2,A4,A1,A3)\begin{align*} f(A1)&=(R1, R4, R2, R3)\\ f(A2)&=(R2, R1, R3, R4)\\ f(A3)&=(R4, R1, R3, R2)\\ f(A4)&=(R1, R4, R3, R2)\\ g(R1)&=(A1, A4, A2, A3)\\ g(R2)&=(A1, A3, A4, A2)\\ g(R3)&=(A4, A1, A3, A2)\\ g(R4)&=(A2, A4, A1, A3)\\ \end{align*}
  4. f(A1)=(R2,R1,R4,R3)f(A2)=(R2,R3,R1,R4)f(A3)=(R1,R4,R3,R2)f(A4)=(R1,R4,R3,R2)g(R1)=(A1,A2,A4,A3)g(R2)=(A4,A2,A1,A3)g(R3)=(A4,A1,A3,A2)g(R4)=(A3,A2,A4,A1)\begin{align*} f(A1)&=(R2, R1, R4, R3)\\ f(A2)&=(R2, R3, R1, R4)\\ f(A3)&=(R1, R4, R3, R2)\\ f(A4)&=(R1, R4, R3, R2)\\ g(R1)&=(A1, A2, A4, A3)\\ g(R2)&=(A4, A2, A1, A3)\\ g(R3)&=(A4, A1, A3, A2)\\ g(R4)&=(A3, A2, A4, A1)\\ \end{align*}

Exercise: Uniqueness with a single reviewer preference list

Consider a matching game where all reviewers have the same preference list. Prove that there is a single stable matching.

Programming

The python Matching library Wilde et al., 2020 implements the Gale-Shapley algorithm as well as a number of other algorithms for different generalisations of matching games.

import matching
import matching.games

authors = [
    matching.Player("A1"),
    matching.Player("A2"),
    matching.Player("A3"),
    matching.Player("A4"),
    matching.Player("A5"),
]

reviewers = [
    matching.Player("R1"),
    matching.Player("R2"),
    matching.Player("R3"),
    matching.Player("R4"),
    matching.Player("R5"),
]

A1, A2, A3, A4, A5 = authors
R1, R2, R3, R4, R5 = reviewers

A1.set_prefs((R3, R1, R4, R5, R2))
A2.set_prefs((R2, R4, R3, R5, R1))
A3.set_prefs((R5, R2, R3, R1, R4))
A4.set_prefs((R2, R3, R5, R1, R4))
A5.set_prefs((R5, R3, R4, R2, R1))

R1.set_prefs((A3, A1, A5, A4, A2))
R2.set_prefs((A4, A2, A5, A1, A3))
R3.set_prefs((A1, A5, A2, A3, A4))
R4.set_prefs((A2, A5, A3, A1, A4))
R5.set_prefs((A5, A3, A4, A1, A2))

game = matching.games.StableMarriage(authors, reviewers)
game.solve()

Notable Research

The original Gale-Shapley algorithm was presented in Gale & Shapley, 1962, a rigorous combinatorial treatment of the algorithm is given in Knuth, 1976. Some refinements to the algorithm are given in Gusfield & Irving, 1989 which is considered to be the reference text on matching games.

In the original paper Gale & Shapley, 1962 Gale and Shapley present the so called hospital-resident matching problem which is a matching problem aiming to match many to one. They do so in the context of College admissions in North America. In Roth, 1984 presents the problem in the context of hospital resident assignement. Further to this, Roth considered the problem of kidney exchange in Roth et al., 2004 as a further matching problem.

In 2012, Lloyd Shapley and Alvin Roth were awarded the Nobel Prize in Economic Sciences for their contributions to stable matching and market design. David Gale, who co-authored the foundational 1962 paper introducing the Gale-Shapley algorithm, was ineligible for the award, having passed away in 2008.

Conclusion

In this chapter we introduced the theory of matching games, motivated by the practical problem of assigning reviewers to papers at a research conference. The central concept of stability ensures that no pair of participants would prefer to deviate from the assignment, making stable matchings attractive in many real-world settings.

The Gale-Shapley algorithm provides an elegant and efficient solution to the stable matching problem, always producing a suitor-optimal stable matching. While stable matchings always exist in the one-to-one setting, extensions to many-to-one settings (such as hospital-resident assignments) preserve many of the desirable properties of the original algorithm.

A summary of key concepts introduced in this chapter is given in Table 3.

Table 3:Summary of key concepts in matching games

ConceptDescription
Matching GameA game where two disjoint sets have preferences over each other
Stable MatchingA matching with no blocking pairs
Blocking PairA pair who would both prefer to be matched to each other over their current assignments
Gale-Shapley AlgorithmAn algorithm that produces a stable matching by iteratively proposing and accepting/rejecting proposals
Suitor-optimalityThe property that each suitor receives the best possible partner across all stable matchings
Reviewer-pessimalityThe property that in suitor-optimal matchings, each reviewer receives the worst acceptable partner
References
  1. Wilde, H., Knight, V., & Gillard, J. (2020). Matching: A python library for solving matching games. Journal of Open Source Software, 5(48), 2169.
  2. Gale, D., & Shapley, L. S. (1962). College admissions and the stability of marriage. The American Mathematical Monthly, 69(1), 9–15.
  3. Knuth, D. E. (1976). Mariages stables et leurs relations avec d’autres problèmes combinatoires. Les Presses de l’Université de Montréal.
  4. Gusfield, D., & Irving, R. W. (1989). The stable marriage problem: structure and algorithms. MIT press.
  5. Roth, A. E. (1984). The Evolution of the Labor Market for Medical Interns and Residents: A Case Study in Game Theory. Journal of Political Economy, 92(6), 991–1016.
  6. Roth, A. E., Sönmez, T., & Ünver, M. U. (2004). Kidney Exchange. Quarterly Journal of Economics, 119(2), 457–488.