PN1 - PowerPoint PPT Presentation

1 / 218
About This Presentation
Title:

PN1

Description:

There are two persons able to manufacture these drinks (Adam and Eve) and the ... Model the manufacturing of a chair from its components: 2 front legs, 2 back ... – PowerPoint PPT presentation

Number of Views:165
Avg rating:3.0/5.0
Slides: 219
Provided by: win4
Category:
Tags: pn1

less

Transcript and Presenter's Notes

Title: PN1


1
Business Processes Petri NetsIPA basic course
on formal methods
  • Prof.dr.ir. Wil van der Aalst
  • Eindhoven University of Technology, Faculty of
    Technology Management,
  • Department of Information and Technology, P.O.Box
    513, NL-5600 MB,
  • Eindhoven, The Netherlands.

2
Outline
  • 10.00 - 11.00 Lecture 1 Petri nets
  • 11.00 - 11.15 Break
  • 11.15 - 12.00 Exercises 1 Hands-on with CPN
    Tools
  • 12.00 - 12.15 Discussion of exercises 1 / demo
  • 12.15 - 13.15 Lunch
  • 13.15 - 14.15 Lecture 2 Workflow modeling and
    analysis
  • 14.15 - 14.30 Break
  • 14.30 - 15.15 Exercises 2 Hands-on with Protos
    and Woflan
  • 15.15 - 15.30 Discussion of excercises 2 / demo
  • 15.30 - 15.45 Break
  • 15.45 - 16.15 Wrap-up session Process Mining

3
Lecture 1 Petri netsPetri-nets by example
4
Role of process models in information systems
5
Limitations of classical Petri nets
  • Inability to test for zero tokens in a place.
  • Models tend to become large.
  • Models cannot reflect temporal aspects
  • No support for structuring large models, cf.
    top-down and bottom-up design
  • (As a result most things are decidable ?)

6
Inability to test for zero tokens in a place
?
t
p
Tricks only work if p is bounded
7
High-level Petri nets
  • To tackle the problems identified.
  • Petri nets extended with
  • Color (i.e., data)
  • Time
  • Hierarchy
  • For the time being be do not choose a concrete
    language but focus on the main concepts.
  • We focus on a concrete language CPN.
  • We show use CPN Tools.

8
DEMO
9
Exercises 1 Hands-on with CPN Tools
Model and simulate the following cases using CPN
Tools ...
10
Coffee and tea example (1)
  • We need to produce 100 cups of tea and 100 cups
    of coffee.
  • There are two persons able to manufacture these
    drinks Adam and Eve.
  • Assume "random allocation".
  • Production times

11
Coffee and tea example (2)
  • Simulate the model a couple of times and record
    the makespan.
  • Evaluate two control strategies
  • Eve just makes tea and Adam just makes coffee.
  • Adam makes coffee and Eve can make both.
  • Eve makes tea and Adam can make both.
  • Why is it diffcult to model priorities/preferences
    ?

12
Coffee and tea example (3)
  • Assume a continuous flow of tea and coffee
    drinker, i.e., every 5 minutes there is request
    for tea and every 10 minutes there is a request
    of coffee.
  • There are two persons able to manufacture these
    drinks (Adam and Eve) and the production times
    are as before.
  • Process the requests in FIFO (first-in-first-out)
    order.

13
Coffee and tea example (4)
  • Assume a continuous flow of tea and coffee
    drinker, but now evaluate the following
    alternatives
  • LIFO (last-in-first-out) order
  • SPT (tea before coffee) order
  • FIFO with Eve preferably working on tea and Adam
    on coffee.
  • Test also your own strategy.

14
Cheat sheet
15
Lecture 2 Workflow Modeling and Analysis
16
Reference model of the Workflow Management
Coalition
What? When? Who?
17
(No Transcript)
18
(No Transcript)
19
(No Transcript)
20
(No Transcript)
21
Focus on "classical" workflow management systems,
but ...
  • Four types of "workflow-like" systems
  • Information systems with hard-coded workflows
    (process organization specific).
  • Custom-made information systems with generic
    workflow support (organization specific).
  • Generic software with embedded workflow
    functionality (e.g., the workflow components of
    ERP, CRM, PDM, etc. systems).
  • Generic software focusing on workflow
    functionality (e.g., Staffware, MQSeries
    Workflow, FLOWer, COSA, Oracle BPEL, Filenet,
    etc.).

22
Workflow perspectives
  • Process perspective (tasks and the routing of
    cases)
  • Resource perspective (workers, roles, 4-eyes
    principle, etc.)
  • Case/data perspective (process instances and
    their attributes)
  • Operation/application perspective (forms,
    application integration, etc.)
  • ...

