SM2

Stable Marriage Problem
Introductory talk 2
Yosuke KIKUCHI
Dept Comp. and Info. Eng.
Tsuyama College of Tech
OKAYAMA, JAPAN
Contents
• Original stable marriage problem (conntinued)
• Experimental study
• Scored stable marriage
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)
My lab. member
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.
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.
Blocking pair
• Men {A,B}, Women {α,β}
Man A
Preference list
Men’s
A
B
Woman α
Women’s
1
2
β
α
β
α
α
β
Aα
Bβ
1
2
B
A
A
B
Man B
Woman β
Blocking pair
• Men {A,B}, Women {α,β}
Man A
Preference list
Men’s
A
B
Woman α
Women’s
1
2
β
α
β
α
α
β
Aα
Bβ
1
2
B
A
B
A
It is not a blocking pair.
Man B
Woman β
Blocking pair
• Men {A,B}, Women {α,β}
Man A
Preference list
Men’s
A
B
Woman α
Women’s
1
2
β
α
β
α
α
β
Aα
Bβ
1
2
B
A
A
B
Man B
Woman β
Example of stable and unstable
Men’s preference list
A
B
C
D
1
γ
β
β
γ
2
β
α
δ
α
Women’s preference list
3
δ
γ
α
δ
4
α
δ
γ
β
α
β
γ
δ
1
A
C
C
B
2
B
A
B
A
3
D
D
D
C
4
C
B
A
D
(Aα, Bβ, Cγ, Dδ) A and β are a blocking pair.
(Aδ, Bα, Cβ, Dγ) This is a stable matching.
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/26
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.
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 ;
Gale-Shapley algorithm
Ωα
Ωβ Ω γ
Ωδ
A δγ
β
Bα
Dγ
Men’s list
A
B
C
D
1
γ
β
β
γ
2
β
α
δ
α
Cβ
Women’s list
3
δ
γ
α
δ
4
α
δ
γ
β
1
α A
β C
γ C
δ B
2
B
A
B
A
3
D
D
D
C
4
C
B
A
D
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.
Number of proposals
Worst case O(n2) times (The maximum number of
rejection is (n-1)2. )
The complexity of the algorithm is O(n2).
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.
Number of rejects
A
B
C
D
α
β
γ
α
β
γ
α
β
γ
α
β
γ
δ
α
β
γ
δ
B
C
D
C
D
A
D
A
B
A
B
C
(Aα)→(Aα, Bβ)→(Aα, B β, C γ)→ (Aα, B β, C γ, Dα)→
(A β, B β, C γ, Dα) → (A β, B γ, C γ, Dα) →
(A β, B γ, C α, Dα) → (A β, B γ, C α, D β) →
(A γ, B γ, C α, D β) → (A γ, B α, C α, D β) →
(A γ, B α, C β, D β) →(A γ, B α, C β, D γ) →
(A δ, B α, C β, D γ)
The number of reject is 9.
When the algorithm is end?
Ωα
Aγ
δ
Ωβ Ωγ Ωδ
β
Bα
Men’s list
A
B
C
D
1
γ
β
β
γ
2
β
α
δ
α
Dγ
Cβ
Women’s list
3
δ
γ
α
δ
4
α
δ
γ
β
α
β
γ
δ
1
A
C
C
B
2
B
A
B
A
3
D
D
D
C
4
C
B
A
D
When the algorithm ends?
We address the order of proposals
δ,
δβ
β,δδ,ββ,γγ,γγ,ββ,δδ,αα, γ, δ
1 2 3 4
δ β all women appear
A When
in
this
sequence, we obtain
β
γ
B
aδstable matching.
C
D γ β δ α
Woman’s list
1 2 3 4
α
β
γ
δ
A
C
C
C
B
A
B
A
D
D
D
B
C
B
A
D
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?
Case n=4 {A,B,C,D}
C B C A C B D D
→we stop to buy boxes, when we obtain 4 kinds of coupon.
mean value
qk : the probability that at least k boxes are
necessary
Mean
number of boxes
m: number of coupons that we
have.
one must buy to obtain
n : number of kinds of coupons
q1=1, q2=m/n, q3=(m/n)2,…
new coupons when he
already have m coupons.
q1+q2+q3+...=1+(m/n)+(m/n)2+...
n /( n  0)  n /( n  1)  n /( n  2)      n /{n  (n  1)}
 n(1  1 / 2  1 / 3      1 / n)
