随机算法 (Fall 2011)/Stable Marriage
Suppose that there are men and women. Every man has a preference list of women, which can be represented as a permutation of . Similarly, every women has a preference list of men, which is also a permutation of . A marriage is a 1-1 correspondence between men and women. The stable marriage problem or stable matching problem (SMP) is to find a marriage which is stable in the following sense:
- There is no such a man and a woman who are not married to each other but prefer each other to their current partners.
The famous proposal algorithm (求婚算法) solves this problem by finding a stable marriage. The algorithm is described as follows:
- Each round (called a proposal)
- An unmarried man proposes to the most desirable woman according to his preference list who has not already rejected him.
- Upon receiving his proposal, the woman accepts the proposal if:
- she's not married; or
- her current partner is less desirable than the proposing man according to her preference list. (Her current partner then becomes available again.)
The algorithm terminates when the last available woman receives a proposal. The algorithm returns a marriage, because it is easy to see that:
- once a woman is proposed to, she gets married and stays as married (and will only switch to more desirable men.)
It can be seen that this algorithm always finds a stable marriage:
- If to the contrary, there is a man and a woman prefer each other than their current partners ('s wife) and ('s husband), then must have proposed to before he proposed to , by which time must either be available or be with a worse man (because her current partner is worse than ), which means must have accepted 's proposal.
Our interest is the average-case performance of this algorithm, which is measured by the expected number of proposals, assuming that each man/woman has a uniformly random permutation as his/her preference list.
Apply the principle of deferred decisions, each man can be seen as that at each time, sampling a uniformly random woman from the ones who have not already rejected him, and proposing to her. This can only be more efficient than sampling a uniformly and independently random woman to propose. All men are proposing to uniformly and independently random woman, thus it can be seen as proposals (regardless which men they are from) are sent to women uniformly and independently at random. The algorithm ends when all women have received a proposal. Due to our analysis of the coupon collector problem, the expected number of proposals is .