A First Problem: Stable Matching

Alfonso HigueraAlfonso Higuera
3 min read

One of the learnings that I want to obtain from reading this book is how to design an algorithmic solution to problems with which I have no experience. By "not having experience with a problem" I mean that I cannot readily classify it, and hence that I don't immediately know how to approach.

Initially, Kleinberg and Tardos present a problem named "Stable Matching" with the aim of illustrating many of the themes that they want to emphasize.

I will proceed to paraphrase the example, but before doing that note that I will start with the more "bare-bones" version of the problem, i.e., the one about devising a system in which \(n\) men and \(n\) women can end up getting married.

Problem: There are \(n\) men and \(n\) women wanting to get married. Each men and woman have a preference in terms of with whom they would like to get married to. We need to match the men with the women in a way that is stable.

First we need to clarify the problem:

  1. What do we mean by "have a preference in terms of with whom they would like to get married to"?

Let \(M\) be the set of men and \(W\) be the set of women. By "have a preference in terms of with whom they would like to get married" we mean that for each \(m \in M\), there exists a function \(rank_m : W \to \mathbb{R}^{\geq 0}\), and that for each \(w \in W\) there exists a function \(rank_w : M \to \mathbb{R}^{\geq 0}\).

  1. What do we mean by "match the men with the women"?

Let's start with some assumptions. We assume that a man and a woman can be married to exactly one person and that marriage is between a man and a woman. Also, let's assume that a solution don't have people which are not married. That is, men and women must match perfectly.

We define a perfect match as a bijection \(M \to W\).

Hence, a solution to this problem is a perfect match that is stable.

  1. What does "stable" means in the context of this problem?

Intuitively a perfect match is stable if no man wants to change partner, or if there are some men that want to change partner but they cannot do so.

What do we mean by a man wanting to change partner?

Let \(m \in M\) and \(w_1 \in W\). Now, let \(S) be a perfect match such that \\(S(m) = w_1\). We say that \(m\) want to change partner if there is a woman \(w_2 \in W\) such that \(w_2 \neq w_2\) and \(rank_m(w_2) > rank_m(w_1)\).

When does a man cannot change partner?

Let \(m_1 \in M\) and \(w_1 \in W\). Now, let \(S\) be a perfect match such that \(S(m_1) = w_1\). We say that \(m\) cannot change partner if he wants to but, for all \(w \in W - \{w_1\}\) such that \(rank_{m_1}(w) > rank_{m_1}(w_1)\) and for which \(m_2 \in M\) and \(S(m_2) = w\), we have that \(rank_w(m_2) > rank_w(m_1)\).

Hence, a perfect match \(S\) is stable iff at least one of the following conditions holds:

  1. For all \(m \in M\) for which \(w_1 \in W\) and \(S(m) = w_1\), we have that, for all \(w \in W - \{w_1\}\), \(rank_m(w) \leq rank_m(w_1)\).
  2. For all \(m \in M\) for which \(w_1 \in W\) and \(S(m) = w_1\), we have that, for all \(w \in W - \{w_1\}\) for which \(m_2 \in M\) and \(S(m_2) = w\) and such that \(rank_m(w) > rank_{m_1}(w_1)\), \(rank_w(m_2) > rank_w(m)\).
0
Subscribe to my newsletter

Read articles from Alfonso Higuera directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Alfonso Higuera
Alfonso Higuera