Presentation is loading. Please wait.

Presentation is loading. Please wait.

McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.1 Table of Contents Chapter 15 (Computer Simulation: Basic Concepts) The Essence of Computer.

Similar presentations


Presentation on theme: "McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.1 Table of Contents Chapter 15 (Computer Simulation: Basic Concepts) The Essence of Computer."— Presentation transcript:

1 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.1 Table of Contents Chapter 15 (Computer Simulation: Basic Concepts) The Essence of Computer Simulation (Section 15.1)15.2 Example 1: A Coin-Flipping Game (Section 15.1)15.3–15.7 Example 2: Heavy Duty Company (Section 15.1)15.8–15.14 Generating Observations from a Probability Distribution (Section 15.1)15.15–15.22 A Case Study: Herr Cutter’s Barber Shop (Section 15.2)15.23–15.29 Analysis of the Case Study (Section 15.3)15.30–15.37 Some Common Types of Applications (Section 15.4)15.38–15.39 Outline of a Major Computer Simulation Study (Section 15.5)15.40–15.42 Introduction to Simulation (UW Lecture)15.43–15.58 These slides are based upon a lecture from the MBA core course in Management Science at the University of Washington (as taught by one of the authors).

2 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.2 The Essence of Computer Simulation A stochastic system is a system that evolves over time according to one or more probability distributions. Computer simulation imitates the operation of such a system by using the corresponding probability distributions to randomly generate the various events that occur in the system. Rather than literally operating a physical system, the computer just records the occurrences of the simulated events and the resulting performance of the system. Computer simulation is typically used when the stochastic system ivolved is too complex to be analyzed satisfactorily by analytical models.

3 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.3 Example 1: A Coin-Flipping Game Rules of the game: 1.Each play of the game involves repeatedly flipping an unbiased coin until the difference between the number of heads and tails tossed is three. 2.To play the game, you are required to pay $1 for each flip of the coin. You are not allowed to quit during the play of a game. 3.You receive $8 at the end of each play of the game. Examples: HHH3 flipsYou win $5 THTTT5 flipsYou win $3 THHTHTHTTTT11 flipsYou lose $3

4 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.4 Computer Simulation of Coin-Flipping Game A computer cannot flip coins. Instead it generates a sequence of random numbers. A number is a random number between 0 and 1 if it has been generated in such a way that every possible number within the interval has an equal chance of occurring. An easy way to generate random numbers is to use the RAND() function in Excel. To simulate the flip of a coin, let half the possible random numbers correspond to heads and the other half to tails. –0.0000 to 0.4999 correspond to heads. –0.5000 to 0.9999 correspond to tails.

5 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.5 Computer Simulation of Coin-Flipping Game

6 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.6 Data Table for 14 Replications of Coin-Flipping Game

7 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.7 Data Table for 1000 Replications of Coin-Flipping Game

8 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.8 Corrective Maintenance versus Preventive Maintenance The Heavy Duty Company has just purchased a large machine for a new production process. The machine is powered by a motor that occasionally breaks down and requires a major overhaul. Therefore, a second standby motor is kept, and the two motors are rotated in use. The breakdowns always occur on the fourth, fifth, or sixth day that the motor is in use. Fortunately, it takes fewer than three days to overhaul a motor, so a replacement is always ready. Cost of a Replacement Cycle that Begins with a Breakdown Replace a Motor$2,000 Lost production during replacement5,000 Overhaul a motor 4,000 Total$11,000

9 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.9 Probability Distribution of Breakdowns Day Probability of a Breakdown Corresponding Random Numbers 1, 2, 30 40.250.0000 to 0.2499 50.50.2500 to 0.7499 60.250.7500 to 0.9999 7 or more

10 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.10 Computer Simulation of Corrective Maintenance

