Concurrent Engineering - PowerPoint PPT Presentation

1 / 64
About This Presentation
Title:

Concurrent Engineering

Description:

Transition t is enabled to fire if its input place p1 is marked with at least w1 ... p such that the weighted sum of tokens, MT y = M0T y = constant, for every M R ... – PowerPoint PPT presentation

Number of Views:200
Avg rating:3.0/5.0
Slides: 65
Provided by: voicu1
Category:

less

Transcript and Presenter's Notes

Title: Concurrent Engineering


1
Hardware/Software Codesign of Embedded Systems
PETRI NETS II
Voicu Groza SITE Hall, Room 5017 562 5800 ext.
2159 Groza_at_SITE.uOttawa.ca
2
References
  • T. Murata, (1989) Petri Nets Properties,
    Analysis and Applications Proceedings of IEEE,
    Vol.77, No 4 pp 541-580. (http//www.cs.unc.edu/m
    ontek/teaching/spring-04/murata-petrinets.pdf)
  • Renâe David, Hassane Alla, Discrete, continuous,
    and hybrid Petri Nets, Springer, Berlin New
    York, 2005.
  • Peter Marwedel, Embedded system design, Kluwer
    Academic Publishers, Boston 2003.

3
Definition
  • Petri nets are a modeling tool designed to reveal
    information about the structure and dynamics of
    the modeled system.
  • A Petri Net is represented by a bipartite
    directed graph, with weighted arcs.
  • The graph has two kinds of nodes places and
    transitions.
  • The weighted arcs are either from a place to a
    transition or from a transition to a place.
  • A place that has an outgoing arc to a transition
    t is called input place of transition t.
  • A place that has an incoming arc from a
    transition t is called output place of transition
    t.
  • Arcs are labeled with their weight, which are
    positive integers.
  • Labels for unitary weight are usually omitted.

4
Dynamics
  • The dynamics of a PN is described by means of the
    concept of marking.
  • A marking is a function that assigns to each
    place a nonnegative integer, called token.
  • If we use the concept of conditions and events,
    places represent conditions and transitions
    represent events. A transition (an event) has a
    certain number of input places representing the
    pre-conditions and a certain number of output
    places representing the post-conditions.
  • Suppose a transition t has
  • one input place p1 marked with k1 tokens and
    the weight of the output arc w1
  • one output place p2 marked with k2 tokens and
    the weight of the output arc w2
  • Transition t is enabled to fire if its input
    place p1 is marked with at least w1 tokens. (w1
    k1 )
  • Firing t, it removes w1 tokens from its input
    place p1 and adds w2 to its output place p2.

5
Example
6
Interpretation
Transition type A transition is said to be pure
if it has no self-loop. An impure transition is
said to be isolated if all its input and output
arcs are null.
Some typical interpretation of places and
transitions
7
Modeling exampleCommunication Protocols
A very simple model of communication protocol
between two processes.
8
Synchronization Control
  • In a multiprocessor or distributed-processing
    system, resources and information are shared
    among several processors. This sharing must be
    controlled or synchronized to insure the correct
    operations of the overall system. Petri nets have
    been used to model a variety of synchronization
    mechanisms, including the mutual exclusion,
    readers-writers, and producers-consumers
    problems.
  • The Petri net shown in figure represents a
    readers-writers synchronization, where the k
    tokens in place p1 represent k processes
    (programs) which may read and write in a shared
    memory represented by place p3.
  • Up to k processes may read concurrently, but when
    one process is writing, no other process can read
    or write. It is easily verified that up to k
    tokens (processes) may be in place p2 (reading)
    if no token is in place p4. Only one token
    (process) can be in place p4 (writing) since all
    k tokens in place p3 will be removed through the
    k-weight arc when t2 fire once.

