You are on page 1of 74

Simulation and Simulation Languages

Simulation

1. Introduction

Simulation

Outline Administrative issues and course goals Simulation as a method of systems study

What is simulation Classification of systems and models


Brief history and simulation examples Simulation: why, how, yes or no, costs Simulation advantages and possible pitfalls Communication networks simulation

Goals Quantities of interest


Simulation 3

Course Staff
Lecturer: Dr.Igor Sheinman

E-mail, igorsh2912@gmail.com Visiting hours: after lectures

Assistants: Mr. Chen Hajaj Mr. Shay Tzadik

Simulation

Literature
A.M. Law and W.D. Kelton, Simulation, Modeling and Analysis, 3rd edition, McGraw Hill, 2000. Harry Perros. Computer Simulation Techniques:The definitive introduction
http://www.csc.ncsu.edu/faculty/perros/simulation.pdf

E.Altman NS Simulator. Course for Beginners


http://www-sop.inria.fr/mistral/personnel/Eitan.Altman/ns.htm

Simulation

Course Goals

By three methods we may learn wisdom: first, by reflection, which is noblest; second, by imitation, which is easiest; and third, by experience, which is the most bitter. Confucius, 551-449 BC
.1
Simulation 6

Course Goals
Methods of system performance evaluation:

Experiments: Use a concrete example of a system and try to measure its performance Analysis: Construct a mathematical abstraction of the system and derive equations describing the systems performance Simulation: Build a model (a representation) of the system, along with its operations, and use this model to numerically evaluate system performance usually with the help of computers

This course : simulations!


Simulation 7

Course Goals
At the end of the course you should:
Know principles of discrete event simulation Gain hands-on experience in developing models of a realworld systems (mainly computer networks but not only). Know basic traffic and queuing models used in network simulations Be familiar with NS-2 network simulator Be able to design, program, run and analyze the simulations Be familiar with basic statistical approaches to output analysis

Emphasis is on practical aspects, not on theory


Simulation 8

Course Outline
Introduction. Working with AWK NS-2 (including networks in a nutshell) Network performance metrics Simulation Principles Overview. A Simple Example Review of probability and statistics. Elementary queuing theory Output data analysis Traffic Models Variance reduction techniques and rare events simulation
Simulation 9

Laboratory Time Table


Laboratory 24.10.2012 AWK Practicum Date Report The first NS-2 model More interesting NS-2 model Network dynamics 7.11.2012 Network Performance Metrics (1) Report # 1 Report # 2 Report # 3 Report # 4 Report # 5

31.10.2012

14.11.2012 21.11.2012 28.11.2012 5.12.2012 12.12.2012 19.12.2012 26.12.2012 2.01.2013 9.01.2013 16.01.2013

Simulation of TCP connections TCP-UDP Simulation of a M-M-1 Output Analysis Practicum

Reports
Simulation 10

Grading 13 laboratory hours 5 final laboratory reports:


Laboratory reports Network Performance Metrics (elicitation from trace using AWK) Simulation of TCP connections, TCP UDP Simulation of M/M/1 queue and Output analysis practicum % of Grade 5 5 5 10 15 60

Final Exam

Minimum 60 required as for laboratory reports as for final exam


Simulation 11

Outline Administrative issues and course goals Simulation as a method of systems study

What is simulation Classification of systems and models


Brief history and simulation examples Simulation: why, how, yes or no, costs Simulation advantages and possible pitfalls Communication networks simulation

Goals Quantities of interest


Simulation 12

What is Simulation
Representation of the operation or features of one process or system through the use of another
The American Heritage Dictionary of the English Language, Fourth Edition

Origin simulare (Latin) : copy, represent In computer science: the technique of representing the real world by a computer program; "a simulation should imitate the internal processes and not merely the results of the thing being simulated"
WordNet 2.0, 2003 Princeton University

The act of giving a false appearance


Simulation 13

System Simulation (Modeling) Paradigm that creates simplified representations of complex systems Generates system histories and observes system behavior and statistics over time Goals are understanding system performance and improving system design
Simulation 14

