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 S={s1ā,ā¦,snā}
A set of hospitals H={h1ā,āÆ,hmā}
Each student sāS has a strict preference order over H, denoted by ā»sā
Each hospital hāH has a strict preference order over S, denoted by ā»hā
A matching M:SāH 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 m times to indicate that the hospital is willing to accept upto m students; and we can insert dummy nodes too, if needed,
Then, a pair (s,h)āSĆH blocks a matching M if hā»sāM(s) and sā»hāMā1(h). That is, both s and h 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 M 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 n2 iterations with a stable matching.
Proof:
n2 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 n2 proposals, and hence, n2 iterations.
Terminates with a perfect matching (i.e., everyone is matched):
If not, some student (say, x) is rejected from all n 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 x was rejected from all hospitals, then all hospitals are matched (because they would only reject x if they found someone better).
Contradiction! If all n hospitals are matched, and each hospital is matched with a unique student, then all the n students must be matched too.
The perfect matching is stable:
Consider a student s and a hospital not matched to each other
Case 1: s never proposed to h This means that s got matched to a better hospital than s, since s goes down her list of preferred hospitals
Case 2: h rejected s But h would only reject s if it found a better student than s.
So, weāve shown that the only way a (s,h) 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 sāS, a hospital hāH is called valid if there exists some stable matching M such that M(s)=h. Let best(s) be the most highly ranked valid hospital for s.
Define a valid student for a hospital similarly. And let worst(h) be the least highly-ranked valid student for h.
š” Theorem: The G-S algorithm (with students proposing) assigns:
Each student sāS to the hospital best(s), and
Each hospital hāH to the student worst(h)
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 s is assigned to best(s)
Proof: Asusme for contradiction that this is not the case.
There is a student s that is NOT assigned to best(s)
Of course, s cannot be matched with any hospital above best(s) in the final matching because that would contradict the definition of best(s).
So, s must be matched to a hospital below best(s). But this can only happen if s proposed to best(s) AND got rejected from it.
Further let s 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, āxāSā{s},xĀ hasĀ notĀ beenĀ rejectedĀ fromĀ best(x)Ā yet. And let best(s)=h (and by definition, h must be a valid hospital ā (s,h) must be part of some stable matching).
Suppose that s ends up matched to some hā², where hā»sāhā².
h mustāve rejected s in favor of some better student, sā² (since sā²ā»hās)
Since s is the first student to be rejected by her best valid hospital, hā½sā²ābest(sā²) ā sā² could not have been rejected by best(sā²) yet, and since students go down their list while proposing.
There exists another stable matching Mā² where s is matched to h ā since best(s)=h needs to be āvalidā.
And in that matching Mā², suppose that sā² is matched to hā²ā²ī =h (canāt be h because h is taken by s).
So, we have: hā²ā²ā¼sā²ābest(sā²)ā¼sā²āh, so hā²ā²āŗsā²āh
But since h rejected s in favor of sā² (i.e., h likes sā² more than s) AND sā² likes h more than hā²ā², then (sā²,h) forms a blocking pair in Mā² ā h would rather choose sā² over s, and sā² would rather choose h over hā²ā².
But this contradicts the fact that Mā² is a stable matching.
Hence, s is never rejected from best(s) ā and this holds true for any s.
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