Presentation is loading. Please wait.

Presentation is loading. Please wait.

Stable Marriage Problem Introductory talk 2 Yosuke KIKUCHI Dept Comp. and Info. Eng. Tsuyama College of Tech OKAYAMA, JAPAN.

Similar presentations


Presentation on theme: "Stable Marriage Problem Introductory talk 2 Yosuke KIKUCHI Dept Comp. and Info. Eng. Tsuyama College of Tech OKAYAMA, JAPAN."— Presentation transcript:

1 Stable Marriage Problem Introductory talk 2 Yosuke KIKUCHI Dept Comp. and Info. Eng. Tsuyama College of Tech OKAYAMA, JAPAN

2 Contents Original stable marriage problem (conntinued) Experimental study Scored stable marriage

3 Review of previous talk Introduction of background Original stable marriage problem – Setting – Definition of stable – application – Gale-Shapley algorithm – Features of the algorithm – Proof of correctness of the algorithm – Number of proposals (worst case and mean value)

4 My lab. member

5 Stable marriage problem There are N -women and N-men. Each parson has a preference list of opposite sex. Then decide N-matching between women and men.

6 A matching is stable A matching is unstable if a man A and a woman a, not married to each other, but they mutually prefer each other to their partners. These pair A and a is called blocking pair. A matching is stable if it does not contain a blocking pair.

7 Blocking pair Men {A,B}, Women {α,β} Preference list Men’sWomen’s A α B β Man A Man B Woman α Woman β 12 Aβα B βα 12 αBA βAB

8 Blocking pair Men {A,B}, Women {α,β} Preference list Men’sWomen’s A α B β Man A Man B Woman α Woman β 12 Aβα B βα 12 αBA βBA It is not a blocking pair.

9 Blocking pair Men {A,B}, Women {α,β} Preference list Men’sWomen’s A α B β Man A Man B Woman α Woman β 12 Aβα B βα 12 αBA βAB

10 Setting of stable marriage problem Case N=4 (Men {A,B,C,D}, Women {a,b,c,d}) 1234 Acbda Bbacd Cbdac Dcadb 1234 aABDC bCADB cCBDA dBACD Men’s preference listWomen’s preference list

11 Example of stable and unstable 1234 A γβδα B βαγδ C βδαγ D γαδβ 1234 α ABDC β CADB γ CBDA δ BACD Men’s preference listWomen’s preference list (A α, B β, C γ, D δ ) A and β are a blocking pair. (A δ, B α, C β, D γ ) This is a stable matching.

12 Simple approach Case N= 3(Men {A,B,C}, Women {a,b,c}) 123 Abac Bcab Cabc 123 aACB bCAB cCBA Men’s preference listWomen’s preference list (Aa, Bb, Cc) (Ab, Ba, Cc) A and b are a blocking pair. b and C are a blocking pair.A and a are a blocking pair. a and C are a blocking pair. (Ac, Ba, Cb) (Ac, Bb, Ca) This approach does not end. But (Ab, Bc, Ca) and (Aa, Bc, Cb) are stable matcihg. Thus this approach can not obtain stable matching for any lists. This is initial matching!

13 What is Stable matching ? Men’s preference listWomen’s preference list Ac Ba Cb Dd → Pair Dc is a blocking pair. → Ad Ba Cb Dc 1234 Acbda Bbacd Cbdac Dcadb 1234 aABDC bCADB cCBDA dBACD

14 Applications of stable matching Distribution of students among laboratory Distribution interns into hospitals [1] - reference - [1] 医師臨床研修マッチング協議会 (JAPAN INTERNS MATCHING CONFERENCE(?)) URL) http://www.jrmp.jp/ 2008/3/26http://www.jrmp.jp/

15 Distribution n interns into m hospitals n k : capacity of k-th hospital n 1 +n 2 + ・・・ +n m =n The number of interns > the capacities of hospitals ⇒ fictitious hospital (the worst choice for inters) (the capacity of fictitious hospital = The number of interns - the capacities of hospitals) The number of interns < the capacities of hospitals ⇒ fictitious interns (the worst choice for hospitals) (the number of fictitious interns = The capacities of hospitals - the number of interns )

