Discrete Event Simulation - PowerPoint PPT Presentation

1 / 42
About This Presentation
Title:

Discrete Event Simulation

Description:

... of what may be unique system, cheap compared to physical experiment, etc. ... Other estimates from hub-bound travel statistics. ... – PowerPoint PPT presentation

Number of Views:269
Avg rating:3.0/5.0
Slides: 43
Provided by: gorden5
Category:

less

Transcript and Presenter's Notes

Title: Discrete Event Simulation


1
Discrete Event Simulation
  • Overview 4/5/09

2
Outline
  • What is discrete event simulation?
  • Events
  • Probability
  • Probability distributions
  • Sample application

3
What is discrete event simulation?
Simulation is the process of designing a model
of a real system and conducting experiments with
this model for the purpose either of
understanding the behavior of the system or of
evaluating various strategies (within the limits
imposed by a criterion or set of criteria) for
the operation of a system. -Robert E Shannon
1975 Simulation is the process of designing a
dynamic model of an actual dynamic system for the
purpose either of understanding the behavior of
the system or of evaluating various strategies
(within the limits imposed by a criterion or set
of criteria) for the operation of a system.
-Ricki G Ingalls 2002 Definitions from
http//staff.unak.is/not/andy/Year20320 Simulati
on/Lectures/SIMLec2.pdf
4
What is discrete event simulation?
  • A simulation is a dynamic model that replicates
    the behavior a real system.
  • Simulations may be deterministic or stochastic,
    static or dynamic, continuous or discrete.
  • Discrete event simulation (DEVS) is stochastic,
    dynamic, and discrete.
  • DEVS is not necessarily spatial it usually
    isnt, but the ideas are applicable to many
    spatial simulations

See many introductions online, such as
http//www.facsim.org/ Documentation/FAQ/Simulatio
nFAQ/S1.html
5
What is discrete event simulation?
  • DEVS has been around for decades, and is
    supported by a large set of supporting tools,
    programming languages, conventional practices,
    etc.
  • Like other kinds of simulation, offers an
    alternative, often simple way of solving a
    problem simulate system and observe results,
    instead of coming up with analytical model.
  • Many other benefits like repeatability, ability
    to use multiple parameter sets, experimental
    treatment of what may be unique system, cheap
    compared to physical experiment, etc.
  • Usually involves posing a question. The
    simulation estimates an answer.

6
What is discrete event simulation?
  • Relationship between models and real system
  • (Base model complete but partially known
    conceptual model lumped model modelers
    understanding of the system with assumptions and
    simplifications morphism structure-preserving
    transformation)

Diagram from Couclelis, H. A Theoretical
Framework for Alternative Models of Spatial
Decision and Behavior. Annals of the Association
of American Geographers, Vol. 76, No. 1, 1986.
7
What is discrete event simulation?
  • Stochastic probablistic
  • Dynamic changes over time
  • Discrete instantaneous events are separated by
    intervals of time
  • Time may be modeled in a variety of ways within
    the simulation.

8
Alternate treatments of time
  • Time divided into equal increments
  • Unequal increments
  • Time as linked events, independent of intervals
    (most common in DEVS)
  • Cyclical

(st moment in spacetime)
9
Termination
  • Simulation may terminate when a terminating
    condition is met.
  • May also be periodic.
  • Can also be conceptually endless, like weather,
    terminated at some arbitrary time.
  • Requires spin-up time to remove initial
    variability due to small number of cases
  • Usually converges or stabilizes on particular
    result.

10
Events
  • May change the state of the system.
  • Have no duration.
  • If time is event-based, events happen when time
    advances.
  • Canonical example flipping a coin.
  • Events usually have a value associated with them
    (e.g. coin true/false).
  • The definition of an event depends on the subject
    of the model.

11
Random Variables
  • A random variable (X) is numerical value
    associated with a random event.
  • X can have different values
  • X1, X2, X3Xn
  • In a stochastic DEVS, the value associated with
    event is probablistic, that is it occurs with a
    given probability.
  • That probability is what allows us to use DEVS to
    estimate results when we dont know the precise
    value of input parameters to our model.

