• 沒有找到結果。

THE AVERAGE PERFORMANCE OF A PARALLEL STABLE MARRIAGE ALGORITHM

N/A
N/A
Protected

Academic year: 2021

Share "THE AVERAGE PERFORMANCE OF A PARALLEL STABLE MARRIAGE ALGORITHM"

Copied!
9
0
0

加載中.... (立即查看全文)

全文

(1)

BIT 29 (1989), 448456

T H E A V E R A G E P E R F O R M A N C E O F A P A R A L L E L S T A B L E M A R R I A G E A L G O R I T H M

S. S. TSENG

Institute of Information Science, National Chiao Tung University, Hsinchu, Taiwan 30050, Republic of China

Abstract.

In this paper, Tseng and Lee's parallel algorithm to solve the stable marriage prolem is analysed. It is shown that the average number of parallel proposals of the algorithm is of order n by using n processors on a CREW PRAM, where each parallel proposal requires O(log tog (n)) time on CREW PRAM by applying the parallel selection algorithms of Valiant or Shiloach and Vishkin. Therefore, our parallel algorithm requires O(nloglog(n)) time. The speed-up achieved is log(n)/loglog(n) since the average number of proposals required by applying McVitie and Wilson's algorithm to solve the stable marriage problem is O(n log (n)).

CR Category: F.2.0

Keywords: average case analysis, parallel algorithm, stable marriage.

1. Introduction.

The stable marriage p r o b l e m was first introduced and solved by Gale and Shapley [-2]. Later, several stable marriage algorithms [-6, 7, 8, 13, 1] were proposed to solve the problem. In [13] Wilson showed that the worst case performance and average performance of the stable marriage algorithm [6] are n 2 - n + 1 and O(n log (n)), respectively. Recently, two parallel stable marriage algorithms have been presented [3, 11]. Tseng and Lee's algorithm, which is a parallel version of McVitie and Wilson's algorithm, has worst case performance n 2 - 2n + log n which is no faster than that of McVitie and Wilson's. In 1-9] and [4] it was suggested that parallel stable marriage algorithms cannot be expected to provide high speed-up on the average. We shall show in this p a p e r that the average n u m b e r of parallel proposals of Tseng and Lee's algorithm [11] is O(n). The result is obtained by using n proces- sors on a C R E W P R A M , which is a s h a r e d - m e m o r y computer allowing in a single cycle the processors to perform concurrent reads from the same location but not concurrent writes (Concurrent Read Exclusive Write Parallel R a n d o m Access

(2)

THE AVERAGE PERFORMANCE OF A PARALLEL STABLE MARRIAGE ALGORITHM 449 Machine). Since each parallel proposal requires O(log log (n)) time on a CREW PRAM by applying either of the parallel selection algorithms proposed in [12] or in [10], the speed-up achieved is O(log (n)/log log (n)).

2. Tseng and Lee's parallel stable marriage algorithm

The stable marriage problem is defined as follows. We are given n men and n women and each man ranks each woman from 1 to n and vice versa. A set of marriages is a one-to-one correspondence of men to women. If there does not exist an unmarried pair both preferring each to their current partners, then we say that this set of marriages is stable.

Tseng and Lee's parallel algorithm [11] is based upon the divide-and-conquer approach. We first divide the problem into two sub-problems, by halving the male ranking matrix and then recursively applying the algorithm to find the male optimal stable solutions for these two subproblems. We then merge these two solutions.

Tseng and Lee's algorithm

Input:

Output:

Step 1:

Step 2:

Step 3:

A male ranking matrix.

A male optimal stable solution.

Divide the problem into two sub-problems, by halving the male ranking matrix. Call these two sub-problems P1 a n d / 2 .

Recursively apply this algorithm to find optimal stable solutions for P1 and P2. Call these two solutions $1 and $2.

Apply Algorithm B which is a merging algorithm to combine $1 and S: into S.

In a solution S, let W~ denote the set of women who are proposed to by more than one man. Assume Mil,..., M~ , k > 2, propose to the same woman W~, where W~ ~ W~. Without loss of generality, we shall assume that so far as W~is concerned, the ranking of M~ is the highest. Then W~ will accept Mi~ and reject M~I , .... M~_ 1" W e shall say that {Mq, .... M~k- 1 } is the set of rejected men of W~. Let Rs be the union of the sets of rejected men of members in V¢~. Then R~ is called the rejected men associated with S.

