Algorithm Search⌘K

Problemadvanced

Egalitarian stable matching

Also called optimal stable marriage.

Find a stable matching that minimizes the sum of the ranks of partners. Irving, Leather and Gusfield solve it by min cut on rotations.

Time
O(n^4) worst
Where
n = the number of men and of women

The egalitarian stable matching problem asks for the stable matching that is best for everyone on average: each person pays the rank of the partner in their own list, and the total over both sides must be as small as possible. It replaces the one-sided optimum of deferred acceptance with a fair objective. It is solved in polynomial time by optimizing over the lattice of stable matchings through its rotations, which turns the problem into a maximum-weight closure and so a minimum cut. Close objectives that look just as simple, such as balancing the costs of the two sides, are NP-hard.

In plain words

In a stable matching, nobody wants to break up and pair with someone who also wants them more. There can be many stable matchings. Deferred acceptance gives the one that is best for the side that proposes and worst for the other side. To be fair to both sides, give each person a score: one if they get their first choice, two for their second choice, and so on. Add up the scores of all people. The egalitarian stable matching is the stable matching with the smallest total. Trying all stable matchings is too slow, because there can be very many. But the stable matchings have a neat structure that turns the search into a flow problem, which is fast to solve.

Definition

An instance has nn men and nn women. Each person ranks all people of the other side in a strict order. Let rm(w)r_m(w) be the position of ww in the list of mm (1 for the first choice), and define rw(m)r_w(m) in the same way. The egalitarian cost of a perfect matching μ\mu is

c(μ)=∑mrm(μ(m))+∑wrw(μ(w)).c(\mu) = \sum_{m} r_m(\mu(m)) + \sum_{w} r_w(\mu(w)).

The task is to find a stable matching of minimum egalitarian cost. The output is the matching; the measure is cc.

The weighted version (the "optimal stable marriage" of Irving, Leather and Gusfield) gives each pair (m,w)(m, w) two weights, one for each person, that grow along each list, and minimizes the sum of the weights of the matched pairs.

Variants

  • Incomplete lists. People may list only some partners. Every stable matching matches the same people (by the rural hospitals theorem), so the cost is still well defined, and the same algorithm applies.
  • Minimum regret. Minimize the largest rank that any person gets. Gusfield (1987) solved it in O(n2)O(n^2) time by walking down the lattice.
  • Sex-equal stable matching. Minimize the difference between the men's total rank and the women's total rank. Kato (1993) proved it NP-hard.
  • Ties. With ties in the lists and weak stability, finding a weakly stable matching of minimum egalitarian cost is NP-hard; see stable matching with ties.
  • Roommates. The egalitarian version of the stable roommates problem is NP-hard, although a stable matching, if one exists, is found in polynomial time.

Examples

Four men and four women with these lists:

person list person list
m1m_1 w2,w3,w1,w4w_2, w_3, w_1, w_4 w1w_1 m1,m4,m2,m3m_1, m_4, m_2, m_3
m2m_2 w3,w1,w2,w4w_3, w_1, w_2, w_4 w2w_2 m4,m2,m3,m1m_4, m_2, m_3, m_1
m3m_3 w2,w4,w1,w3w_2, w_4, w_1, w_3 w3w_3 m3,m2,m1,m4m_3, m_2, m_1, m_4
m4m_4 w4,w2,w1,w3w_4, w_2, w_1, w_3 w4w_4 m2,m3,m4,m1m_2, m_3, m_4, m_1

There are exactly three stable matchings. All three contain the pair m1w1m_1 w_1.

stable matching other pairs men's total women's total cost
AA (man-optimal) m2w3m_2 w_3, m3w2m_3 w_2, m4w4m_4 w_4 6 9 15
BB m2w3m_2 w_3, m3w4m_3 w_4, m4w2m_4 w_2 8 6 14
CC (woman-optimal) m2w4m_2 w_4, m3w3m_3 w_3, m4w2m_4 w_2 13 4 17

