24
Simulation Create the effect or appearance of something. OR Imitate (mimic) the operation of an entire process or system using a computer. Randomly generating and recording the outcomes which drive the system as if it were actual operating. Flight simulators used to train Pilots. Wind tunnel experiments to test new aircraft designs.

8_Simulation CHANGES

  • Upload
    nikhil

  • View
    1

  • Download
    0

Embed Size (px)

DESCRIPTION

Simulation operations research

Citation preview

Queuing Theory

SimulationCreate the effect or appearance of something.ORImitate (mimic) the operation of an entire process or system using a computer.Randomly generating and recording the outcomes which drive the system as if it were actual operating.

Flight simulators used to train Pilots.Wind tunnel experiments to test new aircraft designs.

1

Why Simulate?Is it practical to train a new pilot directly in a real aircraft?Take a new aircraft design directly for a test flight?Simulation of a newly designed system is necessary to avoid- Danger- Cost- TimeManagement Scientist is concerned with the design of Stochastic Systems, e.g.- Queuing Systems- Production/Inventory systems- Maintenance/ Replacement systems

2

Purpose of SimulationTo DetermineOptimum operating policiesOptimum parameter valuesPerformance characteristics

Analytical Methods are not always adequateM/G/s G/G/1 Queuing Systems Large Systems - Too Complex for analytical methodsNetworks of queues

3

Simulation of an M/M/1 queueWhat is the state of the system?No. of customersWhat are the possible events? customer arrival service completionHow to simulate? mimic customer arrivals. How?Generate random numbers that realistically represent inter-arrival times coming from a given distribution.How?

4

ExampleA coin tossing game- You pay Re.1 for each toss- Get back Rs. 8 when |H-T| = 3, and the game endsShould you play this game?What is the expected gain or loss if you play the game?What is the average number, N, of tosses before |H-T| = 3?If N >> 8, should you play the game?How can we simulate the game on a computer?

5

Example (contd.)Suppose the computer can generate uniform(0,1) random numbers. Can we simulate coin tosses using uniform(0,1) random numbers? 0.0 < RN < 0.5 : Head0.5 < RN < 1.0 : Tail

6

0.820.110.340.750.140.680.520.670.74T1H0H1T0H1T0T1T2T3

N = 9, Loss : Re. 10.930.040.15T1H0H1

N = 5, Gain : Rs. 30.440.39H2H3Conduct multiple runscompute average value of NSimilar to samplingLarger the sample size, better the estimate.

ExampleThe manager of a computer store is attempting to determine how many laptop PCs the store should order each week.

Values for a random variable are generated by sampling from a probability distribution.PCs demanded per weekFrequency of demandProbability of demand020.20140.40220.20310.10410.10100 (weeks)1

8

A roulette wheel for demand

20% x=020% x=210% x=310% x=440% x=1

9

Numbered roulette wheel

20% x=210% x=310% x=440% x=120% x=00 - 1920 - 5960 - 7980 - 8990 - 99

10

WeekrDemand, xRevenue1391$ 4300273286003722860047528600537143006020078731290089841720091000104714300119341720012211430013954172001497417200156928600Total31$133300

11

Estimated average demand = 31/15 = 2.07Estimated average revenue =133300/15=8886.67

Analytically, (as it is a simple case)E(x) = .200 + .401 +.202 +.103 +.104 = 1.50 PCs per week!

12

Discrete Event vs. Continuous SimulationEvent: Something of interest, that changes the state of the system.An arrival or a service completion in a queuing system.Discrete Event Simulation:Events take place at discrete points in time.State of the system changes abruptly at these points.State remains unchanged between events.Usually, state variables are discrete in nature.Continuous SimulationState of the system changes continuously in timee.g. chemical reaction, or stress on aircraft wing during takeoff.

13

Generating Random Numbers from Other DistributionsHow to generate random numbers from any given distribution?A random number with U(0,1) distribution can be transformed into any other distribution. How did we simulate the coin toss? Example: Discrete distribution.xf(x)00.1010.3020.4030.20 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0

