Stable Matching of Artificial Companions: Gale-Shapley Algorithm Lab

2D Canvas - how an algorithm pairs people by compatibility (no real feelings involved)

Presets & run

Controls

Live readouts

Independent checks

The science

What it models. Each person has four made-up trait values. Everyone ranks the other side by trait distance plus personal taste noise. The Gale-Shapley (1962) deferred-acceptance algorithm then runs: a free proposer asks the best not-yet-asked choice; the receiver keeps the better offer and rejects the other.

  • Stability: no pair (m,w) exists where both prefer each other to their assigned partners (a blocking pair).
  • Termination: at most n² proposals; on random lists about n·ln n (Wilson 1972, Knuth 1976); n·Hn is the coupon-collector bound.
  • Proposer-optimal: every proposer gets the best partner possible in any stable matching; receivers get their worst.

Honest simplification. This is the pairing mathematics used for school and medical-residency placement. It does not model emotion or attachment; it shows what an algorithm can and cannot do. Traits are random illustrative numbers.