The egalitarian stable matching is BB, which neither proposing order of deferred acceptance finds. The lattice is the chain A,B,CA, B, C, with two rotations. The first, (m3,w2),(m4,w4)(m_3, w_2), (m_4, w_4), moves m3m_3 to w4w_4 and m4m_4 to w2w_2; it changes the cost by +2+2 for the men and −3-3 for the women, so by −1-1. The second, (m2,w3),(m3,w4)(m_2, w_3), (m_3, w_4), moves m2m_2 to w4w_4 and m3m_3 to w3w_3; it changes the cost by +5−2=+3+5 - 2 = +3. The best closed set of rotations is the first rotation alone, which gives BB.

Known algorithms

  • Enumeration. List all stable matchings with Gusfield's algorithm in O(n2+nN)O(n^2 + n N) time, where NN is their number, and take the best. This is exponential in the worst case, since NN can be exponential in nn.
  • Rotations and minimum cut (Irving, Leather and Gusfield 1987). Compute the man-optimal matching and the rotation poset, which has O(n2)O(n^2) rotations. Give each rotation the change in cost that its elimination causes; the cost of a stable matching is the cost of the man-optimal matching plus the weights of the rotations in its closed set. Finding a closed set of minimum total weight is a maximum-weight closure problem, solved by one minimum cut in a network with a node per rotation. The total time is O(n4)O(n^4). The method works for every weighted version in which the cost is a sum over people of a function of their own partner.
  • Minimum regret (Gusfield 1987). O(n2)O(n^2) time, also with rotations.

Bounds

  • The problem is solvable in polynomial time, although the number of stable matchings can be exponential and counting them is #P-complete (Irving and Leather 1986).
  • The input has size Θ(n2)\Theta(n^2), so Ω(n2)\Omega(n^2) time is needed; the gap to the O(n4)O(n^4) bound comes from the minimum cut.
  • Objectives that are not sums of individual costs can be hard: the sex-equal problem is NP-hard, and so is the egalitarian problem with ties.

Reductions

  • To maximum-weight closure. The stable matchings correspond one to one to the closed sets (down-sets) of the rotation poset, and the egalitarian cost is additive over rotations. So the problem is a maximum-weight closure problem with weights −Δ(ρ)-\Delta(\rho), where Δ(ρ)\Delta(\rho) is the change in cost by rotation ρ\rho. The rotation poset is a directed acyclic graph, and the closure problem reduces to a minimum cut by the max-flow min-cut theorem.
  • From the man-optimal matching. The rotations and their poset are found from one run of deferred acceptance and a walk from the man-optimal to the woman-optimal matching.

Applications

Knuth (1976) posed the problem of finding a fair stable matching, and the egalitarian cost is the most used fairness measure for stable marriage. It serves as a compromise between the two one-sided optima in matching markets where both sides are people and both sides' welfare counts. It is also the standard example of optimizing a linear function over a distributive lattice given by a poset of rotations.

References

  1. Robert W. Irving, Paul Leather and Dan Gusfield, An efficient algorithm for the "optimal" stable marriage, Journal of the ACM 34(3), 532 to 543 (1987), the whole paper (the O(n^4) algorithm through rotations and a minimum cut)
  2. Robert W. Irving and Paul Leather, The complexity of counting stable marriages, SIAM Journal on Computing 15(3), 655 to 667 (1986), the whole paper (rotations and the rotation poset)
  3. Dan Gusfield, Three fast algorithms for four problems in stable marriage, SIAM Journal on Computing 16(1), 111 to 128 (1987), the whole paper (the minimum regret stable matching and the listing of all stable matchings)
  4. Akiko Kato, Complexity of the sex-equal stable marriage problem, Japan Journal of Industrial and Applied Mathematics 10(1), 1 to 19 (1993), the whole paper (NP-hardness of the sex-equal problem)
  5. Dan Gusfield and Robert W. Irving, The Stable Marriage Problem, Structure and Algorithms, MIT Press (1989), the chapter on optimal stable matchings

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a known algorithm
  • a contract.yaml