Algorithm B

Input:

Two male optimal stable solutions S 1 and $2 and their associated ranking matrices.

(3)

450

Output:

Step 1:

Step 2:

Step 3:

Step 4:

S. S. TSENG

A male optimal stable solution which combines $1 and $2. Let S be the union of $1 and $2.

If no two men Wopose to the same woman in S, then accept S as the solution and return. Otherwise, go to Step 3.

For each man M~ in

Rs,

and for the set of rejected men associated with S, replace (Mi, Wj) in S by (M~, Wk) where W k is the next best choice of My Go to Step 2.

Let us consider the following example:

M 1 1 4 5 6 2 3 7 8 W 1 8 7 6 4 3 5 1 2 M2 1 2 4 8 7 6 3 5 W2 1 5 4 3 6 2 7 8 M 3 3 2 1 4 8 7 5 6 W 3 1 3 2 4 7 8 6 5 M4 4 6 7 8 1 3 2 5 W4 4 7 8 2 6 1 3 5 M 5 2 3 4 6 7 1 8 5 W 5 3 1 2 5 6 8 7 4 M 6 2 1 8 6 5 7 3 4 W 6 1 2 3 4 5 6 7 8 M 7 5 3 1 4 8 6 2 7 W 7 2 1 3 5 4 6 7 8 M s 5 7 6 3 1 2 4 8 W 8 7 4 2 1 5 6 8 3

Men's Ranking Women's Ranking

The merging steps are illustrated as follows:

I(i.1) (2.2) 1 (3.3)

(4.4) I

1(5.2) (6.1) I

(7.3) (8.5) I

L 1

i -I

L 1

r J

