2. Agenda
? Stable Marriage Problem
? Introduce
? Gale-Shapley Algorithm
? Algorithm Proof
? Algorithm Big O
? Pseudo Code
? Animation Demo
? Reference
3. Stable Marriage Problem
? 亦稱為 Stable matching problem
? 給定兩個相同數量的元素集合
? 每個元素給對面元素一個喜好排序
? 讓彼此之間配對找出穩定配對
? 配對:將兩邊的元素一對一組合成一組
4. Stable Marriage Problem
? 配對後需要達成每個人都有彼此的伴侶,並且提
供給雙方的最大利益
? 穩定配對
– 假設(A,B)是一組配對
– 不存在A男對B’女喜好度大於現任妻子B女
– 並且B女對A’男喜好程度也大於現任丈夫A男
5. Stable Marriage Problem
? Stable marriage 的進行方式:
– 給定兩組一樣的元素集合, men 與 women
– 每個元素給另外一個集合的元素進行喜好順序的排序
– 進行每個元素的配對,依照求婚者喜好最高順序進行
配對
– 配對到兩兩元素間沒有比現在更好的選擇,配對就完
成
– 由上述條件可以知道,如果彼此間沒有更好的選擇,
就代表這兩組元素是穩定配對
6. Introduce
? In 1962, David Gale and Lloyd Shapley proved
that
– For any equal number of men and women, it is
always possible to solve the SMP and make all
marriages stable
19. Algorithm Big O
? Assuming the same number of proposers and
acceptors :
– If exactly one proposer gets his last choice woman,
he will have proposed n times.
– The remaining n?1 men are able to propose a
maximum of n?1 times so
– (n?1)(n?1)+n = n2?2n+1+n = n2?n+1
20. Algorithm Big O
? The Gale-Shapley algorithm terminates after
at most n2?n+1 proposals
? Time Complexity : T(n) = O(n2)
#4: Finding a stable matching between two equally sized sets of elements given an ordering of preferences for each element.
A?matching?is a mapping from the elements of one set to the elements of the other set.
#5: A matching is stable when there does not exist any match (A,?B) by which both?A?and?B?are individually better off than they would be with the element to which they are currently matched.
#6: The stable marriage problem has been stated as follows:
Given?n?men and?n?women
Each person has ranked all members of the opposite sex in order of preference
Marry?the men and women together such that there are no two people of opposite sex who would both rather have each other than their current partners.
When there are no such pairs of people, the set of marriages is deemed stable.