16 Distribution n interns into m hospitals Interns I 1 I 2. I n Hospitals H 1 (capacity n 1 ) H 2 (capacity n 2 ). H m (capacity n m

17 Distribution n interns into m hospitals Interns I 1 I 2. I n Hospitals H 11 (capacity 1) H 12 (capacity 1) H 1n 1 (capacity 1) H 21 (capacity 1) H 22 (capacity 1) H 2n 2 (capacity 1) … … … Same list Same list Then we modify this model to original stable marriage model.

18 Incomplete lists 123 Aa Bcab Cca 123 aCA bBAC cBC Men’s preference listWomen’s preference list In these reference lists, only (Aa, Bb, Cc) is matching. But this matching is not stable matching. It is known that there exists a stable matching for complete lists.

19 Incomplete lists 123 Aaωω Bcab Ccaω 123 aCAΩ bBAC cBCΩ Men’s preference listWomen’s preference list We add new man Ω and new woman ω. Ω is the worst choice for women. ω is the worst choice for men.

20 Gale-Shapley algorithm The algorithm contains following four steps. – 1. man proposes to his desirable woman one by one. – 2. woman decides whether accept or reject. – 3. If a man is refused, then he remove her name from his preference list. – 4. Repeat the steps above, until every man is accepted by a woman.

21 Pseudo code of Gale-Shapley algorithm Variables and constants n: number of women = number of men k: number of couples X: suitor χ: woman toward whom the suitor makes advances Ω: (undesirable) imaginary man k=0; all the women are engaged to Ω; while(k < n){ X=(k+1)-st man; while(X != Ω){ x=the best choice remaining on X’s list; if(χ prefers X to her current partner){ engage X and χ; X=preceding partner of χ;} if(X != Ω) withdraw χ from X’s list; } k = k+1; } Output matching ;

22 γβ Gale-Shapley algorithm Men’s listWomen’s list AB C β α D γ δ 1234 A γβδα B βαγδ C βδαγ D γαδβ 1234 α ABDC β CADB γ CBDA δ BACD Ω α Ω β Ω γ Ω δ

23 1234 aABDC bCADB cCBDA dBACD 1234 Acbda Bbacd Cbdac Dcadb Gale-Shapley のアルゴリズム Men’s listWomen’s list AB C Dc b a c d

24 Gale-Shapley algorithm Features ・ The algorithm always finds a stable matching. ・ The matching is optimal solution for men (women). ・ The matching is independent from the order of proposals.

25 The algorithm can find a stable matching Man A Man Woman Woman a Suppose A is not married to a and if A prefers a to his partner in the matching obtained. Then a has rejected A’s proposal and is married to someone she prefers to A. Then A and a is not blocking pair. Thus the matching is stable.

26 The matching is optimal solution for men (women) A man can not marry with a woman who ranks higher in his list than his partner. If the women make the advances, then the matching obtained is optimal for women.

27 Man A Woman a Man A Man B Woman a Woman b If one stable matching contains Aa, and another contains Ab and Ba, then either A prefers b to a and a prefers A to B or A prefers a to b and a prefers B to A.

28 Man A Woman a Man A Man B Woman a Woman b If one stable matching contains Aa, and another contains Ab and Ba, then either A prefers b to a and a prefers A to B or A prefers a to b and a prefers B to A. Every other stable matching is better for one of the spouses and worse for the other.

29 There are two stbale matching. One is the (Aa, …), and another is the (Ab, Ba, …). Then it is hold that either A prefers b to a and a prefers A to B, or A prefers a to b and a prefers B to A.

30 Proof. We prove the situations of A and a can not both worsen in the second matching. We prove that they can not improve for the two at the same time. Notation: bAa ⇒ A prefers b to a. AaB ⇒ a prefers A to B.

31 A=X 0, a=x 0, b=x 1, and suppose bAa then x 1 X 0 x 0. The matching (Aa, …) is a worse choice for X 0, x 1 marries with X 1 and X 1 x 1 X 0. The matching is better choice for x 1. The matching (Ab, Ba, …) is a worse choice for x 1. X 1 marries with x 2 and x 2 X 1 x 1.

32 We obtain the sequence X 0 x 0 X 1 x 1 X 2 x 2 … in the matching (Aa, …), X 0 x 1 X 1 x 2 X 2 x 3 … in the matching (Ab, Ba, …) where x k+1 X k x k and X k+1 x k+1 X k for all k ≧ 0. Since the number of person is finite, there exist integers j and k, j <k, such that X j = X k. Let j be the smallest integer having this property and for this j, let k be the smallest integer such that X j = X k and k>j. Then x j = x k.

33 If j=0 since otherwise X k-1 x k =X k-1 x j would appear in the matching (Ab, Ba, …) as well as X j-1 x j, from which X j-1 =X k-1, contradicting the fact that j is the smallest integer with X j =X k. Thus X k-1 x 0 appears in the matching (Ab, Ba, …). But x 0 =a. Thus X k-1 =B. Given that X k x k X k-1, we have proved AaB.

34 Number of proposals Worst case O(n 2 ) times (The maximum number of rejection is n(n-1)/2. ) The complexity of the algorithm is O(n 2 ). Best case n times (each man is not rejected. Thus each man’s partner is the really best partner for him. ) Then we estimate the mean number of proposals. We will find an upper bound for the mean number of proposals.

35 γβ When the algorithm is end? Men’s listWomen’s list AB C β α D γ δ 1234 A γβδα B βαγδ C βδαγ D γαδβ 1234 α ABDC β CADB γ CBDA δ BACD Ωα Ωβ Ωγ Ωδ

36 We address the order of proposals When the algorithm ends? Woman’s list A 1234 α ABDC β CADB γ CBDA δ C A B D When all women appear in this sequence, we obtain a stable matching. δ, β, δ, β, γ, γ, β, δ, α, γ, δ δ α βδβγβδ 1234 A δβ B βγ C δ D γβδα γ

37 coupon collector’s problem There are n distinct coupons and that each time one buys a box of detergent one obtains a coupon at random. How many boxes must be bought, on average, to obtain all n coupons? C B C A C B D D Case n=4 { A,B,C,D } →we stop to buy boxes, when we obtain 4 kinds of coupon. Capsuled toy vending machine

38 mean value q k : the probability that at least k boxes are necessary m: number of coupons that we have. n : number of kinds of coupons Mean number of boxes one must buy to obtain new coupons when he already have m coupons. The mean value of boxes one must buy to obtain all n coupons. q 1 =1, q 2 =m/n, q 3 =(m/n) 2,… q 1 +q 2 +q 3 +... =1+(m/n)+(m/n) 2 +...

39 mean value where H n is the sum of the first n terms of the harmonic series 1+1/2+1/3+ ・・・. H n =ln n+γ+1/(2n)-1/(12n 2 )+ε where 0 < ε < 1/(120n 4 ), γ is Euler’s constant. An upper bound for the mean number E(N) of proposals to obtain a stable matching by Gale-Shapley algorithm is nH n =nln n+O(n).

40 mean value An upper bound for the mean number E(N) of proposals to obtain a stable matching by Gale-Shapley algorithm is nH n =nln n+O(n). Man can marry with a woman who is ranked ln n in his list on the average.

41 クロックソリティアのゲーム 52枚のカードを4 枚ずつ、ランダムに 13の山に分ける。 Kが4枚出た時に、 すべてのカードがめ くれていたらゲーム クリア。そうでなけ れば、ゲームオー バー

42 実装結果

43 Gale-Shapley アルゴリズムの動作例 明 勇 梅彦 栄治 秋 郁恵 麗 エリエリ 麗 秋 エリエリ エリエリ 麗 エリエリ 麗 秋 勇栄治 勇 梅彦 明 秋 勇 勇明 麗 秋郁恵 明 明 エリエリ 栄治 Matching={( 明, 郁恵 ),( 勇, 秋 ),( 梅彦, 麗 ),( 栄治, エリ )}

44 Gale-Shapley アルゴリズムとは Stable Marriage Problem に存在する Stable Matching を 求めるアルゴリズム (今回は、男性から告白するアルゴリズムとする) アルゴリズムの内容は次の 3 つの手順からなる 1. 男性は順に 1 人ずつ女性に告白する 2. 女性たちは自らの好みで告白者と付き合うか、 振る 3. 振られた男性は自分のリストから、その女性を 除く この手順を各男性全てが女性と付き合うまで繰り返 す

45 Experimental study ( 1/2 ) Implementing the Gale-Shapley algorithm window.exe

46 Experimental study ( 2/2 ) Measurement of the mean of solution of the Gale-Shapley algorithm ・ Pentium D:2.66GHz ・ Memory: 1 Gbyte ・ OS:Windows XP Random number generator : Random Streamer RPG102 1000times measurements for n=5,50,75,100 – result nMeasured value log n 100(Measured value - log n)/log n 51.78121.609410.675 504.210563.912027.631 754.6054404.3174886.669 1005.0076704.6051708.740

47 Structure of stable matchings All stable matchings : (A α, B β, C γ, D δ ), (A α, B β, C δ, C γ ), (A β, B α, C γ, D δ ), (A β, B α, C δ, C γ ), (A β, B δ, C α, D γ ), (A γ, B α, C δ, D β ), (A γ, B δ, C α, D β ) 1234 α CDBA β DCAB γ ABDC δ BACD 1234 A αβγδ B βαδγ C γδαβ D δγβα Men’s listWomen’s list

48 Structure of stable matchings 1234 α CDBA β DCAB γ ABDC δ BACD 1234 A αβγδ B βαδγ C γδαβ D δγβα Men’s listWomen’s list All stable matchings : ( α, β, γ, δ ), ( α, β, δ, γ ), ( β, α, γ, δ ), ( β, α, δ, γ ), ( β, δ, α, γ ), ( γ, α, δ, β ), ( γ, δ, α, β ) All stable matchings : (A α, B β, C γ, D δ ), (A α, B β, C δ, C γ ), (A β, B α, C γ, D δ ), (A β, B α, C δ, C γ ), (A β, B δ, C α, D γ ), (A γ, B α, C δ, D β ), (A γ, B δ, C α, D β )

49 Structure of stable matchings 1234 α CDBA β DCAB γ ABDC δ BACD 1234 A αβγδ B βαδγ C γδαβ D δγβα Men’s listWomen’s list All stable matchings : ( α, β, γ, δ ), ( α, β, δ, γ ), ( β, α, γ, δ ), ( β, α, δ, γ ), ( β, δ, α, γ ), ( γ, α, δ, β ), ( γ, δ, α, β ) 1 1 1 1 ( α, β, γ, δ ) 1 1 2 2 ( α, β, δ, γ ) 2 2 1 1 ( β, α, γ, δ ) 2 2 2 2 ( β, α, δ, γ ) 2 3 3 2 ( β, δ, α, γ ) 3 2 2 3 ( γ, α, δ, β ) 3 3 3 3 ( γ, δ, α, β )

50 Structure of stable matchings 1 1 1 1 ( α, β, γ, δ ) 1 1 2 2 ( α, β, δ, γ ) 2 2 1 1 ( β, α, γ, δ ) 2 2 2 2 ( β, α, δ, γ ) 2 3 3 2 ( β, δ, α, γ ) 3 2 2 3 ( γ, α, δ, β ) 3 3 3 3 ( γ, δ, α, β ) Distributive lattice

51 Structure of stable matchings Distributive lattice 1234 α CDBA β DCAB γ ABDC δ BACD 1234 A αβγδ B βαδγ C γδαβ D δγβα Men’s listWomen’s list

52 Scored stable marriage problem Men’s preference listWoman’s preference list A γ : 40 + 5 = 45 How to calculate score A δ,B α,C β,D γ : 65 + 40 + 90 + 45 = 240 1234 A γ 40 β 30 δ 20 α 10 B β 85 α 10 γ5γ5 δ0δ0 C β 50 δ 45 α5α5 γ0γ0 D γ 40 α 30 δ 20 β 10 1234 α A 40 B 30 D 20 C 10 β C 40 A 30 D 20 B 10 γ C 60 B 30 D5D5 A5A5 δ B 50 A 45 C5C5 D0D0 How to calculate score of matching

53 1234 α A 40 B 30 D 20 C 10 β C 40 A 30 D 20 B 10 γ C 60 B 30 D5D5 A5A5 δ B 50 A 45 C5C5 D0D0 1234 A γ 40 β 30 δ 20 α 10 B β 85 α 10 γ5γ5 δ0δ0 C β 50 δ 45 α5α5 γ0γ0 D γ 40 α 30 δ 20 β 10 Find optimal matching 順位1番2番3番4番 Abbda Bcacd Cbdac Dcadb Men’s preference list Woman’s preference list αβγδ A 50604565 B 40953550 C 15906050 D 304520 30 + 20 Assignment problem using Hungarian method Maximum score

54 What is Hungarian method ? This method can find n matching such that total amount is minimum in n×n matrix. αβγδ A 50604565 B 40953550 C 15906050 D 304520 αβγδ A 150140155135 B 160105165150 C 185110140150 D 170155180 Maximum score 200-score in matrix

55 αβγδ A 150140155135 B 160105165150 C 185110140150 D 170155180 Finding optimal matching The matching that be found by Hungarian method αβγδ A 50604565 B 40953550 C 15906050 D 304520 Aδ Bβ Cγ DαAδ Bβ Cγ Dα 65 + 95 + 60 + 50 = 270

56 Case: score is inclined. Men’s preference listWoman’s preference list 1234 A α 100 β0β0 δ0δ0 γ0γ0 B α 100 β0β0 γ0γ0 δ0δ0 C α 100 δ0δ0 β0β0 c0c0 D α 100 γ0γ0 δ0δ0 β0β0 1234 α A 100 B0B0 D0D0 C0C0 β A 100 C0C0 D0D0 B0B0 γ A 100 B0B0 D0D0 C0C0 δ A 100 B0B0 C0C0 D0D0 αβγδ A 200100 B 000 C 000 D 000 More than one solution by using Hungarian method A α,Bδ,C β,D γ : 200 A β,B α,Cδ,D γ : 200 A γ,Bδ,C α,D β : 200 ・ Use Gale-Shapley algorithm A α,B β,C δ,D γ : 200

57 Scored stable marriage problem Apply Hungarian method Apply Gale-Shapley algorithm find stable matching compare the score of Gale-Shapley and the core of Hungarian method. If the score of Gale-Shapley = the core of Hungarian method, then we choose the score of Gale-Shapley

58 C言語プログラムの実行結果

59 まとめ 提案したスコア付き安定結婚問題の考察 今後の課題 C言語では、 5×5 の表以内での実装しか行っ ていないので、 n×n で実装する。 ハンガリアン法以外のアルゴリズムを使っ て実装する。 利点: Gale-Shapley のアルゴリズムでは男性 優位または女性優位に解が偏るが、スコア付き で考えるとその偏りがなくなる場合がある。 問題点 : 求めた解(マッチング)に、ブロッ キングペアが存在してしまうことがある。

60 Further work If the preference list is incomplete and includes tie, finding the maximum stable matching is NP-hard [ Halldorsson et al, 2003]. 1.875-approximation algorithm is developed by Iwama et al, 2007. 1.875-approximation algorithm is developed by Iwama et al, 2007. Can we improve the approximation ratio? It is known that lower bound 1.105 unless P=NP.

61 Further work Stable roommates problem This problem does not have solution for any preference list. This problem is a generalization of stable marriage problem.

62 Further work Stable roommates problem 123 ABDC BDAC CABD DABC

63 Further work Stable roommates problem 123 ABDC BDAC CABD DABC AB, CD AC, BD AD, BC B and D are a blocking pair. A and D are a blocking pair. A and B are a blocking pair. This is no solution for this list.

64 Gap between original and scored When the solution of Gale-Shapley algorithm and the solution of Hungarian method? Men’s preference listWoman’s preference list δ 1234 A γ 90 β5β5 δ4δ4 α1α1 B β 40 α 30 γ 20 δ 10 C β 51 δ 49 α1α1 γ0γ0 D γ 40 α 39 δ 20 β1β1 1234 α ABDC β CADB γ CBDA δ BACD

65 Gap between original and scored Men’s preference listWoman’s preference list 1234 A γ 90 β5β5 δ4δ4 α1α1 B β 40 α 30 γ 20 δ 10 C β 51 δ 49 α1α1 γ0γ0 D γ 40 α 39 δ 20 β1β1 1234 α ABDC β CADB γ CBDA δ BACD Stable matching is (A δ, B α, C β D γ ) and the score is 4+30+51+40=125 The maximum score is 218 and the matching is (A γ, B β, C δ, D α ), (90+40+49+39). But this matching is unstable, because C and β is a blocking pair. Which is better for men ?

66 Further reading Please consult Google. Edward G. Thurber, Concerning the maximum number of stable matchings in the stable marriage problem, Discrete Mathematics 248 (2002) 195–219. Jan Eeckhout, On the uniqueness of stable marriage matchings, Economics Letters 69 (2000) 1–8

67 About the women sequence Suppose a sequence S=α 1 α 2 α 3... α n is obtained by Gale-Shapley algorithm. The partial sequence of S, Each alphabet α k is containd at most m in the partial sequence A of S, A=α 1 α 2 α 3... α m(m+1)/2 where m is a positive integer.

68 mean value q k : the probability that at least k boxes are necessary m: number of coupons that we have. n : number of kinds of coupons Mean number of boxes one must buy to obtain new coupons when he already have m coupons. q 1 =1, q 2 =m/n, q 3 =(m/n) 2,… q 1 +q 2 +q 3 + ・・・ +q m+1 =1+(m/n)+(m/n) 2 + ・・・ +(m/n) m Can we obtain more strict upper bound of the number of proposals?


Download ppt "Stable Marriage Problem Introductory talk 2 Yosuke KIKUCHI Dept Comp. and Info. Eng. Tsuyama College of Tech OKAYAMA, JAPAN."

Similar presentations


Ads by Google