9
Properties
Two types of properties can be studied using
Petri nets
Properties dependent on initial marking M0 can be
referred to as behavioral properties
Properties that are depend on the topological
structures of Petri nets, and, i.e., independent
of the initial marking M0 are called structural
properties. They can be often characterized in
terms of incidence matrix.
  • Reachability
  • Boundedness
  • Liveness
  • Reversability and Homestate
  • Coverability
  • Persistence
  • Structural Liveness
  • Controllability
  • Structural Boundedness
  • Conservativeness
  • Repetitiveness
  • Consistency

10
Reachability
  • A marking Mn is said to be reachable from a
    marking M0 if there exist a sequence of firings
    that transforms M0 into Mn.
  • A firing sequence is denoted by
  • ? M0 t1 M1 t2 M2 .. tn Mn or simply
  • ? t1 t2 .. tn
  • In the case Mn is reachable from M0 by ? we write
    M0? ? Mn
  • The set of all possible markings reachable from
    M0 in a net
  • (N, M0) is denoted by R(M0).
  • The set of all possible firing sequences from M0
    in a net
  • (N, M0) is denoted by L(M0).
  • The reachability problem for Petri nets is the
    problem of finding Mn ? R(M0) for a given marking
    Mn and a set (N, M0).

11
Boundedness
  • A Petri net (N, M0) is said to be k-bounded or
    simply bounded if the number of tokens in each
    place does not exceed a finite number k for any
    marking reachable from M0.
  • Ex M(p) ? k for every place p and every marking
    M ? R(M0)
  • A Petri net is said to be safe if it is
    1-bounded.
  • Places in Petri nets are often used to represent
    buffers and registers for sharing intermediate
    data. By verifying that the net is bounded or
    safe it is guaranteed that there will be no
    overflows in the buffers or registers, no matter
    what firing sequence is taken.

12
Liveness
  • This concept is closely related to the complete
    absence of deadlocks (i.e., two or more
    components reciprocally condition their actions
    so that no action take place).
  • A Petri net (N, M0) is said to be live (or
    equivalently M0 is said to be a live marking for
    N) if no matter what marking have been reached
    from M0, it is possible to ultimately fire any
    transition of the net by progressing through some
    further firing sequence.
  • This means that a live Petri net guarantees
    dead-lock free operation, no matter what firing
    sequence is chosen.
  • Strong property, different levels of liveness are
    defined (L0dead, L1, L2, L3 and L4live)

13
Reversibility and Home State
  • A Petri net is said to be reversible if for any
    marking M ? R(M0) ( set of all possible markings
    reachable from M0), M0 is reachable from M. In a
    reversible net we can always get back to the
    initial marking or state.
  • In many applications it is not necessary to get
    back to the initial state as long as we can get
    back to some (home) state. A marking M is said
    to be in a home state if for each marking M ?
    R(M0), M is reachable from M.

14
Coverability
  • A marking M in a Petri net (N, M0) is said to be
    coverable if there exist a marking M ? R(M0) (
    the set of all possible markings reachable from
    M0) such that M(p) ? M(p) for each place p in
    the net.
  • Coverability is closely related to liveness.
  • Let M be the minimum marking needed to enable a
    transition t.
  • The transition t is dead if and only if M is not
    coverable or
  • transition t is live if and only if M is
    coverable.

15
Structural PROPERTIES
  • Structural Liveness
  • A Petri net N is said to be structurally live if
    exists a live initial marking for N.
  • Every marked graph is structurally live.
  • Controllability
  • A Petri net N is said to be completely
    controllable if any marking is reachable from any
    other marking.
  • Structural Boundedness
  • A Petry Net N is said to be structurally bounded
    if it is bounded for any finite initial marking
    M0.

16
Conservativeness
  • A Petri net N is said to be conservative if there
    exists a positive integer y(p) for every place p
    such that the weighted sum of tokens, MT ? y
    M0T ? y constant, for every M ? R(M0) and for
    initial marking M0.
  • In other words, a Petri net N is conservative if
    there exists an m-vector y of positive integers
    such that A ? y 0, y ? 0.
  • A Petri net N is said to be partially
    conservative if there exists a nonnegative
    (positive or zero) integer y(p) for some place p
    such that the weighted sum of tokens, MT ? y
    M0T ? y constant, for every M ? R(M0) and for
    initial marking M0.
  • In other words, a Petri net N is partially
    conservative if there exists an m-vector y of
    nonnegative (positive or zero) integers such that
    A ? y 0, y ? 0