The mean value of boxes
one must buy to obtain
all n coupons.
mean value
n /( n  0)  n /( n  1)  n /( n  2)      n /{n  (n  1)}
 n(1  1 / 2  1 / 3      1 / n)
 nH n
where Hn is the sum of the first n terms of the
harmonic series 1+1/2+1/3+・・・.
Hn=ln n+γ+1/(2n)-1/(12n2)+ε
where 0 < ε < 1/(120n4), γ 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 nHn=nln n+O(n).
mean value
An upper bound for the mean number E(N)
of proposals to obtain a stable matching by
Gale-Shapley algorithm is nHn=nln n+O(n).
More good upper bound is (n-1) Hn+1.
Man can marry with a woman who is
ranked ln n in his list on the average.
Experimental study (1/2)
• Implementing the Gale-Shapley algorithm
window.exe
Experimental study(2/2)
• Measurement of the mean of solution of the Gale-Shapley
algorithm
・Pentium D:2.66GHz ・Memory:1Gbyte
・OS:Windows XP
Random number generator : Random Streamer RPG102
1000times measurements for n=5,50,75,100
– result
n
Measured
value
log n
100(Measured value - log n)/log n
5
1.7812
1.6094
10.675
50
4.21056
3.91202
7.631
75
4.605440
4.317488 6.669
100
5.007670
4.605170 8.740
Structure of stable matchings
Men’s list
A
B
C
D
1
α
β
γ
δ
2
β
α
δ
γ
Women’s list
3
γ
δ
α
β
4
δ
γ
β
α
α
β
γ
δ
1
C
D
A
B
2
D
C
B
A
3
B
A
D
C
4
A
B
C
D
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 β)
Structure of stable matchings
Men’s list
1
A α
B β
C γ
D δ
2
β
α
δ
γ
Women’s list
3
γ
δ
α
β
4
δ
γ
β
α
α
β
γ
δ
1
C
D
A
B
2
D
C
B
A
3
B
A
D
C
4
A
B
C
D
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 β)
All stable matchings : (α, β, γ, δ), (α, β, δ, γ),
(β, α, γ, δ), (β, α, δ, γ), (β, δ, α, γ),
(γ, α, δ, β), (γ, δ, α, β)
Structure of stable matchings
Men’s list
1
A α
B β
C γ
D δ
2
β
α
δ
γ
Women’s list
3
γ
δ
α
β
4
δ
γ
β
α
α
β
γ
δ
1
C
D
A
B
2
D
C
B
A
3
B
A
D
C
4
A
B
C
D
All stable matchings : (α, β, γ, δ), (α, β, δ, γ), (β, α, γ, δ),
(β, α, δ, γ), (β, δ, α, γ), (γ, α, δ, β), (γ, δ, α, β)
1 1 1 1
(α, β, γ, δ)
1 1 2 2
(α, β, δ, γ)
2 2 1 1
(β, α, γ, δ)
2 2 2 2
(β, α, δ, γ)
3 2 2 3
(γ, α, δ, β)
2 3 3 2
(β, δ, α, γ)
3 3 3 3
(γ, δ, α, β)
Structure of stable matchings
1 1 1 1
(α, β, γ, δ)
1 1 2 2
(α, β, δ, γ)
2 2 1 1
(β, α, γ, δ)
2 2 2 2
(β, α, δ, γ)
2 3 3 2
(β, δ, α, γ)
• Distributive lattice
3 2 2 3
(γ, α, δ, β)
3 3 3 3
(γ, δ, α, β)
Scored stable marriage problem
Men’s preference list
A
B
C
D
1
γ
40
β
85
β
50
γ
40
2
β
30
α
10
δ
45
α
30
Woman’s preference list
3
δ
20
γ
5
α
5
δ
20
4
α
10
δ
0
γ
0
β
10
How to
calculate
score of
matching
How
to calculate
score
Aδ,Bα,Cβ,Dγ
Aγ
: 40 +: 5 = 45
65 + 40 + 90 + 45 = 240
1
2
3
4
α
A
40
B
30
D
20
C
10
β
C
40
A
30
D
20
B
10
γ
C
60
B
30
D
5
A
5
δ
B
50
A
45
C
5
D
0
Find optimal matching
Men’s preference list
1
2
3
4
A
γ
40
β
30
δ
20
α
10
B
β
85
α
10
γ
5
δ
0
C
β
50
δ
45
α
5
γ
0
D
γ
40
α
30
δ
20
β
10
Woman’s preference list
1
2
3
4
α
A
40
B
30
D
20
C
10
β
C
40
A
30
D
20
B
10
γ
C
60
B
30
D
5
A
5
δ
B
50
A
45
C
5
D
0
Maximum score
Assignment problem
using Hungarian method
α
β
γ
δ
A
50
60
45
65
B
40
95
35
50
C
15
90
60
50
D
50
30
45
20
30 + 20
What is Hungarian method?
• This method can find n matching such that
total amount is minimum in n×n matrix.
α
β
γ
δ
α
A
50
60
45
65
A
150 140 155 135
B
40
95
35
50
B
160 105 165 150
C
15
90
60
50
C
185 110 140 150
D
50
30
45
20
D
150 170 155 180
Maximum score
200-score in
matrix
β
γ
δ
Finding optimal matching
The matching that be found by
Hungarian method
α
β
γ
65
+ 60Cγ
+ 50Dα
= 270
Aδ+ 95Bβ
δ
α
β
γ
δ
A
150 140 155 135
A
50
60
45
65
B
160 105 165 150
B
40
95
35
50
C
185 110 140 150
C
15
90
60
50
D
150 170 155 180
D
50
30
45
20
Case: score is inclined.
Men’s preference list
A
B
C
A
B
C
D
D
1α
α
200
100
α
100
100
α
100
100
α
100
100
β2
β
100
0
β
00
δ
00
γ
00
γ3 δ 4
γ
δ
100
0 100
0
δ
γ
00 0 0
β
c
00 0 0
β
δ
00 0 0
Woman’s preference list
1
2
3
More than one solution by using
α
AmethodB
D
Hungarian
100: 2000
0
Aα,Bδ,Cβ,Dγ
Aβ,Bα,Cδ,Dγ
β
A : 200C
D
Aγ,Bδ,Cα,Dβ
:
200
100 0
0
・
γ ・ A
B
D
0
0
・ 100
δ
A
100
B
0
C
0
Use Gale-Shapley algorithm
Aα,Bβ,Cδ,Dγ : 200
4
C
0
B
0
C
0
D
0
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
C言語プログラムの実行結果
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.
Can we improve the approximation ratio?
It is known that lower bound 1.105 unless P=NP .
Further work
• Stable roommates problem
This problem does not have solution
for any preference list.
This problem is a generalization of
stable marriage problem.
Further work
• Stable roommates problem
1
2
3
A
B
D
C
B
D
A
C
C
A
B
D
D
A
B
C
Further work
• Stable roommates problem
1
2
3
A
B
D
C
B
D
A
C
C
A
B
D
D
A
B
C
AB, CD
AC, BD
AD, BC
B and D are a blocking pair.
A andisDno
are solution
a blocking for
pair.this list.
This
A and B are a blocking pair.
Gap between original and scored
• When the solution of Gale-Shapley algorithm
and the solution of Hungarian method?
Men’s preference list
A
B
C
D
1
γ
90
β
40
β
51
γ
40
δ
2
β
5
α
30
δ
49
3
α
39
δ
20
δ
4
γ
20
α
1
4
α
1
δ
10
γ
0
β
1
Woman’s preference list
1
2
3
4
α
A
B
D
C
β
C
A
D
B
γ
C
B
D
A
δ
B
A
C
D
Gap between original and scored
Men’s preference list
A
B
C
D
1
γ
90
β
40
β
51
γ
40
Woman’s preference list
2
β
5
α
30
δ
49
3
α
39
δ
20
δ
4
γ
20
α
1
4
α
1
δ
10
γ
0
β
1
1
2
3
4
α
A
B
D
C
β
C
A
D
B
γ
C
B
D
A
δ
B
A
C
D
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 ?
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