Systems and Models System: is a set of entities (machines, humans) that act and interact together towards the completion of certain task. Model: is a set of mathematical and logical relationships that represent the structure and the dynamics of the system.

Simulation

15

Studying systems: how


System Systems too complicated for exact mathematical analysis computer program is used for numerical imitation of the system data is collected in order to estimate the interesting quantities

Experiment with the actual system

Experiment with a physical model of the system

Experiment with a mathematical model of the system

Toys Flight simulators Wind tunnels

Mathematical Analysis

Simulation

Exact mathematical analysis Differential calculus, Probability theory Queuing theory Algebraic methods, etc.

Simulation models Video games Weather forecasts

Most systems of the real world !

Simulation

16

Studying Mathematical Models


If model is simple enough, use traditional mathematical analysis, get exact results, lots of insight into model

Queueing theory (we will actually examine this later) Differential equations Linear programming

But complex systems can seldom be validly represented by a simple analytic model
Danger of over-simplifying assumptions model validity? The simplified model can provide valid bounds

Often, a complex system requires a complex model, and analytical methods dont apply what to do?
Simulation 17

Computer Simulation
Computer simulation or a computer model is a computer program that attempts to simulate an abstract model of a particular system.

Numerically evaluate system behavior on a computer

Use software to imitate the systems operations and characteristics, often over time

Can be used to study simple models but should not usually if an analytical solution is available Real power of simulation is in studying complex models Simulation can tolerate complex models since we dont even try to find an analytical solution
Simulation 18

Model Classification Static vs. dynamic models

Is time a significant variable?


Deterministic vs. probabilistic models Continuous-time vs. discrete-time models Continuous-event vs. discrete-event models

Simulation

19

Deterministic and Stochastic Models


Deterministic: output only depend on initial state Stochastic: output does not only depend on initial state, but also on random events. Randomness in both time of occurrence and events nature. No fixed or single result for such models

Simulation is just a sampling experiment that is performed using a model.

Simulation

20

Continuous and Discrete-time Models


Does the system state evolve continuously as a function of time or only at discrete points in time?

Number of cust. in queue

Number of students, Engineering school

Time (a) Continuous-time


Simulation

Time (Years) (b) Discrete-time


21

Continuous and Discrete-event Models


The dependencies between states are often described by systems of differential equations, classical mechanics, analog systems

Distance traveled by plane

Number of cust. in queue

Time (a) Continuous-event


Simulation

Time (b) Discrete-event


22

Relationships between System and Model


Discrete model for continuous system

Signal digitization Fluid flow model for queuing system Flow model of the traffic chemical processes are actually random (quantum mechanics), deterministic models (which is usually appropriate because of the large number of particles involved)

Continuous model for discrete system

Deterministic model for stochastic system

Choice of the model depends on the goals, feasibility etc.


Simulation 23

Systems Overview
Model

Static Continuous Deterministic Stochastic

Dynamic Discrete Deterministic Stochastic

Simulation

24

How Various Models are Studied


Deterministic Static Logical/algebraic analysis Stochastic Monte Carlo Methods

Dynamic: Discrete Event

Mechanistic and Algorithms

Queuing Theory and Discrete Event Simulation

Dynamic: Continuous Event

Numerical Solution of Differential Equations

Stochastic Differential Equations Advanced Topic

Simulation

25

Outline Administrative issues and course goals Simulation as a method of systems study

What is simulation Classification of systems and models


Brief history and simulation examples Simulation: why, how, yes or no, costs Simulation advantages and possible pitfalls Communication networks simulation

Goals Quantities of interest


Simulation 26

Brief History
1940s: Monte Carlo method is developed by physicists working on Manhattan project to study neutron scattering. Researchers include John von Neumann, Stanislaw Ulan, Edward Teller, Herman Kahn 1950s: First special-purpose simulation languages developed 1970s: Research initiated on mathematical foundations of simulation 1980s: PC-based simulation software developed, graphical user interfaces, object-oriented programming 1990s: Web-based simulation, fancy animated graphics, simulation-based optimization