17
Analysis Methods
  • One can identify three groups of methods for
    analysis of Petri nets
  • Coverability trees consist in enumeration of all
    reachable markings or their coverable markings.
    It is limited to small nets because of the
    complexity.
  • Matrix equation approach is powerful but in many
    cases is applicable only to special subclasses of
    Petri nets.
  • Reduction or decomposition ends with a general
    program to reduce Petri nets.

18
Coverability (reachability) tree 1
  • Tree representation of all possible markings
  • root M0
  • nodes markings reachable from M0
  • arcs transition firings
  • If net is unbounded, then tree is kept finite by
    introducing the symbol ?
  • Properties
  • a PN is bounded iff ? doesnt appear in any node
  • a PN is safe iff only 0s and 1s appear in nodes
  • a transition is dead iff it doesnt appear in any
    arc
  • if M is reachable form M0, then exists a node M
    that covers M

19
Coverability Tree 2
1) Label the initial marking M0 as the root and
tag it new. 2) While new markings exist, do
the following
  • 2.1) Select a new marking M.
  • 2.2) If M is identical to a marking on the path
    from the root to M, then tag M old and go to
    another new marking.
  • 2.3) If no transitions are enabled at M, tag M
    dead-end.
  • 2.4) While there exist enabled transitions at M,
    do the following for each enabled transition t at
    M
  • 2.4.1) Obtain the marking M that results from
    firing t at M.
  • 2.4.2) On the path from the root to M if there
    exists a marking M such that M(p) M(p) for
    each place and M?M, i.e., M is coverable, then
    replace M(p) by w for each p such that M(p) gt
    M(p).
  • 2.4.3) lntroduce M as a node, draw an arc with
    label t from M to M, and tag M new.

20
Coverability (reachability) Tree 3
  • For the initial marking M0 (1 0 0), the two
    transitions t1, and t3 are enabled. Firing t1,
    transforms M0 to M1 (0 0 1), which is a
    dead-end node, since no transitions are enabled
    at M1.

Now, firing t3 at M0 results in M3 (1 1 0),
which covers M0 (1 0 0). Therefore, the new
marking is M3 (1 ? 0), where two transitions t1
and t3 are again enabled.
Firing t1 transforms M3 to M, (0 ? 1), from
which t2 can be fired, resulting in an old node
M5 M4. Firing t3 at M3 results in an old node
M6 M3.
21
Coverability tree example
M0(100)
p1
t3
p2
t1
t0
t2
p3
22
Coverability tree example
M0(100)
t1
p1
t3
M1(001) dead end
p2
t1
t0
t2
p3
23
Coverability tree example
M0(100)
t1
t3
p1
t3
M1(001) dead end
M3(1?0)
p2
t1
t0
t2
p3
24
Coverability tree example
M0(100)
t1
t3
p1
t3
M1(001) dead end
M3(1?0)
t1
p2
t1
t0
M4(0?1)
t2
p3
25
Coverability tree example
M0(100)
t1
t3
p1
t3
M1(001) dead end
M3(1?0)
t1
t3
p2
t1
t0
M4(0?1)
M3(1?0) old
t2
p3
26
Coverability tree example
M0(100)
t1
t3
p1
t3
M1(001) dead end
M3(1?0)
t1
t3
p2
t1
t0
M4(0?1)
M6(1?0) old
t2
t2
p3
M5(0?1) old
27
Coverability tree example
M0(100)
100
t1
t3
t1
t3
M1(001) dead end
M3(1?0)
1?0
001
t1
t3
t1
t3
M4(0?1)
M6(1?0) old
0?1
t2
t2
M5(0?1) old
coverability graph
coverability tree
28
Incidence Matrix
Petri net representation of mutual exclusion
  • For a Petri net N with n transitions and m
    places, the incidence matrix A aij is an n x
    m matrix of integers and its typical entry is
    given by aij aij - aij- where
  • a w(i, j ) is the weight of the arc from
    transition i to its output place j and
  • a- w(j, i ) is the weight of the arc to
    transition i from its input place j .