11 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.11 Preventive Maintenance Options Preventive maintenance would involve scheduling the motor to be removed (and replaced) for an overhaul at a certain time, even if a breakdown has not occurred. The goal is to provide maintenance early enough to prevent a breakdown. Scheduling the overhaul enables removing and replacing the motor at a convenient time when the machine is not in use, so no production is lost. Cost of a Replacement Cycle that Begins without a Breakdown Replace a motor on overtime$3,000 Lost production during replacement0 Overhaul a motor before a breakdown 3,000 Total$6,000

12 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.12 Replace Motor After 3 Days Cost of a replacement cycle is $6,000. (Replacement always occurs without a breakdown). Replacement cycle occurs every three days. E(Cost per day) = ($6,000) / (3 days) = $2,000 per day.

13 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.13 Replace Motor After 4 Days

14 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.14 Replace Motor After 5 Days

15 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.15 Generating Random Observations from a Probability Distribution The method for generating random observations from a continuous distribution is called the inverse transformation method. Notation –r is the random number –F(x) is the cumulative distribution function (CDF) of the distribution from which we wish to generate a random observation. Thus, for each possible value of x, F(x) is the probability of being less than or equal to x. The Inverse Transformation Method 1.Generate a random number r. 2.Find the value of x such that F(x) = r. This value of x is the desired random observation from the probability distribution.

16 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.16 Illustration of Inverse Transformation Method

17 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.17 Inverse Transformation Method for a Discrete Distribution

18 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.18 Herr Cutter’s Barber Shop Herr Cutter is a German barber who runs a one-man barber shop. He opens his shop at 8:00 AM each weekday morning. His customers arrive randomly at an average rate of two customers per hour. He requires an average of 20 minutes for each haircut. As his business has increased, his customers now often wait awhile (sometimes over half-an-hour). His loyal customers are willing to wait, but new customers are much less likely to return if they have to wait. An article in The Barber’s Journal states –In a well-run barber shop, loyal customers will tolerate an average wait of 20 minutes, while new customers will tolerate only a 10 minute average wait. (With longer waits, they typically take their business elsewhere in the future.) Question: Should Herr Cutter hire a new associate to share the workload?

19 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.19 Probability Distributions The time required to give a haircut varies between 15 and 25 minutes. His best estimate is that the times between 15 and 25 minutes are equally likely. –Estimated distribution of service times: The Uniform distribution over the interval from 15 to 25 minutes. –The CDF for this distribution is P(service time ≤ x) = F(x) = 0for x ≤ 15 (x – 15)/10 for 15 ≤ x ≤ 25 1for x ≥ 25 The barber shop has random arrivals of customers, averaging two per hour. –Estimated distribution of interarrival times: An exponential distribution with a mean of 30 minutes. –The CDF for this distribution is P(interarrival time ≤ x) = F(x) = 1–e –x/30 for x ≥ 0.

20 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.20 CDF of Service-Time Distribution (Uniform)

21 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.21 CDF of Interarrival-Time Distribution (Exponential)

22 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.22 Applying the Inverse Transformation Method for the Service Time (Uniform Distribution) F(x) = (x–15)/10 = 0.7270 when x = 22.27

23 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.23 Applying the Inverse Transformation Method for the Interarrival Time (Exponential Distribution) F(x) = 1–e –x/30 = 0.8130 when e -x/30 = 0.187 or –x/30 = ln 0.187 = –1.6767 or x = 50.30

24 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.24 Building Blocks of a Simulation Model 1.A description of the components of the system, including how they are assumed to operate and interrelate. 2.A simulation clock. 3.A definition of the state of the system. 4.A method for randomly generating the (simulated) events that occur over time. 5.A method for changing the state of the system when an event occurs. 6.A procedure for advancing the time on the simulation clock.

25 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.25 Building Blocks for Herr Cutter’s Simulation Model 1.A description of the components of the system, including how they are assumed to operate and interrelate. The components are the customers, the queue, and Herr Cutter as the server. 2.A simulation clock. t = Amount of simulated time that has elapsed so far 3.A definition of the state of the system. N(t) = Number of customers in the barber shop at time t. 4.A method for randomly generating the (simulated) events that occur over time. The interarrival and service times are generated using the inverse transformation method.