Simulation

27

Monte-Carlo Method Monte-Carlo method provides approximate solutions to a variety of mathematical problems by performing statistical sampling experiments on a computer.
http://en.wikipedia.org/wiki/Monte_Carlo_method

Simulation

28

Buffons Needle experiment

Simulation

29

Buffons Needle experiment


L needle length y distance between the crack and the left end of the needle

0<y<d 0< <

d distance between cracks

The experiment : dropping a needle on a hardwood floor. The event of interest : the needle crosses a crack between floorboards. The probability of this event leads to a statistical estimate of the number !
Georges Louis Leclerc Comte de Buffon 1707-1788 Buffon, G. "Essai d'arithmtique morale." Histoire naturelle, gnrale e particulire, Supplment 4, 46-123, 1777.
Simulation 30

Buffons Needle experiment


The needle will intersect one of the lines if and only if y < L sin()

0<y<d 0< <


L = 2; d = 3

Probability that the needle intersects one of the lines : =

P=

Simulation 31

Buffons Needle Experiment


If both L and d are known, Buffon's Needle experiment can be used to estimate the value of . Nn - number of crack crossings in the first n runs . If n is large then the proportion of crack crossings should be about the same as the probability of a crack crossing (law of large numbers) P = 2L/(d ) ~ Nn / n Thus P = 2L/(d ) ~ Nn / n and hence ~ 2Ln /d Nn
See http://www.ms.uky.edu/~mai/java/stat/buff.html
Simulation 32

Simulation Example
Gambling game : a fair coin is repeatedly flipped until |#heads - #tails| = 3. The player receives $8.99 at the end of the game but must pay $1 for each coin flip. (No quitting in the middle of the game.) Is this game a good bet over the long run? That is, what is the expected reward? There are three ways to find out: 1. Try to compute the answer analytically (not easy). 2. Experiment by playing the game a number of times. Use the average reward over all of the games as an estimate of the expected reward (rather time-consuming). 3. Use the power of the computer to experiment, and use the average reward as an estimate of the expected reward. AKA - Simulation!
(Examle from Peter J. Haas Introduction to Simulation Course at Stanford University) Simulation 33

Outline Administrative issues and course goals Simulation as a method of systems study

What is simulation Classification of systems and models


Brief history and simulation examples Simulation: why, how, yes or no, costs Simulation advantages and possible pitfalls Communication networks simulation

Goals Quantities of interest


Simulation 34

Why do Engineers Simulate? (1/3) To evaluate decisions before implementation It is less costly and disruptive than experimenting with the real system

Saves money Saves time Avoids mistakes Optimizes solutions


See Jerry Banks, Randall Gibson Dont Simulate When in
Simulation 35

Why do Engineers Simulate? (2/3) To see and understand behavior of a system over time To investigate the impact of variation on the system To obtain information on multiple measures of effectiveness of the system To compress the time required to get information
Simulation 36

Why do Engineers Simulate? (3/3) To try out different ideas for improving a system To force attention to detail in design of a system or process To gain an understanding of the system or process

Simulation

37

How do Engineers Simulate

Model conceptualization

No

Experimental Design Yes

Problem formulation

Setting of objectives and overall project plan

Model translation No

Yes Verified? Validated? Production runs and analysis Yes Yes More runs? No Documentation and reporting

Data collection

No

Implementation

Problem Formulation
A statement of the problem

the problem is clearly understood by the


simulation analyst the formulation is clearly understood by the client

Setting of Objectives & Project Plan

Project Proposal
Determine the questions that are to be answered Identify scenarios to be investigated Decision criteria Determine the end-user Determine data requirements Determine hardware, software, & personnel requirements Prepare a time plan Cost plan and billing procedure

How do Engineers Simulate

Model conceptualization

No

Experimental Design Yes

Problem formulation

Setting of objectives and overall project plan

Model translation No