A a b c d e ----------------------
t1 -1 1 0 0 -1 t2 1 -1 0 0
1 t3 0 0 -1 1 -1 t4 0 0 1 -1
1
29
State Equation
Let be marking Mk an m x 1 column vector. The
j-th entry of Mk denotes the number of tokens in
place j immediately after the k-th firing in some
firing sequence. The k-th firing or control
vector uk is an n x 1 column vector of n - 1 0's
and one nonzero entry, a 1 in the i-th position
indicating that transition i fires at the k-th
firing. Since the i-th row of the incidence
matrix A denotes the change of the marking as the
result of firing transition i , we can write the
following state equation for a Petri net. Mk
Mk-1 AT uk k 1, 2, 3,
Suppose that a destination marking Md is
reachable from M0 through a firing sequence u1,
u2, , ud . Writing the state equations for i
1 , 2 , . . . , d and summing them, we obtain
AT x ?M where ?M Md M0 and x is the
firing count vector. The i-th entry of x denotes
the number of times that transition i must fire
to transform M0 to Md.
An integer solution of the homogenous equation AT
? x 0 (i.e., M0 Md) is called T-invariant. An
integer solution of the transposed homogenous
equation yT ? AT A ? y 0 is called
S-invariant.
30
State Equation - Example
A p1 p2 p3 p4 ----------------------
t1 -2 1 1 0 t2 1 -1 0 -2
t3 1 0 -1 2
Mk Mk-1 AT uk , k 1, 2, 3,
For k1, the transition t3 fires to result in the
marking M1 (3 0 0 2)T from M0 (2 0 1 0)T
31
Necessary and Sufficient Conditions for some
Structural Properties
32
S-invariants
An m-vector y of integers is called an
S-invariant (place invariant) if A ? y 0
For any firing sequence S from M0, the marking
reached is given by Mk M0 AT s. Left
multiplication of both terms by yT leads to yT
Mk. yT M0 yT AT s. Thus, if yT AT 0,
we have yT Mk yT M0 whatever s may be, i.e.,
for every . Since yT M0 is
a scalar quantity, yT Mk is a marking
invariant. In other words, the number of tokens
in the set of places P(y) weighted by vector y,
is constant.
  • UAT 1 2 3 4
  • -------------------------------------
  • a 1 0 0 0 0 -1 1 0 0
  • b 0 1 0 0 0 1 -1 0 0
  • c 0 0 1 0 0 0 0 -1 1
  • d 0 0 0 1 0 0 0 1 -1
  • e 0 0 0 0 1 -1 1 -1 1
  • y1 0 1 0 1 1T
  • y2 0 0 1 1 0T
  • y3 1 1 0 0 0T
  • Since ? y ? 0, A ? y 0 ? this Petri net is
    structurally bounded.
  • Since ? y ? 0, A ? y 0 ? this Petri net is
    partially conservative.

33
S-invariants
  • For j1 we add new rows ab and be
  • -------------------------------------
  • ab 1 1 0 0 0 0 0 0 0
  • be 0 1 0 0 1 0 0 -1 1
  • Erase used rows a, b, e (having in col 1 elements
    not equal 0)
  • So we have
  • UAT 1 2 3 4
  • ---------------------------------------
  • c 0 0 1 0 0 0 0 -1 1
  • d 0 0 0 1 0 0 0 1 -1
  • ab 1 1 0 0 0 0 0 0 0
  • be 0 1 0 0 1 0 0 -1 1