26 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.26 Building Blocks for Herr Cutter’s Simulation Model 5.A method for changing the state of the system when an event occurs. Reset N(t) = N(t) + 1 if an arrival occurs at time t Reset N(t) = N(t) – 1 if a service completion occurs at time t 6.A procedure for advancing the time on the simulation clock. The Next-Event Time-Advance Procedure a)Observe the current time t and randomly generated times of the next occurrence of each event type that can occur (service or arrival in Herr Cutter’s problem). Determine which event will occur next. b)Advance the time on the simulation clock to the time of this next event. c)Updated the system by determining its new state as a result of this event and by randomly generating the time until the next occurrence of any event type that can occur from this new state (if not previously generated). Also record desired information about the performance of the system. Then return to the first step.

27 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.27 A Computer Simulation of Herr Cutter’s Barber Shop

28 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.28 Evolution of Number of Customers Over First 100 Minutes

29 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.29 Simulating the Barber Shop with an Associate The only difference occurs when the next-event time-advance procedure is determining which event occurs next. Instead of just two possibilities, there are now three: 1.A departure because Herr Cutter completes a haircut. 2.A departure because the associate completes a haircut. 3.An arrival.

30 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.30 Analysis of the Case Study: Financial Factors Revenue = $15 per haircut Average tip = $2 per haircut Cost of maintaining the shop = $50 per working day Salary of an associate = $120 per working day Commission for an associate = $5 per haircut given by the associate. In addition to his salary and commission, the associate would keep his own tips. Otherwise, the revenue would go to Herr Cutter. The shop is open from 8:00 AM to 5:00 PM, so it admits customers for nine hours.

31 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.31 Analysis of Continuing without an Associate The current distribution of interarrival times has a mean of 30 minutes. Therefore, he averages 18 customers per working day. After subtracting the cost of maintaining the shop, his average net income per working day is Net daily income= ($15 + $2) (18 customers) – $50 = $306 – $50 = $256

32 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.32 Features of the Queueing Simulator 1.Can run computer simulations of various kinds of basic queueing systems. 2.Can have any number of servers up to a maximum of 25. 3.Can use any of the following probability distributions for either interarrival times or service times: a)Constant time (also called the degenerate distribution). b)Exponential distribution. c)Translated exponential distribution (the sum of a constant time and a time from an exponential distribution). d)Uniform distribution. e)Erlang distribution. 4.Provides estimates of various key measures of performance: L= Expected number of customers in the system, including those being served. L q = Expected number of customers in the queue. W= Expected waiting time in the system (includes service time) for a customer. W q = Expected waiting time in the queue (excluding service time) for a customer. P n = Probability of exactly n customers in the system (for n = 1, 2, …, 10).

33 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.33 Queueing Simulator for Herr Cutter (Without Associate)

34 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.34 Testing the Validity of the Simulation Model

35 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.35 Analysis of the Option of Adding an Associate Adding an associate would –reduce the average waiting time before a haircut begins to less than 10 minutes. –gradually attract new business until this average waiting time reaches 10 minutes. Queueing Simulator Results: Mean of Interarrival Times Point Estimate of W q 95 Percent Confidence Interval for W q 20 minutes3.33 minutes3.05 to 3.61 minutes 15 minutes8.10 minutes6.98 to 9.22 minutes 14 minutes10.80 minutes9.51 to 12.08 minutes 14.2 minutes9.83 minutes8.83 to 10.84 minutes 14.3 minutes9.91 minutes8.76 to 11.05 minutes

36 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.36 Queueing Simulator for Herr Cutter (With an Associate)

37 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.37 Analysis of the Option of Adding an Associate Herr Cutter believes 14.3 minutes provides an adequate and conservative estimate of the mean interarrival rate with an associate. This corresponds to a mean arrival rate of 37.8 customers per day. Net daily income =37.8 ($15)(shop revenue) + 18.9 ($2)(his tips) – $50(shop maintenance) – $120(associate’s salary) – $18.9 ($5)(associate’s commission) Total$340.30 This compares to Herr Cutter’s current net daily income of $256.

