← Agora

Matching Markets

Candidates rank companies; companies rank candidates back. No prices, no central planner: just deferred acceptance: propose, hold the best offer tentatively, reject the rest, repeat. The result is a stable matching (no pair would rather elope), but it quietly favours whoever does the proposing, and only the proposing side can safely tell the truth. The algorithm behind the real hospital match. Live runs the real Python engine in your browser via Pyodide.

The market

One side (circles) pairs off with the other (squares, filled by how many posts are taken). Scrub the rounds: proposals land, engagements form tentatively and a better offer bumps the old one. The rejection then ripples on. A red ring is an agent the market left unmatched.

candidates companies engaged rejected / bumped unmatched

The matching

Each pair, with the rank every agent gave the partner it ended up with: #left · #right. #1 means first choice.

Who proposes, wins

Average rank of the partner each side receives (lower is better), under both directions. Deferred acceptance hands the proposing side its best stable outcome and the other side its worst.

Live exploration

Random market, both directions, run by the real engine. Watch the proposing side's average rank beat the receiving side's on almost every draw.

Things to notice

No one wants to elope

When the music stops, check any candidate–company pair: at least one of the two prefers what they already have. That's stability: the matching polices itself, with no contracts and no enforcement.

What stability buys

Who proposes, wins

Load "Who proposes, wins": the same market has three stable matchings, and the algorithm picks whichever end of that range favours the proposing side. Neutral procedure, partisan outcome.

Proposer-optimality

Honesty is one-sided

No proposer can ever gain by misreporting, proved here by brute force, not by theorem. But in "The profitable lie", a receiving company games the match just by shortening its list.

One-sided strategy-proofness

The rural hospital rule

In "Hospitals & residents", the unpopular hospital fills the same single post (and the same resident goes unmatched) in every stable matching. No mechanism choice can staff the countryside.

The rural hospital theorem