34
KKKT 6274 Modeling and Simulation of Communication and Computer Network Prof. Dr. Mahamod Ismail [email protected]

KT6274 Lecture 2

  • Upload
    ukays

  • View
    7

  • Download
    0

Embed Size (px)

DESCRIPTION

Modeling and Simulation

Citation preview

Page 1: KT6274 Lecture 2

KKKT 6274

Modeling and Simulation of Communication and Computer

Network

Prof. Dr. Mahamod Ismail [email protected]

Page 2: KT6274 Lecture 2

TEACHING PLAN (1/3)

Week Topics 1

(MBI) Introduction to Simulation and Performance Modeling: Analytical and Monte Carlo

2 (MBI)

Simulation Principle: Event and Time Driven

3 (MBI)

Simulation Model: Statistical, Random and Queue

4 (MBI)

Model Verification/Validation, Input/Output Analysis

Page 3: KT6274 Lecture 2

LECTURE 2

SIMULATION PRINCIPLE

Page 4: KT6274 Lecture 2

Introduction

Page 5: KT6274 Lecture 2

• Stochastic (random process) or deterministic (a computation that given an initial state of the system will always produce the same final state when given the same input)

• Steady-state or dynamic • Continuous (small changes in the input result in small

changes in the output) or discrete (ex: events over time) • Local or distributed (using two or more computers

communicating over a network to accomplish a common objective or task)

Introduction

Page 6: KT6274 Lecture 2

• Stochastic models use random number generators to model the chance or random events; they are also called Monte Carlo simulations. Ex: rainfall/runoff models

• A discrete event simulation (DE) manages events in time. Most computer simulations are of this type. In this type of simulation, the simulator maintains a queue of events sorted by the simulated time they should occur. The simulator reads the queue and triggers new events as each event is processed. It is not important to execute the simulation in real time. It's often more important to be able to access the data produced by the simulation, to discover logic defects in the design, or the sequence of events.

Introduction

Page 7: KT6274 Lecture 2

• A continuous simulation uses differential equations, implemented numerically. Periodically, the simulation program solves all the equations, and uses the numbers to change the state and output of the simulation. Most flight and racing-car simulations are of this type. This may also be used to simulate electrical circuits.

• Distributed models run on a network of interconnected computers, possibly through the Internet. Simulations dispersed across multiple host computers like this are often referred to as "distributed simulations". There are several military standards for distributed simulation.

Introduction

Page 8: KT6274 Lecture 2

Computer simulations are used in a wide variety of practical contexts, such as: – analysis of air pollutant dispersion using atmospheric dispersion

modeling – design of complex systems such as aircraft and also logistics

systems. – design of Noise barriers to effect roadway noise mitigation – flight simulators to train pilots – weather forecasting

Can you think of others?

Introduction

Page 9: KT6274 Lecture 2

Deterministic vs. Stochastic

• Computer simulation has to do with using computer models to imitate real life or make predictions.

• A model consists of a certain number of input parameters and a few equations that use those inputs to give a set of outputs (or response variables).

• The model is usually either deterministic or stochastic.

Page 10: KT6274 Lecture 2

10

Deterministic vs. Stochastic

• In the deterministic model, the results will be the same no matter how many times re-calculate is done.

Page 11: KT6274 Lecture 2

11

Deterministic vs. Stochastic

Page 12: KT6274 Lecture 2

Deterministic v. Stochastic

Fixed Data

7% Fixed Outcomes

$1,200,00

Variable data Variable Outcomes

Deterministic

Stochastic

350.00 425.00 500.00 575.00 650.00

Monthly Savings

Page 13: KT6274 Lecture 2

13

Deterministic vs. Stochastic

• A stochastic model is one that involves probability or randomness.

• For example, random selection of parts in order to assemble the hinge.

Page 14: KT6274 Lecture 2
Page 15: KT6274 Lecture 2

15

Monte Carlo Simulation

• A Monte Carlo method is a technique or computational algorithm that involves using repeated random numbers and probability to solve problems.

• The term Monte Carlo Method was coined by S. Ulam and Nicholas Metropolis in reference to games of chance, a popular attraction in Monte Carlo, Monaco (Hoffman, 1998; Metropolis and Ulam, 1949).

• Monte Carlo simulation is a method for iteratively evaluating a deterministic model using sets of random numbers as inputs.

Page 16: KT6274 Lecture 2

16

Monte Carlo Simulation

• Monte Carlo simulation is often used when the model is complex, nonlinear, or involves more than just a couple uncertain parameters.

• A simulation can typically involve over 10,000 evaluations of the model, a task which in the past was only practical using super computers.

• The Monte Carlo method is analyze uncertainty propagation, where the goal is to determine how random variation, lack of knowledge, or error affects the sensitivity, performance, or reliability of the system that is being modelled.

Page 17: KT6274 Lecture 2

Monte Carlo Simulation

• Monte Carlo simulation is categorized as a sampling method because the inputs are randomly generated from probability distributions to simulate the process of sampling from an actual population.