38 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.38 Some Common Types of Applications Design and Operation of Queueing Systems –New York City’s arrest-to arraignment system (1993) –AT&T’s system to design call centers (1993) –Taco Bell (1998) Managing Inventory Systems –IBM simulating various redesigns of their supply chain (1996) Estimating the Probability of Completing a Project by the Deadline –PERT/CPM (Chapter 8) provides only a rough estimate. –Computer simulation is becoming an increasingly common approach to better estimate this probability. Design and Operation of Manufacturing Systems –How many machines of each type should be provided? –How many materials-handling units of each time should be provided? –Considering their due dates, what rule should be used to choose the order in which jobs are processed? –What are realistic due dates for jobs? –What will be the bottleneck operation in a new production process? –What will be the throughput of a new production process?

39 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.39 Some Common Types of Applications Design and Operation of Distribution Systems –Uncertainties: How long will shipments take? What will customers’ demands be? –Example: Reynolds Metals Company (1991) Financial Risk Analysis –Uncertain future cash flows of proposed capital investments are simulated to provide a probability distribution for the return on the investment. Health Care Applications –Use of hospital resources when treating patients with heart disease. –Health expenditures under alternative insurance plans. –Cost and effectiveness of screening for the early detection of disease. –Use of complex surgical services at a medical center. –Timing and location of calls for ambulance services. –Matching of donated kidneys with transplant recipients. –Operation of an emergency room. Applications to Other Service Industries –US Postal Service (1992) All references available for download at www.mhhe.com/hillier2e/articles

40 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.40 Outline of a Major Computer Simulation Study Step 1: Formulate the Problem and Plan the Study –What is the problem that management wants studied? –What are the overall objectives for the study? –What specific issues should be addressed? –What kinds of alternative system configurations should be considered? –What measures of performance of the system are of interest to management? –What are the time constraints for performing the study? Step 2: Collect the Data and Formulate the Simulation Model –The probability distributions of the relevant quantities are needed. –Generally it will only be possible to estimate these distributions. –A simulation model often is formulated in terms of a flow diagram. Step 3: Check the Accuracy of the Simulation Model –Walk through the conceptual model before an audience of all the key people.

41 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.41 Outline of a Major Computer Simulation Study Step 4: Select the Software and Construct a Computer Program –Classes of software Spreadsheet software (e.g., Excel, Crystal Ball) A general purpose programming language (e.g., C, FORTRAN, Pascal, etc.) A general purpose simulation language (e.g., GPSS, SIMSCRIPT, SLAM, SIMAN) Applications-oriented simulators Step 5: Test the Validity of the Simulation Model –If the real system is currently in operation, performance data should be compared with the corresponding output generated by the simulation model. –Conduct a field test to collect data to compare to the simulation model. –Have knowledgeable personnel check how the simulation results change as the configuration of the simulated system is changed. –Watch animations of simulation runs.

42 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.42 Outline of a Major Computer Simulation Study Step 6: Plan the Simulations to Be Performed –Determine length of simulation runs. –Keep in mind that the simulation runs do no produce exact values. Each simulation run can be viewed as a statistical experiment that is generating statistical observations of the performance of the system. Step 7: Conduct the Simulation Runs and Analyze the Results –Obtain point estimates and confidence intervals to indicate the range of likely values for the measures. Step 8: Present Recommendations to Management

43 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.43 Analytical Models Advantages: –Gives the “optimal” solution. Disadvantages: –Model must fit a solvable form. –Gives results for only one (LP) or a few (Decision Analysis) states of nature.

44 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.44 Simulation Models Advantages: –Can include factors that cause problems in analytical models. –Gives a distribution of results for many possible states of nature. Disadvantages: –Doesn’t give an “optimal solution”. –Good at evaluating, but not finding, solutions.

