← Back to Gallery

Matching with Contracts

Hatfield and Milgrom (2005) extended stable matching so each match specifies contract terms (salary, location). Under substitutability, stable outcomes always exist and form a lattice — unifying matching, auctions, and equilibrium.

Doctors

d1 — Experienced Surgeon
(H-City, $200k) > (H-City, $150k) > (H-Rural, $180k) > (H-Rural, $120k)
d2 — Mid-Career Physician
(H-City, $200k) > (H-Rural, $180k) > (H-City, $150k) > (H-Rural, $120k)
d3 — Rural Health Advocate
(H-Rural, $200k) > (H-City, $180k) > (H-Rural, $150k) > (H-City, $120k)

Hospitals

H-City — Metropolitan Hospital
Quota: 2 positions
Prefers: higher-productivity doctors; willing to pay more for top talent
H-Rural — Community Hospital
Quota: 2 positions
Prefers: doctors who value rural practice; budget-constrained

Adjust Salary Offers

$180k
$150k

Contract Matching Result

Adjust salary offers and click "Run Contract Matching" to see the stable outcome.

Algorithm Steps

Waiting for run...
How this generalizes standard matching: When contracts only specify the pair (no salary terms), the model reduces exactly to the standard Gale-Shapley stable matching. The contract framework adds a rich set of terms that can be negotiated, while preserving the lattice structure of stable outcomes.

Hatfield-Milgrom Theorem (2005)

Under the substitutability condition on hospital choice functions — if a hospital chooses contract X from a set S, it also chooses X from any subset of S containing X — the set of stable outcomes is nonempty and forms a lattice. This unifies:

  • Stable matching (Gale-Shapley, 1962) — contracts specify only the pair
  • Package auctions — contracts specify items and prices
  • Competitive equilibrium — contracts specify goods and wages

The substitutability condition means: as a hospital's options improve (more contracts available), it doesn't suddenly want contracts it previously rejected. This is the key economic condition that makes stable outcomes work.

Hatfield, J.W. & Milgrom, P. (2005). "Matching with Contracts." American Economic Review, 95(4): 913-935.