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}S = \{s_1, \dots, s_n\}

  • A set of hospitals H={h1,⋯ ,hm}H= \{h_1, \cdots, h_m \}

  • Each student s∈Ss \in S has a strict preference order over HH, denoted by ≻s\succ_s

  • Each hospital h∈Hh \in H has a strict preference order over SS, denoted by ≻h\succ_h

  • A matching M:S→HM : S \to 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 mm times to indicate that the hospital is willing to accept upto mm students; and we can insert dummy nodes too, if needed,

Then, a pair (s,h)∈SƗH(s, h) \in S \times H blocks a matching MM if h≻sM(s)h \succ_s M(s) and s≻hMāˆ’1(h)s \succ_h M^{-1}(h). That is, both ss and hh 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 MM 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):

  1. Start with all students unassigned.

  2. While there are unassigned students

    1. 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)

    2. 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.

  3. Return the resulting matching.

Theorem: The G-S algorithm terminates in at most n2n^2 iterations with a stable matching.

Proof:

  • n2n^2 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 n2n^2 proposals, and hence, n2n^2 iterations.

  • Terminates with a perfect matching (i.e., everyone is matched):

    • If not, some student (say, xx) is rejected from all nn 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 xx was rejected from all hospitals, then all hospitals are matched (because they would only reject xx if they found someone better).

    • Contradiction! If all nn hospitals are matched, and each hospital is matched with a unique student, then all the nn students must be matched too.

  • The perfect matching is stable:

    • Consider a student ss and a hospital not matched to each other

    • Case 1: ss never proposed to hh This means that ss got matched to a better hospital than ss, since ss goes down her list of preferred hospitals

    • Case 2: hh rejected ss But hh would only reject ss if it found a better student than ss.

    • So, we’ve shown that the only way a (s,h)(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∈Ss \in S, a hospital h∈Hh \in H is called valid if there exists some stable matching MM such that M(s)=hM(s)=h. Let best(s)best(s) be the most highly ranked valid hospital for ss.

Define a valid student for a hospital similarly. And let worst(h)worst(h) be the least highly-ranked valid student for hh.

šŸ’” Theorem: The G-S algorithm (with students proposing) assigns:

  • Each student s∈Ss \in S to the hospital best(s)best(s), and

  • Each hospital h∈Hh \in H to the student worst(h)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 ss is assigned to best(s)best(s)

Proof: Asusme for contradiction that this is not the case.

  • There is a student ss that is NOT assigned to best(s)best(s)

  • Of course, ss cannot be matched with any hospital above best(s)best(s) in the final matching because that would contradict the definition of best(s)best(s).

  • So, ss must be matched to a hospital below best(s)best(s). But this can only happen if ss proposed to best(s)best(s) AND got rejected from it.

  • Further let ss 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\forall x \in S \setminus \{s\}, x \text{ has not been rejected from } best(x) \text{ yet}. And let best(s)=hbest(s)=h (and by definition, hh must be a valid hospital — (s,h)(s,h) must be part of some stable matching).

  • Suppose that ss ends up matched to some h′h', where h≻sh′h \succ_s h'.

  • hh must’ve rejected ss in favor of some better student, s′s' (since s′≻hss' \succ_h s)

  • Since ss is the first student to be rejected by her best valid hospital, h≽s′best(s′)h \succcurlyeq_{s'} best(s') — s′s' could not have been rejected by best(s′)best(s') yet, and since students go down their list while proposing.

  • There exists another stable matching M′M' where ss is matched to hh — since best(s)=hbest(s)=h needs to be ā€œvalidā€.

  • And in that matching M′M', suppose that s′s' is matched to h′′≠hh'' \neq h (can’t be hh because hh is taken by ss).

  • So, we have: h′′≼s′best(s′)≼s′hh'' \preccurlyeq_{s'} best(s') \preccurlyeq_{s'} h, so h′′≺s′hh'' \prec_{s'} h

  • But since hh rejected ss in favor of s′s' (i.e., hh likes s′s' more than ss) AND s′s' likes hh more than h′′h'', then (s′,h)(s', h) forms a blocking pair in M′M' — hh would rather choose s′s' over ss, and s′s' would rather choose hh over h′′h''.

  • But this contradicts the fact that M′M' is a stable matching.

  • Hence, ss is never rejected from best(s)best(s) — and this holds true for any ss.

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