1. Trang chủ
  2. » Thể loại khác

DSpace at VNU: Parallel combinatorial algorithms for multi-sets and their applications

19 151 1

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 19
Dung lượng 774,5 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

DSpace at VNU: Parallel combinatorial algorithms for multi-sets and their applications tài liệu, giáo án, bài giảng , lu...

Trang 1

PARALLEL COMBINATORIAL ALGORITHMS FOR MULTI-SETS AND THEIR APPLICATIONS

HOANG CHI THANH Department of Computer Science VNU University of Science

334 - Nguyen Trai, Hanoi, Vietnam

thanhhc@vnu.vn

In this paper we extend some well-known notions of combinatorics on multi-sets such as iterative permutation, multi-subset, iterative combination and then construct new e±cient algorithms for generating all iterative permutations, multi-subsets and iterative combinations

of a multi-set Applying the parallelizing method based on output decomposition we parallelize the algorithms Furthermore, we use these algorithms to solve an optimal problem of work arrangement and an extended knapsack one.

Keywords: Iterative combination; iterative permutation; multi-set; parallel algorithm.

1 Introduction

The signi¯cant notions of combinatorics such as permutation, subset, arrangement, combination and partition etc are frequently used in many areas of computer science such as scheduling problems, system controls, data mining and networking [1,3,4,6,

10, 12, 13, 16, 21] They become good tools to develop software and knowledge engineering

The notion of set was extended to multi-set It is a set to which elements may belong more than once This extension sets up many new researches Multi-sets were employed in proving program correctness It is often used in information processing [7,9, 15] and other problems The well-known notions of combinatorics are being transformed for multi-sets

In this paper we ¯rst recall the notion of multi-set Then we extend the notion

of permutation into iterative permutation, investigate its properties and construct an e±cient algorithm to generate all iterative permutations of a multi-set Applying the parallelizing technique based on the output decomposition presented in [8,19,20] we parallelize this algorithm To do that, the sequence of desirable iterative permutations

of a multi-set is divided into sub-sequences with \nearly" equal lengths by appro-priate choice of pivots Using a common program (algorithm) with the corresponding

and Knowledge Engineering

Vol 23, No 1 (2013) 8199

#.c World Scienti¯c Publishing Company

81

Trang 2

input and termination condition, processors will execute in parallel to generate it-erative permutations of these sub-sequences Further, we apply the algorithm pre-sented above for ¯nding the optimal solution of a work arrangement problem Analogously, we extend the notion of subset into multi-subset and combination into iterative combination Some new e±cient algorithms for generating all multi-subsets, k-element multi-subsets and iterative k-combinations of a multi-set are constructed and parallelized Then we apply the algorithms to an extended knapsack problem

The newly constructed algorithms are based on our inheritance principle and bounded sequences generation These algorithms take part in developing combi-natorial computing, software technology and especially in knowledge engineering [5,11] They refer to the building and development of knowledge-based systems The rest of this paper is organized as follows In Sec 2 we recall the notion of multi-set Section 3 presents the notion of iterative permutation and constructs a new e±cient algorithm based on lexicographical order for generating all iterative permutations of a multi-set and then parallelizes the algorithm Section4is devoted

to multi-subsets, an algorithm generating multi-subsets and its parallelism Section5 presents iterative combinations of a multi-set with generation algorithm Using algorithms presented above, two optimization problems are solved in Sec.6 Finally, some directions for future research are proposed in the conclusions

2 Multi-sets

2.1 De¯nition of multi-set

Multi-set is an extended notion of standard set [9,15] and is de¯ned as follows De¯nition 1 A multi-set is an unordered collection of elements in which elements are allowed to be repeated

For example, a set of values of all variables in a program, a marking of a net system [14] etc., are typical examples of multi-sets

A multi-set is written as follows:

X¼ ðk1 x1; k2 x2; ; kn xnÞ; where ki 0 with i ¼ 1; 2; ; n:

It means, there are k1elements x1, k2elements x2,… and knelements xnin the multi-set X

Elements x1; x2; ; xn are called basic elements of the multi-set X, and

k1; k2; ; kn as the multiplicity of the corresponding element

The cardinality of a multi-set is the sum of multiplicities of all its basic elemens,

jXj ¼Xn i¼1

ki:

A multi-set is called regularif all of its element' multiplicities are the same

Trang 3

2.2 Operations on multi-sets

Let A¼ ðt1 x1; t2 x2; ; tn xnÞ and B ¼ ðq1 x1; q2 x2; ; qn xnÞ be two multi-sets

2.2.1 Multi-subsets

De¯nition 2 We say that A is a multi-subset of B i® the multiplicity of each element in A is not greater than the multiplicity of the element in B, i.e

A B , 8 i ¼ 1; 2; ; n : ti qi:

Thus, each multi-subset A¼ ðt1 x1; t2 x2; ; tn xnÞ of the multi-set X ¼

ðk1 x1; k2 x2; ; kn xnÞ must satisfy: 0  ti ki; 8 i ¼ 1; 2; ; n

2.2.2 Power multi-set

De¯nition 3 The power multi-set of a given multi-set X, denoted byðXÞ, is the set of all multi-subsets of X

2.2.3 Union

De¯nition 4 The union of two multi-sets A and B, denoted by A[ B, is the multi-set C¼ ðp1 x1; p2 x2; ; pn xnÞ, where pi¼ maxðti; qiÞ; 8 i ¼ 1; 2; ; n

2.2.4 Intersection

De¯nition 5 The intersection of two multi-sets A and B, denoted by A\ B, is the multi-set D¼ ðr1 x1; r2 x2; ; rn xnÞ, where ri¼ minðti; qiÞ; 8 i ¼ 1; 2; ; n

2.2.5 Di®erence

De¯nition 6 The di®erence of two multi-sets A and B, denoted by AnB, is the multi-set H¼ ðs1 x1; s2 x2; ; sn xnÞ, where si¼ maxðti qi; 0Þ; 8 i ¼

1; 2; ; n

2.2.6 Lattice of multi-subsets

Including relation  on multi-subsets of a given multi-set X is a partial ordering For every two multi-subsets A and B inðXÞ we de¯ne their supremum (sup) and in¯mum (inf ) as follows

De¯nition 7 For every two multi-subsets A and B inðXÞ,

supðA; BÞ ¼ A [ B and infðA; BÞ ¼ A \ B:

The power multi-setðXÞ equipped two operations sup and inf becomes a dis-tributed lattice

Trang 4

3 Iterative Permutations

3.1 Notion of iterative permutation

We extend the notion of permutation of a multi-set as follows

De¯nition 8 An iterative permutation of a multi-set is a checklist of all its elements Consider the following example

Example 1 Given a multi-set X¼ ð2  a; 1  b; 1  cÞ

Iterative permutations of X are sorted by lexicographical order in Table 1

It is easy to show that the number of all iterative permutations of a multi-set

X¼ ðk1 x1; k2 x2; ; kn xnÞ is cl¼ l !

k1!k 2 ! k n !, where l is the cardinality of X

3.2 Iterative permutation generation algorithm

Iterative permutation problem

Given a multi-set X¼ ðk1 x1; k2 x2; ; kn xnÞ, with ki 1ði ¼ 1; 2; ; nÞ Find all iterative permutations of X

In other words, we have to construct an e±cient algorithm for generating all iterative permutations of this multi-set

It is easy to see that bijection is not suitable to represent iterative permutation

So we have to ¯nd another representation

Identify the elements x1 1; x2 2; ; xn n Each iterative permutation of the multi-set X is represented by an integer sequence of the length l, consisting of k1 integers 1, k integers 2,… and k integers n Now we ¯nd all these integer sequences

Table 1 Iterative permutations

of the multi-set X.

No Iterative permutations

Trang 5

Each integer sequence may be considered as a word on the alphabetf1; 2; ; ng.

So we sort these words increasingly by lexicographical order

— The ¯rst word (the least) is 11 1|fflfflfflffl{zfflfflfflffl}

k1

22 2

|fflfflfflffl{zfflfflfflffl}

k2

nn n|fflfflfflffl{zfflfflfflffl}

kn

It is a non-decreasing sequence

— The last word (the most) is nn n|fflfflfflffl{zfflfflfflffl}

kn

n 1n  1 n  1

|fflfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl{zfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl}

kn1

11 1|fflfflfflffl{zfflfflfflffl}

k1

It is a non-increasing sequence and is indeed the reverse of the ¯rst one

Starting with the ¯rst iterative permutation, our algorithm repeats a loop to ¯nd the remaining iterative permutations

Assume that t¼ a1a2 al1al is an iterative permutation We have to ¯nd the iterative permutation t0¼ a0

1a02 a0l1a0lnext to t in the sorted sequence

Because of lexicographic order, the iterative permutation t0is inherited the lon-gest left part possible of the iterative permutation t from the ¯rst component to the component indexed p1; where the changing position p is the maximal index i, such that ai< aiþ1 Thus: p¼ maxfij1  i  l  1 ^ ai< aiþ1g

It is easy to see that the sub-sequence hap þ1; ap þ2; ; ali is a non-increasing sequence The changing part in the iterative permutation t0from the position p to the last is determined as follows:

1) a0p is the least among all elements in the subsequence hapþ1; apþ2; ; ali but greater than ap We swap ap for this element:

ap$ minfaijp þ 1  i  l ^ ai> apg Note that if there are several least elements we choose the element with the greatest index It ensures that after swapping the sub-sequencehapþ1; apþ2; ; ali still is a non-increasing sequence

2) Reverse the sub-sequence hapþ1; apþ2; ; ali The result is a non-decreasing sequence It is indeed the sub-sequence ha0

