12 How to Model and Simulate

Download Report

Transcript 12 How to Model and Simulate

Chapter16
Methodology: How to Model and Simulate
M&S Methodology
•
First think about your objectives- find a level of difficulty that seems achievable in the time
available.
•
Develop the experimental frames first to meet these objectives.
•
Develop your atomic models and coupled models and and test them in hierarchical stage wise
fashion in SimView.
•
Start your exploratory phase -- get some preliminary results of execution within experimental
frames. What is the “lay of the land”? Which factors appear to matter most?
•
Start your production runs (for final results) by concentrating on the factors that seem to be
important from your initial exploration.
•
If you need better performance, remove all unessential code, including output and print
statements. Switch execution from SimView to fast-as-can simulation as shown next.
•
For greater performance migrate your model to parallel/distributed fast-as-can simulation (not
currently available).
•
If your objectives were to develop real-time execution models, migrate them to real-time execution
(distributed, non-distributed) as shown next.
Suggested Project Report Outline
•
Problem statement – Objectives of the Project
•
General Description of the System to be Studied
•
Objectives of the Modeling and Simulation Study
•
The Simulation Model
–
–
–
System Entity Structure or Hierarchical diagrams and
explanation of operation
Illustrative DEVSJAVA code or pseudo code
•
Experimental frame and how it serves to achieve the Objectives
•
Experiments
•
Results
( or expected results)
•
Conclusions
(what did you learn from this work
•
Future Work
•
•
References
Appendix: more details or code
Categorizing Simulation Modes and Packages in DEVSJAVA
Non Distributed
Distributed
centralized
Non threaded
Decentralized
threaded
Atomic
federate
Coupled
Federate
Real-time
SimView supports visual behavior validation.
Using real-time simulation on a single
workstation allows checking timing. Tunable
real-time coordinator used by SimView allows
speed as well.
Packages:
•genDevs.modeling
•genDevs.simulation
•simView
•genDevs.simulation.realtime
Fast-as-can
Packages:
•genDevs.modeling
•genDevs.simulation
Only decentralized is currently available
for distribution. Centralized available
upon requirest.
Packages:
•genDevs.simulation..distributed
•genDevs.simulation.realtime
Not available currently for distribution.
Available upon requirest.
Model Development using Model Continuity
Implementation/
Logical
Simulation
Model
Distribution/
Distributed
Simulation
Real-Time
Distributed
Simulation/
Execution
Checks Model
Logical Behavior
Checks Model
Logical Behavior
in Distributed
Environment
Checks Model
Temporal
Behavior
genDevs.
simulation
genDevs.
simulation.
distributed
Modeling
DEVS
Formalism
genDevs.
simulation.
realTime
Using inheritance and polymorphism to allow easy switching from
structure/behavior viewing to fast simulation
Even though ViewableAtomic and ViewableDigraph models
can hold information intended for SimView, they need not
be altered to run outside of SimView. For example, to run
a ViewableDigraph model in a main routine define:
SimView
Coordinator
Viewable
Digraph
coupledRTSimulator
public static void main(String args[]){
ViewableAtomic
Simulator
ViewableDigraph d = new (Random,rule30CellSpace):
Viewable
Atomic
r = new coordinator (d);
Later, when
ready for
production
runs,
execute
them without
change in
fast-as-can
simulation
r.initialize();
You can develop
models and test
them in SimView
//to measure execution time if desired:
initTime = System.currentTimeMillis();
r.simulate(100);
termTime = System.currentTimeMillis();}
coordinator
Viewable
Digraph
digraph
coupledSimulator
This can be executed in JBuilder of by changing directory to
DevsJava/classes and entering on the command line –
>java Random.rule30CellSpace
atomicSimulator
Viewable
Atomic
atomic
simView.
ViewableDigrap
To understand how this is possible, consider that in
atomicSimulator the Devs Simulator Cycle implementation
includes “hooks” within its methods, e.g.,
public void computeInputOutput(double t){
if(equalTN(t)) { output = myModel.Out();}
else{output = new message();}
computeInputOutputHook1() ;}
simView.
These hooks are dummy methods within atomicSimulator,
e.g.,
ViewableAyato
protected void computeInputOutputHook1() {}
mic
h
In ViableAtomicSimulator the hooks are given definitions
that allow the SimViewCoordinator to get the infromation
it needs to display in SimView, .e.g.,
protected void computeInputOutputHook1(){
if (listener == null) return;
ContentIteratorInterface iterator = output.mIterator();
while (iterator.hasNext()) {
ContentInterface content = iterator.next();
listener.contentOutputted((content)content,\
viewableAtomic, content.getPort().getName()); } }
Using toString() and toObject() to facilitate deploying models in
distributed simulation
receiver
sender
DEVS simulator uses
toString() to encode
the entity as a String
which is sent across
the wire
public message out( ){
message m = new message();
m.add(makeContent("out",
new vect2DEnt(x,y)));
return m;
}
The modeler must define toString() for
the simulator to use polymorphically. For
example:
public String toString(){
return doubleFormat.niceDouble( x ) +
","+doubleFormat.niceDouble(y);
}
public String getName(){
return toString();
}
public void deltext(double e ,message x){
for (int i=0; i< x.getLength();i++)
if (messageOnPort(x,“in",i)) {
entity en = x.getValOnPort(“in",i);
position = vect2DEnt.toObject(en);
}
The modeler also needs to define toObject() and use this method in
decoding the message.
public static vect2DEnt toObject(String nm){
int commaIndex = nm.indexOf(",");
String xs = nm.substring(0,commaIndex);
String ys = nm.substring(commaIndex+1,nm.length());
return new vect2DEnt(Double.parseDouble(xs),Double.parseDouble(ys));
}
public static vect2DEnt toObject(entity ent){
return toObject(ent.getName());
}
Deploying a coupled model onto a distributed, decentralized, real-time simulation
For the coupled model define a RTCoordinatorServer,e.g.,:
public class StartVehicleSpaceServer{
You can develop
public static void main(String[] args)
models and test
{
them in SimView
try{
System.out.println("For use by clients, this host is "
+InetAddress.getLocalHost().getHostAddress());
This will give you
}catch(Exception c){}
new RTCoordinatorServer(new vehicleSpace(), 10);}the address
needed by clients
For each component model define a RTCoordinatorClient,
e.g.,:
public class StartEvaderClient{
public static void main(String[] args) {
new RTCoordinatorClient(
new vehicle("evader",new vect2DEnt(40,40)),
"192.168.1.101", //RTCoordinatorServer’s address
//or if on same machine as the server
//you can use "localhost",
StartVehicleSpace
Server
Continuity.
StartVehicle
intranet
or internet
SpaceServ
er
Constants.serverPortNumber); }}
You can now distribute these classes onto one or more
computers and execute them from jBuilder or from the
command line as illustrated before.
StartPursuer
Client
StartEvader
Client
Later, when ready for
production runs, execute them
without change in distributed,
real0time, decentralized
simulation
You can also distribute hierarchically using RTCoordinatorServerAndClient
V&V
General System Philosophy
Systems
A system is
•a set of things
• a set of relations over those things
General
Systems
(Isomorphism classes of
particular systems based
on relational properties)
abstraction
exemplification
• relational properties (focus on relations)
• domain independent
• interpretation free
• e.g. control theory, information theory
• theoretically based distinctions
Particular
Systems
(Engineering,
Scientific,
Business,etc.)
• constituent properties (focus on things)
• domain dependent
• interpretation dependent
• e.g. aeronautical control systems
, business information systems
• experimentally based distinctions
George Klir, “Architecture of General Systems”
Modeling & Simulation/Systems Theory
uses the formalism of
Framework for
Modeling and
Simulation
Mathematical
Systems
Theory
is interpreted by
entities
relations
Hierarchy of
System
Specifications
Hierarchy of
Specification
Morphisms
M&S Framework
Objectives represented by
Experimental Frame
Collaboration
Decision
Real World
Simulator
Search
modeling
relation
simulation
relation
Model
DEVS Modeling
HLA/SOASimulation
Network
Layered architecture
Entities formalized as systems; relations as system morphisms
DEVS Modeling & Simulation Framework
• DEVS = Discrete Event System Specification
• Provides sound M&S framework
• Derived from Mathematical dynamical system theory
• Supports hierarchical, modular composition and reuse
• Can express Discrete Time, Continuous and hybrid models
• Event-orientation enables efficient simulation
• HLA/SOA enables interoperability of existing simulations
• DEVS supports developing new simulation models within an objectoriented computational framework
Joint MEASURE
TM
• Jointly Developed by Lockheed and UA under
DARPA ASTT
• Mission Effectiveness Simulator for
System-of-Systems
• employs moderate level of resolution
Inter-satellite
Communication
Collaboration
Threat
Detection
Data
JM Application:
C4ISR System-of-System Design
Decision
ME
DEVS
WAN link
Relay
Threat
Analysis
HLA
Search
Modeling
Simulation
Network
*
Mission Effectiveness Analysis Simulator for Utility, Research and Evaluation
Hierarchy of System Specifications
and Morphisms
V&V loop
Network of systems‘
Network of systems
Multi-component system
Multi-component system‘
structure
to
behavior
Structured system‘
Structured system
System
specific
ation
levels
simulation model
construction
at high levels
I/O system
I/O system‘
I/O function
I/O function‘
I/O relation
I/O relation‘
I/O frame‘
I/O frame
behavior
to
structure
Morphisms
at each level
experimental
testing at low
levels
V&V