Yes Verified? Validated? Production runs and analysis Yes Yes More runs? No Documentation and reporting

Data collection

No

Implementation

Model Conceptualization
Real World System

Assumed system

Conceptual model

Logical model

Conceptual Model Abstract essential features

Events, activities, entities, attributes, resources,


variables, and their relationships Performance measures Data requirements

Select correct level of details (assumptions)

Level of Details Low level of details may result in lost of information and goals cannot be accomplished High level of details require:

more time and effort longer simulation runs more likely to contain errors

Level of Details
Accuracy of the model

Scope & level of details

Cost of model

Scope & level of details

Example: Hospital. Components of a System


Entity: is an object of interest in the system

Dynamic objects get created, move around, change status, affect and are affected by other entities, leave (maybe) Usually have multiple realizations Can have different types of entities concurrently Patients Visitors

Example: Hospital - Components of a System


Attribute: is a characteristic of all entities, but with a specific value local to the entity that can differ from one entity to another

Patient
Type of illness, Age, Sex, Temperature Blood Pressure

Example: Hospital. Components of a System


Resources: what entities compete for

Doctors Nurses X-Ray equipment

Entity seizes a resource, uses it, releases it

Example: Hospital. Components of a System


Variable: A piece of information that reflects some characteristic of the whole system, not of specific entities

Number of patients in the system, Number of idle doctors, Current time

Entities can access, change some variables

Example: Hospital. Components of a System


State: A collection of variables that contains all the information necessary to describe the system at any time
{Number of patients in the system, Status of doctors (busy or idle), Number of idle doctors, Status of Lab equipment, etc}

Example: Hospital. Components of a System


Event: An instantaneous occurrence that changes the state of the system

Arrival of a new patient, Completion of service (i.e., examination) Failure of medical equipment, etc.

Activity: represents a time period of specified length

Surgery, Checking temperature, X-Ray

Data Collection and Analysis


Collect data for input analysis and validation Analysis of the data

Determine the random variables Fit distribution functions

Will be discussed in details later

Simulation

52

Model Translation
Coding

General Purpose Language


JAVA, C++, Visual BASIC

Special Purpose Simulation Language/Software


SIMAN, ARENA, EXTEND, NS-2,OPNET

Verification and Validation Verification: the process of determining if the operational logic is correct.

Debugging the simulation software


Validation: the process of determining if the model accurately represents the system.

Comparison of model results with collected


data from the real system

Simulation

54

Verification and Validation


Real World System

Assumed system

Conceptual model

VALIDATION

Logical model

VERIFICATION
Simulation model
Simulation 55

How do Engineers Simulate

Model conceptualization

No

Experimental Design Yes

Problem formulation

Setting of objectives and overall project plan

Model translation No

Yes Verified? Validated? Production runs and analysis Yes Yes More runs? No Documentation and reporting

Data collection

No

Implementation

What is Simulation Analysis?


1. Establish input distributions
Model the behaviour of an input variable

2. Generation of pseudo-random numbers

and random variates


Generating input variables by sampling from probability distributions)

3. Analyzing output data and selecting the

best alternative design.

Simulation

57

Experimental Design
Alternative scenarios to be simulated Type of output data analysis (steady-state vs. terminating simulation analysis) Number of simulation runs Length of each run The manner of initialization Variance reduction Will be discussed in details later

Simulation

58

When is Simulation Appropriate? The system of interest is too complex, and analytical results are not tractable. There is a need to reinforce analytical solution methodologies or verify analytical solutions There is a need to visualize system performance (using animations).

Simulation

59

When is Simulation Inappropriate?


1. When the problem is very simple. 2. When an analytical solution can be found. 3. When direct experimentation is feasible and inexpensive. 4. If costs exceed expected returns. 5. If data is not available. 6. If insufficient development time is available. 7. When the problem is very, very complex.

Simulation

60

Superstitions about Simulation


Models of large systems are usually very complex

