Petri Nets Modeling & Simulation 1. Objective

advertisement
Petri Nets
Modeling & Simulation
1. Objective
•
•
•
Understanding construction elements of Petri Nets
Understanding the types of Petri Nets
Modeling and simulation systems using Petri Nets
2. Overview
Petri nets (PN) is a graphical and mathematical tool, it provides a uniform
environment for modeling, formal analysis, and design of both discrete-event and
continuous-time systems.
Petri nets have been accepted as a powerful formal specification tool for a variety of
systems including concurrent, distributed, asynchronous, parallel, deterministic and
non-deterministic. Petri nets also have applications in a number of different
disciplines including engineering, manufacturing, business, chemistry and
mathematics.
Petri nets as graphical tools provide a powerful communication medium between the
engineer, and the customer. Complex requirements specifications can be represented
graphically using Petri nets, instead of using ambiguous textual descriptions or
mathematical notations difficult to understand by the customer. This combined with
the existence of computer tools allowing for interactive graphical simulation of Petri
nets, puts in hands of the development engineers a powerful tool assisting in the
development process of complex systems.
Petri nets have been used extensively to model and analyze manufacturing systems. In
this area, Petri nets were used to represent simple production lines with buffers,
machine shops, automotive production Systems, flexible manufacturing systems,
automated assembly lines, resource-sharing systems, and recently just-in-time and
kanban manufacturing systems.
The application of Petri nets in modeling sequence of controllers is another success
story. Programmable Logic Controllers are commonly used for the sequence control
in automated systems. They are designed using ladder logic diagrams, which are
known to be very difficult to debug and modify, Petri net based sequence controllers,
on the other hand, are easy to design, implement, and maintain In the early 80's,
Hitachi Ltd. developed a Petri net based sequence controller which was successfully
used in real applications to control pans assembly system, and automatic warehouse
load/unload system. The use of Petri nets, as reported, substantially reduced the
development time compared with the traditional approach.
2.1. Construction Elements of Petri Nets
PN consists of following elements (Place, Transition, Arcs); those elements interact
with each others through the main system event which is called (Firing).
Place Element:
Represented by a circle, it describes local system state; it contains a number of tokens
representing the current state, number of tokens is called "Marking".
For example place can be used to represent a store each token represents a single item
in a store, this means; if the number of tokens is zero the system state is "empty",
otherwise the system is state is "occupied".
Tokens
0
1.23
1.23 M
Place
ON/OFF
States
Empty/Occupied
States
Discrete
Empty/Occupied
States
Continuous
Place describes local system state
The number of tokens could be limited to a certain value, if this value is one the place
could represent the "on" and "off" states.
Also the number of tokens could be integer or real value; real values can represent
continuous quantities like a tank contains a liquid.
Know that, the number of tokens or marking is greater or equal zero; by default this
number has no upper limit, some PN systems limit this number to certain value called
"Capacity", if the marking level reaches this value the place stop suppliers from
bringing more tokens.
Token has different states: When it is added to the place it takes a time (Place Delay)
to completely join the place, in this period it called "Unavailable" token. Then it
become "Available". When it has to leave the place it "Reserved" until the final exit.
Tokens contribute only on the whole system only if they are "Available" otherwise
they represent only the local state of the holding place.
Available
Unavailable
Reserved
01:23
01: 45 02:50
Tokens States
Transition Element:
Represented by a bar or rectangle, it describes the events that may modify the system
state (Transition event called firing).
Arcs Element:
Represented by line from place to transition (In-Arc) or from transition to place (OutArc), it specify the relation between local state and events.
In-Arcs are basically identified by the weight, which contribute in the transition firing.
In-Arc is called "Enabled" if the number of "Available" tokens in the connected place
is greater than or equal the weigh value. Some times In-Arc is terminated with an
empty bubble; this arc is called an inhibited arc.
Special type of In-Arcs are called Inhibited-Arcs, they are represented graphically by
empty circle at the end of the arc. Inhibited-Arcs will be "Enabled" only if the
connected place is "Empty".
Out-Arcs are also identified by the weight, it represents the number of tokens which
will be supplied to the connected place if the connected transition is fired.
Place
In-Arc
Inhibited-Arc
Transition
Out-Arc
In-Arc, Out-Arc and Inhibited-Arc
Firing Event:
Firing is the main system events; it is triggered by the transition when all input arcs
are "Enabled". After certain period (Transition Delay) the firing operation is
performed.
Following action will be taken, after triggering the firing event:
• Each In-Arc "Reserve" a number of tokens equal to its weight in the
connected places. "Reserved" tokens can not be used to fire any transition.
Following action will be taken, when firing event is performed:
• Each In-Arc removes a number of tokens equal to its weight from the
connected place.
• Inhibited-Arc do not remove any thing.
• Each Out-Arc supplies the connected place with a number of tokens equals to
its weight. Those tokens will be "Unavailable" for a certain period (Place
Delay) then it becomes "Available". "Unavailable" tokens can not be used to
fire any transition.
W=1
W=2
W=1
W=2
W=2
W=4
T=2 sec
W=2
Firing conditions
is satisfied
W=4
Firing Event is
triggered
T=3 sec
W=1
W=2
T=5 sec
W=2
W=4
After 2 sec
W=1
W=2
W=2
W=4
3 sec later
After 2 sec
W=1
W=2
W=2
W=4
Special situation happens while firing:
Complete Successful Firing
Scenario
Capacity Limitation
If the place "Capacity" value is specified, the firing condition will be modified as
following; if the Out-Arc weight plus the number of tokens in the place is greater than
the capacity value, the firing condition will not satisfied.
B
A
W=1
W=2
T=2 sec
W=2
W=4
Firing conditions is not satisfied
because the number of tokens in
place C + the connected Arc
weight is greater than the
Capacity value.
D
C
T=3 sec
T=5 sec
Capacity = 2
Conflict
As shown in following figure the firing condition is satisfied for both transitions A
and B, if one of them is fired the condition will not satisfied for the other, this
situation is called a "Conflict".
W=3
W=2
B
A
Conflict
To solve this problem, a new behavior called "Priority Weight" is assigned to InArcs; the In-Arc with higher priority will be more probable to fire first. Some PN
systems specify other value called "Priority or Priority Level" this is an integer value
divide arcs into groups, higher priority group will be tested for firing first. This means
that the transition with low priority value cannot be enabled unless all higher priority
transitions fail to enable.
Following figure show 4 arcs all of them satisfy the firing conditions. Arcs are
divided into tow groups based on “Priority Level" value.
Group 1: (A, B) with Priority Level = 2, B is more probable to fire than A.
Group 2: (C, D) with Priority Level = 1, D is more probable to fire than C.
Group 1 will be tested first A or B could fire but B is more probable. Group 2 will not
be tested because the test is satisfied with one of the Arcs in Group 1.
D
A
B
C
W=2
Priority Level = 1
Priority Weight = 50
W=3
Priority Level = 2
Priority Weight = 0.3
W=2
Priority Level = 2
Priority Weight = 0.4
W=1
Priority Level = 1
Priority Weight = 20
Conflict is look like resource sharing, the tokens represent the resources, and the
transitions represent the competing processes to access the common resource.
Single, Multiple and Infinite Server
Following figure shows a very simple PN system, the transition has a delay equal 10
seconds, and this means if the firing event is triggered it will be performed after 10
seconds. Also it appears that the transition will be triggered for firing four times.
W=1
Transition Delay = 10
For ideal transition four fire events will be scheduled after 10 seconds and performed
in parallel, this means after 10 seconds the four tokens will be removed. This type of
transition is called "Infinite Server" because it can perform infinite number of firing
events at the same time. Other type of transition called "Multiple Server" can process
n events at once. If n=1 the transition called "Single Server". This property is called
"Symantec Type"
After 10 sec
After 10 sec
W=1
W=1
W=1
Transition Delay = 10 sec
Symantec Type = Single Server
After 10 sec
After 10 sec
W=1
After 10 sec
W=1
After 10 sec
W=1
Transition Delay = 10 sec
Symantec Type = Multiple Server (2)
After 10 sec
W=1
Transition Delay = 10 sec
Symantec Type = Infinite Server
W=1
W=1
W=1
Continuous Firing
What happens if the number of tokens in the place is real? Another approach must be
taken to fire the transition and to withdrew and supply tokens.
In this case a new property is assigned to the transition called "Velocity" it equals the
reciprocal of the "Transition Delay".
Velocity = 1 / Transition Delay
3.2
3.2 L
3.2
3.2 L
Weight = 1
?????
Velocity = 1
Weight = 1
0.5 L
0.5 L
The firing events is enabled all the time, which make simulation is impossible for this
case, for that reason a fixed firing event is scheduled every duration called a sampling
time. At this time a new marking quantities is calculated based on the speed, weight,
elapsed time.
M(K+1) = M(K) + [ (WIT1*UIT1+ WIT2*UIT2+…+ WITM*UITM) - (WOT1*UOT1+
WOT2*UOT2+…+ WOTN*UOTN)] * T
Where
UITi are the velocity of the input continuous transitions i
WITi are the weight of the arc between the place and input continuous transitions i
UOTj are the velocity of the output continuous transitions j
WOTj are the weight of the arc between the place and output continuous transitions j
T Sampling Interval
The velocity itself equals:
U = V * min (1, MIP1, MIP2 …UIPM)
Where
V Basic transition velocity = 1 / Transition Delay
MIPi are the marking of the input continuous place i
If velocity is infinite (Transition Delay = 0) another value can be use "Firing
Quantity".
M(K+1) = M(K) + [ (WIT1*FIT1+ WIT2*FIT2+…+ WITM*FITM) - (WOT1*FOT1+
WOT2*FOT2+…+ WOTN*FOTN)]
FITi are the firing quantity of the input continuous transitions i
FOTj are the firing quantity of the output continuous transitions j
50.1
2
1.2
1
3
1
V = 1.5
V=2
4
2
1.5
29
1
After One Sample
0
3.2
3.2
42.3
0
1.2
3
V = 1.5
V=2
4
2
1.5
2.25
9.2
7.2
After Two Sample
27.5
1
0
34.5
1.2
3
V = 1.5
4
2
1.5
15.2
V=2
4.5
7.2
Sampling Time = 1 second
30.5
2.2. Petri Nets Types
As shown, PN can behave completely different based on the assigned properties of
construction elements, for that reason following PN types is proposed.
Based on Time:
• Autonomous Petri Nets: where the Transition Delay and Place Delay equal
zero.
• T-Timed Petri Nets: where the Transition Delay >=0 and Place Delay = 0
• P-Timed Petri Nets: where the Transition Delay =0 and Place Delay >= 0
• Timed Petri Nets: where the Transition Delay >=0 and Place Delay >= 0
Based on type of parameters values (Random or Constant):
• Deterministic Petri Nets: where the PN parameters have constant values.
• Stochastic Petri Nets: where the PN parameters have random values with
certain distribution.
Based on type on modeled system type:
• Discrete Petri Nets: where the system is described by a set of states. System
states change only if a certain event is fired.
• Continuous Petri Nets: where the system is described by a set of states. System
states changes continuously with the time. This system uses the continuous
firing to update its states.
Any mix between PN types is called Hybrid PN system.
3. Modeling and simulation systems using Petri Nets
To understand how to model different systems using Petri-Nets, following examples
can be introduced. SimulaWorks package is used to model those examples, it can be
used to represent stochastic, deterministic, timed, non-timed, discrete and continuous
Petri-nets, also it provide model simulation, with ability to animate the simulation, to
draw graphs and to calculate statistics.
Example 1: How to use SimulaWorks environment
Open SimulaWorks environment, select Petri-Nets components tab, and click New
Model Button to create new schematic model area as shown bellow.
The Petri tab contains 4 components
To investigate the behavior of each
component, first drag the Discrete Place
component, and drop it in the schematic
model area.
Click on the place, the place properties
will be listed in the properties grid as
shown.
To alter certain property, for example, to 1.
change the number of tokens in the
place.
1. Select Marking property entry
2. Enter the required value for
example (5).
3. Press Enter key
2.
3.
Drag
the
Discrete
Transition
component, and drop it in the schematic
model area.
Click on the transition, the transition
properties will be listed in the properties
grid as shown.
To connect the place to the transition
using, do following:
1. Move the mouse arrow inside the
place near the edge
2. Press ALT key
3. Press the left mouse button and
drag it to the transition.
Know that, the green circle and the
squares, are used to deform the Arc.
Drag another Discrete Place and drop it
as show.
To connect the transition to the place
using, do following:
1. Move the mouse arrow inside the
transition near the edge
2. Press ALT key
3. Press the left mouse button and
drag it to the place.
Repeat above steps using continuous
places and transition, as shown.
Following are explanation of Petri-Nets components properties.
1. Discrete Place properties:
Property Name
Marking
Delay
Delay Type
Capacity
Description
Number of tokens (any integer number great or equal zero)
For P-Timed Petri-Nets: It sets the time required by token to
be available after entering the place.
For Autonomous Petri-Nets: Set this value to zero.
The type of delay value (Constant, Random)
Maximum marking value
2. Continuous Place properties:
Property Name
Marking
Capacity
Sampling Time
Description
Marking value (real number great or equal zero)
Maximum marking value
Time between two updates.
For Autonomous Petri-Nets: Set this value to zero.
3. Discrete Transition properties:
Property Name
Delay
Delay Type
Semantic Type
Description
For T-Timed Petri-Nets: It sets the time required to fire the
transition after enabling it.
For Autonomous Petri-Nets: Set this value to zero.
The type of delay value (Constant, Random)
Define how many times the transition can be enabled in
parallel, it takes following values:
• Single Server (Implicit)
• Multiple Server
• Infinite Server (Pure)
4. Continuous Transition properties:
Property Name
Sampling Time
Description
Time between two updates.
For Autonomous Petri-Nets: Set this value to zero.
Velocity
Speed Type
Firing Quantity
Velocity calculation method:
• Constant Speed
• Variable Speed
Real value >= 1, used in Autonomous Petri-Nets
5. Discrete In-Arc properties:
Property Name
Weight
Weight Type
Inhibited
Description
For Discrete: any integer number great or equal zero
For Continuous: any real number great or equal zero
Type of arc weight value:
• Constant value
• Random value
True or False
6. Continuous In-Arc properties:
Property Name
Weight
Weight Type
Inhibited
Priority Level
Priority Weight
Description
For Discrete: any integer number great or equal zero
For Continuous: any real number great or equal zero
Type of arc weight value:
• Constant value
• Random value
True or False
Any integer number great or equal zero
Any real number >=0
7. Discrete Out-Arc properties:
Property Name
Weight
Weight Type
Description
any integer number great or equal zero
Type of arc weight value:
• Constant value
• Random value
8. Continuous Out-Arc properties:
Property Name
Weight
Weight Type
Description
any real number great or equal zero
Type of arc weight value:
• Constant value
• Random value
Example 2: 2 State Petri-Nets
Create new mode, drag and connect the components as shown bellow. You can find the
meter component in outputs tab.
Press start simulation button.
If the simulation runs very fast, you can delay the simulation as follow:
Select
Tools / Library Settings / Common
from main menu
Decrease the tread priority, this will
slow down the simulation.
Example 2: Timed State
Create new mode, drag and connect the components as shown bellow.
Press start simulation button.
Example 3: User access to single resource
Create new mode, drag and connect the components as shown bellow.
Press start simulation button.
Example 4: 2 Users Accessing Single Resource
Create new mode, drag and connect the components as shown bellow.
Press start simulation button.
Example 5: n Users Accessing m Resources
Create new mode, drag and connect the components as shown bellow.
Press start simulation button.
Example 6: Kanban System
Create new mode, drag and connect the components as shown bellow.
Press start simulation button.
Example 7: Reader Writer (Classical Problem)
Create new mode, drag and connect the components as shown bellow.
Press start simulation button.
Example 7: Hybrid System
In this system the input buffer is supplied with liquid with velocity 2 letter per second.
When it reaches above or equal 100 letter the machine will start after 30 second.
It then process the liquid in the buffer with rate equals 0.5 letter per second and
produce the output in the output buffer.
When the output buffer reaches above or equal 50 letter, the machine go to off for rest
or maintenance and the buffer is emptied.
The machine is off for a period equals at minimum 30 sec then it starts again if the
input buffer contains more than 100 letter.
Create new mode, drag and connect the components as shown bellow.
Press start simulation button.
4. Exercises:
Model following system using Petri-Nets:
In this system there are 2 types of products a, b.
Product (a) processed by machine M1, then by one of the two machines M2 or M3
Product (b) processed directly by one of the two machines M2 or M3
The ratio of having part a to b are 80:20
Download