Download - petri net 2

Transcript
Page 1: petri net 2

Solutions of the System Modeling Course

Examination

March 7, 2003

1. Explain the difference between Untimed, Synchronous and Timed modelsof computation in terms of time.(20 points)

2. Consider the alphabet Σ = {a, b, c, d} find a regular expression for thelanguage where each sting contains exactly one c or exactly one d.(10points)SOLUTION:

(a + b + d)∗c(a + b + d)∗ + (a + b + c)∗d(a + b + c)∗

1

Page 2: petri net 2

3. Consider the alphabet Σ = {a, b, c, d} construct a deterministic finite statemachine which recognizes all the strings which contain exactly two c orexactly two d.(10 points)

SOLUTION:

0

ccdd

c cc

cd ccdd

dd cdd

cc

c c

c c

d

d

d

d

d

d

a,b

a,b

a,b

a,b

a,b

a,b

c

c

c

ccc

d d d d

d

da,b

a,b

a,b

a,b,d

a,b,d a,b,d

a,b,c,d

a,b,c

a,b,c

a,b,c

4. For a finite state machine M = (Σ,∆, X, x0, g, f) where:Σ = {0, 1}∆ = {0, 1}X = {x0, x1}

g(x0, 0) = x0

g(x0, 1) = x1

g(x1, 0) = x1

g(x1, 1) = x0

f(x0, 0) = 0f(x0, 1) = 0

2

Page 3: petri net 2

f(x1, 0) = 0f(x1, 1) = 1

find a corresponding Petri Net.

0/0

1/0

1/1x1x0

0/0

(20 points)

SOLUTION:

P = {x0, x1, 0I , 1I , 0O, 1O}T{tx0,0I

, tx0,1I, tx1,0I

, tx1,1I}

~y = [1, 0, 0, 0, 0, 0]I(tx0,0I

) = {x0, 0I}I(tx0,1I

) = {x0, 1I}I(tx1,0I

) = {x1, 0I}I(tx1,1I

) = {x1, 1I}O(tx0,0I

) = {x0, 0O}O(tx0,1I

) = {x1, 0O}O(tx1,0I

) = {x1, 0O}O(tx1,1I

) = {x0, 1O}

3

Page 4: petri net 2

0I

1I

0o

1o

x0

x1

tx0,0I

tx0,1I

tx1,0I

tx1,1I

5. Consider the Petri net defined by:P = {p1, p2, p3, p4}T = {t1, t2, t3, t4 }

A = {(p1, t2), (p2, t3), (p2, t4), (p4, t1), (p4, t3),(t1, p1), (t1, p2), (t2, p3), (t2, p4), (t3, p1), (t4, p3)}with weights: w(t1, p1) = 2,w(t1, p2) = 1,w(t2, p3) = 1,w(t2, p4) = 1,w(t3, p1) = 4,w(t4, p3) = 1,w(p1, t2) = 2,w(p2, t3) = 2,w(p2, t4) = 2,w(p4, t1) = 1,w(p4, t3) = 2;

4

Page 5: petri net 2

Let x0 = [0, 0, 0, 2] be an initial state:

(a) Write the incidence matrix A. (5 points)

(b) Draw the corresponding Petri net graph. (5 points)

(c) Construct the coverability tree of the Petri net. (10 points)

(d) Find a weighting vector such that the Petri net conserves the numberof tokens and the constant C. (10 points)

SOLUTION:

A =

2 1 0 −1−2 0 1 1

4 −2 0 −20 −2 1 0

vec=[1,0,0,2]

P2

P4

P1

P3

t4t1

t3

t2

5

Page 6: petri net 2

[4,w,w,0]

[2,w,w,1]

[0,w,w,2]

[2,w,w,1] [2,w,w,1] [4,w,w,0]

[4,0,1,0]

[2,0,2,1]

[4,w,w,0] [0,0,w,2]

[2,w,w,1]

[4,2,0,0] [0,w,w,2]

[2,1,0,1]

[0,0,0,2]t1

t1

t1

t1 t1

t1

t2

t2 t4

t2

t2 t3

t2

t2

t4

t4 t4

