Lecture 31: Stable Matchings
COSC 311 Algorithms, Fall 2022
- Stable Marriage Problem
- Gale-Shapley Algorithm
- Different Perspectives
Internship Assignment Problem
It is internship application season!
In a small world…
- Four students: $a, b, c, d$
- Four internships: $A, B, C, D$
Question. How should we assign students to internships?
Agents have preferences in the form of a strict ranking of alternatives
- each student ranks available internships
- each internship ranks available students
How do we decide whether a matching “respects” agents’ preferences?
Blocking Pairs and Stability
- students, internships, preferences
- matching $M$
We say $(s, t)$ is a blocking pair if
- $s$ and $t$ are not matched with each other
- $s$ prefers $t$ to assigned internship in $M$
- $t$ prefers $s$ to assigned student in $M$
Blocking Pair Illustration
Blocking Pair Illustration
Stable Marriage Problem
- set of $n$ students
- set of $n$ interships
- for each student $s$, preference list ranking all internships
- for each internship $t$, preference list ranking all students
- a matching $M$ between students and internships
- $M$ is stable
- there are no blocking pairs
- Do stable matchings always exist?
- are there sets of preference lists for which there is no stable matching?
- How can we find a stable matching (if one does exist)?
Theorem (Gale-Shapley 1962). Yes! Stable matchings always exist, and there is an efficient algorithm to find one.
- initially, all students/internships unmatched
- while some student is unmatched
- for each unmatched student $s$,
- $s$ applies to next favorite internship
- for each internship $t$
- $t$ defers best applicant so far, rejects others
- rejected students unmatch
- Students apply sequentially in decreasing order of preference
- $s$ only applies to $t$ after $s$ has been rejected by all preferred internships
- For each internship, deferred candidates are increasingly preferred
- Once an internship receives an application, it stays matched
Claim 1. Gale-Shapley terminates after at most $n (n - 1) + 1$ applications.
Claim 2. When Gale-Shapley terminates, the resulting matching is stable.
Theorem (Gale-Shapley, 1962). Every instance of the stable marriage problem admits a stable matching. If there are $n$ students and internships, a stable matching can be found in $O(n^2)$ time.
Influence and Applications
- Introduced stability as key concept in economics
- 8,000+ papers spanning econ/cs/math
- 2012 Nobel Prize in economics (Roth and Shapley)
- stable allocations and mechanism design
- matching med students with residencies
- content delivery networks
- kidney exchanges (variant)
Influence on My Research
Stable matchings in a decentralized setting
- Each agent is own computational entity
- Agents must communicate in order
Is it reasonable to assume all agents explicitly know their own preferences?
Do not assume preferences are explicitly known:
- match-maker interacts with agents by performing queries
- a query is simply a yes/no (Boolean) function about preferences
- e.g., “Would you prefer to work for a large company, or a small company?”
- match maker performs queries until enough information about preferences is elicited to determine a stable matching
Note. Gale-Shapley can be implemented with $O(n^2 \log n)$ queries.
Theorem (Gonczarowski, Nisan, Ostrovsky, R–). Any mechanism that finds or verifies a stable matching uses $\Omega(n^2)$ queries in the worst case.
- finding/verifying stable matchings reveals a significant amount of information about preferences
- running time of Gale-Shapley is optimal, up to $\log n$ factor
Finding “almost stable” matchings also requires $\Omega(n^2)$ queries.
- Social/political/biological/… problems can be viewed through the lense of algorithms
- Algorithmic methods and complexity measures can yield insights into natural measures of efficiency and quality of solutions
- Such investigation can give quantitative explanation to qualitative behavior
- Theorems are imporant
After the Break
Reductions and NP-completeness
To what extent can we show that a problem cannot be solved efficiently?