Tuesday, February 14, 2023

Stable Marriage Problem

The Stable Marriage problem, also known as the Stable Matching problem, is a classic problem in the field of computer science and mathematics that deals with finding a stable match between two sets of participants based on their preferences. The problem was first introduced by mathematician David Gale and economist Lloyd Shapley in 1962.

The problem involves a set of n men and n women who are trying to find a suitable partner for marriage. Each individual has a list of preferences, which ranks their potential partners in order of preference. The goal is to find a matching between the men and women such that there are no two individuals who would both prefer each other over their current partner.

The Gale-Shapley algorithm is a mathematical method for solving the Stable Marriage problem. The algorithm involves a series of proposals and rejections between the men and women, which ultimately leads to a stable match. The algorithm works as follows:

  1. Each man proposes to his top-ranked woman.

  2. Each woman who receives a proposal accepts the proposal from her most preferred man and rejects all other proposals.

  3. Each rejected man proposes to his next-ranked woman, and the process continues until each man is either engaged or has proposed to all women.

  4. Once all the men are engaged, the algorithm is complete.

This is the most useful video on the Stable Marriage Problem, If you want to know how this algorithm works with an example.


The key insight of the Gale-Shapley algorithm is that each individual acts in their own self-interest by proposing to their most preferred partner. This ensures that each individual is matched with the most preferred partner who is willing to accept them. The algorithm also ensures that once a match is made, it is stable and cannot be disrupted by any pair of individuals who would prefer to be with each other.

The Gale-Shapley algorithm has several important properties. First, it always produces a stable matching, which means that there are no two individuals who would both prefer each other over their current partner. Second, it is efficient and can be implemented in `n^2` time, where n is the number of individuals. This makes the algorithm practical for large-scale applications.

If you want to use this algorithm on a large scale then it not possible to do that using a copy and pen as seen on above video. So, R Software help you with these. You can do this in 2 way:

  • Use of hri function of matchingMarkets package. For more information of this library click here
  • You also use one2one function of matchingR package. For more information and example of this library click here
For download R software latest version go to https://www.r-project.org/ and click on download R

The Stable Marriage problem and the Gale-Shapley algorithm have many applications beyond the domain of marriage. The problem can be used to match medical students with residency programs, job seekers with employers, and even kidney donors with recipients. The algorithm has also been used in the design of computer networks and in the allocation of resources.

In conclusion, the Stable Marriage problem and the Gale-Shapley algorithm are important concepts in the fields of computer science and mathematics. The problem deals with finding a stable match between two sets of participants based on their preferences, and the algorithm provides a practical and efficient method for solving the problem. The algorithm has many applications beyond the domain of marriage and has the potential to revolutionize the way we match individuals with different resources and opportunities.

No comments:

Post a Comment