[(1.1) (2.2)(3.3)(4:4)1 [(5.2) ( 6 . 1 ) ( 7 . 3 ) ( 8 . 5 ) I

[ . . .

1

1

I

(1.5) (2.8) (3.3) (4.4) (5.2) (6.6) (7.1) (8.7)I

Finally, we obtain the male optimal stable solution: (1,5) (2,8) (3,3) (4,4) (5,2) (6,6) (7,1) (8,7).

3. Analysis of Tseng and Lee's algorithm

We are concerned with finding the average number of parallel proposals, which is required to obtain the male optimal stable solution by applying Tseng and Lee's

(4)

THE AVERAGE PERFORMANCE OF A PARALLEL STABLE MARRIAGE ALGORITHM 4 5 1

algorithm [11]. In our model n proposals can be performed simultaneously and each parallel proposal requires O(log log n) time by applying either of the parallel selection algorithms proposed by Valiant [12] or Shiloach and Vishkin [10]. Assume that there are n men and n women. Define

A(n)

to be the average number of parallel proposals required to obtain the male optimal stable solution by applying the algorithm. It is obvious that A(1) -- O. Then we define

M(n/2 k)

to be the average number of parallel proposals required to merge two male optimal stable solutions, where each solution consists of

n/2 k

men. Applying Tseng and Lee's algorithm, the stable marriage solution of

n/2 k

men can be obtained by merging two solutions of

n/2 k+l

men. Without loss of generality, assume n = 2 ~ + 1 where ct is an integer. We have

A(1) = 0

A(n/2 i) = a(n/2i+ l) + M(n/2i+ 1)

Thus

A(n) --- A(n/2) + M(n/2)

= A(n/4) + M(n/4) + M(n/2)

= A(1) + ~ m(2i), where ~ = log2 (n/2).

i=0

In the process of merging two mate optimal stable solutions $1 and $2 o f / m e n , it can be seen that in both S 1 and S 2 there are i possibilities to choose i women from

n women. Assume that each ofthe ( 7 ) i s equally likely. So the total number ofinput

( n ) ( n ) I f t h e r e a r e j m e n i n S 2 w h o p r o p o s e t o t h e s a m e

possibilities ofS 1 and S 2 is i i "

women (]R~I = j)in the two male optimal stable solutions of/men, then there are ( i )

V /

possible ways to choose t h e j rejected men. Once t h e j rejected men are fixed, there

a r e ( 7 2 j ) d i f f e r e n t w a y s t o c h o o s e t h e o t h e r i - j m e n .

Let Pu be the probability that there arej conflict pairs of men who propose to the same woman in the two male optimal stable solutions of i men. Therefore, we have

i

n - i

n 2

P~I=(~)(1)(/--I)/(i)

' P , 2 = ( ~ ) ( £ ) ( 7 2 ~ ) / ( ~ ) 2 and

--

(7)

C)

(7

;)/(7)

i

So

M(i)= Z Pi~Qij

is defined as the average number of parallel proposals j = l

(5)

452 s.s. TSENG

required to merge two male optimal stable solutions o f j conflicts within 2i men. At the m e r g i n g stage, we a s s u m e that the probability of p r o p o s i n g to a p r o p o s e d

w o m a n is ( 2 i - j - 1 ) / ( n - l ) a n d that to an u n p r o p o s e d w o m a n is

(n - 2i +j)/(n - 1). T o simplify o u r notation, let m = n - 1 a n d

fi(/) = (2i - j - 1)/m. After the execution of one parallel p r o p o s a l in the merging

stage, t h e r e a r e ( ~ ) f ~ ( f f - k ( 1 - ) i ( j ) , k p o s s i b i l i t i e s t h a t k o f t h e j r e j e c t e d m e n w i l l b e

engaged. Therefore we have

(1) Q~j = t + fi(j)J-k(1 - Ji(j))kQ~.:_ k for t < j < i < n/2

k = k - - - - a n d Qio = 1, for 1 < i <_ n/2. Let gi(x) = 1/(1 - f~(x)X). T h e n Qi,=gi{j)+gi(j,~.(J.~fi(j)i-k(1--Ji(j))kQi.j_k for j > l .

(2)

k = l

Observe t h a t the first derivative ofg~(x) is negative for x ~ [1, iJ a n d i <_ n/2. By this

property, we have the following lemma.

LEMMA 1: gi(x) is a decreasing function for x ~ [1, i], i <_ n/2.

PROOF. W e only have to show that the first derivative of gi(x) is negative.

g'i(x) = - (1 - fi(x)X)'/(1 - fi(x)~) 2

Since In(fi(x)) < 0 for x e [ I , i ] a n d i <_ n/2, we find g~(x) < O. II

T h e next two l e m m a s are used to derive the upper b o u n d s of g.la(J) for

1 _<j < m 1t2 a n d m < j <_ n/2, respectively. LEMMA 2: I f 1 _<j < m 1/2 t h e n 9./2(/) < 2 m / j 2. PROOF. 2 m / j 2 - - gn/z(J) = 2 m / j 2 - - 1/(1 -- L/z(/) ~) 2 m ( m j - ( m - j)J) - j 2 m J f l ( m j - ( m - j ) ' ) = j a ( m J - - ( m - - j)J)

(6)

T H E A V E R A G E P E R F O R M A N C E O F A P A R A L L E L S T A B L E M A R R I A G E A L G O R I T H M 453

>_ mJj 2 - j(j -

1)

m j - lj2 jZ(mJ - (m - j)J)

t.il2j f /

j

4 j2(mJ -- (m -- j)J)

I f j < m 1 / 2 then the following formula is true:

= mJ_2kjZk_lj ! 2kin - (j - 2k + 1)j > 0 . (2k)!(j - 2k + 1)!

m~2 _ j(j _ 1)m j - tjz

j2(m~ -- (m - j)i) > 0 .

Therefore 2m/j 2 - - gn/2(J) >

LEMMA 3: l f m <_ j <_ n/2, then g.tz(J) <- C where C is a constant.

PROOF. F r o m [5] we have (n + a) "+b = n"+be~(1 + a(b - a/2)/n + O(n-2)). With

m 1 / 2 = p this implies that g . 1 2 ( P ) = P P / ( P P - ( P - 1 ) p ) = e / ( e - l + l / ( 2 p )

+ O ( m - 1)) < C. According to L e m m a 1, g./2(J) < g.12(P) <- C, for p < j < n/2.

The next lemma shows the upper bound of g~(j) for 1 <_ j <_ i <_ n/4.

LEMMA 4. g~(j) < 2 f o r 1 < j < i < n/4.

PROOF. Then g,Q)= 1/(1- fiQy)= II

_(2i-J-m

1)i1-'

2 J - - j - - I 2 i - j - - 1 f o r l _ < j ; _ < i _ < W A,/-, we get

m m

gi(J) -< 1/(1 - (2i - j - 1)/m) = m/(m + 2i + j + 1) _< 2. • .

Because

i

Let h(i) = ~, 2 m / k 2. Before deriving the order of M(i), we need to know the k = l

behavior of Qu.

LEMMA 5: Qn/z,j < h(j) + n C / 2 , f o r 1 <_j < n/2.

PROOF. F r o m (2),

()

Q,,i23 = g,,t2(J) + g,,i2(J) ~

Jk f"12(])J-k(1

- f"i2(j))kQi'~-k

k = l J

= g./2(J) + g./2(J)/mj ~ (m --,1) . j-k.a 7 Q~,j-k. k = l

(7)

454 s.s. TSENG

T h e l e m m a is o b v i o u s l y true w h e n n = 2 . If n > 2 a n d j = l then

Q.Iz,j = g./2(1) + Q./2.o = m + 1 < h(1). A s s u m e t h a t Q . 1 2 . j - I < h(j - 1) for j < j ' < m 1:2.

T h e n

= - - J Y J ~ . / 2 , ; k

Q,,i2.j, o.i2(]') + (g,,i2(J')t m;) 2 k (m .,.V-k-,k.., k = l = O,/2{J') + (g.j20")/mJ')k = 1 k (m - - J r .,,i'-k.,k~ 7 tJ.12.j'-k -- g.i2(j')h(f - l)((m - f ) / m ) m + g.12(J')h(]' - 1)((m - j')/m) J" < O.i2(J') + (g.+2(]')h(j' - 1)lm j') ~ (m - k = O - g.12(i')h(f - 1)((m - f ) / m y ' . But m - j r 7 = (m j + f)s" So Q . i 2 d < g.i2lj ) + - - 0 \ ~ 1 k O . 1 2 ( j ' ) h i j ' - 1)(1 - ( ( m - j ' ) / m ) j') = g . j 2 ( i ' ) + h ( j ' - 1).

According to L e m m a 2, g.12(J) < 2 m / j 2, for j < m, and hence

Q . i z d < 2 m / j '2 + h(j' - 1) = h(j'). F r o m L e m m a 3, it c a n easily be p r o v e d t h a t Q./2.j < h(j) + nC/2, for 1 <_ j <_ n/2, by a p p l y i n g the s a m e a r g u m e n t . • LEMMA 6: Qij <- 3j, f o r i <_ n/4. PROOF. F r o m (2),

'0)

= =~ - f~(j)) Qi,j-~. Q i j 0i(J) + oi(J) + h ( j ) j - , ( 1 - k k 1 k

A c c o r d i n g to L e m m a 4, Qij = gi(1) + Qi, o -< 3. A s s u m e t h a t Q i . j - 1 -< 3q - 1) for

j < j' <_ i <_ n14. T h e n

= _ f,(j)) Q~,~,-~

Olj" gi(J') + g'(J') ~ k f"(J');-k(1 , k

k = l

• t . t *' ,# .# "

-- a,(J )f~(J Y Q i . f - t + g,(J )fiq Y Ol,j' t < g~q') . . .

-- -- gi(J )fi~J Y Qi,¢ .. 1 s, ( j , \

+ 30" - - i )gilJ')k~O C k ) f'[J'Y'- k(l -- fi(i'))k

-< g , q ' ) - - 3(j' - - 1)gi(j')(1 - - f i ( J ' Y ' ) < 2 + 3(j' - 1) _< 3j'.

(8)

THE AVERAGE PERFORMANCE OF A PARALLEL STABLE MARRIAGE ALGORITHM 455 Theorem 1 now follows in a straight forward manner.

THEOREM 1:

The average performance of Tseng and Ice's parallel stable marriage

algorithm is O(n) by using n processors.

PROOF. According to Lemma 5, we have J

Q,,/2.j < h(j) + nC/2 = 2m ~ (1/k) 2 + nC/2 < 4n + nC/2.

k = l n/2

M(n/2) = ~

Pn/2,jQn/2,j

j = l

=

~ = l \ n / 2 - j J \ J

]U./z,j

( n ) - '

~ ( n - - n / 2 ) ( n / 2 )

_ < ( 4 + C / 2 ) n

n/2

j=l n / 2 - j / \

j /"

From the formula

(r)( ) (r+ 0

k

n - k

n

Lemma 6, we have

it follows that

M(n/2)<

(4 +

C/2)n.

According to

M(i) <_

3j

j=l i - j

j=l \ i - j / k j -

(7-I)/(7)

= 3i < 3i, for

i <_ n/4.

Thus with ~ = logz(n/2):

A(n)

= A(1) + L M(2i) i = 0 c t - I

< 3 ~ 2' + (4 + C/2)n = O(n).

i = 1

4. Concluding remarks.

We have shown that the average number of parallel proposals of Tseng and Lee's algorithm is

O(n)

by using n processors on a C R E W PRAM, where each parallel proposal requires O(loglog(n)) time. The speed-up of the algorithm is

(9)

456 s. s, TSENG

O(log n/loglog n) since the average sequential time is

O(n

log n). This research leads us to an interesting problem: Is there a parallel stable marriage algorithm which uses

O(n)

processors and runs in O(log n) time? It might be worthwhile to conduct future

research in this direction.

Acknowledgements,

The author is grateful to an a n o n y m o u s referee for his valuable comments.

REFERENCES

1. Allison, L., Stable marriages by eoroutines, Information Processing Letters, Vo!. I6, No. 2, Feb. 1983, pp. 611-65.

2. Gale, D. and Shapley, L. S., College admissions and the stability of marriage, Am. Math. Monthly 69, 1962, pp. 9-15.

3. Hull, M. E. C., A parallel view of stable marriages, Information Processing Letters, Vol. 18, No. 1, Feb. 1984, pp. 63-66.

4. Kapur, D. and Krishnamoorthy, M. S., Worst-ease choice for the stable marriage problem, Informa- tion Processing Letters, Vol. 21, July 1985, pp. 27-30.

5. Knuth, D. E., The Art of Computer Programming, Vol. l/Fundamental Algorithms, 2nd Edition, Addison-Wesley, Reading, Mass., I973.

6. McVitie, D. G. and Wilson, L. B., Stable marriage assignment for unequal sets, BIT 10, 1970, pp. 295-309.

7. Mc Vitie, D. G. and Witson, L. B., The stable marriage problem, Communication of the A CM, Vol. 14,

No. 7, July 1971, pp. 486-490.

8. McVitie, D. G. and Wilson, L. B., Aloorithm 411, Pts~ 1--3. Three procedures for the stable marriage

problem, Communication of the ACM, Vol. 14, No. 7, July 1971, pp. 491492.

9. Quinn, M. J., A note on two parallel aloorithms to solve the stable marriage problem, BIT 25, 1985, pp. 473-476.

10. Shiloach, Y. and Vishkin, U., Finding the maximum, merging, and sorting in a parallel computation

model, Journal of Algorithms, Vol. 2, 1981, pp. 88-102.

11. Tseng, S. S. and Lee~ R. C. T., A parallel algorithm to solve the stable marria#e problem. BIT 24, 1984, 308-316.

12. Valiant, L. G., Parallelism in comparison probtents, SIAM Journal of Computing, Vol. 4, No. 3, Sep. 1975, pp. 348-455.

參考文獻

相關文件

² Stable kernel in a goals hierarchy is used as a basis for establishing the architecture; Goals are organized to form several alternatives based on the types of goals and

•In a stable structure the total strength of the bonds reaching an anion from all surrounding cations should be equal to the charge of the anion.. Pauling’ s rule-

In the second quarter of 2003, the average number of completed units in each building was 11, which was lower than the average value for 2002 (15 units). a The index of

6 《中論·觀因緣品》,《佛藏要籍選刊》第 9 冊,上海古籍出版社 1994 年版,第 1

Other advantages of our ProjPSO algorithm over current methods are (1) our experience is that the time required to generate the optimal design is gen- erally a lot faster than many

Reading Task 6: Genre Structure and Language Features. • Now let’s look at how language features (e.g. sentence patterns) are connected to the structure

The temperature angular power spectrum of the primary CMB from Planck, showing a precise measurement of seven acoustic peaks, that are well fit by a simple six-parameter

In this work, for a locally optimal solution to the NLSDP (2), we prove that under Robinson’s constraint qualification, the nonsingularity of Clarke’s Jacobian of the FB system