Analysis
Analysis
ANA-1
Analysis
ANA-2
Three types of analysis techniques
1. Reachability/coverability graph
2. Structural techniques
• Place and transition invariants
• Marking equation
• Traps, siphons, etc.
3. Simulation
Mapping technique/use:
• reachability graph (validation, verification)
• invariants (validation, verification)
• simulation (validation, performance analysis)
ANA-3
Informal
introduction ...
ANA-4
Examples of generic questions given a
marked Petri net
• terminating
it has only finite occurrence sequences
• deadlock-free
each reachable marking enables a transition
• live
each reachable marking enables an occurrence
sequence containing all transitions
• bounded
each place has an upper bound that holds for all
reachable markings
• 1-safe
1 is a bound for each place p
• reversible
m0 is reachable from each reachable marking, i.e., the
initial marking is a so-called home marking.
ANA-5
Reachability graph
rg1 rg2
(0,0,1,1,0,0,0) (1,0,0,0,0,1,0)
g1 g2
r1 go1 x go2 r2
(1,0,0,1,0,0,1)
o1 o2
(0,1,0,1,0,0,0) (1,0,0,0,1,0,0)
or1 or2
ANA-6
Alternative notation
• terminating
it has only finite occurrence
sequences
• deadlock-free
rg1 rg2
each reachable marking enables a o1+r2 r1+o2
transition
• live g1 g2
each reachable marking enables an
occurrence sequence containing all
transitions r1+r2+x
r1 go1 x go2 r2
• bounded
each place has an upper bound that
holds for all reachable markings
• 1-safe o1 o2
ANA-8
Infinite reachability graph
rg1 rg2
g1 g2
r1 go1 x go2 r2
o1 o2
Therefore tools use a
coverability graph
which is always
finite!
or1 or2
ANA-9
Exercise: Construct reachability graph
free
occupied
ANA-10
Exercise: Dining philosophers
D:\www\wvdaalst\workflowcourse\examples\philosopher4.swf ANA-11
See also: www.workflowcourse.com
D:\www\wvdaalst\workflowcourse\examples\philosopher4_RG.swf
ANA-12
Analysis in CPN Tools
ANA-13
Example
ANA-14
Create report
1 2 3 4
PAGE 15
Report (1)
CPN Tools state space report for:
/cygdrive/D/courses/BIS-2011/CPN files/voting-bank-etc/bank.cpn
Report generated: Sun Mar 27 14:01:43 2011
Statistics
------------------------------------------------------------------------
State Space
Nodes: 24
Arcs: 44
Secs: 0
Status: Full
Scc Graph
Nodes: 24
Arcs: 44
Secs: 0
ANA-16
Report (2)
Boundedness Properties
------------------------------------------------------------------------
Best Integer Bounds
Upper Lower
main'database 1 3 3
main'deposit 1 5 0
main'withdraw 1 2 0
Liveness Properties
------------------------------------------------------------------------
Dead Markings
[24]
Fairness Properties
------------------------------------------------------------------------
No infinite occurrence sequences.
ANA-18
ANA-19
State Space
Nodes: 28
Arcs: 42
Secs: 0
Status: Full
Scc Graph
Nodes: 1
Arcs: 0
Secs: 0
Boundedness Properties
------------------------------------------------------------------------
Home Markings
All
Liveness Properties
------------------------------------------------------------------------
Dead Markings
None
Fairness Properties
------------------------------------------------------------------------
New_Page'move 1 Impartial ANA-21
Another example
ANA-22
Report (1)
Statistics
------------------------------------------------------------------------
State Space
Nodes: 11
Arcs: 30
Secs: 0
Status: Full
Scc Graph
Nodes: 1
Arcs: 0
Secs: 0
ANA-23
Report (2)
Boundedness Properties
------------------------------------------------------------------------
Liveness Properties
------------------------------------------------------------------------
strongest fairness
Dead Markings
None property, i.e., there
are infinite firing
Dead Transition Instances sequences and in
None each infinite firing
sequence t occurs
Live Transition Instances infinitely often
All
Fairness Properties
------------------------------------------------------------------------
Page'Put_Down_Chopsticks 1 Impartial
Page'Take_Chopsticks 1 Impartial
ANA-25
Fairness properties
Fairness Properties
---------------------------------------------------------------------
main1'a 1 Just
main1'b 1 Just
main1'c 1 Impartial
ANA-27
Example
Fairness Properties
---------------------------------------------------------------------
main2'x 1 No Fairness
main2'y 1 No Fairness
ANA-28
Example
Fairness Properties
-----------------------------------------------
main3't1 1 Fair
main3't2 1 No Fairness
main3't3 1 No Fairness
main3't4 1 No Fairness
main3't5 1 No Fairness
main3't6 1 Just
ANA-29
Exercise
Indicate for
t4
each transition
whether it is
t1 t2 impartial, fair,
p2 or just (or
satisfies no
fairness
p4 property)
p1 p3
t3
ANA-30
• t1, t2, and t3 are all impartial t4
because it is not possible to
construct an infinite firing
sequence where not all of t1 t2
these transitions appear p2
infinitely often. If one stops
executing one of these
transitions, the system will p4
block after a while. p1 p3
• t4 has no fairness as it is
t3
possible to construct an
infinite firing sequence where
t4 remains enabled but never
fires. ANA-31
Simulation
• Most widely used analysis technique.
• From a technical point of view just a "walk" in the
reachability graph.
• By making many "walks" (in case of transient
behavior) or a very "long walk" (in case of steady-
state) behavior, it is possible to make reliable
statements about properties/ performance
indicators.
• Used for validation and performance analysis.
• Cannot be used to prove correctness!
ANA-32
Stochastic process
ANA-33
Uniform distribution
ANA-34
Negative exponential distribution
ANA-35
Normal distribution
ANA-36
Distributions in CPN Tools
ANA-37
Example
color BT = unit;
color Dice = int with 1..6;
var d : Dice;
() ()
Dice.ran()
or even simpler …
ANA-39
Yahtzee
ANA-40
After 2055 times throwing the dices …
five 4’s
ANA-41
Examples
ANA-42
Example
ANA-43
ANA-44
ANA-45
alternative notation [b]%v = if b then 1`v else empty
[result =1]%j
[result =0]%j
ANA-46
Adding hierarchy
ANA-47
Example revisited
ANA-48
Subruns and confidence intervals
ANA-49
Two possible settings
ANA-50
More on calculating confidence
intervals
average
minimum
maximum
variance
utilization
weighted
average
5.6 5.6 6.2 5.5 5.7 5.9 5.4 5.8 5.6 5.7 5.7
ANA-51
5.6 5.6 6.2 5.5 5.7 5.9 5.4 5.8 5.6 5.7 5.7
4.6 6.6 3.2 8.5 1.7 9.9 4.4 6.8 4.6 6.7 5.7
aggregation per
subrun
(average, min,
max, variance,
5.6 5.6 6.2 5.5 5.7 5.9 5.4 5.8 5.6 5.7 5.7 etc.)
subruns = 11 confidence = 0.9
average = 5.7 confidence interval =
standard deviation = 0.21 [5.7-0.117,5.7+0.117] = [5.58,5.82]
ANA-53
Using monitors in CPN Tools
ANA-54
Example of a simulation model
ANA-55
Top-level page: main
arrive Car
HS HS
environment gas_station
drive_on Car
depart Car
ANA-56
Subpage In
put_in_queue drive_on
color Car = string; q
color Pump = unit; q^^[c]
q
color TCar = Car timed; [] q
color Queue = list Car;
var c:Car; queue Queue
var q:Queue; q c::q
fun len(q:Queue) = if q=[] then 0
else 1+len(tl(q)); start
c@+uniform(2,5) () c
pump_free ()
end
c
Out Out
ANA-57
depart Car drive_on Car
Interesting performance indicators:
arrive Car
c c
[len(q)<3] [len(q)>=3]
put_in_queue drive_on
color Car = string;
q
color Pump = unit; q^^[c]
q
color TCar = Car timed; [] q
color Queue = list Car;
var c:Car; queue Queue
var q:Queue; q c::q
fun len(q:Queue) = if q=[] then 0
else 1+len(tl(q)); start
c@+uniform(2,5) () c
Model the following pump_free ()
alternatives:
fill_up TCar Pump
• 6 waiting spaces c ()
• 2 pumps end
• 1 faster pump c
Out Out
ANA-59
depart Car drive_on Car
Experiments
(note time dimension * 1000; not needed in CPN Tools Version 3)
ANA-60
ANA-61
monitors
ANA-62
Number of cars being served
ANA-63
Number of pumps free
ANA-64
Length of queue
ANA-65
Flow time for
cars not served
ANA-66
Flow time for cars
that have been served
ANA-67
Percentage of
cars served
ANA-68
Average
flow is
time 7.359
X 10
CPN'Replications.nreplications 10
ANA-70
Average queue length [0.878,0.906]
ANA-72
Results
PAGE 73
2 pumps
ANA-74
Average queue length [0.105,0.111]
ANA-76
Results
PAGE 77
6 places to queue
ANA-78
Average queue length [1.691,1.770]
ANA-80
Results
PAGE 81
faster pump
ANA-84
Results
PAGE 85
Insights obtained from simulation
ANA-86
Analytical models versus Simulation
models
ANA-87
Example: M/M/1 queue
ANA-88
•λ = 1/100
M/M/1 queue •μ = 1/50
•ρ = 0.5
•L = 1
•S = 100
•λ = 1/100
•μ = 1/80
•ρ = 0.8
•L = 4
•S = 400
flow time
•λ = 1/100
•μ = 1/99
•ρ = 0.99
0 0.2 0.4 0.6 0.8 1 1.2 •L = 99
utilization
•S = 9900
ANA-89
CPN model with monitors
ANA-90
Creating monitors
ANA-91
Single run
ANA-92
CPN'Replications.nreplications 10
90% [96.703-4.01059,96703+4.0159]
•λ = 1/100
•μ = 1/50
•ρ = 0.5
•L = 1
•S = 100
ANA-93
CPN'Replications.nreplications 10
•λ = 1/100
•μ = 1/80
•ρ = 0.8
•L = 4
•S = 400
ANA-94
CPN'Replications.nreplications 10
•λ = 1/100
•μ = 1/99
•ρ = 0.99
•L = 99
•S = 9900
Note deviations.
Why?
ANA-95
Conclusion analysis