Professional Documents
Culture Documents
I ST / DEEC / API
http://users.isr.ist.utl.pt/~jag/courses/api1112/api1112.html
Slides 2010/2011 Prof. Paulo J orge Oliveira
Rev. 2011/2012 Prof. J osGaspar
Discrete Event Systems
Discrete Event Systems
MEEC 2011-2012
Industrial
Industrial
Automation
Automation
(Automa
(Automa
o de Processos Industriais)
o de Processos Industriais)
Page2
I ST / DEEC / API
Chap. 5 CAD/CAM and CNC [1 week]
...
Chap. 6 Discrete Event Systems [2 weeks]
Discrete event systems modeling. Automata.
Petri Nets: state, dynamics, and modeling.
Extended and strict models. Subclasses of Petri nets.
=
=
) ), ( ), ( ( ) (
) ), ( ), ( ( ) (
t t u t x g t y
t t u t x f t x
=
,... , ,
, , , , , ,
abga aaba abg
aab aa ag ab a
G L
c
( ) ( ) ( ) G L G L
m
c
( ) ( ) G L G L
m
=
Chap. 6 DiscreteEvent Systems
The state 5is a deadlock.
The states 3and 4
constitutes a livelock.
Page28
I ST / DEEC / API
Alternative way to detect deadlocks:
Example:
1
2
0
3
4
0
0
a
5
b
3
a
g
g b
a
0
1
2
3
4
5
a
a
a
g
g
b
b
Chap. 6 DiscreteEvent Systems
The state 5is a deadlock.
The states 3and 4
constitutes a livelock.
Page29
I ST / DEEC / API
Timed Discrete Event Systems
Chap. 6 Discrete Event Systems
1 2
3
4
2
2
Page30
I ST / DEEC / API
Petri nets
Developed by Carl Adam Petri in his PhD thesis in 1962.
Definition: A marked Petri net is a 5-tuple
(P, T, A, w, x
0
)
where:
P - set of places
T - set of transitions
A - set of arcs A (P x T) (T x P)
w - weight function w: A N
x
0
- initial marking x
0
: P N
Chap. 6 Discrete Event Systems
Page31
I ST / DEEC / API
(P, T, A, w, x
0
)
P={p
1
, p
2
, p
3
, p
4
, p
5
}
T={t
1
, t
2
, t
3
, t
4
}
A={(p
1
, t
1
), (t
1
, p
2
), (t
1
, p
3
), (p
2
, t
2
), (p
3
, t
3
),
(t
2
, p
4
), (t
3
, p
5
), (p
4
, t
4
), (p
5
, t
4
), (t
4
, p
1
)}
w(p
1
, t
1
)=1, w(t
1
, p
2
)=1, w(t
1
, p
3
)=1, w(p
2
, t
2
)=1
w(p
3
, t
3
)=2, w(t
2
, p
4
)=1, w(t
3
, p
5
)=1, w(p
4
, t
4
)=3
w(p
5
, t
4
)=1, w(t
4
, p
1
)=1
x
0
={1, 0, 0, 2, 0}
Exampleof a Petri net
Chap. 6 DiscreteEvent Systems
Page32
I ST / DEEC / API
(P, T, A, w, x
0
)
P={p
1
, p
2
, p
3
, p
4
, p
5
}
T={t
1
, t
2
, t
3
, t
4
}
A={(p
1
, t
1
), (t
1
, p
2
), (t
1
, p
3
), (p
2
, t
2
), (p
3
, t
3
),
(t
2
, p
4
), (t
3
, p
5
), (p
4
, t
4
), (p
5
, t
4
), (t
4
, p
1
)}
w(p
1
, t
1
)=1, w(t
1
, p
2
)=1, w(t
1
, p
3
)=1, w(p
2
, t
2
)=1
w(p
3
, t
3
)=2, w(t
2
, p
4
)=1, w(t
3
, p
5
)=1, w(p
4
, t
4
)=3
w(p
5
, t
4
)=1, w(t
4
, p
1
)=1
x
0
={1, 0, 0, 2, 0}
Example of a Petri net
p
1
p
2
p
3
t
1
t
3
t
2
p
4
p
5
t
4
2
3
Petri net graph
Chap. 6 Discrete Event Systems
Page33
I ST / DEEC / API
Petri nets
Rules to follow (mandatory):
Arcs(directed connections)
connect placesto transitionsand
connect transitionsto places
A transitioncan have no placesdirectly as inputs (source) ,
i.e. must exist arcsbetween transitions and places
A transitioncan have no placesdirectly as outputs (sink),
i.e. must exist arcsbetween transitions and places
The same happens with the input and output transitionsfor places
Chap. 6 Discrete Event Systems
Page34
I ST / DEEC / API
Alternative definition of a Petri net
A marked Petri net is a 5-tuple
(P, T, I , O,
0
)
where:
P - set of places
T - set of transitions
I - transition input function I : T P
0
- initial marking
0
: P N
Note: P
=bag of places
Chap. 6 DiscreteEvent Systems
Page35
I ST / DEEC / API
Alternative definition
(P, T, I, O,
0
)
P={p
1
, p
2
, p
3
, p
4
, p
5
}
T={t
1
, t
2
, t
3
, t
4
}
I(t
1
)={p
1
} O(t
1
)={p
2
, p
3
}
I(t
2
)={p
2
} O(t
2
)={p
4
}
I(t
3
)={p
3
, p
3
} O(t
3
)={p
5
}
I(t
4
)={p
4
, p
4
, p
4
, p
5
} O(t
4
)={p
1
}
0
={1, 0, 0, 2, 0}
Exampleof a Petri net anditsgraphical representation
p
1
p
2
p
3
t
1
t
3
t
2
p
4
p
5
t
4
2
3
Chap. 6 DiscreteEvent Systems
Page36
I ST / DEEC / API
The stateof a Petri net is
characterized by the marking
of all places.
The set of all possible markings
of a Petri net corresponds to its
state space.
How does the state of a Petri net evolve?
Petri nets
p
1
p
2
p
3
t
1
t
2
3
Chap. 6 Discrete Event Systems
Page37
I ST / DEEC / API
A transition t
j
T is enabledif:
)) ( , ( # ) ( :
j i i i
t I p p P p > e
A transition t
j
e T may firewhenever enabled, resulting in a new
marking given by:
( ) ( ) )) t ( O , p ( # )) t ( I , p ( # p p
j i j i i i
+ =
'
Execution Rules for Petri Nets(Dynamics of Petri nets)
Chap. 6 DiscreteEvent Systems
#(p
i
, I(t
j
)) = multiplicity of the arc from p
i
to t
j
#(p
i
, O(t
j
)) = multiplicity of the arc from t
j
to p
i
Page38
I ST / DEEC / API
Example of evolution of a
Petri net
Initial marking:
0
={1, 0, 1, 2, 0}
p
1
p
2
p
3
t
1
t
3
t
2
p
4
p
5
t
4
2
3
This discrete event system
can not change state.
It is in a deadlock!
.
.
.
.
.
.
.
.
.
.
.
.
.
.. .
..
. . .
.
Chap. 6 DiscreteEvent Systems
Petri nets
Page39
I ST / DEEC / API
Petri nets: Conditions and Events
Conditions:
a) The server is idle.
b) A job arrives and waits to be processed
c) The server is processing the job
d) The job is complete
Events
1) J ob arrival
2) Server starts processing
3) Server finishes processing
4) The job is delivered
Event Pre-conditions Pos-conditions
1 - b
2 a, b c
3 c d, a
4 d -
Chap. 6 Discrete Event Systems
J obs waits
processing
J ob is being
processed
Server is idle
J ob is
complete
J ob arrival
Start of
processing
End of
processing
J ob is
delivered
Example: Machine waits until an order appears and then machines the ordered part and sends it
out for delivery.
Page40
I ST / DEEC / API
Concurrence Conflict
t
1
t
2
t
1
t
2
Chap. 6 Discrete Event Systems
Petri nets: Modeling mechanisms
Page41
I ST / DEEC / API
Mutual Exclusion Producer / Consumer
t
1
t
2
Critical
Section
Critical
Section
m
Chap. 6 Discrete Event Systems
produce
B
consume
B= one element buffer Place m represents the permission to enter
the critical section
Petri nets: Modeling mechanisms
Page42
I ST / DEEC / API
Readers / Writers Producer / Consumer
with finite capacity
Chap. 6 Discrete Event Systems
Petri nets: Modeling mechanisms
produce
B
consume
B'
n
read
write
n
s t
n
n
Page43
I ST / DEEC / API
Discrete Event Systems
Example of a simple automation system modeled using PNs
An automatic soda selling
machine accepts
50c and $1 coins and
sells 2 types of products:
SODA A, that costs $1.50 and
SODA B, that costs $2.00.
Assume that the money return
operation is omitted.
p
1
: machine with $0.00;
t
1
: coin of 50 c introduced;
t
8
: SODA B sold.
Chap. 6 Discrete Event Systems
t
1
t
2
t
3
t
4
t
5
t
6
t
7
t
8
t
9
p
1
p
2
p
3
p
4
p
5
Page44
I ST / DEEC / API
Extensionsto Petri nets
Switches[Baer 1973]
e
f
e
f
e
f
e
f
Possible to be implemented with restricted Petri nets.
Chap. 6 Discrete Event Systems
Page45
I ST / DEEC / API
I nhibitor Arcs
Equivalent to
nets with priorities
Can be implemented with restricted Petri nets?
Zero tests...
Infinity tests...
Chap. 6 Discrete Event Systems
Extensionsto Petri nets
Page46
I ST / DEEC / API
P-Timed nets
Chap. 6 Discrete Event Systems
Extensionsto Petri nets
J obs waits
processing
J ob is beeing
processed
Server is idle
J ob is
complete
J ob arrival Start of
processing
End of
processing
J ob is
delivered
Page47
I ST / DEEC / API
T-Timed nets
Chap. 6 Discrete Event Systems
J obs waits
processing
J ob is being
processed
Server is idle
J ob is
complete
J ob arrival Start of
processing
End of
processing
J ob is
delivered
Extensionsto Petri nets
Page48
I ST / DEEC / API
Stochastic nets
q
0
q
1
q
2
q
0
+q
1
+q
2
=1
Stochastic switches Transitions with stochastic timings
described by a stochastic variable
with known pdf
0
Chap. 6 Discrete Event Systems
Extensionsto Petri nets
Page49
I ST / DEEC / API
Discrete Event Systems
Sub-classes of Petri nets
State Machine:
Petri nets where each transition
has exactly one input arc and one
output arc.
Marked Graphs
Petri nets where each place
has exactly one input arc and one
output arc.
Chap. 6 Discrete Event Systems
Page50
I ST / DEEC / API
Example of DES:
Manufacturing system composed
by 2 machines (M
1
and M
2
) and a
robotic manipulator (R). This takes
the finished parts from machine M
1
and transports them to M
2
.
No buffers available on the machines.
If R arrives near M
1
and the machine is
busy, the part is rejected.
If R arrives near M
2
and the machine is
busy, the manipulator must wait.
Machining time: M
1
=0.5s; M
2
=1.5s; R
M1
M2
=0.2s; R
M2
M1
=0.1s;
M
1
R
M
2
Chap. 6 Discrete Event Systems
Discrete Event Systems
Page51
I ST / DEEC / API
Variables of
M
1
x
1
M
2
x
2
R x
3
Example of arrival of parts:
x
1
={Idle, Busy, Waiting}
x
2
={Idle, Busy}
x
3
={Idle, Carrying, Returning}
=
stamps time other in
in
t a
0
} 5 . 2 , 6 . 1 , 1 . 1 , 7 . 0 , 1 . 0 { 1
) (
M
1
R
M
2
Chap. 6 Discrete Event Systems
Example of DES:
Discrete Event Systems
Page52
I ST / DEEC / API
Definition of events:
a
1
- loads part in M
1
d
1
- ends part processing in M
1
r
1
- loads manipulator
r
2
- unloads manipulator and
loads M
2
d
2
- ends part processing in M
2
r
3
- manipulator at base
M
1
R
M
2
Chap. 6 Discrete Event Systems
Example of DES:
Discrete Event Systems
Page53
I ST / DEEC / API
1 2 3 4
t
a
1
1 2 3 4
t
d
1
1 2 3 4
t
r
1
1 2 3 4
t
r
2
1 2 3 4
t
r
3
1 2 3 4
t
d
2
1 2 3 4
t
x
1
W
B
I
1 2 3 4
t
x
3
R
C
I
1 2 3 4
x
2
t
B
I
Chap. 6 Discrete Event Systems
Discrete Event Systems
Page54
I ST / DEEC / API
M
1
R
M
2
Chap. 6 Discrete Event Systems
Example of DES:
Discrete Event Systems
Events:
a
1
- loads part in M
1
d
1
- ends part processing in M
1
r
1
- loads manipulator
r
2
- unloads manipulator and loads M
2
d
2
- ends part processing in M
2
r
3
- manipulator at base
new
part
reject
part
Idle
Busy
d
1
Waiting
Idle
Carrying
r
1
Idle
Busy
r
2
Returning
d
2
r
3
. . .
M
1
M
2
R