Tải bản đầy đủ (.pdf) (10 trang)

DSpace at VNU: Shift-Left Algorithms transforming sequential processes into concurrent ones

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (3.78 MB, 10 trang )

VNU. JOURNAL O F S C IEN C E, Mathematics - Physics, T.XXII, N q2, 2006

“SHIFT-LEFT” ALGORITHMS TRANSFORMING
SEQUENTIAL PROCESSES INTO CONCURRENT ONES
H oang Chi T hanh
H anoi U niversity o f Science, V N U H
Abstract. Finding concurrent processes of a system is an objective of system
controls, because it shows an optimal way to perform processes. In this paper
we build two iterative algorithms for transforming sequential processes of a
reliance alphabet and of a Place/Transition net into concurrent ones. The
complexity of these algorithms is also considered.
K eyw ords: Reliance alphabet, trace, Petri net, concurrent step.

1. INTRO DUCTIO N
C ontrols on c o n c u rre n t system s alw ays a re a n im p o rta n t a n d com plicated
problem . So far, o p tim al perform ance of processes occurred on a c o n c u rre n t system
is am ong th e controls. F o r th is purpose, recognition of c o n c u rre n t processes of th e
system is e sse n tia l. A lo t of m odels, such as P e tri n e ts [6,9], tra c e s [1,3,4, 8], CSP
[7], CCS [5], process a lg e b ra s [2]
have been b ein g good tools for rep re se n tin g
s ta tistic a l as w ell as d y n am ical stru c tu re of system s. From th e s e m odels, seq u en tial
processes of a system a re n o t difficult to recognize b u t c o n c u rre n t ones still are.
T herefore, how to tra n sfo rm seq u en tial processes of a sy stem onto c o n cu rren t ones
is a g re a t problem on th e o ry and application indeed.
A sim ple alg o rith m for finding th e norm al form of tra c e s is a good solution for
system s re p re se n te d by relian c e alp h ab et. P la ce /T ran sitio n n e t is one of su itab le
m odels to re p re s e n t c o n c u rre n t system s. B ut th e lan g u a g e g e n e ra te d by a P/T n e t is
seq u en tial. I t show s u s only seq u en tial perform ances of th e n e t’s processes. So
w hen sev eral tra n s itio n s c an be perform ed co n cu rren tly . W e w ill co n ce n tra te on
building a n ite ra tiv e a lg o rith m for tran sfo rm in g s e q u e n tia l p ro cesses of a P/T n e t
into c o n cu rren t ones.


T his p a p e r is o rg an ized as follows. Section 2 c o n stru c ts a “sh ift-le ft” algorithm
for finding th e n o rm al form of a trace. In Section 3 we propose th e n o tatio n of
concurrency in P/T n e ts . Section 4 builds up a n ite ra tiv e a lg o rith m for finding
sequences of m axim al c o n c u rre n t step s on a P la c e /T ra n sitio n n e t from th e n e t’s
sequence of single steps. F in ally , some conclusions a re given in S ection 5.

2. N orm al fo rm o f tr a c e a n d its fin d in g
T he th e o ry of tra c e s w as o rig in ated by A. M arzu rk iew icz in [4] a s an a tte m p t
to provide a good m a th e m a tic a l description of th e b e h a v io u r of c o n c u rre n t system s.
T he n o rm al form of a tra c e gives a n optim al way to p erform a p ro cess re p re se n te d
55


H oang Chi T hanh

56

by th e trace. In th is section we will c o n stru ct a sim ple ite ra tiv e alg o rith m for
finding th e n o rm al form of a trace.

2.1.

In depen den ce re la tio n a n d traces

D e f in itio n 2.1: L et E be an alp h ab et.
1 . A n independence relation over z is a sy m m etric a n d irreflexive b in a ry

relatio n over z.
2 . A reliance a lp h a b et is a couple c = (E, I), w here E is an a lp h a b e t and I is an