34
S-invariants
  • For j3 we add new rows cd and dbe
  • cd 0 0 1 1 0 0 0 0 0
  • dbe 0 1 0 1 1 0 0 0 0
  • Erase used rows c, d, be (having in col 3
    elements not equal to 0)
  • So we have
  • UAT 1 2 3 4
  • ---------------------------------------
  • ab 1 1 0 0 0 0 0 0 0
  • cd 0 0 1 1 0 0 0 0 0
  • dbe 0 1 0 1 1 0 0 0 0
  • y1 0 1 0 1 1T
  • y2 0 0 1 1 0T
  • y3 1 1 0 0 0T

35
Search for S-invariants
36
T-invariants
A n-vector x of integers is called a T-invariant
(firing invariant) if it is a non-trivial
solution of
AT ? x 0 UA a b
c d e ---------------------------------------
- t1 1 0 0 0 -1 1 0 0 -1 t2
0 1 0 0 1 -1 0 0 1 t3 0 0
1 0 0 0 -1 1 -1 t4 0 0 0 1
0 0 1 -1 1 The T-invariants are x1
0 0 1 1T x2 1 1 0 0T
Mk Mk-1 AT ? xk Mk-1
37
Reduction
  • To facilitate the analysis of large systems, we
    often reduce the system model to a simpler one,
    while preserving the properties to be analyzed.
    Conversely, techniques to transform an abstract
    model into a more refined one can be used for
    synthesis.
  • There exist many transformation techniques for
    Petri nets.
  • Due to theirs complexity it is important to
    develop methods of transformations which allow
    hierarchical reductions and preserve properties
    to be analyzed. In such an approach, subnets are
    reduced to single transition or places while
    keeping liveness and/or boundedness properties

38
Analysis methods
  • Reduction rules that preserve liveness, safeness
    and boundedness
  • Fusion of Series Places
  • Fusion of Series Transitions
  • Fusion of Parallel Places
  • Fusion of Parallel Transitions
  • Elimination of Self-loop Places
  • Elimination of Self-loop Transitions
  • Help to cope with the complexity problem

39
Place Reduction R1
  • A place pi can be eliminated if
  • 1) Its output transition has no other input
    places.
  • 2) There is no transition that is simultaneous
    input and output.
  • 3) At least one output transition of pi has at
    least an output place.
  • The elimination process is associated with
    modifications of input and output transitions as
    well the marking.

40
Place Reduction (1)
  • If the place p to be eliminated has k outputs and
    is marked, then by eliminating process we obtain
    k distinct nets.
  • In each case the marking is placed in a place
    corresponding to an output transition.

The properties conserved by R1 reduction are
boundedness, safeness, liveness, reversibility,
conservability.
41
Implicit place reduction (R2)
  • A place pi is implicit if
  • Its marking permits execution of any output
    transition which can be executed if pi is
    ignored.
  • Its marking can be determined from the other
    places marking.
  • An implicit place can be eliminated together with
    its connected arcs

The properties conserved by R2 reduction are
boundness, liveness, reversibility,
conservability.
42
Null transition reduction (R3)
  • A transition is called null transition if and
    only if the set of its input places is the same
    with output places.
  • In the figure transition t5 is a null transition
    it can be reduced together with its connecting
    arcs.
  • Properties of boundness, safeness, liveness and
    conservability holds for initial Petri net if and
    only if they hold for reduced Petri net.

43
Reduction with invariants conservation
  • Pre(p, t) ?t the set of the input places of
    transition t.
  • Post(t, p) t? the set of output places of
    transition t.
  • Recall that
  • A Petri net is said to be ordinary if all of its
    arcs weights are 1.
  • A Petri net is said to be generalized if it has
    some arcs with weight greater than 1.
  • A transition is said to be pure if it has no
    self-loop. In other words all its inner products
    Pre(pj, t) x Post(t, pj) 0
  • A transition is said to be impure if it has a
    place p in the same time as input node and output
    node. In other words, at least one inner product
    Pre(pj, t) x Post(t, pj) ! 0

44
Identical transition reduction
  • Two transitions t1 and t2 is said to be identical
    if they have the same input places and the same
    output places.
  • It is possible to reduce one of them together
    with its input and output arcs.
  • The properties conserved by such a reduction are
    boundedness, safeness, liveness, reversibility,
    conservability.

