Repository navigation
🧩 Constraint Solving POTD:Problem of the Day: Stable Marriage Problem #71421
Closed
Replies: 1 comment
|
This discussion has been marked as outdated by Constraint Solving — Problem of the Day. A newer discussion is available at Discussion #71634. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem Statement
The Stable Marriage Problem (SMP) asks: given
nmen andnwomen, each with a ranked preference list of all members of the opposite gender, can we find a perfect matching where no unmatched pair would both prefer each other to their current partners?Concrete Instance
Consider 3 men (M1, M2, M3) and 3 women (W1, W2, W3) with preferences:
A stable matching is one where no "blocking pair" exists—a man and woman not matched to each other who would both be happier together.
Input/Output
{(m_i, w_j)} ∀i∈[1..n]such that no pair (m, w) prefers each other to their matched partners.Why It Matters
College and Residency Matching: Medical residency programs worldwide use stable matching algorithms to assign graduating doctors to hospital positions, respecting both applicant and hospital preferences.
Job Markets & Internships: Many internship and entry-level hiring pipelines use variants of the stable marriage algorithm to coordinate offers and acceptances.
Kidney Exchange Programs: Hospitals coordinate living kidney donor–recipient pairs using extensions of this model to find compatible exchanges that maximize fairness.
Modeling Approaches
Approach 1: Constraint Programming (CP)
Key idea: Model as bipartite matching with preference constraints.
match[m] = w(which woman each man is matched to)alldifferent(match[*])— each woman matched once(m, w): eithermatch[m]is better thanwin m's ranking, ORmatch[w]is better thanmin w's ranking (symmetry-breaking)rank[person][preferred] < rank[person][current]Trade-offs:
alldifferentand reified constraints enable strong domain reduction.O(n2)preference constraints can grow costly; best for medium instances (n ≤ 1000).Approach 2: Procedural Algorithm (Irving / Gale–Shapley)
Key idea: Iterative proposal-rejection with phase-out logic.
O(n2)time.Trade-offs:
Key Techniques
1. Symmetry & Blocking-Pair Characterization
The core insight: a matching is stable iff no blocking pair exists. This transforms the problem from "find any matching" to "ensure all potential blocking pairs are prevented." Encoding this as reified constraints (
b ∨ c ∨ ...) enables the solver to prune infeasible regions early.2. Augmenting Paths & Flow Networks
For weighted or extended SMP variants (e.g., maximizing total preference scores), model as a minimum-cost maximum-flow problem. Men and women are nodes; edges have weights inversely proportional to preference rank. Standard network algorithms find optimal stable matchings in polynomial time.
3. Decomposition & Local Search
For large instances or many-sided matching (e.g., three-agent markets), decompose into sub-problems:
Challenge Corner
Can you extend the stable marriage model to a three-sided market where we have men, women, and employers, and each must be matched consistently across all three parties? How would you encode "no blocking triple" constraints?
Bonus: If preferences are only partial (not all options ranked), how does this change the CP formulation?
References
Gale, D. & Shapley, L.S. (1962). "College Admissions and the Stability of Marriage." American Mathematical Monthly, 69(1), 9–15. — The original paper; clear and concise.
Knuth, D.E. (1997). Stable Marriage and Its Relation to Other Combinatorial Problems. American Mathematical Society. — Comprehensive book-length treatment with algorithms and complexity.
Irving, R.W. (1985). "An Efficient Algorithm for the 'Stable Roommates' Problem." Journal of Algorithms, 6(4), 577–595. — Extends SMP to symmetric preferences; introduces phase-elimination technique.
Manlove, D.F. (2013). Algorithmics of Matching Under Preferences. World Scientific. — Modern reference covering variants, approximations, and applications.
All reactions