6. Using the equation ~x = ~x0 + ~zA show that ~x = [3, 2, 4] is not reachablefrom ~x0 = [2, 2, 4] for the acyclic Petri net defined by:

P = {p1, p2, p3},T = {t1, t2, t3}and the incidence matrix:

A =

−1 0 2

0 2 −13 −1 −2

(10 points)

SOLUTION:

[3, 2, 4] = [2, 2, 4] + [nt1 , nt2 , nt3 ]

−1 0 2

0 2 −13 −1 −2

3 = 2 − nt1 + 3nt3

2 = 2 + 2nt2 − nt3

4 = 4 + 2nt1 − nt2 − 2nt3

Solving the equation system we get: nt1 = 5/7,nt2 = 2/7,nt3 = 4/7. Sincewe can execute transition only an Integer number of times and the givennumbers are not Integers the Petri net can not reach the required state.

6

Page 7: petri net 2

f g h

Process P

a

b

c ab

c a cux v

7. A process P consists of three sub-processes Q1, Q2, Q3.

The three sub-processes are defined by the following characteristic func-tions:FQ1 = f(a, b) = (a + b)FQ2 = g(a, b) = (b − a)FQ3 = h(a) = (−3a)

(a) What is the characteristic function FP in the perfectly synchronousmodel? (10 points)SOLUTION:

FP (x) = (u, v) = (h(g(f(x, v), u), g(f(x, v), u))= (h(g(x + v, u)), g(x + v, u))= (h(u − x − v), u − x − v)= (−3u + 3x + 3v, u − x − v)

{u = −3u + 3x + 3vv = u − x − v

v = u − x − v ⇒ v = u/2 − x/2u = −3u + 3x + 3v ⇒ u = 3x/4 + 3v/4 = 3x/4 + 3/8u − 3/8x =3/8u + 3/8x ⇒ u = 3/5x

(b) What is the characteristic function FP in the clocked synchronousmodel? (10 points)SOLUTION:

FP (xi) = (ui, vi) = (∆h(∆g(∆f(xi, vi), ui),∆g(∆f(xi, vi), ui))= (∆h(∆g(xi−1 + vi−1, ui)),∆g(xi−1 + vi−1, ui))= (∆h(ui−1 − xi−2 − vi−2), ui−1 − xi−2 − vi−2)= (−3ui−2 + 3xi−3 + 3vi−3, ui−1 − xi−2 − vi−2)

8. Given is a synchronous data flow graph:

Determine the following:

(a) The topology matrix and its rank. (10 points)

7

Page 8: petri net 2

1 2 3 4

5 6

A

B

C

D

8

4

2

1

4

1

1

4

3

121

2

(b) The smallest q such that Γq = 0. (10 points)

(c) A periodic admissible schedule and the initial buffer conditions. (10points)

SOLUTION:

A =

8 −4 0 0−2 1 0 0

0 0 1 −40 0 −3 120 4 −1 0

−2 0 0 1

Rank(A) = 3

q=[1,2,8,2]

If the schedule = {ABBCCCCCCCCDD} then the b0 = [0, 2, 0, 24, 0, 2]

020

2402

A→

800

2400

B→

410

2440

B→

020

2480

C→

021

2170

C→

022

1860

C→

023

1550

C→

024

1240

C→

025930

C→

026620

C→

027310

C→

028000

D→

024

1201

D→

020

2402

9. “pr mealy = mealySY f g s0” defines a Mealy FSM which has next-statefunction f, output-function g and initial state value s0. Define a pro-cess network in ForSyDe which has the same functionality as the pro-cess pr mealy without using process constructors mealySY and mooreSY.

8

Page 9: petri net 2

You are allowed to use the following process constructors : {mapSY, zip-WithSY, scanlSY, scanl2SY, scanlDelaySY, scanlDelay2SY, delaySY,zipSY,unzipSY }.(20points)

SOLUTION:

pr2 = scanlDelaySY f s0pr3 = zipWithSY g

system inA = outpwheres1 = pr2 inAoutp = pr3 s1 inA

Grading : 141 . . . 160 points → 5111 . . . 140 points → 481 . . . 110 points → 30 . . . 80 points → Failed

9