45
Reduction with invariants conservation
  • The following transforms preserve the invariants
  • Ra reduction refers to impure transitions.
  • An impure transition t is a transition that has a
    place p which is, at the same time, an input node
    and an output node.
  • We reduce it by
  • -eliminating arcs (p, t) and (t, p).
  • -eliminating t if t becomes isolated.
  • Rb reduction refers to a pure transition.
  • It is absolutely necessary that the set of input
    places and the set of output places for this
    transition to be not void.
  • The Rb reduction works as follow
  • - replace each pair of places pi ? Pre(p, t) and
    pj ? Post(t, p) with a new place pi pj whose
    marking is M(pi) M(pj).
  • The input transitions of the place pi pj are
    given by
  • input transitions of pi ? input transitions of
    pj less transition t.
  • The output transitions of the place pi pj are
    given by
  • output transitions of pi ? output transitions
    of pj less transition t.

46
Irreducible cases
47
Example
  • Rb reductions are applied successively for
    transitions t2, t3 and t4.
  • Then a Ra reduction is applied to transition t1.
  • The result consists in two S-invariants as
    follows
  • M(p1) M(p2) M(p4) 1
  • M(p1) M(p3) M(p5) 2

(a) initial Petri net (b) after Rb(t2)
(c) after Rb(t3) (d) after Rb(t4) (e) after
Ra(t1)
48
Properties conserved by different types of
reductions
49
Ra ImpureTran Reduction Algorithm
  • Let t such a transition and a place p for which
  • Pre(pj, t) r gt 0 and Post(t, pj) q gt 0.
  • The reduction depends on the relation between r
    and q and consists in the reduction of the arc
    (p, t) or (t, p) as follows
  • if(r lt q)
  • reduce arc (p, t)
  • set the weight of the arc (t, p) r q
  • else if(r q)
  • reduce arc (p, t)
  • reduce arc (t, p)
  • else if(r gt q)
  • reduce arc (t, p)
  • set the weight of the arc (p, t) r p
  • Finally if transition t becomes isolated reduce
    it.

50
Rb PureTran Reduction Algorithm
  • Let t a pure transition which has at least one
    input place and at least one output place.
  • The process of elimination works as follows
  • -reduce the pure transition t.
  • -for each pair (pj, pk) where
  • pj is an input place of transition t and
  • pk is an output place of transition t
  • we associate a place q ? pj r ? pk, (where q
    Post(t, pk) and r Pre(pj, t)) having marking q
    ? M(pj) r ? M(pk)
  • -each input (output) transition of place pi
    (except t) becomes input (output) transition of
    the place q ? pj r ? pk with weight multiplied
    by q.
  • -each input (output) transition of place pk
    (except t) become input (output) transition of
    the place q ? pj r ? pk with weight multiplied
    by r.
  • The input transitions of the place q ?pj r ? pk
    are given by
  • input transitions of pj ? input transitions of
    pk less transition t.
  • The output transitions of the place pj pk are
    given by
  • output transitions of pj ? output transitions
    of pk less transition t.

51
The result shows the existence of one
invariant M(p3) 2M(p4) 2 The net is not
bounded.
52
Rez_a
53
Rez_b
54
Machine Example without Constraints
T-invariants describe sets of transitions which
reproduce the initial marking when occurring in a
suitable order. Example operators O1 and O2
work on M1, M2 and M3 machines
t9
  • There are four elementary t-invariants
  • t1 t2 t5 t6 t9 (process working only with
    operator 1 - O1)
  • t1 t2 t7 t8 t9 (process with operator 1 working
    first, and operator 2 afterwards)
  • t3 t4 t7 t8 t9 (process working only with
    operator 2 O2)
  • t3 t4 t5 t6 t9 (process with operator 2 working
    first, and operator 1 afterwards).

55
Machine Example with Constraints
p1 task A before a new execution,
  • p3 M1 available,
  • p5 O1 available,
  • p7 O2 available,
  • p8 M2 available,
  • p11 M3 available.