But now have better modeling software more general, flexible, but still (relatively) easy to use But now have faster, bigger, cheaper hardware to allow for much better studies than just a few years ago this trend will continue However, simulation will also continue to push the envelope on computing power in that we ask more and more of our simulation models Theres a lot more to a simulation study than just coding a model in some software and running it to get the answer Need careful design and analysis of simulation models simulation methodology
Simulation 61

Can consume a lot of computer time

Impression that simulation is just programming

Academic level
Winter Simulation Conference (600-700 people every year) Is one of the three important operations-research techniques (in surveys related to the use of operations research techniques: math programming, statistics, simulation) The second only to math programming among 13 techniques considered (in 1294 papers from the journal Interfaces from 1970 through 1992)

Simulation

62

Simulation: Application Areas Examples (1/2) Determining hardware requirements or protocols for communications networks Determining hardware and software requirements for a computer system Designing and analyzing manufacturing systems Evaluating military weapons systems or their logistics requirements

Simulation

63

Simulation: Application Areas Examples (2/2) Designing and operating transportation systems such as airports, freeways, ports, and subways Evaluating designs for service organizations such as call centers, fast-food restaurants, hospitals, and post offices Reengineering of business processes Determining ordering policies for an inventory system Analyzing financial or economic systems
Simulation 64

How much does it cost? PCs are now powerful enough to run most simulation models The software can be expensive ($500 $40,000+) Very large and complex models may require engineering workstations (>$8000) (e.g. communications networks, large 3D factory designs with animation) Development efforts
Simulation 65

Outline Administrative issues and course goals Simulation as a method of systems study

What is simulation Classification of systems and models


Brief history and simulation examples Simulation: why, how, yes or no, costs Simulation advantages and possible pitfalls Communication networks simulation

Goals Quantities of interest


Simulation 66

Advantages of simulation (1/2) Simulation allows to study the operation of very complicated systems experiment with systems in the planning stage (without building a real system or a prototype)

compare different planning options or operation


policies sometimes building the simulation model is more important than the simulation itself
Simulation 67

See Tips for Successful Practice in Simulation in

Advantages of simulation (2/2) Simulation allows to examine the behavior of an existing system under different operation conditions

by means of simulation one can tune the system


parameters more easily and accurately than in the real system

study the behavior of the system over longer periods of time (in a compressed time scale) or conversely very fast events (in a slowed down time scale)

Simulation

68

Common pitfalls in simulation (1/2) The goals of the simulation are not clearly defined

the system or important questions are not understood well enough lets simulate, the problem will become clearer

Not enough communication with the problem owner

Simulation

69

Common pitfalls in simulation (2/2) Inappropriate level of detail (too many / too few details)

with too many details any simulation program


will get stuck too little detail may depend on missing data

Focus on the simulation program as if the task is solely to write a demanding program Lack of expertise on the system, performance analysis, statistical analysis Use of wrong tools Will be discussed in details later
Simulation 70

Outline Administrative issues and course goals Simulation as a method of systems study

What is simulation Classification of systems and models


Brief history and simulation examples Simulation: why, how, yes or no, costs Simulation advantages and possible pitfalls Communication networks simulation

Goals Quantities of interest


Simulation 71

Typical questions to be answered by computer networks simulation How does the network behave with increasing load? How many and how fast links / switches or how big buffers are needed in a WAN network? What are the consequences of a link failure? Which protocol gives the best performance? What is the most advantageous network structure?

Simulation

72

Typical questions to be answered by computer networks simulation What happens if the number workstations attached to a network is increased? How do new applications affect the LAN? Should one divide the LAN in smaller segments? Does one obtain the desired performance with a client server architecture? How many satellites are needed for a certain quality of service between two earth stations?

Simulation

73

Typical quantities of interest in networks simulation


The utilization of links Throughput (Mbit/s) The blocking probability of a connection End to end delay Delay between two points, A and B, in the network Number of packets in a buffer The probability of failure of a call handover in a mobile network The collision probability of packets in a LAN Will be discussed in details later
Simulation 74

You might also like