23
Process perspective Protos (extended Petri nets)
24
Process perspective Staffware
25
Process perspective COSA (Petri nets)
26
Process perspective Baan DEM
27
Process perspective Event driven process chains
(ARIS/SAP)
28
(Oracle) BPEL
ltsequence name"main"gt ltflow name"Flow_1"gt
ltlinksgt ltlink name"receive-to-assess
"/gt ltlink name"receive-to-approval"/gt
ltlink name"approval-to-reply"/gt
ltlink name"assess-to-setMessage"/gt ltlink
name"setMessage-to-reply"/gt ltlink
name"assess-to-approval"/gt lt/linksgt
ltsequence name"sequenceReceive"gt ltsource
linkName"receive-to-assess" transitionCondition"
bpwsgetVariableData('inputVariable','payload','/c
lientLoanApprovalProcessRequest/clientamount')
lt 10000"/gt ltsource linkName"receive-to
-approval" transitionCondition"bpwsgetVariableDa
ta('inputVariable','payload','/clientLoanApproval
ProcessRequest/clientamount') gt 10000"/gt
ltreceive name"receiveInput"
partnerLink"client" portType"clientLoanApproval
" operation"initiate" variable"inputVariable"
createInstance"yes"/gt lt/sequencegt
ltsequence name"sequenceAssess"gt lttarget
linkName"receive-to-assess"/gt ltsource
linkName"assess-to-setMessage"
transitionCondition"bpwsgetVariableData('risk')
'low'"/gt ltsource linkName"assess-to-app
roval" transitionCondition"bpwsgetVariableData('
risk') ! 'low'"/gt ltassign
name"initiateAssessor"gt ltcopygt
ltfrom variable"inputVariable" part"payload"
query"/clientLoanApprovalProcessRequest/clientf
irstName"/gt ltto variable"invokeAssess
or_initiate_InputVariable" part"payload"
query"/ns1AssessorProcessRequest/ns1firstName"/
gt lt/copygt ltcopygt
ltfrom variable"inputVariable" part"payload"
query"/clientLoanApprovalProcessRequest/clientn
ame"/gt ltto variable"invokeAssessor_in
itiate_InputVariable" part"payload"
query"/ns1AssessorProcessRequest/ns1name"/gt
lt/copygt ltcopygt ltfrom
variable"inputVariable" part"payload"
query"/clientLoanApprovalProcessRequest/clienta
mount"/gt ltto variable"invokeAssessor_
initiate_InputVariable" part"payload"
query"/ns1AssessorProcessRequest/ns1amount"/gt
lt/copygt lt/assigngt
ltinvoke name"invokeAssessor" partnerLink"Assesso
r" portType"ns1Assessor" operation"initiate"
inputVariable"invokeAssessor_initiate_InputVariab
le"/gt ltreceive name"receiveAssessor"
partnerLink"Assessor" portType"ns1AssessorCallb
ack" operation"onResult" variable"receiveAssesso
r_onResult_InputVariable" createInstance"no"/gt
ltassign name"completeAssessor"gt
ltcopygt ltfrom variable"receiveAssessor
_onResult_InputVariable" part"payload"
query"/ns1AssessorProcessResponse/ns1level"/gt
ltto variable"risk"/gt
lt/copygt lt/assigngt lt/sequencegt
ltsequence name"sequenceNoApproval"gt
lttarget linkName"assess-to-setMessage"/gt
ltsource linkName"setMessage-to-reply"/gt
ltassign name"setAccepted"gt ltcopygt
ltfrom expression"'Accepted'"/gt
ltto variable"outputVariable" part"payload"
query"/clientLoanApprovalProcessResponse/client
result"/gt lt/copygt lt/assigngt
lt/sequencegt
29
Design-time (a-priori) and run-time
(a-posteriori) questions
Run-time
Design-time
ProM
Woflan
- verification- validation- performance
analysis
- process mining
30
A-priori analysis Woflan
31
A process in Staffware (a similar process could
have been made using BPMN, etc.)
32
(No Transcript)
33
Corresponding WF-net
Not sound!
34
Syntactic sugaring
  • Note silent (tau) steps.
  • Branching bisimulation is used as an equivalence
    relation to distinguish internal/external choices.

35
Soundness
  • A WF-net is sound if and only if
  • marking o is reachable from every reachable
    marking (initial marking is i),
  • marking o is the only reachable marking marking
    place o, and
  • there are no dead transitions.

36
Reachability analysis
37
Place invariants can be used to check detect
errors
end
begin
  • There should be a positive place invariant
    assigning positive weights to all places and
    identical weights to begin and end.
  • 1.begin 1.end ..... constant

38
Transition invariants can be used to detect errors
short-circuited net
end
begin
  • There should be a positive transition invariant
    assigning positive weights to all transitions.

39
Languages/products we can verify
  • Event-driven process chains (SAP, ARIS, ARIS
    PPM)
  • BPEL (Websphere and Oracle BPEL)
  • Staffware
  • COSA
  • Protos
  • YAWL
  • PNML (Yasper, ProM, XRL, ...)
  • ...

40
Exercises 2 Hands-on with Protos and Woflan
Model the following cases using Protos, export
models to Woflan and verify (make some mistakes
on purpose). You can also start by rebuilding the
example.
41
Insurance company
  • Insurance company X processes claims which result
    from traffic accidents with cars where customers
    of X are involved in. Therefore, it uses the
    following procedure for the processing of the
    insurance claims.
  • Every claim, reported by a customer, is
    registered by an employee of department CD (CD
    Car Damages). After the registration of the
    claim, the insurance claim is classified by a
    claim handler of rank A or B within CD. There are
    two categories simple and complex claims.
  • For simple claims two tasks need to be executed
    check insurance and phone garage. These tasks are
    independent of each other.

42
Insurance company (2)
  • The complex claims require three tasks to be
    executed check insurance, check damage history
    and phone garage. These tasks need to be executed
    sequentially in the order specified.
  • Both for the simple and complex claims, the tasks
    are done by employees of department CD. After
    executing the two respectively three tasks a
    decision is made. This decision is made by a
    claim handler of rank A and has two possible
    outcomes OK (positive) or NOK (negative).
  • If the decision is positive, then insurance
    company X will pay. An employee of the finance
    department handles the payment. In any event, the
    insurance company sends a letter to the customer
    who sent the claim. An employee of the department
    CD writes this letter.

43
Complaints handling
  • Each year travel agency Y has to process a lot of
    complaints (about 10.000). There is a special
    department for the processing of complaints
    (department C). There is also an internal
    department called logistics (department L) which
    takes care of the registration of incoming
    complaints and the archiving of processed
    complaints. The following procedure is used to
    handle these complaints.

44
Complaints handling (2)
  • An employee of department L first registers every
    incoming complaint. After registration a form is
    sent to the customer with questions about the
    nature of the complaint. This is done by an
    employee of department C. There are two
    possibilities the customer returns the form
    within two weeks or not. If the form is returned,
    it is processed automatically resulting in a
    report which can be used for the actual
    processing of the complaint. If the form is not
    returned on time, a time-out occurs resulting in
    an empty report. Note that this does not
    necessarily mean that the complaint is discarded.
    After registration, i.e., in parallel with the
    form handling, the preparation for the actual
    processing is started.

45
Complaints handling (3)
  • First, the complaint is evaluated by a complaint
    manager of department C. Evaluation shows that
    either further processing is needed or not. Note
    that this decision does not depend on the form
    handling. If no further processing is required
    and the form is handled, the complaint is
    archived. If further processing is required, an
    employee of the complaints department executes
    the task process complaint (this is the actual
    processing where certain actions are proposed if
    needed). For the actual processing of the
    complaint, the report resulting from the form
    handling is used. Note that the report can be
    empty. The result of task process complaint is
    checked by a complaint manager. If the result is
    not OK, task process complaint is executed
    again. This is repeated until the result is
    acceptable. If the result is accepted, an
    employee of the department C executes the
    proposed actions. After this the processed
    complaint is archived by an employee of
    department L.

46
Travel agency
  • Consider a fragment of the process of booking
    trips involving six steps register, (booking of)
    flight, (booking of) hotel, (booking of) car,
    pay, and cancel.
  • The process starts with task register and ends
    with pay or cancel.
  • The tasks flight, hotel and car may succeed or
    fail.
  • Let us consider a number of variants

47
Travel agency Variant 1
  • Every trip involves a flight, hotel and car and
    these are booked in parallel. If all three
    succeed, the payment follows. Otherwise task
    cancel is executed. Cancel is delayed until all
    three bookings succeed/fail and does not withdraw
    work.

48
Travel agency Variant 2
  • Every trip involves a flight, hotel and car and
    these are booked in parallel. If all three
    succeed, the payment follows. Otherwise task
    cancel is executed. Task cancel can be executed
    the moment the first task fails and withdraws
    work-items waiting for remaining booking tasks.

49
Travel agency Variant 3
  • Every trip may involve a flight, hotel and/or car
    and these are booked in parallel. A trip should
    involve at least a flight, hotel or car but may
    be any combination of the three bookings, e.g., a
    flight and car but not a hotel. If all bookings
    succeed, the payment follows. Otherwise task
    cancel is executed. Task cancel can be executed
    the moment the first task fails and withdraws
    work-items waiting for remaining booking tasks.

50
Travel agency Variant 4
  • Every trip may involve a flight, hotel and/or car
    and these are booked in parallel. A trip should
    involve at least a flight, hotel or car but may
    be any combination of the three bookings, e.g., a
    flight and car but not a hotel. If all bookings
    succeed, the payment follows. Otherwise task
    cancel is executed. Task cancel can be executed
    the moment the first task fails and withdraws
    work items waiting for remaining booking tasks.
    All bookings that have completed successfully
    need to be compensated.

51
Wrap-up Process mining
52
from languages and systems to analysis ...
53
Design-time (a-priori) and run-time
(a-posteriori) questions
Run-time
Design-time
ProM
- verification- validation- performance
analysis
- process mining
54
A-posteriori analysis ProM
55
(No Transcript)
56
Process discovery Reversing the process
process discovery
1
57
Conformance testing
2
58
Log based verification
formula four_eyes_principle (a1activity,a2activi
ty) forallpperson (!(execute(p,a1)) \/
!(execute(p,a2)))
3
59
ProM
Outlook
CPN Tools
ARIS/ARIS PPM
YAWL
Caramba
60
XML format
61
ProM architecture
62
Demo
63
Conclusion
  • Petri nets have and strong theoretical basis and
    are close to languages used in practise.
  • The workflow/process mining domain offers many
    research challenges!

useful links
  • www.processmining.org
  • www.workflowpatterns.com
  • is.tm.tue.nl/research/woflan/
  • www.workflowcourse.com
  • BPMcenter.org
  • www.yawl-system.com

64
Reference slides
65
Petri netsClassical Petri nets The basic model
  • Prof.dr.ir. Wil van der Aalst
  • Eindhoven University of Technology, Faculty of
    Technology Management,
  • Department of Information and Technology, P.O.Box
    513, NL-5600 MB,
  • Eindhoven, The Netherlands.

66
Process modeling
  • Emphasis on dynamic behavior rather than
    structuring the state space
  • Transition system is too low level
  • We start with the classical Petri net
  • Then we extend it with
  • Color
  • Time
  • Hierarchy

67
Classical Petri net
  • Simple process model
  • Just three elements places, transitions and
    arcs.
  • Graphical and mathematical description.
  • Formal semantics and allows for analysis.
  • History
  • Carl Adam Petri (1962, PhD thesis)
  • In sixties and seventies focus mainly on theory.
  • Since eighties also focus on tools and
    applications (cf. CPN work by Kurt Jensen).
  • Hidden in many diagramming techniques and
    systems.

68
Elements
69
Rules
  • Connections are directed.
  • No connections between two places or two
    transitions.
  • Places may hold zero or more tokens.
  • First, we consider the case of at most one arc
    between two nodes.

70
Enabled
  • A transition is enabled if each of its input
    places contains at least one token.

enabled
Not enabled
Not enabled
71
Firing
  • An enabled transition can fire (i.e., it occurs).
  • When it fires it consumes a token from each input
    place and produces a token for each output place.

fired
72
Play Token Game
  • In the new state, make_picture is enabled. It
    will fire, etc.

73
Remarks
  • Firing is atomic.
  • Multiple transitions may be enabled, but only one
    fires at a time, i.e., we assume interleaving
    semantics (cf. diamond rule).
  • The number of tokens may vary if there are
    transitions for which the number of input places
    is not equal to the number of output places.
  • The network is static.
  • The state is represented by the distribution of
    tokens over places (also referred to as marking).

74
Non-determinism
Two transitions are enabled but only one can fire
75
Example Single traffic light
76
Two traffic lights
OR
77
Problem
78
Solution
How to make them alternate?
79
Playing the Token Game on the Internet
  • Applet to build your own Petri nets and execute
    them http//www.tm.tue.nl/it/staff/wvdaalst/Downl
    oads/pn_applet/pn_applet.html
  • FLASH animations http//www.tm.tue.nl/it/staff/wv
    daalst/courses/pm/flash/

80
Exercise Train system (1)
  • Consider a circular railroad system with 4
    (one-way) tracks (1,2,3,4) and 2 trains (A,B). No
    two trains should be at the same track at the
    same time and we do not care about the identities
    of the two trains.

81
Exercise Train system (2)
  • Consider a railroad system with 4 tracks
    (1,2,3,4) and 2 trains (A,B). No two trains
    should be at the same track at the same time and
    we want to distinguish the two trains.

82
Exercise Train system (3)
  • Consider a railroad system with 4 tracks
    (1,2,3,4) and 2 trains (A,B). No two trains
    should be at the same track at the same time.
    Moreover the next track should also be free to
    allow for a safe distance. (We do not care about
    train identities.)

83
Exercise Train system (4)
  • Consider a railroad system with 4 tracks
    (1,2,3,4) and 2 trains. Tracks are free, busy or
    claimed. Trains need to claim the next track
    before entering.

84
WARNINGIt is not sufficient to understand the
(process) models. You have to be able to design
them yourself !
85
Multiple arcs connecting two nodes
  • The number of arcs between an input place and a
    transition determines the number of tokens
    required to be enabled.
  • The number of arcs determines the number of
    tokens to be consumed/produced.

86
Example Ball game
87
Exercise Manufacturing a chair
  • Model the manufacturing of a chair from its
    components 2 front legs, 2 back legs, 3 cross
    bars, 1 seat frame, and 1 seat cushion as a Petri
    net.
  • Select some sensible assembly order.
  • Reverse logistics?

88
Exercise Burning alcohol.
  • Model C2H5OH 3 O2 gt 2 CO2 3 H2O
  • Assume that there are two steps first each
    molecule is disassembled into its atoms and then
    these atoms are assembled into other molecules.

89
Exercise Manufacturing a car
  • Model the production process shown in the
    Bill-Of-Materials.

car
subassembly2
engine
2
chair
subassembly1
4
chassis
wheel
90
Formal definition
  • A classical Petri net is a four-tuple (P,T,I,O)
    where
  • P is a finite set of places,
  • T is a finite set of transitions,
  • I P x T -gt N is the input function, and
  • O T x P -gt N is the output function.
  • Any diagram can be mapped onto such a four tuple
    and vice versa.

91
Formal definition (2)
  • The state (marking) of a Petri net (P,T,I,O) is
    defined as follows
  • s P-gt N, i.e., a function mapping the set of
    places onto 0,1,2, .

92
Exercise Map onto (P,T,I,O) and s
93
Exercise Draw diagram
  • Petri net (P,T,I,O)
  • P a,b,c,d
  • T e,f
  • I(a,e)1, I(b,e)2, I(c,e)0, I(d,e)0, I(a,f)0,
    I(b,f)0, I(c,f)1, I(d,f)0.
  • O(e,a)0, O(e,b)0, O(e,c)1, O(e,d)0, O(f,a)0,
    O(f,b)2, O(f,c)0, O(f,d)3.
  • State s
  • s(a)1, s(b)2, s(c)0, s(d) 0.

94
Enabling formalized
  • Transition t is enabled in state s1 if and only
    if

95
Firing formalized
  • If transition t is enabled in state s1, it can
    fire and the resulting state is s2

96
Mapping Petri nets onto transition systems
  • A Petri net (P,T,I,O) defines the following
    transition system (S,TR)

97
Reachability graph
  • The reachability graph of a Petri net is the part
    of the transition system reachable from the
    initial state in graph-like notation.
  • The reachability graph can be calculated as
    follows
  • Let X be the set containing just the initial
    state and let Y be the empty set.
  • Take an element x of X and add this to Y.
    Calculate all states reachable for x by firing
    some enabled transition. Each successor state
    that is not in Y is added to X.
  • If X is empty stop, otherwise goto 2.

98
Example
(3,2)
(3,1)
(3,0)
(1,3)
(1,2)
(1,1)
(1,0)
Nodes in the reachability graph can be
represented by a vector (3,2) or as 3 red 2
black. The latter is useful for sparse states
(i.e., few places are marked).
99
Exercise Give the reachability graph using both
notations
100
Different types of states
  • Initial state Initial distribution of tokens.
  • Reachable state Reachable from initial state.
  • Final state (also referred to as dead states)
    No transition is enabled.
  • Home state (also referred to as home marking) It
    is always possible to return (i.e., it is
    reachable from any reachable state).
  • How to recognize these states in the reachability
    graph?

101
Exercise Producers and consumers
  • Model a process with one producer and one
    consumer, both are either busy or free and
    alternate between these two states. After every
    production cycle the producer puts a product in a
    buffer. The consumer consumes one product from
    this buffer per cycle.
  • Give the reachability graph and indicate the
    final states.
  • How to model 4 producers and 3 consumers
    connected through a single buffer?
  • How to limit the size of the buffer to 4?

102
Exercise Two switches
  • Consider a room with two switches and one light.
    The light is on or off. The switches are in state
    up or down. At any time any of the switches can
    be used to turn the light on or off.
  • Model this as a Petri net.
  • Give the reachability graph.

103
Modeling
  • Place passive element
  • Transition active element
  • Arc causal relation
  • Token elements subject to change
  • The state (space) of a process/system is modeled
    by places and tokens and state transitions are
    modeled by transitions (cf. transition systems).

104
Role of a token
  • Tokens can play the following roles
  • a physical object, for example a product, a part,
    a drug, a person
  • an information object, for example a message, a
    signal, a report
  • a collection of objects, for example a truck with
    products, a warehouse with parts, or an address
    file
  • an indicator of a state, for example the
    indicator of the state in which a process is, or
    the state of an object
  • an indicator of a condition the presence of a
    token indicates whether a certain condition is
    fulfilled.

105
Role of a place
  • a type of communication medium, like a telephone
    line, a middleman, or a communication network
  • a buffer for example, a depot, a queue or a post
    bin
  • a geographical location, like a place in a
    warehouse, office or hospital
  • a possible state or state condition for example,
    the floor where an elevator is, or the condition
    that a specialist is available.

106
Role of a transition
  • an event for example, starting an operation, the
    death of a patient, a change seasons or the
    switching of a traffic light from red to green
  • a transformation of an object, like adapting a
    product, updating a database, or updating a
    document
  • a transport of an object for example,
    transporting goods, or sending a file.

107
Typical network structures
  • Causality
  • Parallelism (AND-split - AND-join)
  • Choice (XOR-split XOR-join)
  • Iteration (XOR-join - XOR-split)
  • Capacity constraints
  • Feedback loop
  • Mutual exclusion
  • Alternating

108
Causality
109
Parallelism
110
Parallelism AND-split
111
Parallelism AND-join
112
Choice XOR-split
113
Choice XOR-join
114
Iteration 1 or more times
XOR-join before XOR-split
115
Iteration 0 or more times
XOR-join before XOR-split
116
Capacity constraints feedback loop
AND-join before AND-split
117
Capacity constraints mutual exclusion
AND-join before AND-split
118
Capacity constraints alternating
AND-join before AND-split
119
We have seen most patterns, e.g.
Example of mutual exclusion
How to make them alternate?
120
Exercise Manufacturing a car (2)
  • Model the production process shown in the
    Bill-Of-Materials with resources.
  • Each assembly step requires a dedicated machine
    and an operator.
  • There are two operators and one machine of each
    type.
  • Hint model both the start and completion of an
    assembly step.

car
subassembly2
engine
2
chair
subassembly1
4
chassis
wheel
121
Modeling problem (1) Zero testing
  • Transition t should fire if place p is empty.

?
t
p
122
Solution
  • Only works if place is N-bounded

t
Initially there are N tokens
N input and output arcs
p
p
123
Modeling problem (2) Priority
  • Transition t1 has priority over t2

t1
?
t2
Hint similar to Zero testing!
124
A bit of theory
  • Extensions have been proposed to tackle these
    problems, e.g., inhibitor arcs.
  • These extensions extend the modeling power
    (Turing completeness).
  • Without such an extension not Turing complete.
  • Still certain questions are difficult/expensive
    to answer or even undecidable (e.g., equivalence
    of two nets).
  • Turing completeness corresponds to the ability
    to execute any computation.

125
Exercise Witness statements
  • As part of the process of handling insurance
    claims there is the handling of witness
    statements.
  • There may be 0-10 witnesses per claim. After an
    initialization step (one per claim), each of the
    witnesses is registered, contacted, and informed
    (i.e., 0-10 per claim in parallel). Only after
    all witness statements have been processed a
    report is made (one per claim).
  • Model this in terms of a Petri net.

126
Exercise Dining philosophers
  • 5 philosophers sharing 5 chopsticks chopsticks
    are located in-between philosophers
  • A philosopher is either in state eating or
    thinking and needs two chopsticks to eat.
  • Model as a Petri net.

127
Preview Analysis (Chapter 8)
  • Various types of analysis techniques
  • Simulation (repeatedly playing the token game)
  • Reachability analysis (constructing the
    reachability graph)
  • Markovian analysis (reachability graph with
    transition probabilities)
  • Invariants place invariants and transition
    invariants (conservation of tokens and sequences
    without effect)
  • Role of models (1) insight, (2) analysis, and
    (3) specification.

128
Place invariant Example
waitbeforeaftergone freeoccupied
129
Transition invariant Example
entermake_pictureleaveaccident
130
CPNA concrete language for high-level Petri nets
  • Prof.dr.ir. Wil van der Aalst
  • Eindhoven University of Technology, Faculty of
    Technology Management,
  • Department of Information and Technology, P.O.Box
    513, NL-5600 MB,
  • Eindhoven, The Netherlands.

131
CPN (Colored Petri nets)
  • CPN is the language developed by Kurt Jensen.
  • CPN supports the extensions with time, color and
    hierarchy.
  • CPN is based on standard ML.
  • CPN is supported by Design/CPN and CPN Tools.
  • First, we only consider the extensions with color
    and time.
  • For more information http//www.daimi.au.dk/CPnet
    s/

132
Values and types
  • Syntax is needed to type places and give values
    (colors) to tokens.
  • Adopted from Standard ML
  • Outline
  • Basic types int, string, bool, (real), and unit.
  • Type constructors with, product, record, list.
  • Defining constants.

133
Basic types
  • Integers (int), e.g., 5, 34234, 32423.
  • Reals (real), e.g., 34.34, 23.0, 7e3, 4e2.
  • Strings (string), e.g., "Hallo", "28-02-2003".
  • Booleans (bool) true and false.
  • unit type with just one value ()
  • 32423 means -32423
  • 23.0 means 23, 7e3 means 7000.0, and 4e2
    means 0.04
  • unit is used to represent black (i.e., uncolored)
    tokens
  • Reals are no longer supported.

134
Basic operators
  • for the unary minus
  • and for reals and integers
  • (multiplication) for reals and integers
  • / (division) for reals
  • div and mod for integers (28 div 10 2, 28 mod
    10 8)
  • , gt, lt, gt, lt, ltgt for comparing things (note
    the notation for gt (greater than), lt (smaller
    than), and ltgt (not equal)).
  • for strings (concatenation "AA""BB" "AABB")

135
Logical operators
  • not (for negation)
  • andalso (for logical AND)
  • orelse (for logical OR)
  • if then else (choice based on Boolean argument,
    the then and else part should be of the same
    type)
  • not(11) results in false
  • (11) andalso not(0gt1 orelse 2gt3) results in true
  • if "X""X" then 3 else 4 results in 3

136
Exercise Give type and value of each result
  • if (4gt4) then ("Hello" " " "World") else "X"
  • if true then 20 div 8 else 20 mod 8
  • not (11 orelse 12)
  • not (11 andalso 12)
  • if ("Hello" " " "World" "X") then 20 else 3

137
Color set declarations
  • A color set is a type that is defined using a
    color set declaration color ... ... , e.g.,
  • color I int
  • color S string
  • color B bool
  • color U unit
  • Once declared, it may be used to type places.
  • Newly defined types like I,S,B,U may be used in
    other color set declarations.

138
Creating subtypes using the "with" clause
  • color Age int with 0..130
  • color Temp int with 30..40
  • color Alphabet string with "a".."z"
  • color YN bool with (no,yes)
  • color BlackToken unit with null

139
Creating new types using the "with" clause
  • color Human with man woman child
  • color ThreeColors with Green Red Yellow

140
Creating new types using product, record, and
list constructors
  • color Coordinates product I I I
  • color HumanAge product Human Age
  • color CoordinatesR record xI yI zI
  • color CD record artistsS titleS
    noftracksI
  • color Names list S
  • color ListOfColors list ThreeColors

141
Possible values (colors)
  • Coordinates (1,2,3), (4,66,0), ...
  • HumanAge (man,50), (child,3), ...
  • CoordinatesR x1, y2, z3, x4, y66, z0,
    y2, x1, z3, ...
  • CD artists"Havenzangers", title"La La",
    noftracks10, ...
  • Names "John", "Liza", "Paul", , ...
  • ListOfColors Green, Red, Yellow, ...
  • Note the difference between products and records.

142
Example
  • color Driver string
  • color Lap int with 1..80
  • color TimeMS real with 0..10000000
  • color LapTime product Lap TimeMS
  • color LapTimes list LapTime
  • color DriverResults record dDriver
    rLaptimes
  • color Race List DriverResults

143
Example (2)
  • A possible color of type Race is
  • d"Jos Verstappen", r(1,31000),(2,33400),(3,32
    800),
  • d"Michael Schumacher", r(1,32200),(2,31600),(3
    ,30200),(4,29600),
  • d"Rubens Barrichello", r(1,34500),(2,32600),(3
    ,37200),(4,42600)

144
Operations on lists and records
  • denotes the empty list
  • concatenates two lists, e.g., 1,2,34,5
    evaluates to 1,2,3,4,5
  • adds an element in front of a list, e.g.,
    "a""b","c" evaluates to "a","b","c"
  • extracts a field of a record xx1,y2
    evaluates to 1

145
Constants
  • It is possible to define constants, e.g.,
  • val jv "Jos Verstappen" Driver
  • val lap1 1 Lap
  • val start 0 Time
  • val seven 7 int

146
Example
  • Determine the value of constant Monaco
  • val jv "Jos Verstappen" Driver
  • val r1jos (1,31000) LapTime
  • val r2jos (2,33400) LapTime
  • val r3jos (3,32800) LapTime
  • val r123jos ((1,31000)(2,33400))(3,32800)
    LapTimes
  • val jos djv,r123jos DriverResults
  • val michael d"Michael Schumacher",
    r(1,32200),(2,31600),
  • (3,30200),(4,29600)DriverResults
  • val rubens d"Rubens Barrichello",
    r(1,34500),(2,32600),(3,37200),
    (4,42600)DriverResults
  • val Monaco jos (michaelrubens) Race

147
Exercise
  • Determine the value of the following constants
  • val e1 r1jos
  • val e2 d(michael)
  • val e3 r(jos)r(Rubens)

148
So what?
149
We can now type and initialize places!
declarations
name of place
type of place
initial marking
150
Multi-sets
  • To initialize places with multiple tokens but
    also for various other purposes we need
    multi-sets also referred to as bags.
  • In CPN multi-sets are denoted using the following
    notation x1v1 x2v2 ... xnvnwhere v1
    is a value and x1 the number of times this
    element appears in the multi-set, etc.
  • E.g., 4"Red" 2"Green" 1"Blue" is a
    multi-set containing 7 elements

151
Initialization expressions
one token
no tokens
six tokens
152
Arc inscriptions
  • Arc inscriptions are used to define input-output
    behavior.
  • Arc inscriptions may use variables.
  • Variables are typed and need to be declared

153
Example
  • Give final marking.

154
Binding
  • Given a transition t with variables x1, x2, ...,
    xn on its input and output arcs, a binding of t
    allocates a concrete value to each of these
    variables. These values should be of the
    corresponding type.
  • A binding is enabled if there are tokens matching
    the values of the arc inscriptions.
  • If a binding is enabled, it can occur, i.e., the
    transition fires while consuming and producing
    the corresponding tokens.
  • The pair (t1,ltx1v1,x2v2, ...xnvngt) is called a
    binding element.

155
Example
  • Two binding elements (t1,ltx2gt) and (t1,ltx3gt)

156
Example
  • Binding element (t1,ltx0gt). After it occurred
    (t1,ltx1gt), etc.

157
Example
No binding possible!
(t2,ltx1,y2gt)
(t2,ltx1,y3gt)
158
Exercise
  • Give all possible binding elements and final
    markings

159
Exercise
  • Give all possible binding elements and final
    markings

160
Exercise
  • Give all possible binding elements and final
    markings

161
Exercise
  • Give all possible binding elements and a final
    marking

162
Exercise
  • Give all possible binding elements and a final
    marking

163
Exercise
  • Give all possible binding elements and a final
    marking

164
Example Voting
165
Exercise Bank
  • Consider a simple banking system. There are 1000
    accounts numbered from 1 to 1000. People can
    deposit or withdraw money. Only amounts between 1
    EURO and 5000 EURO can be deposited or withdrawn.
    The account may have a negative balance.
  • Model this in terms of a CPN model.

166
Exercise Article database
  • Consider a database system where authors can
    submit articles. The articles are stored in such
    a way that it is possible to get a sequential
    list of articles per author. The list is ordered
    in such a way that the oldest articles appear
    first.
  • Note that the system should support two actions
    submit articles (with name of author and article)
    and get articles of a given author.
  • We assume that each article has a single author
    and that only authors already registered in the
    database can submit articles.
  • Model this in terms of a CPN model.

167
Exercise (2)
  • Extend the CPN model such that each article can
    have multiple authors, i.e., the article is
    stored once for each author, and that there is an
    explicit action to add authors to the database.

168
Guard
  • A guard is a Boolean expression attached to a
    transition. Only binding elements which evaluate
    to true are enabled.
  • Denoted by square brackets.

guard evaluates to false for binding
(t1,ltx1,y2gt)
169
Example
  • Give all enabled binding elements and the final
    marking

170
Exercise
  • Give all enabled binding elements and the final
    marking

171
Exercise
  • Give all enabled binding elements and all
    possible final marking

172
Exercise
  • The CPN model assumes that an account could have
    a negative balance. Change the model such that
    the balance cannot become negative, i.e., do not
    accept transactions which lead to a negative
    balance.

173
Function declarations
  • color INT int
  • fun fac(xINT) if xgt1 then xfac(x-1) else 1
  • fun fib(xINT) if xlt2 then 1 else fib(x-1)
    fib(x-2)
  • color L list INT
  • fun odd(xL) if x then else
    hd(x)even(tl(x))
  • fun even(xL) if x then else odd(tl(x))
  • Calculate fac(fib(3)) and modify odd and even
    such that the odd lines are returned in reversed
    order.

174
Example
175
Questions
  • Is it possible to have multiple arcs connecting a
    place and a transitions?
  • Is it possible to have multi-sets as arc
    inscriptions on input arcs?
  • Is it possible to use constants or other
    expressions without variables as arc
    inscriptions?
  • Is it possible to use records, lists, etc. with
    variables (e.g., ax,by and xy) in arc
    inscriptions?

4x
176
Example Multiple arcs
177
Example Multi-sets and constants
178
Example Records
179
Example Lists
180
Requirement
It should be possible to bind variables to
concrete token values!!
181
Time in CPN
  • Tokens are either untimed (are always available)
    or timed (bear a timestamp).
  • Color sets can be made timed color sets by adding
    the keyword timed.
  • A delay is modeled by v_at_d as arc expression on
    an outgoing arc where v is the value and d is the
    delay of the produced token.
  • Delays may depend on the values of tokens to be
    consumed (i.e., through the binding of variables).

182
Example
183
Exercise
  • Determine a possible final state.

184
Exercise
  • Modify the left-hand side such that for positive
    values of y the delay is 10 while for other
    values the delay is 20.
  • Modify the right-hand side such that the delay
    for "Hi'' is 10 while for other values the delay
    is y.

185
Overview of CPN (with color and time)
186
Coffee and tea example (1)
  • We need to produce 100 cups of tea and 100 cups
    of coffee.
  • There are two persons able to manufacture these
    drinks Adam and Eve.
  • Assume "random allocation".
  • Production times

187
Coffee and tea example (2)
  • Simulate the model a couple of times and record
    the makespan.
  • Evaluate two control strategies
  • Eve just makes tea and Adam just makes coffee.
  • Adam makes coffee and Eve can make both.
  • Eve makes tea and Adam can make both.
  • Why is it diffcult to model priorities/preferences
    ?

188
Coffee and tea example (3)
  • Assume a continuous flow of tea and coffee
    drinker, i.e., every 5 minutes there is request
    for tea and every 10 minutes there is a request
    of coffee.
  • There are two persons able to manufacture these
    drinks (Adam and Eve) and the production times
    are as before.
  • Process the requests in FIFO (first-in-first-out)
    order.

189
Coffee and tea example (4)
  • Assume a continuous flow of tea and coffee
    drinker, but now evaluate the following
    alternatives
  • LIFO (last-in-first-out) order
  • SPT (tea before coffee) order
  • FIFO with Eve preferably working on tea and Adam
    on coffee.
  • Test also your own strategy.

190
Example revisited Punch card desk
191
Improved color sets
  • color Name string
  • color Street string
  • color Number int
  • color Town string
  • color Address record sStreet nNumber
    tTown
  • color Day int with 1..31
  • color Month with Jan Feb Mar Apr May
    Jun
  • Jul Aug Sep Oct Nov
    Dec
  • color Year int with 0..2100
  • color Date record dDay mMonth yYear
  • color Gender with male female
  • color Pat record nameName addressAddress
  • birthdateDate genderGender
    timed

192
Improved color sets (2)
  • color EmpNo int with 100000..999999
  • color Emp record empnoEmpNo experienceYear
    timed
  • color EP product Pat Emp timed
  • var pPat
  • var eEmp
  • val Klaas name"Klaas",
  • addresss"Plein",n10,t"Unknown",
  • birthdated13,mDec,y1962,
  • gendermalePat
  • val Ann empno641112, experience7Emp
  • fun d(xEmp) if experience(x) gt 5 then 3 else
    4

193
Example revisited Stock keeping system
194
Store
  • Place stock is a so-called store, i.e., it will
    always contain a single token.
  • Only the value of the token matters (not its
    presence).
  • Stores that aggregate elements are always of type
    list.
  • Drawback complex functions/inscriptions
  • Advantage easy to query the individual items as
    a whole, e.g., taking the sum of things ...

195
Function "totalstock"
  • fun totalstock(sStock)
  • if s
  • then 0
  • else (number(hd(s)))totalstock(tl(s))

196
Alternative model
Note the simplicity/elegance of the arc
inscriptions.
197
Example Signing documents
  • Documents need to be signed by persons.
  • Four persons Tim, Sue, Clare and John.
  • Each document requires three signatures.
  • No two signatures of the same person.
  • Work in progress is limited to five documents.

198
Signing documents Declarations
199
Signing documents Network structure
200
WARNINGIt is not sufficient to understand the
(process) models. You have to be able to design
them yourself !
201
Exercise
  • Replace place free by a place always holding one
    token.

202
Example Thermostat system
  • At any point the room has a temperature
    (initially 15 degrees centigrade).
  • There is a heater to warm up the house and there
    is a door which opens every hour such that part
    of the warmth escapes.
  • When the door opens the temperature in the room
    suddenly drops by three degrees centigrade.
  • The heater has a capacity of heating the room 1
    degree centigrade every 15 minutes.
  • When the heater would be switched on the whole
    time the temperature would continue to rise by 1
    degree per hour. Therefore, there is a control
    system, i.e., the thermostat, which switches off
    the heater. The thermostat uses the following
    rules.
  • If the temperature drops below 18, the heater is
    switched on.
  • If the temperature rises above 22, the heater is
    switched off.

203
CPN model of thermostat system
204
Exercise
  • Describe the room temperature in time starting in
    the initial state shown, i.e., play a timed,
    colored token game''.
  • Extend the model such that there is a day program
    and a night program. From midnight to 8am, the
    thermostat tries to keep the temperature between
    14 and 18 degrees centigrade. (If the temperature
    drops below 14 the heater is switched on. If the
    temperature rises above 18 the heater is switched
    off.) From 8am to midnight, the temperature is
    kept between 18 and 22 degrees, like before.

205
Exercise Train system
  • 7 sectors (tracks)
  • 2 trains A and B
  • When moving to a new sector both this sector and
    the next one should be empty.
  • Trains drive in one direction.
  • Model as a classical Petri net.
  • Model in terms of CPN without folding the tracks.
  • Model as a CPN with folding the tracks (i.e.,
    only two places).

206
Exercise Philosophers
  • 5 philosophers
  • 5 chopsticks
  • Each philosopher is either thinking or eating.
  • For eating two chopsticks are needed.
  • Chopsticks need to be shared among neighbors.
  • Both chopsticks are taken and released at the
    same time.
  • Model as a classical Petri net.
  • Model in terms of CPN using only three places and
    two transitions.

207
Exercise Philosophers (2)
  • 5 philosophers
  • 5 chopsticks
  • Each philosopher is either thinking or eating.
  • For eating two chopsticks are needed.
  • Chopsticks need to be shared among neighbors.
  • First the right chopstick is taken. Then the
    second one is taken.
  • The two chopstick are released in reversed order.
  • Model in terms of CPN.
  • Are deadlocks possible?

208
Exercise Philosophers (3)
  • 5 philosophers
  • 5 chopsticks
  • Each philosopher is either thinking or eating.
  • For eating two chopsticks are needed.
  • Chopsticks need to be shared among neighbors.
  • First the one chopstick (either left or right) is
    taken. Then the other one is taken.
  • Also released in arbitrary order.
  • Model in terms of CPN.
  • Are deadlocks possible?

209
More on functions Recursion
  • fun fac(xINT) if xgt1 then xfac(x-1) else 1
    is a recursive function since the function is
    expressed in terms of itself.
  • Two cases
  • fac(x) xfac(x-1)
  • fac(1) 1
  • fac(10)10fac(9)109fac(8)1098fac(7)
    10987654321 3628800

210
Recursion (1)
color Product string color Number int color
StockItem record prodProduct
numberNumber color Stock list StockItem fun
totalstock(sStock) if s then 0 else
(number(hd(s)))totalstock(tl(s))
Recursion in length of list
211
Recursion (2)
Instead of sum the maximum is taken
fun maxstock(sStock) if s then 0 else
if (number(hd(s))) gt maxstock(tl(s)) then
number(hd(s))
else maxstock(tl(s))
212
Recursion (3)
Function calls other function
fun maxstockname(sStock) if s then "no
product found" else if (number(hd(s)))maxstock
(tl(s)) then prod(hd(s))
else maxstockname(tl(s))
213
Recursion (4)
Function has two arguments
fun enoughstock(sStock,nNumber) if s
then else if (number(hd(s)))gt n then
hd(s)enoughstock(tl(s),n)
else enoughstock(tl(s),n)
214
Recursion (5)
Length of list rather than list itself
fun enoughstockn(sStock,nNumber) if s
then 0 else if (number(hd(s)))gt n then
1enoughstockn(tl(s),n)
else enoughstockn(tl(s),n)
215
More on functions Pattern matching
fun lenlist1(sStock) if s then 0 else
1lenlist(tl(s))
base case
induction step
fun lenlist2() 0 lenlist2(sis)
1lenlist2(s)
No explicit typing!!!
216
Pattern matching (1)
fun totalstock(sStock) if s then 0 else
(number(hd(s)))totalstock(tl(s))
fun totalstock(Stock) 0
totalstock(sis) (number(si))totalstock(s)
217
Pattern matching (2)
fun maxstock(sStock) if s then 0 else
if (number(hd(s))) gt maxstock(tl(s)) then
number(hd(s))
else maxstock(tl(s))
fun maxstock(Stock) maxstock(sis)
if (number(si))gtmaxstock(s) then number(si)
else
maxstock(s)
218
Pattern matching (3)
fun incrs(xStockItem,Stock) x incrs
(x,(sis)) if (prod(si))(prod(x))
then prod(prod(si)),number((number(si))(num
ber(x)))incrs(x,s) else (siincrs(x,s))
219
Pattern matching (4)
fun reverse() reverse(xy)
reverse(y)x fun odd() odd(xy)
xeven(y) fun even() even(xy)
odd(y)
220
More information
  • About Standard ML
  • Robin Milner, Mads Tofte, Robert Harper, and
    David MacQueen.The Definition of Standard ML
    Revised 1997. The MIT Press, 1997.
  • J. D. Ullman. Elements of ML Programming (ML 97
    edition). Prentice-Hall, 1998.
  • About CPN
  • K. Jensen Coloured Petri Nets. Basic Concepts,
    Analysis Methods and Practical Use. Volume 1,
    Basic Concepts. Monographs in Theoretical
    Computer Science, Springer-Verlag, 1997.
  • K. Jensen Coloured Petri Nets. Basic Concepts,
    Analysis Methods and Practical Use. Volume 2,
    Analysis Methods. Monographs in Theoretical
    Computer Science, Springer-Verlag, 1997.
  • K. Jensen Coloured Petri Nets. Basic Concepts,
    Analysis Methods and Practical Use. Volume 3,
    Practical Use. Monographs in Theoretical Computer
    Science, Springer-Verlag, 1997.
  • K. Jensen and G. Rozenberg (eds.) High-level
    Petri Nets. Theory and Application.
    Springer-Verlag, 1991.
Write a Comment
User Comments (0)
About PowerShow.com