There are linear invariant equations
(place-invariants) holding in all reachable
markings m
t9
56
1-st Abstraction of the Machine Example
  • If the action of a machine is considered as an
    indivisible , then the two different transitions
    for its start and termination are combined,
    including the place connecting them.
  • The closed sets t1, p2, t2, t3, p4, t4, t5,
    p9, t6, and t7, P10, t8 are replaced by
    transitions t1, t3,
    t5 and t7 respectively.
  • The previous occurrence sequence t1t2t5 name t6
    corresponds here to t1t5

O2 available
t9
57
Further Abstraction of the Machine Example
M2
The net abstracts from the two modes of operation
of machine M1. The transitions are named Mi,
since their occurrence represents an entire
action of machine Mi on a task. The abstraction
includes places p3, p8, and p11 (Mi available),
M3
Here the places p5 (O1 available) and p7 (O2
available) are merged by abstraction to a new
place Pa.
58
More Abstractions of the Machine Example
  • The sub-net obtained by omitting place pa
    restricts the view of the system to the machines
    without representing the operators.
  • The first net of this slide can be abstracted to
    the net in the middle, where the set of actions
    of all machines is modeled by a single transition
    t.
  • In these examples, the abstractions have a
    meaningful dynamic behavior that is related to
    the behavior of the original refined net.
  • But, if for instance, as shown in the last
    figure, the original three places p5 (O1
    available), p7 (O2 available) and p6 are
    abstracted to one place px, then the initial
    marking is not predefined in a unique way

59
Implementation
Input The program reads the model description
from a text file specified as a command line
argument. The format of this input is A line
Places n containing the number of initial
places A line Transitions m containing the
number of initial transitions For each transition
y A line Pre(y) containing all touples (ltinput
placegtltweightgt) of this transition. Pre(y)
(ltinput placegtltweightgt) (ltinput
placegtltweightgt) A line Post(y) containing all
touples (ltoutput placegtltweightgt) of this
transition. Post(y) (ltoutput placegtltweightgt)
(ltoutput placegtltweightgt) A line Marking
containing the initial marking for each place,
space separated. Marking m0 m1 m2 ..
60
Implementation cont
Output The program displays the results and
writes them to a text file specified as a command
line argument. The format is the same with the
one used for the input except that only the
remaining transitions and remaining places will
be listed. Memory If we use static allocation of
the needed memory we are confronted with two
major disadvantages. - running a Petri Net of
dimensions far less than the allocated matrices
gives a bad memory utilization. - running a
Petri Net of dimensions greater than the
allocated matrices will result in rejecting the
Petri Net by the program or if no array bound
check has been designed, the system will crash.
61
Implementation cont
Dynamic allocation using new or malloc
operators is preferred in this situation but care
to avoid memory leaks. Due to the fact that
after each the dimensions of incidence matrix
changes, a good solution to the problem is to use
STL (Standard Template Library) taking into
consideration that STL is the most appropriate
for handling such situations. Classes The
implementation is organized in four classes as
follows A singleton class CPetriNet that governs
the whole process of reduction. A class
CTransition that handle the transitions and is
also base class. Two classes CImpureTran and
CPureTran that inherit from CTransition and
handle specific transitions.
62
Class Diagram_1ClassesThe implementation is
organized in four classes as followsCPetriNet
governs the whole process of reduction.CTransiti
on handles the transitions Two classes
CImpureTran and CPureTran that inherit from
CTransition and handle specific transitions.
63
Class Diagram_2
64
Main Loop
CPetriNet petri new CPetriNet(argv1) while(1
) // infinite loop int indexImpure
petri-gtgetIndexImpure() while(indexImpure !
-1) //Treat Impure petri-gtreduceImpure(inde
xImpure) indexImpure petri-gtgetIndexImpure()
int indexPure petri-gtgetIndexPure() if(in
dexPure ! -1) //Treat Pure petri-gtreducePu
re(indexPure) if(indexImpure -1
indexPure -1) break // brake the loop
Write a Comment
User Comments (0)
About PowerShow.com