• The data generated from the simulation can be represented as probability distributions (or histograms) or converted to error bars, reliability predictions, tolerance zones, and confidence intervals.

Page 18: KT6274 Lecture 2

Monte Carlo Simulation

• Monte Carlo follows the five simple steps listed below: – Step 1: Create a parametric model, y = f(x1, x2, .., xq). – Step 2: Generate a set of random inputs, xi1, xi2, .., xiq. – Step 3: Evaluate the model and store the results as yi. – Step 4: Repeat steps 2 and 3 for i = 1 to n. – Step 5: Analyze the results using histograms, summary

statistics, confidence intervals, etc.

Page 19: KT6274 Lecture 2

Monte Carlo techniques can be used in “Battleship”

Monte Carlo Simulation

Page 20: KT6274 Lecture 2

The first figure is simply a unit circle circumscribed by a square. We could examine this problem in terms of the full circle and square, but it's easier to examine just one

quadrant of the circle.

Calculation of π using Monte Carlo Techniques

Monte Carlo Simulation

Page 21: KT6274 Lecture 2

Poor dart players simulate Monte Carlo techniques

Monte Carlo Simulation

Page 22: KT6274 Lecture 2

MC makes it easy as

pi!

• # darts hitting shaded area / # darts hitting square = ¼ π r2 / r2 π = 4 [# darts hitting shaded area / # darts hitting

square]

Monte Carlo Simulation

Page 23: KT6274 Lecture 2

Time-Driven Simulation • In a time-driven simulation we have a variable

recording the current time, which is incremented in fixed steps.

• After each increment we check to see which events may happen at the current time point, and handle those that do.

• For example, suppose we want to simulate the trajectory of a projectile. – At time zero we assign it an initial position and

velocity. – At each time step we calculate a new position and

velocity using the forces acting on the projectile.

Page 24: KT6274 Lecture 2

Time-Driven Simulation

• Time-driven simulation is suitable here because there is an event (movement) that happens at each time step.

• How do know when to stop the simulation? – We can use either the criterion of time reaching a

certain point, or the model reaching a certain state, or some combination of the two.

Page 25: KT6274 Lecture 2

Time-Driven Simulation

• General algorithm for time-driven simulation: 1. Initialize the system state and simulation

time 2. while (simulation is not finished)

a) Collect statistics about the current state b) handle events that occurred between last

step and now c) Increment simulation time

Page 26: KT6274 Lecture 2

Event Driven Simulation

• Use when – events aren't guaranteed to occur at regular

intervals – don't have a good bound on the time step (it

shouldn't be so small as to make the simulation run too long, nor so large as to make the number of events unmanageable)

• Example – A line-up at a bank, where customers don't arrive

at regular time intervals, and may be deterred by a long line-up.

Page 27: KT6274 Lecture 2

Event Driven Simulation • Use when

– events aren't guaranteed to occur at regular intervals

– don't have a good bound on the time step (too small make simulation run too long; too large make the number of events unmanageable)

• Stop program? – when time reaches a certain point, or when the

system reaches a certain state. • Example

– A line-up at a bank, where customers don't arrive at regular time intervals, and may be deterred by a long line-up.

Page 28: KT6274 Lecture 2

Event Driven Simulation • A generic event-driven algorithm:

1. Initialize system state 2. Initialize event list 3. While (simulation not finished)

a) Collect statistics from current state b) Remove first event from list, handle it c) Set time to the time of this event.

• The list of events can be managed in ordered by increasing time (a priority heap might be efficient) and not to generate all the events in the list at the beginning.

Page 29: KT6274 Lecture 2

Event Driven Simulation • We initialize the simulation with certain

events, with their associated times. • Certain events may be handled by scheduling

later events, which are inserted at the appropriate place in the event list.

• Stop the event: – When time reaches or exceeds a certain point, or

once the system reaches a certain state – Can also be randomized:

• Schedule a random pseudo-event which doesn't change the state of the model, but simply stops the simulation.

Page 30: KT6274 Lecture 2

Discrete Event Model • An instant is a value of system time at which the value

of at least one attribute of an object can be assigned. • An interval is the duration between two successive

instants. • A time span is the contiguous succession of one or

more intervals. • The state of an object at a particular instant is the

enumeration of all attribute values of that object at that instant, The state consists of all the object states at a particular instant.

Page 31: KT6274 Lecture 2

Event Driven Simulation

Page 32: KT6274 Lecture 2

Event Driven Simulation • An instant is a value of system time at which the value

of at least one attribute of an object can be assigned. • An interval is the duration between two successive

instants. • A time span is the contiguous succession of one or

more intervals. • The state of an object at a particular instant is the

enumeration of all attribute values of that object at that instant, The state consists of all the object states at a particular instant.

Page 33: KT6274 Lecture 2

Event Driven Simulation

Page 34: KT6274 Lecture 2

References

• Dr. Anis Koubâa, CS433: Modeling and Simulation (http://coins.csrlab.org/imamu/akoubaa/cs433/)

• ref