1 / 49

Simulation II

Simulation II. IE 2030 Lecture 18. Outline: Simulation II. Advanced simulation demo Review of concepts from Simulation I How to perform a simulation concepts: state variables, events , etc. example Sampling Verification and Validation. Steady State Transient

javen
Download Presentation

Simulation II

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Simulation II IE 2030 Lecture 18

  2. Outline: Simulation II • Advanced simulation demo • Review of concepts from Simulation I • How to perform a simulation • concepts: state variables, events, etc. • example • Sampling • Verification and Validation

  3. Steady State Transient Sample size, run length Variability of runs State variables Event Clock Activity Simulation Table FEL (future event list) Core Concepts

  4. (Pseudo-) Random number generator Length of run startup or transient behavior steady state Stability Variability of runs There is no perfect random number generator Should be enough to get steady state behavior. Often initial behavior is atypical E.g. of queue length 2 runs of a simulation perform differently Concepts from Simulation I

  5. Using pseudo-random numbers • Most generators produce a (pseudo)random value x uniformly distributed on [0,1]. • Example: you want 1 w.p. 1/3, 2 w.p.1/3, • and 5 w.p. 1/3. • 0 <= x <= 1/3 gives value 1 • 1/3<= x <= 2/3 gives value 2 • 2/3<= x <= 1 gives value 5 • cumulative distribution function F : • F(.9)=0; F(1)=1/3 ; F(2)=2/3; F(5)=1

  6. Using pseudo-random #’s • What are you doing? Let F* be the inverse of the cumulative distribution function of your distribution. • F*(x)= 1 for 0 <= x <= 1/3 • F*(x) = 2 for 1/3 < x <= 2/3 • F* (x) = 5 for 2/3 < x <= 1 • You are computing F*(x) where x is U[0,1] ctovey: don’t worry about < vs. <=

  7. Another example: exponential • You want to generate a value for an exponentially distributed random variable. • You have x, a uniform [0,1] value • Compute F*(t) = - log(1-t) • Apply F* to x

  8. Using tables of random numbers • Use consecutive values in table to approximate a uniform distribution • then apply same method shown for U[0,1] • If you only need a Bernoulli p=1/2 valuecan use one value more directly e.g. even/odd or 0-4 and 5-9. • Same for some other simple discrete distributions, probabilities in tenths • thirds: skip 0, 1-3,4-6,7-9

  9. How to perform a simulation • State variables -- describe state of system, give a “system snapshot”. • Event: anything that can change the state of the system • FEL, Future Event List • Clock • Keep all these and any desired cumulative statistics in a simulation table

  10. Events and State Variables State variables x1 = 5.6 x2 = 4.8 x3 = 7.9 n =3 Future Event List 2:16 n decreases by 1 Clock 2:14

  11. Events and State Variables State variables x1 = 5.6 x2 = 4.8 x3 = 7.9 n =3 Future Event List 2:16 n decreases by 1 Clock 2:15 (we don’t need this)

  12. Events and State Variables State variables x1 = 5.6 x2 = 4.8 x3 = 7.9 n =3 Future Event List 2:16 n decreases by 1 Clock 2:16

  13. Events and State Variables State variables x1 = 5.6 x2 = 4.8 x3 = 7.9 n =2 Future Event List 2:21 x1 = x3 - x2 Clock 2:16

  14. Events and State Variables State variables x1 = 5.6 x2 = 4.8 x3 = 7.9 n =2 Future Event List 2:21 x1 = x3 - x2 Clock 2:21

  15. Events and State Variables State variables x1 = 3.1 x2 = 4.8 x3 = 7.9 n =2 Future Event List 2:25 n increases by 2 Clock 2:21

  16. Example: Clocks and Socks(Foley & Tovey) • I have n pairs of socks in my dryer. I remove socks 1 at a time and place them on top of the dryer. When I get a matching pair, I fold them and place them in my laundry basket. • How much room do I need on top of my dryer?

  17. Clocks and Socks • n couples plan to meet under the clock at 6:00 pm. People arrive 1 at a time. When a couple meets, they leave to go eat dinner. • How big does the crowd under the clock get?

  18. clocks and socks • Orders for parts arrive at a warehouse. Each order is for Kmin to Kmax different parts. • The ASRS system retrieves one type of part for one order at at time. • Partially completed orders are stored on pallets in a WIP storage area. • How big should the WIP storage area be?

  19. Simulating Clocks and Socks • Assume n pairs distinct socks • notation: Li, Ri, i=1,...,n: the two socks • Assume I remove a sock from dryer in 1 sec. I check for match and fold, all in 2 sec • Could have assumed I check for a match in 5 sec; fold and toss into basket in 3 sec. • This is like implementing an algorithm. You usually have to make additional decisions or assumptions.

  20. clocks and socks: state variables • For each i=1,...n, Li and Ri can equal • D if in dryer • T if on top of dryer • DT if being moved to dryer top • B if in basket • The values of the variables Li and Ri (together with the clock time t) provide a complete system snapshot

  21. initial snapshot • Li = Ri = D for all i=1,...,n • t=0 • useful extra state variable (not logically necessary): • nD = # of socks in dryer • nD = 2n initially • nT = # socks on dryer top • nT = 0 initially

  22. Future event list • Event: anything that can change the state of a system • FEL: a list of events that you know about, but that have not yet occurred, i.e. with times > =t (usually >t) • First event on FEL: time 0. Grab a sock from dryer. (t=0) • Second event will be: put sock on dryer top (t=1).

  23. Event types • 1st type (grab) : a sock leaves the dryer. Its state changes from D to DT. nD decreases. • 2nd type (arrive top): a sock arrives at the dryer top. Its state changes from DT to T. • 3rd type (fold): a pair of socks is matched, folded, and put in basket. Both socks have a change in state from T to B

  24. Clock and Sock Activities • Activity: a time interval. Triggers an event. • Activity: moving sock from dryer to top • event triggered: sock arrives on top of dryer • Activity: checking for a match (2sec) • event triggered: possibly, fold (placing sock pair in basket); certainly, grab sock from dryer, unless nD=0

  25. L1=D R1=D L2=D R2=D nD=4 nT=0 t=0 Grab a sock from dryer Simulation: n=2t=0- (startup)

  26. L1=D R1=D L2=DT R2=D nD=3 nT=0 t=0 Grab a sock from dryer to process this event we need a random integer in [1,...,nD]. In this case, say it is 3. So grab L2. Simulation: n=2t=0

  27. L1=D R1=D L2=DT R2=D nD=3 nT=0 t=1 arrive top sock L2 placed on top of dryer Simulation: n=2t=0+

  28. L1=D R1=D L2=T R2=D nD=3 nT=1 t=1 arrive top sock L2 t=3 grab a sock from dryer Simulation: n=2t=1

  29. L1=D R1=D L2=T R2=D nD=3 nT=1 t=3 grab a sock from dryer Simulation: n=2t=1+

  30. L1=DT R1=D L2=T R2=D nD= 2 nT=1 t=3 grab a sock from dryer. Needs random integer from 1 to 3=nD. In this case, say it was 1. Simulation: n=2t=3

  31. L1=T R1=D L2=T R2=D nD= 2 nT=2 event t=4 arrive top L1 Simulation: n=2t=4

  32. L1=T R1=D L2=T R2=D nD= 2 nT=1 t=6 grab a sock Simulation: n=2t=4+

  33. L1=T R1=DT L2=T R2=D nD= 1 nT=2 t=6 grab a sock, say it is R1 Simulation: n=2t=6

  34. L1=T R1=DT L2=T R2=D nD= 1 nT=2 t=7 arrive top R1 Simulation: n=2t=6+

  35. Processing Events • (grabz) : Sock z state changes from D to DT. nD--. Sock move activity (1 sec) triggers arrive top z. • (arrive top z): Sock z state changes from DT to T. nT++. Checking for match, 2 secs: If z’s match is on T, triggers fold z’s pair. Triggers grab unless nD=0. • (fold): both socks change state from T to B.nT decreases by 2.

  36. L1=T R1=T L2=T R2=D nD= 1 nT= 3 t=7 arrive top R1 Simulation: n=2t=7

  37. L1=T R1=T L2=T R2=D nD= 1 nT= 3 t= 9 fold pair 1 t=9 grab (R2) we process the fold before the grab Simulation: n=2t=7+

  38. L1=B R1=B L2=T R2=D nD= 1 nT= 1 t= 9 fold pair 1 t=9 grab (R2) we process the fold before the grab Simulation: n=2t=9

  39. L1=B R1=B L2=T R2=DT nD= 0 nT= 1 t=9 grab (R2) Simulation: n=2t=9

  40. L1=B R1=B L2=T R2=DT nD= 0 nT= 1 t=10 arrive top R2 Simulation: n=2t=9+

  41. L1=B R1=B L2=T R2=T nD=0 nT= 2 t=10 arrive top R2 add the event: t=12 fold pair 2 don’t add grab event since nD=0 Simulation: n=2t=10

  42. L1=B R1=B L2=B R2=B nD=0 nT= 0 t=12 fold pair 2 no events are placed on FEL -- simulation terminates Simulation: n=2t=12

  43. other variables • Summary stats you might keep track of: • number of socks on top of dryer • maximum number of socks on top of dryer • average (by time? by sock pick?) number of socks on dryer top • for each i, length of time 2,1, and 0 socks in pair i are in dryer • You can walk through your simulation a second time to collect these statistics. • Almost always easier to collect them as the simulation progresses

  44. Clocks and Socks • If we were only interested in nT, number on dryer top, we could eliminate the activity of checking for a match. • If checking for a match took longer when nT was big, we might let the activity time in the simulation vary with nT, and collect more information about time spent checking.

  45. Sampling • How to deal with transient behavior: • discard it • use long enough runs that its effect is negligible • “hot-start” the simulation (can be risky) • run length: how do you know in “steady state”? • Not defined for one sample path • the more variability, the longer run length is needed • Variability from one run to another • sample size: number of runs

  46. Building the model right like debugging a computer program use a pseudo-random number generator that is deterministic given the seed Building the right model does the model accurately predict what happens in the real system? Several levels of validation use many seeds Verification & Validation

  47. Building the model right Examples of bugs: triggering a grab when nD=0 not decreasing nT Building the right model Do we really remove socks from the dryer in random order? Are our activity times accurate (if we care)? Does it accurately predict dryer top usage? Verification & Validation

  48. Types of Validation • Face Validity: Does an expert think that the simulation model behaves realistically? • domain expert, not simulation expert • Weak External Validity: Does the output of the simulation match the behavior of the system that is being simulated?

  49. More Kinds of Validation • Strong External Validity: Make a change to the simulation model and make the corresponding change to the actual system. Compare the simulation output to the actual system behavior. • Does the model correctly predict the effects of changes to the system? • Validation of Assumptions: Test the assumptions made by the model. • E.g., independence or distribution of arrivals

More Related