



















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
An overview of simulations, their advantages and disadvantages, common mistakes, and the importance of generating good random numbers. It covers various simulation techniques, including time-driven, event-driven, and trace-driven simulations, and discusses the role of simulation languages and event schedulers.
Typology: Slides
1 / 27
This page cannot be seen from the preview
Don't miss anything!
OVERVIEW:
Example:
Since modeling is not something to dive into lightly, what warnings are needed up- front?
Engineers inherently don’t trust models. We tend to believe only things we can see. So you need to generate belief in your model among your “customers”. Be very careful giving out answers to your model – don’t do so before you believe the results yourself. Here are a number of issues you need to take into account:
Pitfalls
of code (random number generators, event handlers, etc.) you can waste a great deal of time writing your own. Conversely, simple models don’t need fancy simulation packages. More on this later.
get the number of samples you need or to avoid end conditions. Your random number generator wasn’t really random.
Pitfalls
This section describes briefly some of the terms used in Simulation.
State Variables: All the program variables needed to define where the simulation is at time T.
Event: A change in the system state. Arrivals and departures from any center is an event.
Time Driven Simulations: Where time is what matters. The state variables are defined in terms of time. They can be either continuous or discrete.
Event Driven Simulations: Where changes of state (events) are what matters. State variables are defined in terms of these events.
Simulation Lingo
This section describes briefly some of the terms used in Simulation.
Deterministic or Probabilistic: Every time you run the model, do you get the same answer or a different answer. Either can be correct, but you should know beforehand what to expect. With a probabilistic model, running it longer doesn’t give it a better result.
Open and Closed: Open means jobs/inputs are coming in external to the model. Closed means all jobs recycle through the model.
Stable and Unstable: Does the model converge to some answer or not.
Simulation Lingo
TRACE-DRIVEN SIMULATIONS:
Example:
Collecting the disk activity at a Brokerage Firm at market open. Then running that data back through a real operating system.
Example:
Collecting user keystrokes used to make queries of a database. Then playing back those keystrokes.
Types of Simulations
Example: The instruction fetch cycle - on each clock tick the CPU tries to obtain an instruction ( or part of an instruction from memory.)
Example: Rainfall, water usage, and the resultant height of a reservoir.
Types of Simulations
Example: A CPU - disk system, where processes use variable amounts of time at each resource.
See the schematic of an event driven simulation below.
Example: Cars being serviced at a tool booth. Look at the picture on a later page.
Question: How long would it take to write this simulation?
Types of Simulations
Types of Simulations
Initialize
Determine Next Event
T = T( next_event )
Event 1
Event Queue
case = next_event
Generate New Event
Event 4
Generate New Event
Event 3
Generate New Event
Event 2
Generate New Event
Update Statistics
One of the key pieces that is provided by a simulation package is an event scheduler.
It works exactly like the scheduler in a operating system;
You want this scheduler to be efficient.
It may be called on to maintain hundreds of upcoming events.
To do this requires a low-cost way to insert a future event in a time-ordered queue.
Event Scheduler
Generating good random numbers is an art form. There are well known techniques for doing this and you are best off using the work of those who have gone before you.
All numbers are in fact “pseudo-random”. Think of a 16 bit random number containing a sequence of 65,536 numbers. Each of those numbers, when used as the seed of a generator produces another of the 65,536 numbers, and so on. They actually form a sequence. A good generator will produce all the 65,536 numbers before it repeats.
Linear Congruential Generators (LCGs) have good generation properties. These are of the general form
X (^) n = ( a Xn-1 + b ) mod m
The correct choice of a, b, and m matter a great deal.
Random Number Generators
if (first_time) { while( random_seed.high > 1000000 ) random_seed.high -= 1000000; X = (long)random_seed.high + (long)random_seed.low; first_time = FALSE; } if ( X == 0 ) X = 1; X_div_q = X / q; X_mod_q = X % q; X = a * X_mod_q - r * X_div_q; if ( X < 0 ) X = X + m; return( ((double)X)/(double)m );
} / End of get_random_number /
Random Number Generators
Do random numbers produced by Excel, meet the properties of randomness? Let ’ s find out!
Here are the steps:
Random Number Generators