Stable Matchings
Until now, we had been talking about markets with money. For example, auctions include items on sale, and players can bid money to buy them. The shapley value and core dealt with how to distribute the value generated (in the form of money) to the different players in the group.
But now, we consider markets without any money. Instead, we consider markets in which we have two groups (think: bipartite graph) and each of them have preferences for members of the other group. Here, “preferences” is asusmed to be a total order (aka ranking).
Examples;
Two-sided markets: Dating websites (guys have preferences over girls, and girls have preferences over guys), College Admission (students have preferences over colleges and colleges have preferences over students), Job markets, etc.
One-sided markets: Students bidding for courses (students have preferences over courses, but courses umm, hopefully, don’t), dormitory room assignment (students have preferences over rooms, but a room don’t care which student occupies it)
Barter Exchanges: Kidney exchange
What makes for a Good Market?
Again (like with Shapley value), we’re trying to make our desires explicit (about what we would like to achieve through the mechanism) and then we will try to find an algorithm that achieves these properties.
Thick — lots of buyers, lots of sellers, lots of options.. and everyone is aware of all the options available to them (i.e., transparency)
Timely — not too fast (people to have the time to weigh out decisions), not too slow (offers are processed quickly, and new offers arrive quickly)
Safe — people cannot be hurt by revealing preferences (aka truthfulness / strategyproof), outcomes are fair, and people are better off by participating than not (i.e. playing should have a positive payoff)
An example of a bad equilibium is companies trying to get the best students to sign full-time contracts long before they graduate so that other companies can’t “steal” them — this is bad for companies since they have less signal about the students at the time of offer, and bad for students because they don’t have all the options available to them. Another example is “exploding offers” by companies.
Stable Matchings
Consider the problem of medical students being assigned to hospitals (for their residency program) — it’s a two-sided market, and we hope to find a “fair” matching.
So, we have:
A set of students
A set of hospitals
Each student has a strict preference order over , denoted by
Each hospital has a strict preference order over , denoted by
A matching maps each student to a hospital.
Assume for simplicity that we have the same number of hospitals and students, though this is not an issue in practice because we can just “duplicate” a hospital node times to indicate that the hospital is willing to accept upto students; and we can insert dummy nodes too, if needed,
Then, a pair blocks a matching if and . That is, both and prefer each other over their current partners. So… they would rather run away from this mechanism and not participate (maybeee it’s easier to think of the dating app example — if boy x and girl y prefer each other over their current matches, they would (probably?) ditch their current partners, and go out with each other). It measures a notion of “deviation” — you don’t want any pair of players to have the incentive to ignore the matching’s advice, and deviate from the group.
A matching is called stable if there are no blocking pairs.
Gale-Shapley Algorithm
First of all, appreciate the difficulty of the problem we’re trying to solve. We’re trying to find a stable matching for any given preference order.
It’s not even obvious that such a matching exists in the first place! And even if it does exist, it’s not obvious whether it can be found in polynomial time.
Well… that’s why Gale and Shapley got the Nobel Price in Economics for coming up with this algorithm!
Btw, it’s also called (by very few folks) the “deferred acceptance” algorithm (since the assignments made during the algorithm are “temporary’ and is only “accepted” at the very end; hence, the acceptance has been deferred).
The algorithm is actually very simple (and elegant):
Start with all students unassigned.
While there are unassigned students
Each unassigned student proposes to his/her favorite not-yet-proposed-to hospital (i.e., a student cannot propose to the same hospital twice — hmm not bad advice even for the dating example)
Each hospital looks at the list of students that proposed to it in this round + whoever is assigned to it right now, and it chooses its most preferred student. Everyone else remains unassigned.
Return the resulting matching.
Theorem: The G-S algorithm terminates in at most iterations with a stable matching.
Proof:
iterations, because in each round there is at least one unassigned student, who will propose to a hospital — and since no student proposes to the same hospital twice, we can have at most proposals, and hence, iterations.
Terminates with a perfect matching (i.e., everyone is matched):
If not, some student (say, ) is rejected from all hospitals
A hospital only rejects a student in favor of a better student
So, once a hospital is matched, it remains matched throughout (meaning that there is some student attached to it, even though which student it is can change, it will only change to someone better)
Since was rejected from all hospitals, then all hospitals are matched (because they would only reject if they found someone better).
Contradiction! If all hospitals are matched, and each hospital is matched with a unique student, then all the students must be matched too.
The perfect matching is stable:
Consider a student and a hospital not matched to each other
Case 1: never proposed to This means that got matched to a better hospital than , since goes down her list of preferred hospitals
Case 2: rejected But would only reject if it found a better student than .
So, we’ve shown that the only way a pair is not matched is when at least one of them prefers their current partner to the other.
How Fair is the Gale-Shapley Algorithm?
Suppose that students’ preferences are such that each student ranks a different hospital first. Then, G-S terminates in a single round with a perfect stable matching. Sounds great right? Well… not really — because the hospitals didn’t get any say in this! They were only ever given the choice of a single student, and so it’s very “unfair” to them. In this case, the students get their top choice but the hospitals might not.
Note that the two groups (students and hospitals) are not treated the same way by the algorithm — that is, there is a “proposing” group and the other group that receives the proposals.
So, in general, when we “swap” the roles of the two groups, we shouldn’t expect to find the same stable matching. In fact, this is a way to test whether there exists only one unique stable matching — run the algorithm 2 times, one with students proposing and the other with hospitals proposing, and if they yield the same matching, then there is a unique matching.
Intuitively, the proposing group has more “power” (kind of?) because each of its members has the choice to propose to any of the other group members but the other group only sees the proposals it receives. So, it seems as if the algorithm “favors” the proposing group.
And indeed, this intuition turns out to be correct!
Given a student , a hospital is called valid if there exists some stable matching such that . Let be the most highly ranked valid hospital for .
Define a valid student for a hospital similarly. And let be the least highly-ranked valid student for .
💡 Theorem: The G-S algorithm (with students proposing) assigns:
Each student to the hospital , and
Each hospital to the student
Firstly, this is not an obvious claim — we’re saying that ALL the students get matched to their best valid hospital simultaneously (in a single matching!). So, looking at the matching determined by G-S, all students will find that they’ve reached the best scenario (given stability constraints).
Again, the intuition is that students go down their priority lists, so they only propose to a worse hospital IF they have been rejected from a better one… So, they get the best hospitals they can (we’ll prove it formally in a bit). And the opposite is true for the hospitals, because they don’t have any optionality here.
It’s clearly much better for the proposing side and worse for the side that receives proposals (i wonder if this is true even in the dating example hmm 🤔). So, it’s not “really’” fair because both sides would fight to be the proposing side in this algorithm.
Note: As the algorithm progresses, the quality of matches that a particular hospital gets increases (as it rejects students in favor of better students), and the quality of matches that a particular student gets decreases (as it gets rejected from hospitals and has to propose to worse hospitals). That is, hospitals go up their preference list, and students go down theirs.
We’ll only prove one part of the theorem above (the second is similar).
Claim: each student is assigned to
Proof: Asusme for contradiction that this is not the case.
There is a student that is NOT assigned to
Of course, cannot be matched with any hospital above in the final matching because that would contradict the definition of .
So, must be matched to a hospital below . But this can only happen if proposed to AND got rejected from it.
Further let be the first student rejected by her best valid hospital (i.e., none of the other students have been rejected by their respective best valid hospitals yet). Precisely, . And let (and by definition, must be a valid hospital — must be part of some stable matching).
Suppose that ends up matched to some , where .
must’ve rejected in favor of some better student, (since )
Since is the first student to be rejected by her best valid hospital, — could not have been rejected by yet, and since students go down their list while proposing.
There exists another stable matching where is matched to — since needs to be “valid”.
And in that matching , suppose that is matched to (can’t be because is taken by ).
So, we have: , so
But since rejected in favor of (i.e., likes more than ) AND likes more than , then forms a blocking pair in — would rather choose over , and would rather choose over .
But this contradicts the fact that is a stable matching.
Hence, is never rejected from — and this holds true for any .
Some other important Results:
Gale-Shapley is non-truthful for non-proposing participants, but truthful from the point of view of the proposing dside. But successful mirepresentation requires knowledge of the other agents’ preferences too — without such knowledge, misrepresentation could give an agent a worse assignment. So, it’s a “regret-free truth-telling mechanism” in that even after seeing the final matching, an agent cannot deduce a strategy that could guarantee a better outcome in hindsight.
There is a known impossibility result that it is IMPOSSIBLE to design a mechanism that is simultaneously truthful for both sides AND always produces a stable matching. (i.e., G-S is the next best thing we can hope for)
Last updated