Title: PN simulation, token games
1PN simulation, token games
- dr. András Pataricza pataric_at_mit.bme.hu
- dr. Tamás Bartha bartha_at_mit.bme.hu
- Department of Measurement and Information Systems
of BME
2Approaches for PN analysis
- Simulation
- Exploration of state space reachability graph
analysis - Structural and dynamical properties
- Invariant analysis
- Semi-decision (abstraction)
3Simulation
- Goal sound modeling of the real system
- sound validated (VV)
- Investigating the trajectories in the system
- State of the PN token distribution (marking)
- State transition firing
- Trajectories in the state space firing
sequences - PN is non-deterministic
- Non-determinism must be modeled as well
- Randomization
- Exploration (state space) interactive simulation
(decision)
4Simple simulation algorithm
- while (true) do
- Evaluation of fireable transitions (1)
- if There is fireable transition
- then Pick one to fire (non-det.)
- else End of simulation.
- Firing
- end while
(2)
5(1) Evaluation of fireable transitions
- function collect_fireable_transitions(M )
- // Set of fireable transitions
- Lfireable ? ?
- for all t ? T do
- if enabled(t, M ) then Lfireable ? Lfireable ?
t - return Lfireable
- end function
6(2) Firing
- // Initialization
- M ? M0
- Lfireable ? collect_fireable_transitions(M )
- while Lfireable ? ? do
- // Firing
- t ? rnd(Lfireable)
- M ? M W?et
- Lfireable ? collect_fireable_transitions(M )
- M ? M
- end while
7Redundancy
- Problem
- Why do we evaluate the fireability of every
transition (T evaluation), if only the
neighbourhood (?t ? t?) has been changed?
8Disabled transitions
- If t transition fires
- t transition may become disabled, if its input
is connected to ?t - If it is in conflict with t ?t ? ?t ? ?
- The numerical definition
- of tokens taken M- W-?et
- (Relevant) predecessors of t (input places) ?t
p ? P M-(p) gt 0 - transitions in conflict with t T (?t )?
9Enabled transitions
- If t fires
- Transition t may become enabled, if its input is
connected to t? - t may enable t ?t ? t? ? ?
- The numerical definition
- of tokens added M W?et
- (Relevant) successors of t (output places) t?
p ? P M(p) gt 0 - Transitions enabled by t T (t?)?
- T ARE SUFFICIENT TO EVALUATE!
10Efficient algorithm Initialization (1)
- Initialization is the same
- // Initialization
- M ? M0
- Lfireable ? ?
- // Initial set of fireable transitions
- for all t ? T do
- if enabled(t, M0) then Lfireable ? Lfireable ? t
11Efficient algorithm Firing phase (2)
- while Lfireable ? ? do
- // Firing
- t ? rnd(Lfireable)
- M ? M W?et
- // Omitting disabled transitions
- for all t ? (?t )? do
- if not(enabled(t, M )) then Lfireable ?
Lfireable \ t - // Adding enabled transitions
- for all t ? (t?)? do
- if enabled(t, M ) then Lfireable ? Lfireable ?
t - M ? M
- end while
12Priority
- Firing condition is extended t is fireable iff
- Enabled AND
- There exists no priority greater then its
priority ?(t ) - Conclusion
- Lfireable is not a set, but a vector of sets
ordered by ? ? ? priorities Lfireable ? - If firing we pick one transition (non-det.) from
the set (Lfireable ?) of the greatest priority
(?)
13Algorithm with priority Initialization (1)
- // Initialization
- M ? M0
- for all ? ? ? do
- Lfireable? ? ?
- // Initial set of fireable transitions
- for all t ? T do
- if enabled(t, M0) then Lfireable?(t ) ?
Lfireable?(t ) ? t
14Algorithm with priority Firing phase (2)
- while do
- for ? ?max to ?min step -1 do // Firing
- if Lfireable? ? ? then
- t ? rnd(Lfireable?)
- M ? M W?et
- exit for
- end if
- for all ? ? ? do // Enabled transitions
- for all t ? (?t )? do
- if not(enabled(t, M )) then Lfireable?(t) ?
Lfireable?(t) \ t - for all t ? (t?)? do
- if enabled(t, M ) then Lfireable?(t) ?
Lfireable?(t) ? t - end for
- M ? M
- end while
15Timeliness
- Introducing logical timeliness
- Actions (firings) takes a given amount of time
- Possibilities
- Non-timed transitions
- Timed transitions
- Deterministic timing
- Stochastic timing firing time is a stochastic
variable - Ex. Exponential distribution SPN (Stochastic
Petri Net)
16Timed Petri Nets
- Firing phases
- Firing condition
- Timing
- Stochastic transitions draw a value of timing
- One of the transitions (non-det.) of the smallest
timing value fires - Firing
- Stepping the logical time
17Problems to solve
- Timed vs. Non-timed transitions?
- Solution non-timed transitions with high
priority - immediate transition
- What if timed transitions are in conflict (one
fires and disables another one)? - Different semantics
- Timing starts again
- Reward saving
- For SPN doesnt matter (for the statistical point
of view) - Due to the memorylessness of the exponential
distr. - P(? ? xy ? ? x) P(? ? y)
18Algorithm timing starts again (aux.
definition)
- procedure maintenance(t, M )
- // Immediate transitions
- for all ? ? ? do
- for all t ? (?t )? ? Timmediate do
- if not(enabled(t, M ) then Limmediate?(t) ?
Limmediate?(t) \ t - for all t ? (t?)? ? Timmediate do
- if enabled(t, M ) then Limmediate?(t) ?
Limmediate?(t) ? t - end for
19Algorithm timing starts again (aux.
definition) contd
-
- // omitting transitions already started
- for all ? gt ?simulation do
- for all t ? (?t )? ? Ttimed ? Ltimed? do
- if not(enabled(t, M ) then Ltimed? ? Ltimed?
\ t - // adding new enabled transitions
- for all t ? (t?)? ? Ttimed do
- if enabled(t, M ) then Ltimedtime(t) ?
Ltimedtime(t) ? t - end for
- end procedure
20Algorithm Initialization (1)
- // Initialization
- M ? M0
- ?simulation ? 0
- for all ? ? ? do
- Limmadiate? ? ?
- // Initial set of fireable transitions
- for all t ? Timmediate do
- if enabled(t, M0) then Limmediate?(t ) ?
Limmediate?(t ) ? t
21Algorithm Non-timed transitions (2)
- MAIN while do
- for ? ?max to ?min step -1 do
- if Limmediate? ? ? then
- // Firing immediate transition
- t ? rnd(Limmediate?)
- M ? M W?et
- maintenance(t, M )
- M ? M
- exit for
- end if
- end for
- end while
22Algorithm Timed transitions (2)
-
- if ?? ? ?simulation Ltimed? ? ? then
- // Stepping the time (if necessary)
- ?simulation ? min(? Ltimed? ? ?)
- // firing timed transaction
- t ? rnd(Ltimed?simulation)
- M ? M W?et
- maintenance(t, M )
- M ? M
- goto MAIN
- end if
- end.