12
Pseudorandom Number Generators
  • A stochastic simulation depends on a pseudorandom
    number generator to generate usable random
    numbers.
  • These generators can vary significantly in
    quality.
  • This is a subject of a large body of research.
  • For practical purposes, it may be important to
    check the random number generator you are using
    to make sure it behaves as expected.
  • For example, if you are generating millions of
    numbers and expect them to be close to random, a
    generator that only can generate 32768 random
    numbers (as was the case with the old C rand()
    function) will be very un-random and could
    corrupt your results.

13
(Very) Basic Probability
  • The probability of X equaling some value is
    central to describing its behavior in a DEVS.
  • All possible values for X is the sample space,
    e.g., heads/tails for coin flips 1,2,3,4,5,6 for
    dice.
  • An event in that space could be a coin flip
    equaling true for example.
  • S is the sample space of X. Probability is
    between zero and 1 the probability of X being in
    S is 1 the sum of the probabilities of all
    values of X is 1 if they are mutually exclusive
    the probability that an event does not occur is
    equal to 1 minus the probability that it does.

14
(Very) Basic Probability
15
(Very) Basic Probability
  • The expected value (mean) will converge after a
    number of repetitions.
  • We can demonstrate the process of flipping
    coinswith a simulation. Here are 4 runs of a
    simulated sequences of 1000 coin flips (see
    code), displaying the average result (sum of Xi /
    n)

Note that the variance is high initially and
diminishes with time.
16
(Very) Basic Probability
  • Joint probability is the probability of two
    events happening together, if they are
    independent
  • Here for example is a display of a simulation
    where the event is two independent coin flips
    both being true in sequence (converges on .25
    see code)

17
(Very) Basic Probability
  • Conditional probability is the probability of two
    events happening in sequence. If they are
    independent, this is the same as the joint
    probability. If not, it is the probability of
    both happening divided by the probability of the
    second
  • For example, if we our event is two consecutive
    tails, and the first flip is tails, the
    probability of the next one being tails is .25,
    so the result is .25 / .5, or .5.

18
(Very) Basic Probability
  • For mutually exclusive events
  • P(B) P(BA1)P(A1) P(BAn)P(An).
  • Suppose the chance of a fire per square km in a
    pine forest is .01, in a deciduous forest is
    .005, and in mixed forest is .0085 (these numbers
    are fictitious). 5 of all forest first reach
    the tree canopy. What is the probability that a
    sq. km of forest will have a canopy fire?
  • P(A1) .01
  • P(A2) .005
  • P(A3) .0085
  • P(BA1) .05
  • P(BA2) .05
  • P(BA3) .05
  • P(B) P(BA)(PA1) P(BA3)(PA3) P(BA3)(PA3)
  • .05 .01 .05 .005 .05 .0085
  • .0005 .00025 .000425
  • .001175

19
(Very) Basic Probability
  • Expected value average mean sum of X / n.
  • Variance expected value of the squared
    difference between X and mean always positive
    and unit-less
  • Covariance expected value of the difference
    between X and mean of X times the difference
    between Y and the mean of Y
  • Graph summarizes change in variance over the
    course of a simulation

20
Probability distributions
  • In a DEVS, you need to decide what probability
    distribution functions best model the events.
  • Pseudorandom number generators generate numbers
    in a uniform distribution
  • One basic trick is to transform that uniform
    distribution into other distributions.
  • There are many basic probability distributions
    are convenient to represent mathematically.
  • They may or may not represent reality, but can be
    useful simplifications.

21
Exponential distribution
  • Many phenomena behave like an exponential
    distribution such as radioactive decay.
  • Other examples?

Graphs from http//zoonek2.free.fr/UNIX/48_R/07.ht
ml
22
Normal or gaussian distribution
  • Ubiquitous in statistics
  • Many phenomena follow this distribution
  • When an experiment is repeated, the results tend
    to be normally distributed.