45 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.45 Two Types of Simulation System Simulation—Simulate a sequence of events over time, to determine how a system performs. –Examples: Queueing systems Manufacturing systems Inventory management Monte Carlo Simulation—Sampling experiment for estimating the distribution of an outcome that depends on several probabilistic inputs. –Examples: Profitability of a business venture Duration of a project Retirement planning

46 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.46 Generating Random Variables Methods –Mechanical device –Random number table –Random number generator (e.g., RAND() in Excel) Suppose u is a random number between 0 and 1 (e.g. = RAND() ). How do we generate the following random variables? –Continuous uniform on [0, 20] –Continuous uniform on [15, 25] –Roll of a die (i.e., integer uniform on [1, 6]) –Discrete: ValueProbability 30.2 40.3 50.4 60.1

47 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.47 The Cumulative Distribution Function Suppose W is a random variable. Then, its CDF is F(x) = Prob(W ≤ x)

48 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.48 To Generate Any Continuous Random Variable 1.Generate u ~ Uniform [ 0, 1 ] 2.Find x for which F(x) = u. 3.Then x is the generated random variable.

49 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.49 Generating Random Variables in Excel Uniform[a, b] = a + (b – a) * RAND() Discrete Uniform[a, b] = INT(a + (b - a + 1)*RAND() ) Normal( ,  ) = NORMINV(RAND(), ,  ) Exponential (with rate = ) =(–1/ ) * LN( RAND() )

50 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.50 Freddie the Newsboy Freddie runs a newsstand in a prominent downtown location of a major city. Freddie sells a variety of newspapers and magazines. The most expensive of the newspapers is the Financial Journal. Cost data for the Financial Journal: –Freddie pays $1.50 per copy delivered. –Freddie charges $2.50 per copy. –Freddie’s refund is $0.50 per unsold copy. Sales data for the Financial Journal: –Freddie sells anywhere between 40 and 70 copies a day. –The frequency of the numbers between 40 and 70 are roughly equal.

51 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.51 Spreadsheet Simulation Model

52 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.52 A Queueing Problem ABC Car Wash is an automated car wash. Each customer deposits four quarters in a coin slot, drives the car into the auto- washer, and waits while the car is automatically washed. Cars arrive randomly at an average rate of 20 cars per hour. The service time is exactly 2 minutes.

53 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.53 A Queueing Problem (The First Three Arrivals)

54 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.54 A Queueing Problem (The First Three Arrivals) Customer Arrival Time Until Next Arrival Time of Arrival Time Service Begins Service Time Time Service Ends Waiting Time #12222 2 + 2 = 4 2 – 2 = 0 #213 Max(3, 4) = 4 2 4 + 2 = 6 4 – 3 = 1 #347 Max(6, 7) = 7 2 7 + 2 = 9 7 – 7 = 0

55 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.55 Queueing Problem Simulation Model

56 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.56 A Game of Craps A popular game in gambling casinos is the game of craps. In its most basic form, the game is played as follows: –A player rolls two dice and calculates the sum. –If the sum is 7 or 11, the play wins right away. –If the sum is 2, 3, or 12, the player loses right away. –If the sum is any other number (4, 5, 6, 8, 9, or 10), the number becomes the player’s “point”. In this case, the dice are thrown repeatedly until the sum is either: –the “point” (in which case the player wins), or –7 (in which case the player loses).

57 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.57 Spreadsheet Simulation Model

58 McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.58 Using a Data Table to Perform Many Simulation Trials 1.In the first row of the table (row 12), put equations referring to the output cells of the simulation spreadsheet (=E4 in M12, =E5 in N12). 2.In the first column of the table, label each simulation trial (1 to 100). 3.Select the entire table (L12 through N112). 4.Choose Table from the Data menu. 5.For the Column input cell, select any empty cell (e.g., K7).


Download ppt "McGraw-Hill/Irwin © The McGraw-Hill Companies, Inc., 2003 15.1 Table of Contents Chapter 15 (Computer Simulation: Basic Concepts) The Essence of Computer."

Similar presentations


Ads by Google