Approach and Techniques for Building Component

Download Report

Transcript Approach and Techniques for Building Component

Approach and Techniques for Building
Component-based Simulation Models
Bernard P. Zeigler, Ph.D.
Hessam S. Sarjoughian, Ph.D.
Arizona Center for Integrative Modeling and Simulation
(ACIMS)
Arizona State University
University of Arizona
www.acims.arizona.edu
Google: ACIMS
and
Joint Interoperability Test Command (JITC)
Fort Huachuca, AZ
Outline
• Basic principles of M&S from a system-theoretic
worldview
• Component-based characterization of dynamic systems
• Unified framework for discrete and continuous models
• Discrete event system specification (DEVS) formalism
• Modular, hierarchical model composition
• Systems theory support of model reusability and
composability
• Experimental Frame and model validation
• Simulation verification using the concept of abstract
simulators
• DEVSJAVA, a modular, hierarchical simulation
environment
• DEVS component-based M&S over network centric
middleware
M&S Entities and Relations
Device for
executing model
Real World
Simulator
Data: Input/output
relation pairs
modeling
relation
Each entity is represented
as a dynamic system
Each relation is represented
by a homomorphism or other
equivalence
simulation
relation
Model
structure for generating behavior
claimed to represent real world
M&S Entities and Relation(cont’d)
Experimental Frame
Real World
Simulator
modeling
relation
Experimental frame specifies
conditions under which the system
is experimented with and observed
• captures modeling objectives
• needed for validity, simplification
justifications
simulation
relation
Model
Dynamic Systems Framework
for Continuous and Discrete Models
Simulator:
Numerical
Integrator
System
System Specification:
DESS: differential equation
DTSS: discrete time
DESS model:
dq/dt = a*q +bx
DEVS: discrete event
Simulator:
Recursive
Algorithm
Simulator:
Event
Processor
System
System
DEVS model
DTSS model:
time to next event,
q(t+1) = a*q(t)+ b*x(t)
state at next event ...
Dynamic Systems Framework
for Continuous and Discrete Models (cont’d)
System
Specification
Differential
Equation
Discrete-Time
Discrete-Event
Time Base
continuous
(reals)
discrete (integers)
continuous
(reals)
Inputs,States,
Outputs
real vector
space
arbitrary
arbitrary
Input
Segments
piecewise
continuous
sequences
State &
Output
Segments
continuous
sequences
discrete-event
piecewise
constant
Discrete Event Time Segments
X
x0
t0
x1
t1
S
e
y0
Y
t2
DEVS Background
• DEVS = Discrete Event System Specification
• Provides formal M&S framework: specification,simulation
• Derived from Mathematical dynamical system theory
• Supports hierarchical, modular composition
• Object oriented implementation
• Supports discrete and continuous paradigms
Exploits efficient parallel and distributed simulation
techniques
Theory of Modeling and Simulation, 2nd Edition, Academic Press,
2000, Bernard P. Zeigler, Herbert Praehofer, Tag Gon Kim
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
DEVS Component-Based Expressability
Coupled Models
Atomic Models
Ordinary
Differential
Equation
Models
Processing/
Queuing/
Coordinating
Spiking
Neuron
Models
Petri Net
Models
Partial
Differential
Equations
Networks,
Collaborations
Processing
Networks
Physical
Space
Spiking
Neuron
Networks
n-Dim
Cell Space
Discrete
Time/
StateChart
Models
Stochasti
c
Models
Fuzzy
Logic
Models
can be
components
in a coupled
model
Cellular
Automata
Quantized
Integrator
Models
Reactive
Agent
Models
Multi
Agent
Systems
Self Organized
Criticality
Models
DEVS Theoretical Properties
• Closure Under Coupling
• Universality for Discrete Event Systems
• Representation of Continuous Systems
– quantization integrator approximation
– pulse representation of wave equations
• Simulator Correctness, Efficiency
DEVS Atomic Model
•
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.
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
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
DEVS Coupled Model
Elements of coupled model:
• Components
• Interconnections
– Internal Couplings
– External Input Couplings
– External Output Couplings
Coupling in Action
Coupling
(internal)
AB
B
A
external
State
Output
port
Input
port
external
State
internal
time advance
output
internal
time advance
output
Coupled Model Example – Neuron net
pulseIn
Pulse
Generator
FireOnce
Neuron 1
pulseOut
pulseIn
FireOnce
Neuron 2
pulseOut
pulseOut
pulseIn
pulseIn
FireOnce
Neuron 3
FireOnce
Neuron 4
pulseOut
pulseOut
FireOnce Neuron Network can compute the shortest path
in a directed graph by mapping distances of edges to equivalent time values.
We separated models and simulators – now
we bring them together
Single
processor
Distributed
Simulator
Real-Time
Simulator
DEVS
Simulation
Protocol
Simulator
Non
DEVS
C++
Java
DEVS
Other
Representation
The DEVS simulation
protocol is the agreement
between the DEVS
modeler and the
implemented simulator
DEVS Simulation
Protocol Classes
Atomic models as
components within
coupled models are
assigned to
coupledSimulators
coupledSimulator
coupledCoordinator
genDevs.
simulation.
coupledSimul
ator
Atomic
Simulator
Stand alone
atomic models are
assigned to
AtomicSimulators
coordinator
1:n
1:n
Coupled models as
components within
coupled models are
assigned to
coupledCoordinators
Coupled
models are
assigned to
coordinators
genDevs.
simulation.
coordinator
Atomic Model Simulator
• Every atomic model has a simulator
assigned to it which keeps track of the
time of the last event, tL and the time
of the next event, tN.
m
timeline
(abstract or logica)
tN
tL
inject at time t
s =: s init
If t == tN
tL =: 0
generate output  (s)
tN =: ta(sinit)
When receive m
if m!= null and t < tN,
s := ext (s,t-tN,m)
Legend:
if m!= null and t == tN,
m = message
s = state
t = clock time
tL = time of last event
tN = time of next event
s := con (s,t-tN,m)
if m= null and t == tN,
s =: int (s)
tL =: t
tN =: t + ta(s)
• Initially, the state of the model is
initialized as specified by the modeler
to a desired initial state, sinit. The event
times, tL and tN are set to 0 and
ta(sinit), respectively.
• If there are no external events, the
clock time, t is advanced to tN, the
output is generated and the internal
transition function of the model is
executed. The simulator then updates
the event times as shown, and
processing continues to the next cycle.
• If an external event is injected to the
model at some time, text (no earlier than
the current clock and no later than tN),
the clock is advanced to text.
•If text == tN the output is
generated.
•Then the input is processed by
the confluent or external event
transition function, depending
on whether text coincides with tN
or not.
Basic DEVS Simulation Protocol
For a coupled model with atomic model components, a coordinator is assigned
to it and coupledSimulators are assigned to its components. In the basic DEVS
Simulation Protocol, the coordinator is responsible for stepping simulators
through the cycle of activities shown.
1 nextTN
3 getOut
coordinator
Coupled
Model
Coupled Model Coordinator:
1.
Coordinator sends nextTN to
request tN from each of the
simulators.
2.
All the simulators reply with their
tNs in the outTN message to the
coordinator
3.
Coordinator sends to each
simulator a getOut message
containing the global tN (the
minimum of the tNs)
4.
Each simulator checks if it is
imminent (its tN = global tN) and if
so, returns the output of its model
in a message to the coordinator in
a sendOut message.
5.
Coordinator uses the coupling
specification to distribute the
outputs as accumulated messages
back to the simulators in an
applyDelt message to the
simulators – for those simulators
not receiving any input, the
messages sent are empty.
5 applyDelt
4 sendOut
simulator
tN
2. outTN
simulator
tN
simulator
tN
After each transition
tN = t + ta(), tL = t
Component
tN. tL
Component
tN. tL
Component
tN. tL
Each simulator reacts to the incoming message as follows:
•If it is imminent and its input message is empty, then it invokes its model’s internal
transition function
•If it is imminent and its input message is not empty, it invokes its model’s confluence
transition function
•If is not imminent and its input message is not empty, it invokes its model’s external
transition function
•If is not imminent and its input message is empty then nothing happens.
DEVS as the basis for Network Centric M&S
Discrete
Event
Formalisms
Discrete Time
Systems
Diff Eqn.
Systems
DEVS Model
DEVS Model
DEVS Model
Simulator
Simulator
Simulator
message
Translator
message
message
Translator
Translator
Network Centric Middleware – NCES