p þ1; a0

p þ2; ; a0

li in the iterative per-mutation t0

Our algorithm terminates when the last iterative permutation was generated At that time, the changing position p is equal to 0 We have Algorithm 1

(p)

t a1 a p-1 a p a p+1 a l

Fig 1 Inheritance of iterative permutations.

Trang 6

Complexity of the algorithm:

— Instructions 2–3 input data with the complexity O(nÞ

— Instructions 4–5 calculate the number of elements and assign the ¯rst iterative permutation with the complexity O(lÞ

— Loop 7–14 computes and prints an interative permutation, where: Instruction 7 prints an interative permutation with the complexity O(lÞ Loop 9 locates the changing position p with the complexity O(lÞ Instructions 11–13 ¯nd the ele-ment a0p and swap it for apwith the complexity O(lÞ Instruction 14 reverses the sub-sequencehapþ1; apþ2; ; ali with the complexity O(lÞ

So the complexity of generating an iterative permutation is O(lÞ The total complexity of Algorithm1 is O(cl:lÞ

3.3 Parallel algorithm generating iterative permutations

For the iterative permutation problem, we know the number of all desirable solutions and their arrangement in the sequence sorted by lexicographic order So we can split the sequence into sub-sequences and use a common program (algorithm) in a parallel computing environment to ¯nd concurrently the sub-sequences Therefore,

Trang 7

the amount of time required for ¯nding all desirable solutions will be drastically decreased by the number of sub-sequences

To perform the above parallel computing we split the sequence of all desirable solutions into sub-sequences The number of sub-sequences depends on the number of calculating processors

Let us split the sequence of all solutions of the problem into m sub-sequences (m 2) The model of the parallel computing organization to ¯nd the problem's all solutions is illustrated as in Fig 2

This model is an illustration of the following Condition/Event system [14,17]:

It is clear that events e1; e2; ; emcan be executed concurrently in this system

In order to make the parallel computing organization realistic and optimal, the sub-sequences of solutions should be satis¯ed for the following two criteria:

(1) It is easy to determine the input and the termination condition for the com-puting process of each sub-sequence

(2) The di®erence of lengths of the sub-sequences is the less, the better

Fig 2 The model of the parallel computing organization to ¯nd the problem's solutions.

Fig 3 The Condition/Event system representing the above parallel computing model.

Trang 8

Of course, Input 1 is indeed the input of the problem and last termination con-dition is the termination concon-dition of the algorithm The ¯rst criterion ensures that the splitting of solutions sequence is realistic In many cases, we can use (a part of) the input of the computing process for the next sub-sequence as the termination condition of the computing process for the previous sub-sequence The second criterion implements the balance of computing to processors Then the parallel computing processes become optimal

Applying the parallelizing technique presented above we parallelize Algorithm1

To do so, we split the sequence of all desirable iterative permutations of a multi-set into m sub-sequences (m 2), such that lengths of the subsequences are \nearly" equal The number m depends on the number of processors the computing system devotes to computing Each sub-sequence will be generated by one computing process executed on one processor So input and termination condition for each computing process must be already determined

This parallelizing method is an illustration of the output decomposition technique

in parallel computing [8,19,20]

For simplicity of presentation we perform with m¼ 3 With greater values of m one can do analogously:

Assume that n 3 This assumption makes our splitting realistic We split the sequence of all sorted diserable iterative permutations into 3 sub-sequences with \nearly" equal lengths by appropriate choice of the two following basic elements:

r¼ max 1; max qX

q

i ¼1

ki l 3







and

s¼ max r þ 1; max q X

q

i¼rþ1

kil 3







:

The ¯rst pivot chosen is the ¯rst iterative permutation of a block, whose ¯rst element is rþ 1 It is:

rþ 1 11 1|fflfflfflffl{zfflfflfflffl}

k1

22 2

|fflfflfflffl{zfflfflfflffl}

k2

rr r|fflfflffl{zfflfflffl}

kr

rþ 1r þ 1 r þ 1

|fflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl{zfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl}

krþ11

rþ 2r þ 2r þ 2

|fflfflfflfflfflfflfflfflfflfflfflffl{zfflfflfflfflfflfflfflfflfflfflfflffl}

krþ2

nn n|fflfflfflffl{zfflfflfflffl}

kn

:

It becomes the input of the second computing process The second pivot chosen is the ¯rst iterative permutation of a block, whose ¯rst element is sþ 1 It is:

sþ 1 11 1|fflfflfflffl{zfflfflfflffl}

k1

22 2

|fflfflfflffl{zfflfflfflffl}

k2

ss s|fflfflffl{zfflfflffl}

ks

sþ 1s þ 1 s þ 1

|fflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl{zfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl}

ksþ11

sþ 2s þ 2s þ 2

|fflfflfflfflfflfflfflfflfflfflfflffl{zfflfflfflfflfflfflfflfflfflfflfflffl}

ksþ2

nn n|fflfflfflffl{zfflfflfflffl}

kn

:

and it becomes the input of the third computing process The last iterative permu-tation of the ¯rst sub-sequence is indeed the last in a block, whose ¯rst element is r

Trang 9

Then it is the following iterative permutation:

r nn|fflfflfflffl{zfflfflfflffl} n

kn

n 1n  1 n  1

|fflfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl{zfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl}

kn1

r þ 1r þ 1 r þ 1|fflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl{zfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl}

krþ1

 rr r|fflfflffl{zfflfflffl}

kr1

r 1r  1 r  1

|fflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl{zfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl}

kr1

11 1|fflfflfflffl{zfflfflfflffl}

k1

:

So the termination for the ¯rst computing process is: A½1 ¼ r ^ p ¼ 1

The last iterative permutation of the ¯rst sub-sequence is indeed the last in a block, whose ¯rst element is s It is just the following iterative permutation:

s nn|fflfflfflffl{zfflfflfflffl} n

kn

n 1n  1 n  1

|fflfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl{zfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl}

kn1

s þ 1s þ 1 s þ 1|fflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl{zfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl}

ksþ1

 ss s|fflfflffl{zfflfflffl}

ks1

s 1s  1 s  1

|fflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl{zfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl}

ks1

11 1|fflfflfflffl{zfflfflfflffl}

k1

:

Thus, the termination for the second computing process is: A½1 ¼ s ^ p ¼ 1 The sequence of all iterative permutations of the multi-set X is divided into three sub-sequences as in Table 2

These three sub-sequences are generated concurrently by three parallel computing processes, with the corresponding input and termination condition, executed

Table 2 Three sub-sequences of iterative permutation of the multi-set X.

Sub-sequence

Iterative permutations

k 1

22 2

|fflfflfflffl{zfflfflfflffl}

k 2

ii i |fflfflffl{zfflfflffl}

k i

nn n |fflfflfflffl{zfflfflfflffl}

k n

r nn |fflfflfflffl{zfflfflfflffl} n

k n

n  1n  1 n  1

|fflfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl{zfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl}

k n 1

r þ 1r þ 1 r þ 1 |fflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl{zfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl}

k rþ1

rr r

|fflfflffl{zfflfflffl}

k r 1

r  1r  1 r  1

|fflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl{zfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl}

k r1

11 1 |fflfflfflffl{zfflfflfflffl}

k 1

2 r þ 1 11 1|fflfflfflffl{zfflfflfflffl}

k 1

22 2

|fflfflfflffl{zfflfflfflffl}

k 2

rr r |fflfflffl{zfflfflffl}

k r

r þ 1r þ 1 r þ 1

|fflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl{zfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl}

k rþ1 1

r þ 2r þ 2r þ 2

|fflfflfflfflfflfflfflfflfflfflfflffl{zfflfflfflfflfflfflfflfflfflfflfflffl}

k rþ2

nn n |fflfflfflffl{zfflfflfflffl}

k n

s nn |fflfflfflffl{zfflfflfflffl} n

k n

n  1n  1 n  1

|fflfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl{zfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl}

k n1

s þ 1s þ 1 s þ 1 |fflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl{zfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl}

k sþ1

ss s

|fflfflffl{zfflfflffl}

k s 1

s  1s  1 s  1

|fflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl{zfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl}

k s 1

11 1 |fflfflfflffl{zfflfflfflffl}

k 1

3 s þ 1 11 1|fflfflfflffl{zfflfflfflffl}

k 1

22 2

|fflfflfflffl{zfflfflfflffl}

k 2

ss s |fflfflffl{zfflfflffl}

k s

s þ 1s þ 1 s þ 1

|fflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl{zfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl}

k sþ1 1

s þ 2s þ 2s þ 2

|fflfflfflfflfflfflfflfflfflfflfflffl{zfflfflfflfflfflfflfflfflfflfflfflffl}

k sþ2

nn n |fflfflfflffl{zfflfflfflffl}

k n

nn n

|fflfflfflffl{zfflfflfflffl}

k n

n  1n  1 n  1

|fflfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl{zfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflfflffl}

k n 1

ii i |fflfflffl{zfflfflffl}

k i

11 1 |fflfflfflffl{zfflfflfflffl}

k 1

Trang 10

concurrently on three processors P1, P2 and P3 as follows:

Ngày đăng: 16/12/2017, 09:09

TỪ KHÓA LIÊN QUAN