simulation and modeling

21
Simulation and Simulation and modeling modeling presented by presented by Vidya Sivakumar Vidya Sivakumar

Upload: jillian-cleveland

Post on 30-Dec-2015

32 views

Category:

Documents


0 download

DESCRIPTION

Simulation and modeling. presented by Vidya Sivakumar. A discipline of designing a model of actual or theoretical physical systems,executing the model on a digital computer and analyzing the execution output. It embodies a principle of “learning by doing”. What is simulation?. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Simulation and modeling

Simulation and Simulation and modelingmodeling presented bypresented by Vidya SivakumarVidya Sivakumar

Page 2: Simulation and modeling

A discipline of designing a model of A discipline of designing a model of actual or theoretical physical actual or theoretical physical

systems,executing the model on a systems,executing the model on a digital computer and analyzing the digital computer and analyzing the

execution output.execution output.It embodies a principle of “learning It embodies a principle of “learning

by doing”by doing”

What is simulation?What is simulation?

Page 3: Simulation and modeling

Characterisation of simulation:

computer graphics:computational study of light and its effects on geometric objects -key focus was to produce meaningful rendered images of real world or hypothetical objects.

Animation:is the use of graphics to generate a sequence of frames which,when passed before your eyes quickly,produces a n illusion of continuous motion.

Virtual Reality : is primarily focussed on human computer interaction as found in devices such as HMD’s,position sensors and data gloves.

Simulation is an”engine” that drives the graphics and VR tchnologies-provides the infrastructure necessary for the other fields.

Page 4: Simulation and modeling
Page 5: Simulation and modeling

Why do simulation?Simulation is essential in the following areas:

1. Model is complex with many variables and interacting components.

2.Underlying variable relationships are non_linear.

3.model contains random variables

4.model’s output is to visual as in 3D computer animation.

Page 6: Simulation and modeling

Model classifications:

1.Continuous and discrete time models

2.Continuous state and discrete state models

3.Deterministic and probabilistic models

4.Static and Dynamic models

5.Linear and nonlinear models

6.Open and closed models

7.Stable and unstable models

Page 7: Simulation and modeling

Model Verification and Validation techniques:

Two steps involved in the goodness of a simulation model:

• Ensure that the assumptions are reasonable - Validation-Are we building the right system?

•Ensure that the model implements those assumptions correctly-verification (also called debugging)-Are we building the system right?

Page 8: Simulation and modeling

Verification techniques:

1.Modular design

2.Antibugging

3.Structured walkthrough

4.Deterministic models

5.Run simplified cases

6.Trace

7.On-line graphic displays

Page 9: Simulation and modeling

Model validation techniques:

Validation techniques used for one model cannot be applied to another.

Key aspects:

1.Assumptions

2.input parameter values and distributions.

3.Output values and conclusions.

Page 10: Simulation and modeling

Each of the key aspects are subjected to validity test with that obtained from the following sources:

1.Expert intuition - brainstorming meeting

2.Real-system mesurements

3.Theoretical results

Page 11: Simulation and modeling

Simulation Languages

General purpose languages (C, C++, Fortran, Ada, etc.) Simulation languages (SIMSCRIPT, GPSS, COMNET,

SimPack, etc.) Selecting a language for simulation is one of the most important choice since incorrect decision causes long development times,incomplete studies and failures.Advantages of Using Simulation Languages

1.Simulation languages automatically provide most (if not all) of the features needed in programming a simulation model. 2.Simulation languages provide a natural framework for simulation modeling. 3.Most simulation languages provide better error detection.

Page 12: Simulation and modeling

Advantages of General purpose languages 1.Most programmers already know a general purpose language. 2.General purpose languages are available on almost every computer. 3.An efficiently written general purpose language may require less execution time than the corresponding program written in a simulation language. 4.General purpose languages allow greater programming flexibility.

Page 13: Simulation and modeling

What is Simjava?

Simjava is a process based discrete event simulation package for java

A collection of entities each running on its own thread.

Entities are connected by ports and can communicate with each other by sending and receiving objects.

A central system class that controls all the threads and advances the simulation time.

Progress is recorded as trace messages and saved in a file.

Page 14: Simulation and modeling

A simulation layout

Page 15: Simulation and modeling

An Example:

Constructing a simulation involves :

•Coding the behavior of simulation entities - done by extending the sim_entity class and using the body() method.

•Adding instances of these entities using sim_system object using sim_system.add(entity)

•linking entities ports together,using sim_system.link_ports()

• finally,setting the simulation in motion using sim_system.run().

Page 16: Simulation and modeling

/* A simple Source and Sink example * The source sends 100 messages to the sink, and waits for acks * Messages are sent via ports */

import eduni.simjava.*;

class Source extends Sim_entity { private Sim_port out; private int index; private int state;

public static final int SRC_OK = 0; public static final int SRC_BLOCKED = 1;

public Source(String name, int index, int state) { super(name); this.index = index; this.state = state; out = new Sim_port("out"); add_port(out); }

Page 17: Simulation and modeling

public void body() { Sim_event ev = new Sim_event(); int i;

System.out.println("About to do body S"); for (i=0; i<100; i++) { sim_schedule(out,0.0,0); sim_wait(ev); sim_hold(10.0); sim_trace(1,"C Src loop index is "+i); } System.out.println("Exiting body S"); }}

class Sink extends Sim_entity { private Sim_port in; private int index; private int state;

public static final int SINK_BLOCKED = 0; public static final int SINK_OK = 1;

Page 18: Simulation and modeling

public Sink(String name, int index, int state) { super(name); this.index = index; this.state = state; in = new Sim_port("in"); add_port(in); }

public void body() { Sim_event ev = new Sim_event(); int i = 0;

System.out.println("About to do body R"); while(true) { i++; if(i>50) break; sim_wait(ev); sim_hold(1.234); sim_schedule(in,0.0,1); } System.out.println("Exiting body S"); }}

Page 19: Simulation and modeling

class Example1 { public static void main(String args[]) { Sim_system.initialise(); Sim_system.add(new Source("Sender", 1, Source.SRC_OK)); Sim_system.add(new Sink("Receiver", 2, Sink.SINK_OK)); Sim_system.link_ports("Sender", "out", "Receiver", "in"); Sim_system.run(); System.out.println("Exiting main()"); }}

Compiling Simulations:1. Add the sim_java package to the CLASSPATH environment variableexport CLASSPATH=/home/rmcn/summ96/simjava/classes/:$CLASSPATH

2.Compile and execute the code in the normal way3.After running the simulation will leave a trace file in the current directory,containing the trace lines of the simulation.

Page 20: Simulation and modeling

Timing diagram bean using the simanim package

Page 21: Simulation and modeling

“Simulation should be closely interwoven with empirical studies where possible; it is not a substitute for physical

experimentation”