independence re la tio n over s.
C onsidering a d ja ce n t in d ep e n d en t sym bols in a s trin g to be com m uting, one
can re la te d ifferen t strin g s as follow.
D e f in itio n 2.2: L et c = (Z, I) be a reliance a lp h a b e t.
1. The relation =c c= Z*xZ* is defined as follow: for X, y e E*, X =c y if and only if
there exist Xj, x 2 € E* and (a,6) € I such that X = x j a b x 2 and y = x j b a x 2.
2 . The C -equivalence relation =c c

is defined a s th e le a s t equivalence

relatio n over E* co n ta in in g = c .
T hus, =c id en tifies ‘com m utatively sim ila r’ s trin g s — each such group of
strin g s is called a trace.
D e f in itio n 2.3: L et c = (£, I) be a reliance a lp h a b e t.
1. For an X e E*, t h e t r a c e o f X, denoted by [x]c , is the equivalence class of
containing X.

=c

2. A tr a c e over c is a set t of strings over E such th at t = [*]c for some X e £*
and X is called a representative of t .
3. A set of tra c e s over c is called a trace language over c .
E x a m p le 2.4: L et c = (E, I) be th e reliance a lp h a b e t given by th e u n d irected
g rap h in Fig. 1.
a

b

c


d

The trace t of abcecd = [abcecd]c = {abcecd, bacecd, acbecd, abeccdy abcced,
abcedcy baeccd, bacced, bacedc, acebcd, acbced, acbedc, aebccd, abecde, abccdel.

2.2.

N o rm a l form o f tra ces

One can define a com position operation on tra c e lan g u ag e.


“S h itf-left” a lg o r ith m s tr a n sfo r m in g seq u en tia l p rocesses..

57

D e f in i t io n 2.5: L et c —(£, I) be a reliance a lp h a b e t.
F o r tra c e s t h t2 over c , the trace com position of tj a n d t2, denoted by t,.t2, is
defined by t , t 2 = [Xj.x2]c> where Xj, x 2 € £* are representatives of tỵ and t 2
respectively.
In g en eral, a tra c e can be o b tain ed as a trac e com position of o th e r traces b u t
trace decom positions of th e given trace do not h ave to be unique. Hence it is
d esirab le to h a v e ‘n o rm al form ’ decom position of traces.
D e f in i t io n 2.6: L et c = (£, I) be a reliance a lp h a b e t a n d / be a trace over c .
The following decom position t = t,.t2. □ tm, such th a t:
1 . for a ll 1 s i s m, £, * 0 ;

2. for all 1 < i < m , t, can be w ritten as [«;], where Uị G £*, #a(u,)=l for each a e
alph(u,), and (a ,b ) e I for a ll a, b e alph(Uj) such th a t a # b ; an d
3. for a ll 1 s ỉ' s m -1, if Í, = [Uj] and tUj = [ui+1] th e n , for each a e a lp h ( u 1+i),

there exists b e alph(ii(), such that (a , b ) Ể I; is called the normal form of the trace t.
In [ 1 ] J . I. A a lb e rsb e rg an d G. Rozenberg poin ted o u t th a t every trace can be
uniquely decom posed in to a n o rm al form, i.e. a m in im al n u m b er of ‘m axim al
in d ep en d en t p a rts . T hey h a v e b u ilt two algorithm s for fin d in g th e norm al form of
traces. T he firs t a lg o rith m is b ased on in teg er p o in ters a n d th e second one is based
on dependence g ra p h s.
In th e n e x t su b sec tio n we b u ild a sim ple ite ra tiv e alg o rith m for finding the
norm al form of a tra c e from its re p re se n ta tiv e .

2.3.

A lg o rith m fo r f in d in g the n orm al form o f tra ces

We give a n in tu itiv e d e scrip tio n of th e algorithm . F ir s t we consider th e in p u t
strin g a s a se q u en ce of sin g le p a rts , every p a rt co n sists of one symbol. The
alg o rith m re p e a te d ly goes back on th e sequence of p a rts a n d sh ifts a symbol from a
p a rt onto th e p rev io u s p a r t if th e symbol is in d e p e n d e n t w ith every symbol
belonging to th e p rev io u s p a rt. W hen no symbol can be shifted, th e algorithm
term in a te s.
A lg o r ith m 2 .7 (“S h ift-le ft” a lg o rith m 1 ):
In p u t: A re lia n c e a lp h a b e t c = (£, I) and a s trin g w e z*.
D e cla ra tio n : L e t k = I w I , le t V be an a rra y of le n g th k over 2s and let u be an
a rra y of le n g th k over I*.
C o m p u ta tio n:
1 . for i := 1 to k do v(i) := {i£>[i]};
2 . 7':= 2 ;

3. re p e a t
4. for ev ery a € u(j) do
5. begin



H oang Chi T hanh

58
6 . i := j - 1; OK := false-,

7. w hile V b € v(i), (a ,b )



I do begin i:= i -1

8 . if OK th e n begin v(j)

:=

v(j) \ {o}; ư(i):= v(i) u {a}end;

;

OK :=true end;

9. end;
10 . if v(j) - 0 th e n ignore v(j) and d ecrease k := k - 1 ;

1 1 .j := 7 + 1 ;
12 . u n til j > k ;
13. for i := 1 to £ do u(i) :=


lin(u(i,)) ;

O utput: T he strin g s u (l), u(2),

u(k).

E x a m p le 2.8: L et c be th e reliance alp h a b et given in E xam ple 2.4 an d let
U) = a e cb b e d . Computing by the above algorithm, we have:
V : (a/, lei. I d , Ibl, Ibl, {el, id} ; k - 7
V : iq i, ie, cl, lb), ibl, lei, IdI ; k = 6
u : {a, bl, le, cl, (bl, lei, Idl ; k = 5
V : la, bl, le, c, bl, lei, [ d j ; k = 4
V : la, bl, le, c, b}, le, d l ; k = 3

Hence, th e o u tp u t of th e algorithm is u( l ) = ab , u(2) = bee , u(3) = de.
Formalizing the above we get the'following result.
T h e o r e m 2.9: L et c = (£, I) be a relian ce alp h a b et a n d le t w e £*. L et strin g s
u(l), u(2),..., u(k) be th e o u tp u t of A lgorithm 2.7 for th e in p u t (C,u;). T hen
[u(l)].[u(2)] ... [u(k)\ is th e norm al form of [w].
The alg o rith m is very sim ple and easy to im plem ent on com puter. It tra n sfe rs
a se q u en tial process re p re se n te d by a strin g into a c o n c u rre n t process. T he
com plexity of th is alg o rith m is 0 ( k 2).

3 . Concurrency in P/T nets
F irs t of all, we recall som e n o tatio n s concerning P e tri n ets.

3.1. P la ce/T ra n sitio n nets
A P etri net is a trip le N = (P, T, F), w here p, T a re d isjo in t se ts and F c ( P x T )
u (T X P) is a relatio n , so-called the flow relation of th e n e t N.
A n e t is sim ple if and only if its two different e le m e n ts h ave no common p re ­

se t and p ost-set. A sim ple n e t is used to re p re se n t s ta tis tic a l s tru c tu re of a system .
From a sim ple n et one can co n stru ct different n e t m odels by adding some
com ponents for re p re se n tin g dynam ical stru c tu re of th e system . The
Place/Transition net is such a net and is defined in [6] as follows:


“S h itf-le ft” a l g o r i t h m s tr a n s f o r m in g s e q u e n tia l p ro c e s se s..

59

D e fin itio n 3.1:
The 6-tuple X = (P, T, F, K, M°, W) is called a
rLace / T ra n sitio n net iff:
l . 7 í = (P, T, F) is a sim ple net, whereas an elem ent of p is called a p l a c e and

an elem ent of T is called a tra n sitio n .
2. K : p
N 3. w : F -> N \ {oc} is a function assig n in g a w eight on each arc of the flow
relation F.
:p
u ^ is an in itia l m arking, which is not g re a te r th a n capacity
on each place, i.e.: V p e p, M°(p) < K(p).
The in itial m arking represents given tokens on each place of a net. The tokens
a re no g re a te r th a n th e cap a city of the corresponding place. If to k en s on each place
belonging to the pre-set of som e transition are greater than or equal to w eight of the
arc connecting th is place to th e transition, i.e. it is enough for “paying” then the
nitial m ark in g can a c tiv a te th e corresponding tra n sitio n A fter perform ing the
Place. bei- 2 n g to the p r e se t of th is“


ion are

and tokens o 7 1
1
Kr
COnneCting ^ cor^ P o n d i n g place to th is tra n sitio n
ea
ce beIon^ ng t0 the p °s t -set of th is tra n s itio n a re increased by
weight of th e arc connecting th is tran sitio n to the corresponding place It m ust be
ensured that new tokens on each place are not greater than the O pacity of that place
perform edna n d t h in itia l T rk in g „activ ates som e tra n s itio n , th e tra n s itio n is
tra n s itio n ĩ n d
n we
a new m ark in g ’ th e new m a rk ing can a c tiv a te a n o th e ĩ
.
.
u
pr0ces! re p e a te d ly continues in such a way. T herefore, th e
ac ivities h a p p e n e d on a P/T n e t will be
m ath em atically form alized a s follows: ’
T h e m a r k i n g M : p -> N u {oc} can a c tiv a te a t r a n s i t i o n t iff:
1. V p e 't , M ip) > w (p, t) and

of t

2 V p 6 * ’ M (p^ ~ K (p^ " W ^ ' P^’ w here 't' t% a re th e p re -s e t an d th e po st-set

t.h J n
a l a s e ’ th e m a yk in g M is S0' called M o tiv a tin g . A fter perform ance of
th e tra n s itio n t, we get th e follow ing new m arking:

M(p) - W(p,t)

, if p

M ’fpJ = M (p) + W (t,p)

, if p e t' \ 't

M (p) - W(p,t) + W (t,p) , if p e ' t n t '
, otherwise

M (p )

and we often w rite th a t: M [í > M ’

»ím Ĩ. This, Zt .

°11 a,

SOrae 0ther, tra n siti0 n and th e n we s e t a " ° th “
m ark in g s reachable from th e m a rk in g M i s den o ted by
° sto ie spoce of * e " e t *

narkings and ĩ : Ĩ : F ’ r
,

11 is “ •

‘ f° r


T b " • P /T "e t' i * * M'’ M/ ........ M" be a “ «>>•“ * of
be a sequence of tra n s itio n s of th e n e t I , such th a t:


Hoang Chi T hanh

60

M‘ '[ í* > M ', ỉ = 1, 2, ... , n.
T he sequence M°[ t 1 > M ‘[ t2 > M 2 ... Mn l [ r > M n i l l u s t r a t e s aseq u en tial
process of th e n e t and th e word a = t 1 t2 ... tn e T * is called activities sequence on
th e n et.
The set of all activities sequences on the net £ is called the la n g u a g e g e n e r a t e d
by the net £ and denoted by L(z):
L(E) = { t ể t2 ... t n 13 M 1, M 2 , . . . , M n l, Mn e *[M °] :
M°[ t 1 > M‘[ t2 > M2 . . . Mn l[ tn > Mn}
B u t th e lan g u ag e g e n erate d by a n e t is seq u en tial. I t show s us only seq u en tial
perform ances of th e P/T n e t’s processes.
So w hen several tra n s itio n s of th e n e t can be perform ed concurrently.

3.2. Sequence o f m a x im a l concurrent steps
L et u c T be a su b se t of tra n s itio n s of th e n e t z and u * 0 .
D e f in itio n 3.2: T he su b set u is called a step on th e
m ark in g M 6 |«[M 0) satisfy in g th e following in equalities:
1 . V p e *u, M(p) > £

n e t I iff th e re is a

w (p, t) and


teU

2 . V p 6 u \ M (p) < K(p) - X

p )'

teU

In such a case, the transitions in the step u can be performed concurrently
and a fte r th e ir perform ance we get th e following m arking:
M(p)-ỵw(p,t)

ưu

M(p)

+

X

w (t’P)

, i f

p

6

u


,

p

e

u *

\

p

G

* u

n

i f

\

u

* u

M ’(p) =

M(p) - ỵ W(p,t)
tẻu


+

X

w(t>p)

tèu

M(p)
We also denote th a t: M[

u > M ’ and th e

, i f

u *

, otherwise
m arking M is called U -activatin g .

Such as above, we can find sequences of step s on th e n et. As big are th e steps
as hig h concurrency is.
E x a m p le 3.3: C onsider a P/T n e ts p resen te d by th e labelled directed b ip a rtite
g rap h in Figure 2.


s h i t f - l e f t a lg o r ith m s tr a n s fo r m in g s e q u e n tia l processes...

^


K



Pi

3

3

P2

2

0

Ps

8

1

P4

5

5

Ps


4

1

F ig 2. A P/T net

On this net we recognize the following sequential process:


[ tt >

M1

[h >

M2

[ t3 >

M3

[t4>

M4

Pi

3


1

2

2

2

P2

0

2

0

0

0

Pi

1

6

6

2


4

p4

5

2

2

2

0

Ps

1

1

4
----------The initial m arking M° can activate the subset {t„ t 4} and we have:
2



4

-


M° [ {tj, t4} > M r = ( 1 , 2 , 6 , 0 , 1 ).
So th e su b se t {th t 4} is a c o n cu rren t step on th is P/T net.
L et M°ỊUi > M 'fUa > M 2 ... Mk l[Uk > M k be a sequence of step s on th e n e t s.
The sequence illu strates a concurrent process on the net. What steps are “biggest”?
The following definition answ ers this question.
D e f in itio n 3.4: The sequence of step s M ^Ư ! > M 1[U2 > M 2 . . . Mk l[Uk> M k is
called a sequence o f m a x im a l concurrent steps iff for each i - 1 2 ... k-lVt

G

u i+1, M ''1 is not (UịUỊí}) -activating.

If transitions of each step can be performed concurrently, then the total time
for perform ance of th e process decreases considerably. T herefore, we alw ays expect
to find sequences of m aximal concurrent steps and at that time, the performance of
processes becomes optimal. In order to do so, we propose second “shift-left”
algorithm in the next section.


H oang Chi Thanh

32



A lgorith m fin d in g s e q u e n c e s o f m a x im a l c o n c u r r e n t ste p s

Let s = (P T F, K, M°, W) be a P/T net. Each se q u en tial process: M °[i; > MUi 2
> M2 .
> Mk of th e n e t m ay be considered as a sequence of single steps:

M°[{*;} > M '[{í2} > M 2 . . ,Mk l [{£*} > Mk and as an in p u t of our alg o rith m .
The algorithm repeatedly goes back on the sequence of steps and shifts a
t r a n s i t io n from a s te p in to t h e p rev io u s ste p if w h en a d d in g th e t r a n s i t i o n to th is
previo u s

step,

the

o b ta in sd

step

becom GS

activ a ted

b y

the

co rresp o n d in g

m arkin g.

When no transition can be shifted, the algorithm term inates.
A lg o r ith m 4.1 (“S h ift-left” alg o rith m 2):
I n p u t: A se q u e n tia l process M°[£;> M'[£2> M 2 . . . M k *[£*> M k on a P/T net.
Output'. A sequence of m axim al c o n cu rren t step s on th e net.
1 . for i := 1 to k do u , := {£,} ;

2 . for j := 1 to k-1 do

3. begin
4. i := j ;
5 . w hile i >= 1 do

begin
for every tra n s itio n t e U i+1,
if MM is (U ,u{i})-activating then
begin we replace:

M l l (p)-

I

W(p,t)

, if p 6 *(U, uW ) \ (U,

W(t,p)

, if p € (U,
tẻ ư ịẩ ịtì

M i i (p)+


tẻ U ịẩ ltl


M ‘(p) =
M i l (p)-


tè U ịẩ ltl

M l I (p)

W(p,t)+



W (t,p)

, if p e *(U, u{í}) n (U,

tè U ịẩ lt)

, otherwise

and u, := UịU{í} , U i+1 := ui+1\{i} , i.e. we “sh ift-left” th e tra n s itio n t from the
ỉtep u +1 into the previous step Uj. After shifting, if ui+
1=0 then we ignore both ui+1
____1 A /ĩi+ 1 .
and
Ml+1;

end ;
i := i - 1
end :

6. end ;
7. stop.
The algorithm goes back because we w ant not only m aking steps maximal
concurrent but also reducing the number of steps.


“S h itf-le ft” a lg o r ith m s tra n sform in g seq u en tia l p r o c e s s e s ..
Example 4 .2 : We apply this algorithm to the P/T net drawn in Fig. 2 with tltu
input M°[íi > M l [t2 > M 2[t3 > M 3[t4 > M4.
- After 1st going back:
The m arking M° is {tj, t2}- activating, so we shift left t 2 and get the follow ing
sequence:


[

>

M1

M2

[ {t3} >

[ {t4} >

M3

Pi


3

2

2

2

P2

0

0

0

0

p3

1

6

2

4

p4


5

2

2

0

Ps

1

2

4

4

------1--------1

- A fter 2 nd going back:
The m arking M 1 now is {t3, t 4}- activating, so we shift left t 4 and obtain th e
following sequence:


[ {^2^ 2} >

M1

[


>

M2

Pi

3

2

2

p2

0

0

0

Ps

1

6

4

p4


5

2

0

Ps

1

2

4

The obtained sequence M° [{tlft 2} > M l [{t3, t 4) > M2 is indeed a sequence of
maximal concurrent steps of the net..

Theorem 4 .3 : When Algorithm 4.1 term inates, its output is the sequence of
maximal concurrent steps of the P/T net.
The com plexity of this algorithm is 0 ( 1 T I. Ip I.k2). So the complexity is square
in the number of steps. This algorithm is sim ple and easy to im plem ent on
computers.

5 . Conclusion
In the paper, we construct one more a very sim ple algorithm for finding the
normal form of a trace; propose the notation of concurrent step on a P/T net and
build up an efficient algorithm to transform sequential processes of a P/T net into
concurrent ones. These algorithm s are not only useful for concurrency control on
system s but also suitable for calculating concurrent behaviours of a system with



H o a n g Chi Thanh

(34

jv n a m ic a l s tru c tu re s . T he a lg o rith m s m ay be applied for processing tra n sac tio n s on
d a ta b a se , for fin d in g th e norm al form of a sem i-trace.
A c k n o w le d g e m e n t-. T his p a p er w as w ritte n d u rin g my sta y a t De M ontfort
U n iv ersity, L eicester, UK. I would like to th a n k P rofessor Hongji Yang, Dr. D ang
Van H u n g an d th e IIST /U N U for my v aluable tim e a t L eicester.

R eferen ces
1.

J .I . A alb ersb e rg a n d G. R ozenberg, Theory o f Traces, T h eoretical C om puter
Science 60(1988), pp. 1-82.

2 J.A. Bergstra and J.w . Klop, Algebra for com m unicating processes with
a b stra ctio n , T h eo retical C om puter Science 37, 1(1985), pp. 77-121.
•3

R. Janicki, T r a c e s e m a n t i c s fo r c o m m u n i c a t i n g s e q u e n t i a l processes, Tech.
R ep o rt R-85-12, U niv. of A alborg, D enm ark, 1985.
C oncurrent program schem es a n d
DAIMI R e p o rt PB-78, A arh u s U niv., D enm ark, 1977.

4 A. M azurkiew icz,

ị.


th eir interpretations,

R. M ilner, C o m m u n ica tio n a n d Concurrency, P ren tice H all, 1989.

Ó. w . R eisig, P etri N ets: A n In tro d u ctio n , Springer-V erlag, 1985.
f.

A .w . Roscoe, The Theory a n d Practice o f Concurrency, P re n tic e H all, 1998.

ị H .c . T h a n h ,
A n a lg o rith m for fin d in g the norm al form o f traces and
synchronous traces, J o u rn a l of C om puter Science and C ybernetics, Vol. 17, No.


1(2001), pp. 72-77.
H .c . T h a n h , C ontrol problem on T im ed place I tra n sitio n nets, VNUH Jo u rn a l of
Science, Vol. XX, No 4(2004), pp. 48-55.