← All challenges

Stable Marriage Problem

June 2024

optimizationconstraint-solving

This challenge is the classic stable marriage problem: given n men and n women, where each person has ranked every member of the opposite sex in order of preference, pair everyone up so that there’s no man and woman who would both rather have each other than their current partners. A pairing with no such pair is called stable.

Example preferences:

How men rank women (1 = most preferred):

AliceBarbaraClaireDorisElsie
Adam51243
Bob41325
Charlie53241
Dave15432
Edgar43215

How women rank men (1 = most preferred):

AdamBobCharlieDaveEdgar
Alice12435
Barbara35124
Claire54213
Doris14325
Elsie42351

Find a stable pairing for this example, and build a decision model general enough to handle any such preference table.

Send your solutions to DecisionManagementCommunity@gmail.com, or open a pull request to add yours here.

Solutions