ECE 575 - Arizona Center of Integrative Modeling and

Download Report

Transcript ECE 575 - Arizona Center of Integrative Modeling and

ECE 449/549
Class Notes #2
Introduction to Discrete-Event Systems
Specification (DEVS)
Sept. 2008
Basic Entities and Relations in Modeling
and Simulation
Experimental Frame
Source
System
behavior database
Modeling
Relation
Simulator
Simulation
Relation
Model
DEVS Formalism
DEVS = Discrete Event Systems Specification
• Atomic Models
• Coupled Models
• Hierarchical Models
Discrete Event Time Segments
X
x0
t0
x1
t1
S
e
y0
Y
t2
DEVS Atomic Model
Elements of an atomic model:
• input events
• output events
• state variables
• state transition functions
• output function
• time advance function
Atomic Model Operation
•
Ports are represented explicitly – there can be any number of input and output ports on which
values can be received and sent
•
The time advance function determines the maximum lifetime in a state
•
A bag can contain many elements with possibly multiple occurrences of its elements.
•
Atomic DEVS models can handle bags of inputs and outputs.
•
The external transition function handles inputs of bags by causing an immediate state change,
which also may modify the time advance.
•
The output function can generate a bag of outputs when the time advance has expired.
•
The internal transition function is activated immediately after the output function causing an
immediate state change, which also may modify the time advance.
•
The confluent transition function decides the next state in cases of collision between external
and internal events.
Basic specification:
DEVS = <X,S,Y, dint , d ext ,dcon, ta,l >
X : a set of input events.
Y : a set of output events.
S : a set of states
ta : S -> R+0,inf time advance function
dint :S -> S internal transition function.
d ext :Q x Xb -> S external transition function,
d con :Q x Xb -> S confluent transition function,
where Xb is a set of bags over elements in X.
Q= {(s,e)|se S, 0<= e <= ta(s)}
l: S -> Y output function
DEVS Atomic Model
Implements Basic DEVS
Make a
transition
(external)
Make a
transition
(internal)
input
external
Handle
input
State
internal
time advance
output
output
Hold for
some time
Send an
output
Internal Transition /Output Generation
output
Generate output
using the
output
function
Time advance
s’
s
Make a transition
using the
internal
transition
function
Response to External Input
input
Make a transition
elapsed
time
Time advance
using the
external
transition
function
Response to Simultaneous External Input and Internal Event
output
input
Make a transition
elapsed
time
Time advance
Generate output
using the
confluent
transition
function
Atomic Model Examples
pulse
start Pulse
Generator
out
time
Pulse Generator
Output
interPulseTime >0
start
active
passive
ta = ∞
Output
Fire-once Neuron
receptive
Input
Firing delay >0 ta = ∞
ta = ∞
external event
refract
fire
Internal event
output event
Basic DEVS: Example Scuba Model
1 hr
Dive
Plan
5ft
5 min
40ft
25 min
60ft
Emergency
Phone
Call
Response
35 min
=dint (“five”) for phase != “five” ,“surface1”, “surface2”
dint (“five”,s ) otherwise //except when already on “five
DEVS Hierarchical Modular Composition
Atomic: lowest level model,
contains structural
dynamics -- model level
modularity
Atomic
Coupled: composed of
one or more atomic
and/or coupled
models
hierarchical
construction
Ato mic
Atomic
Atomic
A to mic
Atomic
Atomic
Coupled model specification:
DN = < X ,Y,D,{Mi },{Ii },{Zi,j }>
X : a set of input events.
Y : a set of output events.
D : an index set for the components of the coupled model.
For each i e D ,
Mi is a component DEVS model.
For each i e D u self , Ii is the set of influencees of i .
For each j e D u self ,
Zi,j is output translation mapping
create components
class ef:public digraph{
public:
ef():digraph(){
genr * g = new genr("g);
transd * t = new transd("t");
ef
start
out
start
g
result
ariv
add(g);
add(t);
add coupling
add_coupling(this, "in", t, "done");
add_coupling(this, "start", g, "start");
t->add_coupling(t,"out",g,"stop");
t->add_coupling(t, "out", this, "result");
g->add_coupling(g, "out", this, "out");
g->add_coupling(g, "out", t, "ariv");
DIGRAPH
out
t
in
done
declare ports
inports->add("in");
outports->add("out");
inports->add("start");
outports->add("result");
out
ENTITY
Object Oriented
DEVS CLASSES
DEVS
Legend
ATOMIC
inherits
can hold
devs
COUPLED
CONTAINER
entity
MESSAGE
content
port,
value -> ENTITY
Simulation Cycle for DEVS
Parallel /Confluent
1 Compute the global next event time, tN: use reduce to get
minimum of component times to next event (tN)
2 Tell all components the global tN and
if component is imminent (tN == global tN ),
then generate output message(using l)
3 Sort and distribute (using coupling) output messages.
4
Tell all components
if component is imminent (tN == global tN )
or has incoming mail (external events)
or both
then execute transition function (wrap_deltfunc).
wrap_deltfunc(t,m)
deltext(t-tN,m
deltint() deltcon(m)
Simulation Cycle Step 1
Compute the next event time (tN) : uses reduction to get
minimum of the component times to next event.
Block
(UI)
Tell_all (next_tN) Ensemble Message
Collection of Minimum tN Values
i
compute tN
return MIN tN
Low Node
i +2
i +1
compute tN
return MIN tN
compute tN
return MIN tN
i +3
compute tN
return MIN tN
i +7
i+8
compute tN compute tN
return tN
return tN
i+4
compute tN
return MIN tN
i +9
i + 10
compute tN compute tN
return tN
return tN
i +5
compute tN
return MIN tN
i + 11
compute tN
return tN
High Node
i +6
compute tN
return tN
Simulation Cycle Step 2
Tell all components global tN:
if component is imminent generate and sort output messages
i
Low Node
Tell_all (compute_IO) Ensemble Message
compute_IO
i+2
i +1
compute_IO
compute_IO
i +3
compute_IO
i +7
compute_IO
i+8
i +5
i+4
compute_IO
compute_IO
i+9
i + 10
i + 11
compute_IO compute_IO compute_IO compute_IO
High Node
i +6
compute_IO
Mail Exchange in Step3
tell all imminents,
sort, and distribute output messages (mail) using coupling
i +1
i+2
i +3
i+4
Step 1 : Mail Message Size Information
Step 2 : Mail Exchange
i +5
Simulation Cycle Step 4
Tell all components with to execute their
transition functions.
i
Low Node
Tell_all (wrap_deltfunc) Ensemble Message
wrap_deltfunc
i+2
i +1
wrap_deltfunc
wrap_deltfunc
i +3
i+4
wrap_deltfunc
wrap_deltfunc
i +7
i+8
i+9
i +5
wrap_deltfunc
i + 10
i + 11
wrap_deltfuncwrap_deltfuncwrap_deltfunc
wrap_deltfunc wrap_deltfunc
High Node
i +6
wrap_deltfunc