23
Gamma distribution
  • Phenomena with a sharp initial increase then long
    tail can be modeled with a gamma distribution.
  • Useful for things like service times
  • When an experiment is repeated, the results tend
    to be normally distributed.

24
Poisson distribution
  • Example of algorithm to sample from a
    distribution.
  • X follows a Poisson distribution if
  • An algorithm for sampling from a Poisson
    distribution
  • 1. Generate a random number U
  • 2. If i0, pe-lambda, Fp
  • 3. If U lt F, return I
  • 4. P lambda p / (i 1), F F p, i i 1
  • 5. Go to 3
  • There are similar tricks to sampling from other
  • probability distributions. Some tools like
    Matlab
  • have these built in.
  • Algorithm from Ross, Sheldon M., Simulation,
    Fourth Edition, Elsevier 2006.

25
Probability distributions
  • Sampling values from an observational
    distribution with a given set of probabilities
    (discrete inverse transform method).
  • Generate a random number U
  • If U lt p0 return X1
  • If U lt p0 p1 return X2
  • If U lt p0 p1 p2 return X3
  • Etc.
  • This can be speeded up by sorting p so that the
    larger intervals are processed first, reducing
    the number of steps.

26
Sample DEVS Application
27
Congestion Pricing Plan
  • Plan NYC modeling study claimed that only between
    .2 and 1.3 percent of commuting trips to NYC
    could be avoided by telecommuting incentives.
  • Other sources claim 30-40
  • Whats the maximum possible amount, without
    considering incentives?
  • Many uncertainties, but amenable to estimation by
    simulation.

28
Source Data
  • Event is a commute
  • Census residence-county to work-county data.
  • Census work-industry data.
  • Other estimates from hub-bound travel statistics.
  • Assertionsespecially, estimates of per-industry
    telecommuting rates.

29
Simplifying Assumptions
  • County distances were used instead of actual or
    census tract distances.
  • The maximum commutable distance was asserted to
    be 175 miles.
  • Miles-to-CO2 conversion factors were applied
    uniformly without regard to specific efficiencies
    of different vehicles or of different routes.
  • All forms of non-car transit were assigned a
    single CO2 conversion factor.
  • Emissions were calculated per-passenger, not
    per-vehicle.
  • Days-per-week telecommuting was folded into
    overall percentage.

30
Data

Conversion factors 0.4 pounds of CO2 per person
mile for transit 1.2 pounds of CO2 per person
mile for car 1 passenger per car
31
Commutes by County

32
Commute by Distance from Sampled Distribution

33
Sampled Counties Versus Data
34
Sampled Industries Versus Data
35
Sampled Versus Observed CDF
36
95 Confidence Interval
37
Mathematical Distribution
  • Exponential, lambda 34.0418
  • Formula arrived at by minimizing sum of
  • absolute values of differences between
  • exponential distribution and observed.

38
Distance by County
39
Distance From Exponential Distribution
40
KS Comparison of Observed Versus Mathematical
Distributions
D 0.5501 P 0
Plot from www.physics.csbsju.edu/stats/KS-test.n.p
lot_form.html
41
Results
42
Results
  • The mean emissions per trip were around 20
    pounds, plus or minus about .5 pounds at a 95
    confidence interval, as given in run A.
  • The percentage eligible for telecommuting was
    approximately 20 percent, higher than PlanNYC but
    less than federal government high of 70.
  • The mathematical distribution gave a slightly
    higher estimate, in run B.
  • Increasing N to 1,000,000 narrowed the 95
    confidence interval to 0.06, with a result closer
    to that of the mathematical distribution, as
    given in run C.
  • Doubling the number of riders per car in run D
    had a small effect.
  • The original model assumed that only 10 of
    service jobs were telecommutable. Boosting that
    number to 50 in run E boosted the total
    estimated percent reduction up to 33.
  • This suggests that researching the percentage of
    telecommutable jobs in the services sector would
    be especially useful in refining the estimate.
  • Simplifying assumptions need to be tested.
Write a Comment
User Comments (0)
About PowerShow.com