+ All Categories

chap15

Date post: 20-Nov-2015
Category:
Upload: sankalpakash
View: 9 times
Download: 6 times
Share this document with a friend
Description:
optional reading
Popular Tags:
35
Chapter 15 COMPUTER SIMULATION: THE GENERAL METHODOLOGY In all the examples throughout this book, it has been possible to obtain solutions through mathe- matical techniques. When dealing with some real-world problems, however, the resulting model may be so complex or large that it is not possible or practical to develop a solution methodology based on mathematical analysis. Alternatively, to apply an existing mathematical technique may require additional assumptions that are not applicable or realistic. In such cases, an alternative approach is to use the management science technique of computer simulation. As the term indicates, with this technique you design and build a computer model that mimics the actual problem scenario. You then use the model to learn how the system behaves — asking managerial “What happens if ...?” questions. For example, you might build a computer model to simulate: 1. The daily operation of a bank or hospital, to understand the impact of adding more tellers or nurses. 2. The operation of a harbor or airport, to understand the ow of trac and its associated congestion. 3. The production process in a manufacturing plant, to identify bottlenecks in the production line. 4. The trac ow on a freeway or in a complicated communication system, to determine whether expansion is necessary. To illustrate the basic concepts used in designing a computer simulation model, two elementary examples are presented in Section 15.1. Then, the advantages and disadvantages of this technique are discussed. 15.1 THE BASIC CONCEPT OF COMPUTER SIMULATION In this section two examples illustrate the basic steps involved in building a simulation model. 1
Transcript
  • Chapter 15

    COMPUTER SIMULATION:THE GENERALMETHODOLOGY

    In all the examples throughout this book, it has been possible to obtain solutions through mathe-matical techniques. When dealing with some real-world problems, however, the resulting model maybe so complex or large that it is not possible or practical to develop a solution methodology basedon mathematical analysis. Alternatively, to apply an existing mathematical technique may requireadditional assumptions that are not applicable or realistic.In such cases, an alternative approach is to use the management science technique of computer

    simulation. As the term indicates, with this technique you design and build a computer modelthat mimics the actual problem scenario. You then use the model to learn how the system behaves asking managerial What happens if ...? questions. For example, you might build a computermodel to simulate:

    1. The daily operation of a bank or hospital, to understand the impact of adding more tellersor nurses.

    2. The operation of a harbor or airport, to understand the flow of traffic and its associatedcongestion.

    3. The production process in a manufacturing plant, to identify bottlenecks in the productionline.

    4. The traffic flow on a freeway or in a complicated communication system, to determinewhether expansion is necessary.

    To illustrate the basic concepts used in designing a computer simulation model, two elementaryexamples are presented in Section 15.1. Then, the advantages and disadvantages of this techniqueare discussed.

    15.1 THE BASIC CONCEPT OF COMPUTERSIMULATION

    In this section two examples illustrate the basic steps involved in building a simulation model.

    1

  • 2 Chapter 15

    ppppppppppppppppppppppppppppppppppppppppppppppppppppppp pppppppppppppppppppppppppppppppppppppppppppppppppppppppRow 3ppppppppppppppppppppppppppppppppppppppppppppppppppppppp pppppppppppppppppppppppppppppppppppppppppppppppppppppppRow 2ppppppppppppppppppppppppppppppppppppppppppppppppppppppp pppppppppppppppppppppppppppppppppppppppppppppppppppppppRow 1Lottery

    Card

    Scratch one box in each row.

    Figure 15.1: Instant Lottery Card for the New York Lottery Commission

    15.1.1 A FIRST EXAMPLE OF COMPUTER SIMULATION

    Consider the problem faced by the New York Lottery Commission

    Example 15.1 The Computer Simulation Problem of the New York Lottery Commission

    The staff of the New York Lottery Commission has just designed a new instant lottery. Asshown in Figure 15.1, each lottery card contains three rows. In each row there are two boxes, oneof which has a hidden value of $1 and the other $5. The player scratches any one box from eachrow to discover the associated dollar value. If all three uncovered numbers are the same, the playerwins that amount. Before committing the state to this game and printing a large number of cards,you, as director of the Lottery Commission, want to evaluate the economic feasibility of the game.Among the questions you must answer is, What is the lowest amount that the state can charge foreach card?Due to the simple nature of this problem, it is possible to apply probability theory to obtain the

    desired answer: the amount to charge should be at least equal to the expected payoff for the card.The expected payoff, based on the two possible winnings of $1 and $5, is computed as follows:

    Expected payoff = $1 Probability ofwinning $1

    + $5 Probability ofwinning $5

    .

    It is now necessary to determine the probability of winning each of $1 and $5. Observe that thereis an even chance of scratching either value in each row, and recall the rules of the game, so

    Probability of winning $1 = Probability that the scratched boxin all three rows have $1

    = Probability that the scratched box in row 1 has $1 Probability that the scratched box in row 2 has $1 Probability that the scratched box in row 3 has $1

    = (1/2) (1/2) (1/2)

    = 1/8.

  • Chapter 15 3

    Similarly,

    Probability of winning $5 = Probability that the scratched boxin all three rows have $5

    = Probability that the scratched box in row 1 has $5 Probability that the scratched box in row 2 has $5 Probability that the scratched box in row 3 has $5

    = (1/2) (1/2) (1/2)

    = 1/8.

    Using these two probabilities:

    Expected payoff = $1 Probability ofwinning $1

    + $5 Probability ofwinning $5

    = $1 (1/8) + $5 (1/8)

    = $0.75.

    In other words, by charging $0.75 the Commission can expect to break even in the long run.In this problem it is possible to obtain the desired result directly by mathematical analysis.

    However, this example is also used to illustrate how the methodology of computer simulation isapplied to obtain a similar result.The idea of simulation is to mimic the actual situation in which a large number of people are

    expected to play the new lottery game. Three different ways to do so are now described.

    Physical Simulation

    You might simulate the game physically as follows. Print a large number of cards (say, 100), havesomeone scratch the boxes on each card, tabulate the payoff for each card ($0, $1, or $5), and usethe payoffs from all the cards to compute the average payoff. This process provides an estimate ofthe expected payoff and that can be used as the basis for making decision. To obtain an accurateestimate would require printing a large number of cards just for this experiment, but this is bothcostly and time consuming. The next alternative avoids some of these problems.

    Simulation by Analogy

    Rather than simulate this game physically, you might simulate the game by analogy. For example,consider the analogy between scratching a box in one row of the card and flipping a coin. The valueof the box scratched in each row is either $1 or $5, with equal probability. Similarly, the value ofa coin flip is either heads or tails, with equal probability. Here, heads by analogy is $1 andtails by analogy is $5. You can simulate the lottery results by following these steps a large numberof times (say, 100):

    1. Flip a coin three times, once to determine the outcome for each row.

    2. Record the associated payoff for the outcome in (1): $1 if all three flips are heads, $5 ifall three flips are tails, and $0 otherwise.

  • 4 Chapter 15

    - Uniform Random Number0.0 0.5 1.0

    Head Tail

    Figure 15.2: Simulating the Flip of a Coin Using a Uniform 0 1 Random Number

    Adding up the payoffs of these 100 trials and dividing by 100 provides an estimate of the expectedpayoff for the game.

    This approach has eliminated the need to print the 100 cards, but it requires significant manualeffort to flip the coins, tabulate the results, and perform the final computations. The repetitivenature of these tasks makes them ideally suited for the computer.

    Simulation by Computer

    How can you use a computer to flip the coin, tabulate the results, and perform the neededcomputations? The answer is to write a computer program in which the flipping of the coin isaccomplished using random numbers to represent the result of the flip. For instance, all computerlanguages include the capability of generating a random number uniformly distributed between 0and 1 (see Appendix B). You can then associate a value between 0.0 and 0.5 as corresponding tothe outcome of a head and a value exceeding 0.5 and less than or equal to 1.0 correspondingto a tail, as shown in Figure 15.2. Because the random numbers are uniformly distributed, theoutcome of a head and a tail is equally likely.

    With this capability, the computer simulation consists of repeating the following steps a largenumber of times (say, 100):

    1. Generate three uniformly-distributed random numbers between 0 and 1 corresponding tothe outcomes of the three coin flips.

    2. Record the payoff of $1 if all three numbers are less than or equal to 0.5 (all three heads),$5 if all three numbers are greater than 0.5 (all three tails), and $0 otherwise.

    Finally, the computer can be programmed to add up these 100 payoffs and divide the total by 100to obtain an estimate of the expected payoff.

    Normally, you would write a computer program to generate the random numbers in this simula-tion. For illustration purposes, however, the random numbers in the table in Appendix D are usedinstead. These random numbers were generated by a computer.

    To begin the simulaion, arbitrarily start with any number in the table and choose successivenumbers, by row, as needed. For example, to simulate one trial of the new lottery card, choose anythree consecutive numbers in a row of the table say, row 2 leading to the following results:

  • Chapter 15 5

    Table 15.1: The Results of Simulating the First 5 Cards for the Problem of the New York LotteryCommission

    Row 1 Row 2 Row 3Random H/ $ Random H/ $ Random H/ $

    Trial number T Amt. number T Amt. number T Amt. Payoff

    1 0.995255 T $5 0.577849 T $5 0.980588 T $5 5.002 0.894206 T $5 0.332668 H $1 0.355729 H $1 0.003 0.937265 T $5 0.520743 T $5 0.449925 H $1 0.004 0.524444 T $5 0.540955 T $5 0.802009 T $5 5.005 0.287153 H $1 0.639474 T $5 0.535043 T $5 0.00

    OutcomesFlip number Random number Flip result $ Amount

    1 0.995255 Tails 52 0.577849 Tails 53 0.980588 Tails 5

    This trial corresponds to scratching a $5 value in each of the three rows and therefore results ina payoff of $5. For the second trial, use the next three random numbers in row 2 of the table inAppendix D:

    OutcomesFlip number Random number Flip result $ Amount

    1 0.894205 Tails 52 0.332668 Heads 13 0.355729 Heads 1

    This trial corresponds to scratching a $5 value in the first row of the card and a $1 value in thesecond and third rows, resulting in a payoff of $0.The first 5 trials thus obtained are shown in Table 15.1. Continuing this process for a total

    of 100 trials results in a total payoff of $82.00, which provides an estimate of the expected payoffof 82/100 = $0.82 per card. Observe that this value is higher than the actual expected payoff of$0.75 obtained using probability theory. To obtain a more accurate estimate of the expected payoff,you will need to perform many more trials than the 100 performed in this example. The details ofdetermining how many more trials are necessary is discussed in Chapter 16.Observe that the approach of computer simulation has overcome the drawbacks of the previous

    two methods by eliminating the cost associated with printing the cards in the physical simulationand the time and manual effort needed to flip the coins and tabulate the results in the simulationby analogy. Moreover, once the computer program is written and tested, it is a simple matterto perform the experiment 100,000 times instead of 100 times to obtain a better estimate of theexpected payoff.

    15.1.2 A SECOND EXAMPLE OF COMPUTER SIMULATION

    Consider the problem faced by the manager of First-Run Videos, Inc.

  • 6 Chapter 15

    Example 15.2 The Computer Simulation of the Problem of First-Run Videos, Inc.

    First-Run Videos, Inc., is a company that purchases first-run videos for $25 a copy, rents themfor $3 per day, and after one month sells them to another store for $5 a copy. Based on historicaldata, the company has estimated the following probabilities of daily demand for each movie:

    Number of copies Probability

    0 0.151 0.252 0.453 0.104 0.05

    As manager of First-Run Videos, Inc., you want to decide how many copies of each new movie toorder: 0, 1, 2, 3, or 4.

    It is again possible to apply probability theory to obtain the desired answer. The optimal decisionis the one that results in the largest expected profit over the life of the video, which is one month(30 days). To illustrate, suppose that 3 copies are ordered. In this case:

    Expected profit = Expected revenue for one month +Selling price of the 3 copies Purchase cost of the 3 copies

    = (Expected revenue per day 30 days) +($5 3) ($25 3)

    = (Expected revenue per day 30) $60.

    In computing the expected revenue on a given day, keep in mind that there are only three copies ofthe tape available for rental. A fourth demand for a particular movie during any one day cannot bemet and thus generates no additional income. Therefore, the expected daily revenue is computed asfollows:

    Expected revenue per day = $0 Probability of 0 requests +$3 Probability of 1 requests +$6 Probability of 2 requests +$9 Probability of 3 requests +$9 Probability of 4 requests

    = (0 0.15) + (3 0.25) +(6 0.45) + (9 0.10) + (9 0.05)

    = $4.80.

    Therefore,

  • Chapter 15 7

    Table 15.2: Expected Profits for the Problem of First-Run Videos, Inc.

    Number of Purchase Expected revenue Resale Netcopies cost ($) ($/day) ($/month) value ($) profit ($)

    0 0 0.00 0.00 0 0.001 25 2.55 76.50 5 56.502 50 4.35 130.50 10 90.503 75 4.80 144.00 15 84.004 100 4.95 148.50 20 68.50

    Expected profit = (Expected revenue per day 30) $60

    = ($4.80 30) $60

    = $84.

    In other words, purchasing three copies of the video is expected to result in a profit of $84 at the endof the month. The results of performing similar computations for ordering 0, 1, 2, 3 and 4 tapes aregiven in Table 15.2. You can see that ordering two copies of the video is optimal because it resultsin the largest profit, $90.50.

    For this problem, it has again been possible to obtain the desired results by direct mathematicalanalysis. The methodology of computer simulation is now used to achieve a similar result. Sosuppose you decide to order two copies of the tape at a cost of $50.

    To estimate the expected revenues using simulation, it is necessary to mimic the process of cus-tomers requesting copies of the video tape over a 30-day period and then perform the computationsto determine the associated revenues and, ultimately, the total profit. In particular, the followingsteps are performed for each of the 30 days in the month:

    1. Generate the daily demand, that is, the number of requests for this tape on the given dayaccording to the probability distribution given in the problem description.

    2. Compute the associated rental revenue based on the fact that you have two copies of thetape available.

    Subsequently, the total expected profit is computed by:

    Total expected profit = Total rental revenue +Resale revenue Purchase cost

    = Total rental revenue +(2 5) + (2 25)

    = Total rental revenue 40.

    To obtain the total rental revenue, as described in steps (1) and (2) above, it is necessary togenerate the daily demand according to the following table:

  • 8 Chapter 15

    -UniformRandomNumber0

    Demand

    ?0

    0.15

    1

    0.40

    2

    0.85

    3

    0.95

    4

    1

    Figure 15.3: Generating the Daily Demand Using a Uniform 0 1 Random Number

    Number of copies Probability

    0 0.151 0.252 0.453 0.104 0.05

    Once again, uniformly-distributed random numbers between 0 and 1 can be used to do so. The ideais to use the capability of the computer language to generate such a random number and use itsvalue to determine an associated daily demand in such a way that there is a 15% chance that theresulting demand is 0, a 25% chance that it is 1, and so on. This can be accomplished as shownin Figure 15.3. That is, generate a uniform random number between 0 and 1 and determine theassociated daily demand according to the following table:

    Range of uniform Associatednumber daily demand

    0.00 0.15 00.15 0.40 10.40 0.85 20.85 0.95 30.95 1.00 4 Each interval is meant to include thesmaller value but not the larger one.

    For example, if the uniform random number generated is 0.333, the corresponding daily demand is1 because the value of 0.333 falls in the range of 0.15 0.40.Normally, you would write a computer program to generate these random numbers. For illustra-

    tion purposes, however, uniform random numbers from the table in Appendix D are used instead.For example, to simulate the first day, choose any number in the table, say the value of 0.856269 inrow 16 and column 2. This random number corresponds to a daily demand of 3 copies. Since only2 copies of the tape are available for rental, the associated revenue is:

  • Chapter 15 9

    Table 15.3: Simulating 10 Days of Demand for the Problem of First-Run Videos, Inc.

    Uniformrandom

    Day number Demand Revenue

    1 0.856269 3 62 0.201616 1 33 0.091010 0 04 0.990284 4 65 0.926374 3 66 0.090610 0 07 0.519490 2 68 0.988134 4 69 0.516041 2 610 0.629143 2 6

    Revenue for Day 1 = 2 copies ($3 per copy) = $6.To simulate the second day, select the next random number by row in the table, that is, the one

    of 0.201616 in row 16 and column 3. This in turn corresponds to a demand of 1 copy, thus theassociated revenue is:

    Revenue for Day 2 = 1 copy ($3 per copy) = $3.The rest of the simulation consists of:

    1. Selecting the next random number by row.

    2. Determining the associated daily demand.

    3. Computing the daily revenue based on 2 copies of the tape being available.

    These computations are summarized for the first ten days in Table 15.3. Continuing the simulationfor a total of 30 days and adding up the daily revenues results in a total rental revenue of $135 fromthis simulation. The 30-day profit is:

    Total profit = Total revenue 40

    = 135 40

    = $95.

    To determine the optimal number of copies to purchase, it is necessary to repeat the abovesimulation for each of the remaining choices of buying 1, 3, or 4 copies. However, rather thangenerating new daily demands in each case, you can reuse the same demands in Table 15.3 andsimply compute the rental revenue associated with the number of copies available. The resultsof doing so for 30 days and computing the profits are summarized in Table 15.4. Based on thissimulation, you can see that it is optimal to order 3 copies because its associated profit of $99 is the

  • 10 Chapter 15

    Table 15.4: Profits for the Simulation Results of the Problem of First-Run Videos, Inc.

    Number of Purchase Revenue Resale Profitcopies cost ($) ($/month) value ($) ($)

    0 0.00 0.00 0.00 0.001 25.00 78.00 5.00 58.002 50.00 135.00 10.00 95.003 75.00 159.00 15.00 99.004 100.00 165.00 20.00 85.00

    most. Observe that the conclusion to order 3 copies based on the result of this one simulation isdifferent from the analytical results in Table 15.2 in which it is optimal to order only 2 copies. This isbecause the simulation methodology provides only an estimate. To obtain more accurate estimates,you will need to repeat this 30-day simulation many more times, as you will learn in Chapter 16.

    15.2 ADVANTAGES AND DISADVANTAGES OFCOMPUTER SIMULATION

    From the examples presented in Sections 15.1.1 and 15.1.2, you can identify the following disadvan-tages of using a computer simulation:

    1. The numerical results obtained are based on the specific set of random numbers used in thesimulation, the values of which correspond to only one of many possible outcomes. Thus, thefinal values reported in a simulation are only estimates of the true values you are looking for.For instance, the computer simulation of the New York Lottery Commission in Example 15.1resulted in overestimating the expected payoff per card. As another example, the simulationof the problem of First-Run Videos, Inc., in Example 15.2 indicated that 3 copies of thevideo tape should be purchased but the mathematical analysis showed that it is best to buyonly 2 copies.

    Making wrong decisions based on the results of a simulation may have serious financialconsequences. For example, if the simulation in Example 15.1 underestimates the expectedpayoff of a lottery card, the New York Lottery Commission may not charge enough for thatcard and might loose significant amounts of money.

    2. To obtain more accurate estimates and to minimize the likelihood of making a wrong deci-sion, you should (a) use a large number of trials in each simulation and/or (b) repeat theentire simulation a large number of times. For instance, in Example 15.1, you might havethe computer simulate 10,000 cards instead of 100; in Example 15.2, you might simulatethe profit from one month twenty different times rather than just once. In these examplesthat can easily be done with a reasonable amount of computational effort. For more com-plex problems, however, a large number of repetitions can require significant amounts ofcomputer time.

    3. Each simulation requires its own special design to mimic the actual scenario under investi-gation and its own associated computer program. Although it is possible to learn and usespecialized software packages, development effort in designing and programming real-worldsimulations is extremely time consuming.

  • Chapter 15 11

    As a result of these disadvantages, you should attempt to solve your problem using analyticaltechniques whenever possible. Doing so requires less effort and results in exact answers rather thanestimates. Therefore, the problems in Example 15.1 and 15.2 should be solved analytically ratherthan with a computer simulation. Nonetheless, in spite of the disadvantages, computer simulationis one of the more commonly used techniques because it offers the following advantages:

    1. Simulation allows you to analyze large, complex problems for which analytical results arenot available. In fact, most real-world problems fit in this category. Consider the problemof First-Run Videos, Inc., in Example 15.2. Analytical results were obtained assuming thatthe demand distribution is the same on each day and that each tape is returned after oneday. However, a more realistic scenario is one in which the demand distribution depends onthe day of the week. Friday and Saturday would have higher demands. Also, a rented tapemay be returned after one, two, or even three days. Even if the return distribution wereknown, obtaining analytical results in this case would be quite difficult. Simulation providesa practical alternative.

    2. As with any form of simulation, computer simulation allows the problem solver to experimentwith many different policies and scenarios without actually changing or experimenting withthe actual existing system. For example, with computer simulation you can study the impactof adding a new work station to a production line without having to set up the work stationphysically.

    3. Computer simulation allows you compress time. For example, you can study the long-rangeimpact of a policy for a bank for an entire year in a computer simulation lasting just a fewminutes. The alternative of actually implementing the policy and observing its results overa year may not be practical.

    4. Some analytical techniques require a sophisticated mathematical background both to useand to understand. A computer-simulation may require little or no complex mathematicsand so may be intuitively more understandable. As a result, it may be easier to convinceothers in the organization that your proposal or policy is sound when it is backed up by asimulation model rather than by an analytical model. For this reason, computer simulationmay be used even though the problem can be analyzed using mathematical techniques.

    In Section 15.1 you learned the basic concepts of how a computer simulation is used to obtainestimates of certain values on which a decision is based. In Section 15.3, the details of the stepsinvolved in designing a simulation are presented.

    15.3 THE COMPUTER-SIMULATION METHODOLOGY

    Designing and implementing a computer simulation depends on the system being modeled and alsoon the specific computer language or package you have available. However, certain general steps areperformed in each simulation, as described in this section.

    15.3.1 CLASSIFYING THE SYSTEM

    The design of a simulation model depends on classifying the system as one of two types:

    1. A discrete-event system, in which the state of the system changes only at certain points intime. For example, in modeling the operation of a bank, the state of the system is describedby the number of customers in line and which of the tellers are currently busy. The state ofthis system changes only at those points in time when either (a) a new customer arrives or(b) a customer finishes being served and leaves the bank.

  • 12 Chapter 15

    2. A continuous system, in which the state of the system changes continuously over time,that is, at each moment in time. For example, in simulating the flight of the space shuttle,the state of the system is described by its position, speed, accelaration, and so on. Thesecharacteristics are changing constantly at each moment in time.

    In this text, only discrete-event systems are modeled.A discrete-event system can be further classified as one of the following two types:

    1. A terminating system, in which there are precise and known starting and ending points.For instance, the problems of the New York Lottery Commission and of First-Run Videos,Inc., in Section 15.1 are terminating. In the first example, the starting point is the purchaseof the lottery card and the ending point is when the three boxes are scratched to reveal thepayoff. In the second example, the starting point is when the new videos arrive and theending point is 30 days later, when these videos are sold.

    2. A nonterminating system is one that is ongoing, one without precise known startingand ending points. Consider simulating a manufacturing facility. The production processcontinues on and on. The conditions at the end of one day are the starting conditions forthe next day. There is no clear beginning and ending point for the process.

    When a system is terminating, the length of the simulation that is, the amount of time overwhich to conduct the simulation for purposes of analysis is from its beginning point to its endingpoint. To obtain reliable results for a terminating system, you need to determine how many timesto repeat the simulation. In contrast, for a nonterminating system, you need to choose not only thenumber of times to repeat the simulation, but also, an appropriate length of each simulation. Forexample, you might choose to simulate the production process for a length of one day and repeat thesimulation 50 times. Alternatively, you might choose a length of 50 days and perform the simulationonly once. Details on the length and number of simulation runs are given in Chapter 16.

    15.3.2 IDENTIFYING THE COMPONENTS OF A COMPUTERSIMULATION

    Before designing the details of a computer simulation, it is critical to have a clear understanding ofthe objectives of the study in the form of specific numerical outputs. For instance, in Example 15.1,the objective is to determine a price for the new lottery card which creates the need to obtain anoutput value of the expected payoff of the card. Examples of possible outputs for other simulationsare:

    1. To evaluate the performance of a bank: (a) the average time a customer spends waiting inline, (b) the fraction of time the tellers are busy serving customers, and (c) the average andmaximum length of the waiting line.

    2. To evaluate an inventory policy: (a) the average inventory level over a period of time, (b)the number of times and the amount by which you are unable to meet the demand, and (c)the total associated cost.

    3. To evaluate the anticipated cash flow of a business based on future probabilistic sales: (a)the expected net-present value of the cash flow and (b) the expected rate of return.

    Having identified the outputs, the next step is to identify the inputs. These are the numericalvalues that, once determined, allow you to start the simulation and to calculate all the desiredoutputs. These inputs fall into three general categories.

  • Chapter 15 13

    1. Initial conditions that is, initial values that express the state of the system at thebeginning of the simulation. For example, in simulating the daily operation of a bank,the initial conditions correspond to opening the bank in the morning when there are nocustomers and all the tellers are available. In simulating the monthly operation of a steelplant, the initial conditions might include such items as the amount of iron ore in inventory,the initial work-in-process inventory, the amount of finished steel in inventory, and thenumber of furnaces in operation at the beginning of the month.

    2. Deterministic data that is, known values that are needed to perform the calculationsthat yield the outputs. For example, in simulating the daily operation of a bank, onedeterministic data value is the number of tellers available and the number of hours eachworks. For the simulation of steel production, these deterministic values might include thecost of producing steel, the selling price, the number of shifts and the number of workers oneach shift, and so on. In addition, deterministic data for both of these problems include thelength of the simulation. In the case of the bank a terminating system the length of thesimulation is one eight-hour day. For the steel production a nonterminating system youmust determine an appropriate length of the simulation.

    3. Probabilistic data that is, quantities whose values are uncertain but needed to obtainthe outputs of the simulation. In simulating the daily operation of a bank, the arrival timesof the customers and the amount of time needed to serve each of them are two probabilisticdata values. In simulating the steel plant, the demands for the finished goods as well as theamount of time needed at each stage in the production process might constitute probabilisticdata. Although the specific values of these probabilistic data are uncertain, their generalbehavior must be known through a probability distribution or a density function depending,respectively, on whether the value is discrete or continuous (see Appendix B).

    To illustrate the design of a simulation for the problem of First-Run Videos, Inc., recall that thedesired output is the expected 30-day profit associated with purchasing a given number of copies ofa video tape. To obtain this value requires the following inputs:

    1. Initial conditions stating that all the purchased tapes are in the store and available for rentalat the beginning of the simulation.

    2. The deterministic data consisting of:

    (a) The number of copies purchased.

    (b) The purchase price of a new tape.

    (c) The rental cost per day for each tape.

    (d) The sales price after 30 days.

    (e) The length of the simulation 30 days.

    3. Probabilistic data consisting of the number of tapes demanded on each of the 30 days in themonth.

    In this example, the initial conditions that all purchased tapes are available for rent every daymakes the process of initialization straightforward. However, in many simulations defining the initialcondition is not so trivial. Furthermore, the choice of the initial conditions can affect the outputvalues of the simulation. One commonly used approach is to choose what you consider to be likelyor reasonable starting conditions, and then to run the simulation for a long enough period of timeso that the effect of the initial conditions is not significant.

  • 14 Chapter 15

    15.3.3 DESIGNING THE COMPUTER SIMULATION

    Once you have identified the outputs and the inputs needed to compute them, the actual simulationconsists of the following two steps:

    Step 1. Generating Random Numbers: Obtain the probabilistic inputs for the model by generatingrandom numbers according to the associated known distributions.

    Step 2. Bookkeeping: Design a systematic method for storing and processing all the input valuesand for performing the computations needed to obtain the output values.

    For First-Run Videos, recall that the desired output is the expected 30-day profit associated with agiven number of purchased tapes, say 2. The inputs for that simulation are:

    (i) 2 copies purchased.

    (ii) A purchase price of $25 per tape.

    (iii) A rental revenue of $3 per day.

    (iv) The daily demands whose distribution is:

    Number of copies Probability

    0 0.151 0.252 0.453 0.104 0.05

    (v) The resale value of $5 per tape after 30 days.

    In Section 15.1.2 you saw how Step 1 is performed using uniform random numbers between 0 and 1to generate daily demands with the distribution in (iv) above (see Figure 15.3 in Section 15.1).The bookkeeping for Step 2 is accomplished by

    (a) Storing the known data values in (i), (ii), (iii), and (v).

    (b) Using the daily demands generated in Step 1 together with the data values in (a) to computethe associated daily revenue as:

    Daily revenue =

    Demand 3 if demand copies purchasedCopies purchased 3 if demand > copies purchased

    (c) Computing the total rental revenue as the sum of the revenue for each of the 30 days.

    (d) Computing the total profit by:

    Total profit = Total rental revenue Total purchase cost +Total resale revenue

    = Total rental revenue (25 * Number of copies) +(5 * Number of copies).

  • Chapter 15 15

    The bookkeeping scheme depends on the specific system being modeled. Once the probabilisticinputs are generated, the scheme is usually straightforward. As you have seen in Examples 15.1 and15.2, it is necessary to use random numbers to compute the probabilistic inputs for a simulation.Some insight into how this is done in general is given in Section 15.3.4.

    15.3.4 GENERATING RANDOM NUMBERS

    In the examples in Section 15.1, you saw how random numbers between 0 and 1 are used to obtainvalues for random variables that have a known discrete probability distribution in which the randomvariable of interest can assume one of a finite number of different values. In some applications,however, the random variables are continuous, that is, they can assume any real value accordingto a continuous probability distribution. For example, in simulating the operation of a bank, theamount of time a teller spends with a customer is such a random variable which might follow anexponential distribution (see Appendix B) defined by the density function:

    f(t) = et

    where (1/) is the average time of service (that is, is the average number of customers served perunit of time). In this section you will learn how to generate random numbers having an exponentialdistribution with a known value of as well as any other type of probability distribution.

    Generating Uniform 0-1 Random Numbers

    One of the most commonly used methods to generate random numbers following a known distri-bution relies on using uniformly-distributed random numbers between 0 and 1. As discussed inAppendix B and illustrated in Figure 15.4, such numbers have the following density function, f(x),and cumulative distribution function, F (x):

    f(x) = 1,

    F (x) = x.

    The computer languages used for developing simulations all have a built-in capability for gener-ating a sequence of random numbers between 0 and 1 in which:

    1. The approach is based on numerical methods.

    2. The specific sequence depends on a user-supplied initial value called the seed. For a par-ticular seed, the sequence is then determined. Each time that same seed is used, the samesequence of random numbers is generated.

    3. The generated numbers satisfy the following properties: (a) they are uniformly distributedbetween 0 and 1 and (b) successive numbers are statistically independent of each other. Asa result, even though the seed determines the precise sequence of numbers, collectively thesenumbers obey the desired statistical properties of 01 random numbers. They are thereforecalled pseudo-random numbers.

    To use pseudo-random-number generators in a computer simulation, you need supply only an initialarbitrary integer number as a seed. Then, each time the pseudo-random-number generator is used,the next 0 1 random number in the sequence is provided.

  • 16 Chapter 15

    - x

    6

    f(x)

    0.0 1.00.0

    1.0

    2.0

    Figure 15.4 (a): Density Function f(x)

    - x

    6

    F (x)

    0.0 0.5 1.0

    pppppppppppppppppppppppppppppppppppppppp pppppppppppppppppppppppppppppppppppppppp

    0.0

    0.5

    1.0

    Figure 15.4 (b): Cumulative Distribution Function F (x)

    Figure 15.4: Density Function and Cumulative Distribution Function for Uniform 0 1 RandomNumbers

  • Chapter 15 17

    Using 0 1 Random Numbers to Generate a Continuous DistributionTo generate a random number following a distribution other than the uniform distribution, startwith a uniform random number between 0 and 1 and appropriately transform that number into thedesired value. This approach is used in Examples 15.1 and 15.2. For instance, in Example 15.2, arandom number between 0 and 1 is used to generate a demand between 0 and 4 according to theknown discrete distribution given in that problem description.You will now see how 0 1 random numbers are used to generate random values for continuous

    variables following a known probability distribution. Suppose that T is such a variable representingthe amount of time a teller spends with a customer in a bank. From historical records, suppose thatthis teller serves an average of 12 customers an hour. Suppose that statistical analysis of historicaldata also indicates that the associated random variable T closely follows an exponential distributionin which = 12. As discussed in Appendix B, the associated density function, f(t), and cumulativedistribution function, F (t), are:

    f(t) = et= 12 e12t,

    F (t) = Prob(T t)= 1 et= 1 e12t.

    The functions are graphed in Figure 15.5.Suppose that in developing a simulation, you need to know how much time the teller spends

    with one specific customer. That is, you need to generate a random number following the aboveexponential distribution. To do so using 0 1 random numbers, follow these steps that work forany general distribution whose justification is given in Appendix 15A:

    1. Generate a uniform random number between 0 and 1 say, U .

    2. For the given value of U from (1), use the cumulative distribution F (t) to determine thevalue of t as shown in Figure 15.6. That is, use the value of U to find the value of t for which

    F (t) = U.

    3. Use the value of t obtained in (2) as the random number.

    The next two examples show how these steps are used to generate random numbers following anexponential and normal distribution.

    Example 15.3 Generating Exponential Random Numbers

    To apply this general approach to generate random numbers following an exponential distributionwith a known value of , you would:

    1. Generate a uniform 0 1 random number U .2. Use the value of U to solve the following equation for t:

    F (t) = U, or

  • 18 Chapter 15

    Figure 15.5: Density Function and Cumulative Distribution Function for Random Numbers Withan Exponential Distribution

  • Chapter 15 19

    Figure 15.6: Generating a Random Number Using a Cumulative Distribution Function and a Uni-form 0 1 Random Number

    1 et = U, or

    et = 1 U.

    Doing so requires using the logarithm function, ln, to obtain:

    t = (1/) ln(1 U).

    For the specific example involving the bank teller, in which = 12 and a uniform randomnumber of, say, U = 0.3329 is generated, the amount of time needed to serve one particularcustomer is:

    t = (1/) ln (1 U)= (1/12) ln (1 0.3329)= (1/12) (0.4048)= 0.3373 of an hour.

    Example 15.4 Generating Normal Random Numbers

  • 20 Chapter 15

    As a second example, suppose you need to generate the demand D for milk that follows a normaldistribution with a mean of 750 gallons per day and a standard deviation of 100 gallons. To do sofor a normally-distributed random variable having a mean of and a standard deviation of :

    1. Generate a uniform 0 1 random number say, U .2. Use this value of U to find a value of t for which

    F (t) = Prob(D t) = U.

    That is, find the value of t for which the area under the normal distribution to the left oft in Figure 15.7 is U . To do so, use the standard normal table in Appendix E to find theassociated z-value; then compute t, as follows:

    z =t , so

    t = + ( z).

    For the specific milk example in which U = 0.1515, = 750, and = 100, the z-value fromAppendix E is about -1.03, and so:

    t = + ( z)

    = 750 + [100 (1.03)]

    = 647 gallons.

    The methods described here are not the most efficient ones available but are used in this textbecause they are conceptually easy to understand. You will now see how these ideas are used indesigning a computer simulation.

    15.4 A SIMULATION OF A BUS STOP

    In this section, you will see an example of how the simulation methodology is used to analyze amore challenging decision problem. Consider the problem faced by the Regional Transit Authorityof Cleveland.

    15.4.1 PROBLEM DESCRIPTION

    The Regional Transit Authority (RTA) has bus service from various suburbs to downtown. Themanagement has received a number of complaints that customers at one of the suburban stops arehaving to wait too long during the morning rush hours of 7 to 9 AM. The riders are also complainingthat there are not enough seats in the shelter for all the passengers to wait in the winter months. Torespond to these complaints, the management is considering increasing the frequency on that routefrom the current service of every 20 minutes to every 15 minutes. As manager of operations, youhave been asked to investigate the impact of this policy on customer service by measuring:

    1. The average amount of time a customer has to wait for a bus.

  • Chapter 15 21

    Figure 15.7: Generating Normal Random Numbers

    2. The average number of customers waiting at the stop.

    3. The maximum number of customers waiting.

    Through data studies, the RTA has determined that about 30 customers arrive per hour at thisstop during the rush hour (that is, at a rate of about 0.5 per minute). The data also show that thetime between two arriving customers can be approximated by an exponential distribution with anaverage rate of = 0.5 per minute. A time study also reveals that buses typically arrive late at theirscheduled stops by an amount of time that follows a normal distribution with a mean of 4 minutesand a standard deviation of 1 minute.To evaluate the proposed bus schedule, you should realize that the models described in Chapter

    14 are not directly applicable to this queueing problem. The main reason is that the customers arenot served one-at-a-time but rather, as a group. Simulation is therefore a reasonable way to evaluatethis system.

    15.4.2 DESIGNING THE SIMULATION

    As discussed in Section 15.3.1, before designing the details of a computer simulation, it is critical tohave a clear understanding of the objectives of the study in the form of specific numerical outputs. Forthe problem of the RTA, the appropriate outputs are the three described in the problem descriptionin Section 15.4.1.The next step is to identify the inputs for this simulation whose values, once determined, allow

    you to calculate these outputs. Recall, from Section 15.3, that the inputs fall into the following threecategories:

    1. The initial conditions which, in this case, are the number of customers already at the stop atthe time corresponding to the beginning of the simulation and the time when the next bus is

  • 22 Chapter 15

    scheduled to arrive. These values should represent the most likely starting conditions at thebeginning of the rush-hour period being simulated and should be estimated based on yourexperience. For the purposes of illustration, assume that you are starting the simulation ata point in time when a bus has just left. In this case, there is no one waiting at the stopand the next bus is scheduled to arrive in 15 minutes. If the simulation is performed for along enough period of time, the effect of these initial conditions on the output should beminimal.

    2. The deterministic data consisting of the length of time over which to perform this simulation.In this case, suppose you decide to simulate the bus stop for one hour.

    3. The probabilistic data that are generated when needed, consisting of:

    (a) The arrivals of the customers whose interarrival times are assumed to follow an expo-nential distribution with a mean rate of = 0.5 per minute.

    (b) The arrival time of each bus. The buses are scheduled to arrive every 15 minutes.However, they might be late by an amount of time that follows a normal distributionwith a mean of = 4 minutes and a standard deviation of = 1 minute.

    With these outputs and inputs, the actual simulation consists of generating appropriate randomnumbers and an associated bookkeeping scheme, both of which are described below.

    15.4.3 GENERATING RANDOM NUMBERS

    As discussed above, there are two probabilistic inputs, each of which needs to be generated usingrandom numbers according to their underlying probability distributions.

    Generating Arriving Customers

    One of the probabilistic inputs for this simulation is the arrival of customers at the stop, whoseinterarrival times follow an exponential distribution with a mean of = 0.5 per minute. Recall,from Section 15.3, that the time, ta, in minutes between successive arrivals is obtained by:

    (a) Generating a uniform 0 1 random variable U .(b) Computing:

    ta = (1/0.5) ln (1 U).

    Generating the Arrival of a Bus

    The buses are scheduled to arrive every 15 minutes. If the simulation is started at time T = 0, thenthe first bus should arrive at time T = 15, the second bus at time T = 30, and so on. However,these buses are late by an amount of time that follows a normal distribution with a mean of = 4minutes and a standard deviation of = 1. Recall from Section 15.3 that this random time, tl, bywhich a bus is late is generated using the following steps:

    (a) Generate a uniform 0 1 random number U .(b) Find a z-value from the standard normal table in Appendix E so that the area to the left of

    z is U .

  • Chapter 15 23

    (c) Compute tl as follows:

    tl = + ( z)

    = 4 + (1 z).

    15.4.4 DESIGNING THE BOOKKEEPING SCHEME

    One of the best ways to approach the bookkeeping scheme is to use the technique of working througha specific example in which you take specific values for the given inputs and perform the neededcomputations by hand to determine the desired output. Recall the values for the initial conditionsat time T = 0 for this problem: the stop is empty and the next bus is scheduled to arrive in 15minutes.To compute the outputs, you will need to know the status of the system (number of customers

    in the system) at every point in time. However, observe that the status of the system changes onlywhen either:

    1. A new customer arrives, or when

    2. A bus arrives.

    Thus, it is necessary to record the status of the system only at these points in time. You must knowwhich of these events occurs next and when. To begin with, consider the initial state of the systemat time T = 0.

    Bookkeeping at Time T = 0

    At time T = 0 there is no one waiting at the stop and a bus has just left. To determine when thestatus of this system changes, you need to know:

    1. The time at which the next customer arrives.

    2. The time at which the next bus arrives.

    These values need to be generated randomly according to their distributions.

    Determining When the Next Customer Arrives

    Use 0 1 random numbers to determine the arrival time of the next customer, as follows:

    1. Arbitrarily start by choosing a uniform 0 1 random number say, U = 0.894206 in row 2and column 4 of the table in Appendix D.

    2. Compute the interarrival time, ta, as follows:

    ta = (1/0.5) ln (1 U)

    = 2 ln (1 0.894206)

    = 4.49 minutes.

  • 24 Chapter 15

    Table 15.5: The Status of the System at Time T = 0

    Number of Arrival time ofTime Event Customers Next customer Next bus

    0.00 0 4.49 18.57

    In other words, the next customer arrives 4.49 minutes from now, at time T = 0 + 4.49 = 4.49.

    Determining When the Next Bus Arrives

    The next bus is scheduled to arrive at time T = 15 minutes, but will actually arrive late by a randomamount of time, tl. To determine tl, use the next 0 1 random number in the table, U = 0.332668in row 2 and column 5. From the standard normal table in Appendix E, the z-value for which thearea to the left of z is U is about -0.43. Using this z-value, compute:

    tl = + (z )

    = 4 + (0.43 1)

    = 3.57 minutes.

    In other words, the next bus is 3.57 minutes late, that is, it arrives at time T = 15 + 3.57 = 18.57.These arrivals and the status of the system at T = 0 are summarized in Table 15.5.

    Moving the Clock Time T

    From Table 15.5, you can see that the status of the system remains the same until the first customerarrives at time T = 4.49. This is because this customer arrives before the next bus.

    Bookkeeping at Time T = 4.49

    When this customer arrives at time T = 4.49, you must perform the following steps:

    1. Change the Status of the System: The customer joins the others waiting at the stop, soincrease the number of waiting customers by 1.

    2. Schedule the Next Arriving Customer: A new customer will arrive. To determine when,generate an interarrival time, ta, according to an exponential distribution. Using the next0 1 random number, U = 0.355729 from row 3 and column 1, and compute:

    ta = (1/0.5) ln (1 U)

    = 2 ln (1 0.355729)

    = 0.88 minutes.

    The next customer arrives 0.88 minutes from now, at time T = 4.49 + 0.88 = 5.37.

  • Chapter 15 25

    Table 15.6: The Status of the System Up to Time T = 4.49

    Number of Arrival time ofTime Event Customers Next customer Next bus

    0.00 0 4.49 18.574.49 Customer 1 5.37 18.57

    Table 15.7: The Status of the System Up to Time T = 5.37

    Number of Arrival time ofTime Event Customers Next customer Next bus

    0.00 0 4.49 18.574.49 Customer 1 5.37 18.575.37 Customer 2 10.91 18.57

    These changes are summarized in Table 15.6 in the row corresponding to time T = 4.49. At thistime, a new customer arrives, as indicated by the word Customer in the column labeled Event.

    Moving the Clock Time T

    From the second row of Table 15.6, you can see that the status of the system remains the sameuntil the next customer arrives at time T = 5.37. When this customer arrives, perform the followingsteps:

    1. Change the Status of the System: The customer joins the others waiting at the stop, soincrease the number of waiting customers from 1 to 2.

    2. Schedule the Next Arriving Customer: A new customer will arrive. To determine when,generate an interarrival time, ta, according to an exponential distribution. Using the next0 1 random number, U = 0.937265 from row 3 and column 2, and compute:

    ta = (1/0.5) ln (1 U)

    = 2 ln (1 0.937265)

    = 5.54 minutes.

    The next customer arrives 5.54 minutes from now, at time T = 5.37 + 5.54 = 10.91.

    These changes are summarized in Table 15.7 in the row corresponding to time T = 5.37, at whichtime a new customer arrives.Repeating this process reveals that customers continue to arrive until time 16.62, as summarized

    in Table 15.8. On the basis of the information in the last row of Table 15.8, you can see that thenext event is the arrival of the first bus at time T = 18.57.

  • 26 Chapter 15

    Table 15.8: The Status of the System Up to Time T = 16.62

    Number of Arrival time ofTime Event Customers Next customer Next bus

    0.00 0 4.49 18.574.49 Customer 1 5.37 18.575.37 Customer 2 10.91 18.5710.91 Customer 3 12.38 18.5712.38 Customer 4 13.58 18.5713.58 Customer 5 15.06 18.5715.06 Customer 6 16.62 18.5716.62 Customer 7 19.86 18.57

    Bookkeeping at Time T = 18.57

    When this bus arrives, perform the following bookkeeping steps:

    1. Change the Status of the System: All customers board the bus, so reduce the number ofwaiting customers to 0.

    2. Determine the Arrival Time of the Next Bus: The next bus is scheduled to arrive at timeT = 30 minutes, but will actually arrive late by a random amount of time, tl. To determinetl, use the next 0 1 random number in the table, U = 0.287153 in row 4 and column 3.From the standard normal table in Appendix E, the corresponding z-value is about -0.565.Using this z-value, compute:

    tl = + (z )

    = 4 + (0.565 1)

    = 3.44 minutes.

    In other words, the next bus is 3.44 minutes late, that is, it arrives at time T = 30+ 3.44 =33.44.

    This arrival and the status of the system at T = 18.57 are summarized in the last row of Table 15.9.From these sample events, you can see that the status of the system changes only when one of

    two events occurs: (a) a new customer arrives or (b) a bus arrives. Depending on which event occursfirst, the clock is moved to that point in time and the following associated bookkeeping operationsare performed.

    Bookkeeping When a New Customer Arrives

    1. Change the Status of the System: Increase the number of waiting customers by 1.

    2. Schedule the Arrival Time of the Next Customer: Determine when the next customer arrivesby generating a random interarrival time from the exponential distribution.

    3. Add this information as the next row in the table.

  • Chapter 15 27

    Table 15.9: The Status of the System Up to Time T = 18.57

    Number of Arrival time ofTime Event Customers Next customer Next bus

    0.00 0 4.49 18.574.49 Customer 1 5.37 18.575.37 Customer 2 10.91 18.5710.91 Customer 3 12.38 18.5712.38 Customer 4 13.58 18.5713.58 Customer 5 15.06 18.5715.06 Customer 6 16.62 18.5716.62 Customer 7 19.86 18.5718.57 Bus 0 19.86 33.44

    BookKeeping When a Bus Arrives

    1. Change the Status of the System: Decrease the number of waiting customers to 0 becauseall these customers board the bus.

    2. Determine the Arrival Time of the Next Bus: Determine when the next bus arrives by addingto its scheduled arrival time, a random amount of time generated from a normal distribution.

    3. Add this information as the next row in the table.

    These steps are repeated over and over again until the clock time exceeds the duration establishedat the start of the problem, which in this case is one hour. These data up to time T = 60 minutesare provided in Table 15.10.

    15.4.5 OBTAINING THE FINAL STATISTICS

    Recall from Section 15.4.1 that the sought after objectives that is, the outputs of this simulationare:

    1. The expected waiting time for a customer at the stop.

    2. The average number of customers waiting.

    3. The maximum number of customers waiting.

    The last step is to use the information in Table 15.10 to obtain these statistics, as now illustrated.

    Computing the Expected Waiting Time

    The average waiting time at the stop is computed using the following formula:

    Average waiting time =Total waiting time of all customers

    Total number of customers

    From the data in Table 15.10, a total of 27 customers have arrived at the stop.

  • 28 Chapter 15

    Table 15.10: The Status of the System Up to Time T = 60.0

    Number of Arrival time ofTime Event Customers Next customer Next bus

    0.00 0 4.49 18.574.49 Customer 1 5.37 18.575.37 Customer 2 10.91 18.5710.91 Customer 3 12.38 18.5712.38 Customer 4 13.58 18.5713.58 Customer 5 15.06 18.5715.06 Customer 6 16.62 18.5716.62 Customer 7 19.86 18.5718.57 Bus 0 19.86 33.4419.86 Customer 1 21.90 33.4421.90 Customer 2 23.43 33.4423.43 Customer 3 26.42 33.4426.42 Customer 4 30.49 33.4430.49 Customer 5 32.00 33.4432.00 Customer 6 36.35 33.4433.44 Bus 0 36.35 50.8336.35 Customer 1 39.29 50.8339.29 Customer 2 40.92 50.8340.92 Customer 3 40.98 50.8340.98 Customer 4 41.14 50.8341.14 Customer 5 42.45 50.8342.45 Customer 6 43.29 50.8343.29 Customer 7 45.95 50.8345.95 Customer 8 49.68 50.8349.68 Customer 9 51.82 50.8350.83 Bus 0 51.82 64.2351.82 Customer 1 52.16 64.2352.16 Customer 2 52.22 64.2352.22 Customer 3 56.21 64.2356.21 Customer 4 58.06 64.2358.06 Customer 5 63.55 64.23

  • Chapter 15 29

    - Time (minutes)

    6

    Number in line

    2

    4

    6

    8

    0 10 20 30 40 50 60

    Figure 15.8: Number in Line at the Bus Stop Over Time

    To obtain the value in the numerator requires knowing how the number of waiting customersvaried over time. That information is also available in Table 15.10 and has been transferred toFigure 15.8. From time T = 0 to T = 4.49, there are no customers at the stop. However, from timeT = 4.49 to T = 5.37, there is 1 customer waiting for a period of 0.88 minutes, that is:

    Waiting time from T = 4.49 to T = 5.37 = 1 (5.37 4.49)

    = 0.88 minutes.

    Then, from time T = 5.37 to T = 10.91, there are 2 customers waiting and their combined waitingtime during that period is:

    Waiting time from T = 5.37 to T = 10.91 = 2 (10.91 5.37)

    = 11.08 minutes.

    Performing this computation for each time interval in Figure 15.8 and adding these waiting timestogether provides the total waiting time of:

    Total waiting time = 205.03 minutes,

    and so the average waiting time is:

    Average waiting time = Total waiting timeNumber of customers

    =205.0327

    = 7.5938 minutes.

    On average, a customer can expect to wait about 7.6 minutes before the next bus arrives.

  • 30 Chapter 15

    Computing the Average Number of Customers at the Stop

    As shown in Figure 15.8, during a total of 60 minutes, the number of customers at the stop variesfrom 0 up to a maximum of 9. The number of waiting customers is 0 for a total of 9.69 minutes,that is, 9.69/60 = 0.1615 fraction of the time. The number of waiting customers is 1 for a total of6.20 minutes, that is, 6.20/60 = 0.1034 fraction of the time. These various fractions are summarizedin the following table:

    Fraction of timeNumber waiting Total time (Total time / 60.0)

    0 9.69 0.16151 6.20 0.10342 8.76 0.14603 8.50 0.14174 7.28 0.12135 6.25 0.10426 3.83 0.06397 4.60 0.07678 3.74 0.06239 1.15 0.0191

    With these values, the average number of customers is:

    Average number = 0 fraction of time 0 are waiting +1 fraction of time 1 is waiting +2 fraction of time 2 are waiting +3 fraction of time 3 are waiting +

    ...9 fraction of time 9 are waiting

    = (0 0.1615) + (1 0.1043) + (2 0.1460)+(3 0.1417) + (4 0.1213) + (5 0.1042)+(6 0.0639) + (7 0.0767) + (8 0.0623)+(9 0.0191)

    = 3.4172

    In other words, there is an average of 3 to 4 customers waiting at the stop during the 60 minutes.

    Computing the Maximum Number of Customers Waiting

    From Table 15.10, you can see that during this simulation of 60 minutes, there is a maximum of 9customers waiting at the stop.

    Additional Considerations

    It is important to realize that the specific statistics obtained this section are based on:

    1. The given initial conditions, in which there is no one waiting at the stop.

    2. The data generated during a rush hour for one day, which are based on the specific randomnumbers used.

  • Chapter 15 31

    When the computation of the statistics is based on the relatively short period of 60 minutes, theinitial conditions can have a significant effect on the final values. However, if the simulation isperformed over a longer period of time, say over a two-hour period, you can assume that the effectsof the initial conditions are relatively insignificant. In general, the longer the period you simulate,the less the impact of the initial conditions.Another way to become more certain of the values of the estimates of the performance measures is

    to repeat the above simulation and computations for many different days, and then take the averageof each statistic. In Chapter 16 you will learn more about how many days you need to repeat thesimulation to become reasonably confident of the estimates.Once the final statistics are obtained, the management of the RTA can determine if this schedule

    will provide an accepatble level of service. For example, the management will implement this scheduleif they feel that customers will not mind waiting an average of 7.5 minutes.The management of the RTA can use the average number of waiting customer and the maximum

    number of customers to decide how big a shelter is needed.

    15.5 ADDITIONAL MANAGERIAL CONSIDERATIONS

    You have seen how and when simulation is used to analyze complex systems. Doing so involvesbuilding an appropriate computer model to calculate desired outputs using relevant inputs. Decisionsare then made based on the results of the simulation. In this section, several issues related to usingsimulation and implementing the results are discussed.

    15.5.1 DATA COLLECTION

    In designing a computer simulation, you learned to identify three types of inputs:

    1. Initial conditions, which describe the state of the system at the time the simulation is started.

    2. Deterministic inputs, whose values are assumed to be known and are then used in computingthe desired outputs.

    3. Probabilistic inputs, whose values are not known with certainty but rather are assumed tofollow a known probability distribution.

    Although the probabilistic inputs are eventually generated by the computer using random num-bers, their distribution must first be determined. In addition, the deterministic inputs and the initialconditions must also be specified when the simulation model is built. Keep in mind that obtaining allthree types of inputs can be costly and time-consuming because it involves collecting and analyzingappropriate data.For example, in using a computer simulation to determine how long a traffic light should remain

    green and how long it should remain red at a busy intersection, the interarrival times betweencars constitute a probabilistic input. From historical experience there is reason to believe that theunderlying distribution is exponential, but you should verify this assumption for the traffic flow atthis particular intersection. Even if this assumption is valid, you must still estimate the mean ofthe distribution. You may have to hire an individual or purchase a mechanical device to record thearrival times of cars at the light over a certain period of time. Statistical analysis is then needed todetermine the appropriate mean and to validate the assumption that the interarrival times followan exponential distribution. If the exponential assumption is not valid, you can still use whateverdistribution is appropriate in the simulation.Because the output of a simulation is based entirely on the values of the inputs, the reliability of

    the output is only as good as the accuracy of the inputs. Therefore, sufficient time and effort shouldbe devoted to this task.

  • 32 Chapter 15

    15.5.2 STATISTICAL ASPECTS OF SIMULTAION

    As you learned in Section 15.3, one set of input values to a simulation model is the initial conditionsthat describe the state of the system at the time the simulation begins. In many cases, these valuesare fixed and easily determined due to the nature of the system. For example, in simulating thedaily operation of a bank, the initial values that describe the conditions at the beginning of thesimulation (that is, the day) are that no customers are yet in the system and, consequently, thatall available tellers are idle. In contrast, in some problems the initial conditions are not so readilyavailable or, in fact, are not known. For example, in simulating the rush-hour operation of the busstop for the problem of the Regional Transit Authority in Section 15.4, the initial conditions consistof the number of customers at the stop and the scheduled arrival of the next bus. These values varyfrom day to day and cannot be known with certainty. In these cases, initial values are generallychosen in one of the following ways:

    1. By assigning values on the basis of your knowledge of how the system works and what youwould most likely expect at the time corresponding to the beginning of the simulation.

    2. By assigning any reasonable initial values and running the simulation long enough to mini-mize the influence of the initial conditions. For example, whether you start with no customersor three customers at the stop will have little impact on the final statistics if the simulationis run for a period of two hours.

    3. By assigning any reasonable initial values and running the simulation for some initial timeperiod, say T . Then discard all statistics accumulated during this period except the finalconditions. Use these final conditions as the initial conditions for running another simulation.This second set of statistics are then compiled and recorded.

    Statistical analysis is used to determined the appropriate length of the simulation run in (2) and theinitial time period T in (3). These analyses are beyond the scope of this textbook but they can befound in any standard book on computer simulation.Obtaining the output value from a single simulation run is statistically analogous to drawing

    a single sample from a population. This is because the sequence of random numbers used in thesimulation run is based on the initial uniform random number chosen and is only one of manypossible outcomes. In Chapter 16 you will learn how to determine the number of simulation runsneeded to achieve a specified level of confidence in estimating the average of the output value.

    15.6 SUMMARY

    In this chapter you have learned that the management science technique of computer simulation isa useful tool for studying complex systems that cannot be analyzed mathematically because:

    1. It is not possible or practical to develop a solution methodology based on mathematicalanalysis.

    2. To apply mathematical analysis requires additional assumptions about the model that arenot applicable or realistic.

    The design and analysis of a simulation model depends on first classifying the system as eithera discrete-event system, in which the state of the system changes only at certain points in time, ora continuous system, in which the state of the system changes at every moment in time, continu-ously. Only discrete-event systems are discussed in this chapter. These discrete systems are furtherclassified as terminating, in which there are precise and known starting and ending conditions, or

  • Chapter 15 33

    nonterminating, in which the system is on going. In the former case it is necessary to determineonly the number of simulation runs; in the latter case you must also determine the length of eachsimulation run.Designing the details of a computer simulation involves specifying the objectives of the study in

    the form of specific numerical outputs. Then, you must identify the needed inputs, which fall intoone of the three categories of:

    1. Initial conditions, which describe the beginning state of the system.

    2. Deterministic data, consisting of known values needed to perform the calculations in obtain-ing the outputs.

    3. Probabilistic data, consisting of those quantities whose values are needed to obtain the out-puts of the simulation, but are uncertain. Although the specific values of these probabilisticdata are unknown, their general behavior must be known through a probability distribu-tion or a density function depending, respectively, on whether the values are discrete orcontinuous.

    The actual simulation consists of using a computer simulation package or other computer lan-guage to write a model to perform the following two steps:

    Step 1. Generating Random Numbers: Obtain the probabilistic inputs for the model by generatingrandom numbers according to the associated distributions.

    Step 2. Bookkeeping: Design a systematic method for storing and processing all the input valuesand for performing the computations needed to obtain the output values.

    The output obtained from one simulation run is only one of many possible values. Therefore,in general, you cannot have confidence in the output value from a single simulation run. Rather,you need to repeat the simulation run many times each time using a different initial uniformrandom number thereby obtaining different output values. The actual number of runs to performis discussed in Chapter 16.

  • 34 Chapter 15

    Appendix 15AUSING 0 1 RANDOM NUMBERS TO OBTAINRANDOM NUMBERS FROM A GIVEN DISTRIBUTION

    In Section 15.2, you learned how to transform a 0 1 random number into one that follows agiven density function, f(t), and its associated cumulative distribution function, F (t), by performingthe following steps:

    1. Generate a uniform random number between 0 and 1 say, U .

    2. For the given value of U in Step 1, use the cumulative distribution F (t) to determine thevalue of t for which

    F (t) = U

    3. Use the value of t computed in Step 2 as the desired random number.

    These three steps are justified by the following mathematical theorem.

    Theorem 15.1 Let f(t) is a given density function with cumulative distribution function F (t). IfR is a uniformly distributed random variable whose value is between 0 and 1, then the value T thatsatisfies R = F (T ) is a random variable whose cumulative distribution is F (t).

    Proof: From the definition of a cumulative probability distribution as reviewed in Appendix B, toprove that T has cumulative distribution F (t) requires showing that

    P( T t ) = F (t)

    To show this is true for the random variable T for which R = F (T ), from Figure 15.9, observe thatT t whenever R U (where U = F (t)). Thus,

    P( T t ) = P( R U )

    = U (because R is uniform 0 1)

    = F (t) (because U = F (t))

    As a result of Theorem 15.1, if you know a value U for the uniform 01 random variable R, thenyou can generate a corresponding value for the random variable T with a cumulative distributionF(t) by determining that value of t for which:

    F (t) = U

  • Chapter 15 35

    Figure 15.9: Generating a Random Number Using a Cumulative Distribution Function and a Uni-form 0 1 Random Number


Recommended