*(Guest Post by Devanshu Pandey)*

At the beginning of Wednesday’s class we went over some of the definitions that we discussed last class on Friday. These included:

The set of men and the set of Women.

**Preferences**: Rankings given to every individual in the other set by a man or a woman.

**Matching**: A subset of the such that there is no polygamy.

**Perfect Matching**: A matching which ensures that everyone gets married.

**Instability**: A situation in which and are pairs but prefers to and prefers to , which gives them an incentive to break up with their current partners and join up with each other.

**Stable Matching**: A perfect matching in which everyone is perfectly happy with their current matches.

After this was done we moved on to covering two examples which would help clear up the situation a little. The examples we covered were very trivial compared to what the real world problem looks like. However, we did so with a small number of men and women because it is easier to work with. We picked i.e. the number of men (which is also the number of women) is equal to . We noted that the two perfect matching possible were and . I will call these and respectively:

- Example 1: Both men prefer over and both women prefer over . When asked which of the two matchings were stable, the class shouted out all the possible answers except the correct one which was is stable and is not. This is because in neither nor have any intention of leaving each other (since they rank highest on each other’s preference lists) and hence there is no instability. Where as in , would be an instability. This led us to a new and a more intuitive way of predicting when an instability occurs. That was: “An instability occurs only if there is someone in both the parties ( and ) who wants to switch”. To make this clearer and more specific if w wants to switch to m then for there to be an instability, should also want to switch to (i.e. the will to switch should be on both sides). This Dr. Rudra pointed out was similar to saying that “You cannot force someone to get married unless they really want to get married”. I’d like to make an addition, the same is true about forcing someone to break up.
- In the second example, the preference lists were: and . Here both the perfect matchings were stable because in either case there was a pair which had no incentive whatsoever to break up.

Then we tried picking a very informal and “naïve” algorithm to solve the generalization of this problem (i.e. with an arbitrary number of men and women). Andrew suggested Guess and Check. However we analyzed that this would be very inefficient because there were perfect matchings possible when . This meant that the algorithm would have a best case running time of ( i.e. ). The factor is added because we also have to verify if these perfect matchings are actually stable. Also it isn’t necessary that a stable matching would be the output in every case. This also resulted in the question: “Does a stable matching always exist?”

Hence, we turned to the Gale-Shapely algorithm developed in 1962 by David Gale and Lloyd Shapely. Following is the algorithm in my own words:

- In the beginning all men and women are free (single).
- As long as there is a woman (say ) who is allowed to propose (i.e. she is single and has someone on her list that she hasn’t proposed to already):
- proposes to the man highest on her preference list that she hasn’t proposed to (say ).
- if is free then and enter an engagement which like in real life is an intermediate (and possibly temporary) stage. On the other hand if he isn’t free then he checks his preference list. If is higher up on his preference list that his partner, is formed and breaks up with his current partner. If isn’t higher on the preference list then she stays free and remains engaged.

- This algorithm runs till there are no women left who can propose.

In the next class we plan to check that the algorithm runs in and that it always outputs a stable matching.

Hello everyone. This was written by me and I’d appreciate any comments that anyone has to make here. Thank You.

By:

Devanshu Pandeyon September 11, 2009at 2:03 am

That was a good summary. The thing that makes the Gale-Shapley so effective is the fact that there are checks and balances. The woman is allowed to assert her preference while the man is allowed the option to change the woman he eventually marries based on his preference. I suspect this algorithm always results in a stable matching because of this balance.

By:

John Barkeron September 11, 2009at 4:30 pm

John,

Yes the check and balance you mention works in the algorithm’s favor. Also the fact that every woman proposes in one direction (and never “goes back”) is crucial for the GS algorithm to work.

By:

atrion September 11, 2009at 6:06 pm

[...] of exactly what we’re trying to do with tokens! So, the solution to this problem is called the Gale-Shapley algorithm, and get this, it’s only worst case O(M*W) where M is the number of men tokens and W is the [...]

By:

Record Linkage in F# – Token Matching, Stable Marriages and the Gale-Shapley algorithm « Inviting Epiphanyon September 13, 2011at 1:03 pm