14

Generating Random Number (Contd.)xf(x)00.1010.3020.4030.20F(x)0.10.40.81.0

0123

Step 1. Generate a U(0,1) random numberStep 2. Locate this number on the y axis.Step 3. Read off the corresponding number on x axis.

The same idea is applicable for continuous distribution also.Generating Random Number (Contd.)

Step 1: Generate U[0,1] random number r.xF(x)

rx = F-1(r)Step 2: Let F(x) = r, and solve for x, then x is the desired value.

16

Generating RN ~ Exp()For exponential distribution F(x) = 1-e-x Generate r~U(0,1) and let r = 1-e-x or e-x = 1-ror-x = ln(1-r)or x = ln(1-r)/(- )If r~U(0,1), what is the distribution of (1-r) ?So the formula can be further simplified to

x = ln( r )/(- )

17

Back to M/M/1 QueueMimic the arrival process by generating inter-arrival times.Generate the service time from appropriate distribution.Develop the logic of simulation program.Simulation clock moves from one event to next.One event of each kind should always in the pipeline.Should always know the time of next arrival.If a service is in progress, should know its completion time.When to generate the random numbers?When to advance the clock?What data to gather?

18Certain events trigger other events.Time of next event of a certain type can be determined only when the triggering event is known.An arrival triggers another arrival. Why?Start of a service triggers a service completion.Start of a service will coincide with eithera) arrival of a customer, when system is in state 0orb) completion of service already in progress.

Generate next arrivalAdvance clock to next event

Advance clock to next eventGenerate next arrivalGenerate service completion time

Generate next arrivalAdvance clock to next event

Generate service completion timeAdvance clock to next event

Advance clock to next event

Generate next arrivalAdvance clock to next eventGenerate service completion time

19

Clock N rA Arr. rs Serv. Next Arr Next Dep. Next E.

00.0980----80--80 A801.7310.25279010790 A902.3337----127107107 D1071----.765127112112 D1120--------127--127 A1271.5321.0192148219148 A1482.3535----183219183 A1833.865----188219188 A1884.3436----224219219 D2193----M/M/1 Queue, = 0.03, = 0.05

Nikhil Madan (NM) - IF DEPARTURE THE LAST EVENT AND 0 IN "N" THEN NO ENTRIES IN ARRIVAL OR DEPARTURENikhil Madan (NM) - IF DEPARTURE THE LAST EVENT THEN NO ARRIVALProblemWe wish to simulate a pair of queues operating in series. Customers arrive as a Poisson process of rate 0.1 per minute to queue A, which has only one server. The service times at queue A (in minutes) are uniformly distributed on [1, 8]. After leaving queue A, customers join queue B immediately, which also has one server. The service times at queue B are exponentially distributed with mean 2 minutes. Simulate this queuing system and compute 8 rows of the corresponding simulation table.

Queue 1Queue 2 ClockN1raArr.Serv1Next Arr.Next Dep. Q1N2rs2Serv2Next Dep. Q2NextEvent000.201616016 A1610.77361922019 A1920.5072622022 D12218263010.1342626 A D22620.4193530030 D13013353310.0193933 D13303523935 A3510.35105454023939 D2391454010.3724140 D1

Inventory System SimulationDaily demand ~ U(2,6)Reorder Point : 10Reorder Qty: 20 - current stockLead Time distribution1 day0.52 days0.33days0.2Inv. Carrying Cost : Rs. 5 per item per dayStock-out cost : Rs. 50 per itemWhat is the average long run cost of this policy?Given that, a new order can not be placed until the receipt of the previous order. All the deliveries are received at the end of the day and demands are fulfilled in the beginning of the day.

DayBeginInv.DemandFulfilledLostSupply Recd.End Inv.Qty. orderedrL(0,99)Lead Time

2644--2--

326241414--

41422--12--

51244--812913

6866--2--72422-0--803031212--912550-713171

11155--614752