Вы находитесь на странице: 1из 54

SIMULATION

SIMULATION vs. OPTIMIZATION In an optimization model, the values of the decision variables are outputs.

The result of the model is a set of values for the decision variables that will maximize (or minimize) the value of the objective function.
In a simulation model, the values of the decision variables are inputs. The model evaluates the objective function for a particular set of values. The result of the model is a measure of the quality of a suggested solution and the variability in various performance measures due to randomness in the 3 inputs.

When should simulation be used?


Simulation is one of the most frequently used tools of quantitative analysis today because:

1. Analytical models may be difficult or impossible to obtain, depending on complicating factors.


2. Analytical models typically predict only average or steady-state (long-run) behavior. 3. Simulation can be performed with a variety of software on a PC or workstation. The level of computing and mathematical skill required to design and run a simulator has been substantially reduced.
4

Steps in simulation
1. Problem formulation 2. Set objectives and overall project plan

Phase 1 Problem Definition

3. Model conceptualization

4. Data Collection

Phase 2
Model Building

5. Model Translation No No 6. Verified Yes 7. Validated Yes 8. Experimental Design 9. Model runs and analysis Yes No 11. Documentation, reporting and implementation No

Phase 3

Experimentation

Phase 4

Implementation

10. More runs

Model Verification and Validation


Verification (efficiency)

Is the model correctly built/programmed? Is it doing what it is intended to do?


Validation (effectiveness) Is the right model built? Does the model adequately describe the reality you want to model? Does the involved decision makers trust the model? Two of the most important and most challenging issues in performing a simulation study

Model Verification Methods


Find alternative ways of describing/evaluating the system
and compare the results Simplification enables testing of special cases with

predictable outcomes
Removing variability to make the model deterministic Removing multiple job types, running the model with one job type at a time Reducing labor pool sizes to one worker

Build the model in stages/modules and incrementally test each module

Uncouple interacting sub-processes and run them separately


Test the model after each new feature that is added Simple animation is often a good first step to see if things are working as intended
7

Simulation and Random Variables


MONTE CARLO METHOD: Simulation models are often used to analyze a decision under risk. Under risk, the behavior of one or more factors is not known with certainty. For example: demand for a product during the next month

the return on an investment


the number of trucks that will arrive to be unloaded The factor that is not known with certainty is called the random variable. The behavior of the random variable can be described by a probability distribution.
9

Design of Docking Facilities. In the following model, trucks of different sizes carrying different types of loads, arrive at a warehouse to be unloaded.

T r u c k

D o c k 3

T r u c k

D o c k 2

T r u c k

D o c k 1

Exit

Entrance

Truck waiting

Truck waiting
10

The uncertainties are: When will a truck arrive? What kind and size of load will it be carrying?

How long will it take to unload the trucks?


Each uncertain quantity would be a random variable characterized by a probability distribution.

The planners must address a variety of design questions:


How many docks should be built?

What type and quantity of material-handling equipment are required?


How many workers are required over what 11 periods of time?

The design of the unloading dock will affect its cost of construction and operation. Management must balance the cost of acquiring and using the various resources against the cost of having trucks wait to be unloaded.

12

Determination of Inventory Control Policies. Simulation can be used to study inventory control models.
Factory

Warehouse 1 Demand

Warehouse 2 Demand

Warehouse 3 Demand

In this model, the factory produces goods that are sent to the warehouses to satisfy customer demand. The random variables are: daily demand at each warehouse and shipping times from factory to warehouse.

13

Simulation can be used to study inventory control models. Some of the operational questions are: When should a warehouse reorder from the factory and how much? How much stock should the factory maintain to satisfy the orders of the warehouses? The main costs are: Cost of holding the inventory Cost of shipping goods from a factory to a warehouse Cost of not being able to satisfy customer demand at the warehouse The objective is to find a stocking and ordering policy 14 that keeps the total cost low while meeting demand.

Generating Random Variables


To generate a random variable, draw a random sample from a given probability distribution.

Two broad categories of random variables:


Discrete Can assume only certain specific values (e.g., integers) Continuous Can take on any fractional value (an infinite number of values)
15 Using a Random Number Generator in a Spreadsheet

A GENERALIZED METHOD: To generate a discrete random variable with the RAND() function in a spreadsheet, two things are needed: 1. The ability to generate discrete uniform random variables 2. The distribution of the discrete random variable to be generated

To generate a continuous random variable, two things are needed:


1. The ability to generate continuous uniform random variables on the interval 0 to 1 2. The distribution (in the form of the cumulative distribution function) of the random variable to 16 be generated

Conversion of a Random No. to a Uniform Distribution

17

200 Random Numbers Generated Between 0 and 100

18

200 Uniform Discrete Random Numbers Generated Between 20 and 100

19

The Cumulative Distribution Function (CDF). Consider a random variable, D, the demand. The CDF for D [called F(x)] is then defined as the probability that D takes on a value < x.

F(x) = Prob{D < x}


Knowing the probability distribution for D, the CDF for key values of D is: X F(x) 8 0.1 9 0.3 10 0.6 11 0.8 12 0.9 13 1.0

20

Here is a graph of the CDF. To generate a discrete demand using the graph:
Probability

1.2

1 0.8 0.6 0.4 0.2


u

Step 1: Locate the particular value of U on this axis

F(x)

Step 2: Read the particular value of the random quantity, d, on this axis d x

0 7 8 9 10 11 12 13

14
21

Suppose you want to model a discrete uniform distribution of demand where the values of 8 through 12 all have the same probability of occurring (uniform, equally likely). The spreadsheet has a function, =RAND(), that returns a random number between 0 and 1. However, this will result in a continuous uniform distribution. To create a discrete uniform distribution, use the INT() function. For example:

In general, if you want a discrete, uniform distribution of integer values between x and y, use the formula: 22 INT(x + (y x + 1)*RAND() )

Generating from the Exponential Distribution. The exponential distribution is often used to model the time between arrivals in a queuing model. Its CDF is given by: F(x) = Prob{t>T} = e-lT Where 1/l is the mean of the random variable T. Therefore, we want to solve the following equation for w: u = e-lT The solution is: T = -1/l ln(u) where we can get u from Random number which represents cumulative distribution function
24

Generating from the Normal Distribution. The normal distribution plays an important role in many simulation and analytic models. Consider drawing a random demand from a normal distribution with a mean (m) of 1000 and a standard deviation (s) of 100. If Z is a unit normal random variable (normally distributed with a mean of 0 and a standard deviation of 1) then m + Zs is a normal random variable with mean m and standard deviation s. So, we can draw from a unit normal distribution. Excel has a built-in function that can do this: = NORMINV( RAND() , 1000, 100) Excel will automatically return a normally distributed 25 random number with mean 1000 and std. dev. 100.

CAPITAL BUDGETING PROBLEM

26

A CAPITAL BUDGETING EXAMPLE: ADDING A NEW PRODUCT LINE Airbus Industry is considering adding a new jet airplane (model A3XX) to its product line. The following financial information is available: Startup Costs Sales Price Fixed Costs (per year) Variable Costs (per year) $150,000 $ 35,000 $ 15,000 75% of revenues

Tax depreciation on the new equipment would be $10,000 per year over the 4 year expected product life. Salvage value of the equipment at the end of the 4 years is estimated to be 0. Airbus cost of capital is 10% and tax rate is 34%.
27

If demand is known, then a spreadsheet can be used to calculate the net present value (NPV). For example, assume that the demand for A3XXs is 10 units for each of the next 4 years:

=C16 + C13
=NPV($D$3,C17:F17)+B17 =-$B$2
28

THE MODEL WITH RANDOM DEMAND It is unlikely that demand will be the same every year. A more realistic model would be one in which demand each year is a sequence of random variables. This model of demand is appropriate when there is a constant base level of demand that is subject to random fluctuations from year to year. Sampling Demand with a Spreadsheet: Assume initially that the demand in a year will be either 8, 9, 10, 11, or 12 units with each value being equally likely to occur. This is an example of a discrete uniform distribution. Now, use the formula =INT(8 + 5*RAND() ) to sample from a discrete uniform distribution on the integers 8, 9, 10, 11, 12 . Multiple trials can be performed by pressing the 29 recalculation key for the spreadsheet (e.g., F9).

Using this formula results in random demands.

=INT(8+5*RAND() )

Hitting the F9 key would result in a different sample of demands, and possibly a different NPV. The demands are random variables, therefore, the NPV 30 is also a random variable.

EVALUATING THE PROPOSAL Two questions need to be answered about the NPV distribution: 1. What is the mean or expected value of the NPV? 2. What is the probability that the NPV assumes a negative value (making the proposal to add the A3XX less attractive)? To answer these questions, a simulation model must be built. To run the simulation automatically and capture the resulting NPV in a separate spreadsheet, use the Data Table command.

31

The resulting analysis gives the estimated mean NPV and standard deviation.

Downside Risk and Upside Risk: To get a better idea about the range of possible NPVs that could occur, look 39 at the minimum and maximum NPVs.

In the resulting analysis, the Frequency (column B) indicates the number of trials that fell into the bins (categories) defined by column A.

The cumulative % column indicates the cumulative percentage of observations that fall into each category 41 or bin.

The histogram gives a visual representation of the distribution of NPVs. Note that it is somewhat bell shaped.

42

How Reliable is the Simulation? Now the two questions about the distribution can be answered:

1. What is the mean or expected value of the NPV?


In this trial, the mean is $12,100. 2. What is the probability that the NPV assumes a negative value (making the proposal to add the A3XX less attractive)? In this trial, the probability is <15%. The next questions to ask are: 1. How much confidence do we have in the answers from the first trial? 2. Would we be more confident if we ran more trials?
43

For a 95% confidence interval, the formula is:

estimated mean + 1.96(standard deviation)


In this case, the standard deviation is the standard error (the standard deviation divided by the square root of the number of trials). Based on this trial, the upper and lower confidence limits are: =$E$4-1.96*$E$8/SQRT($E$16)

=$E$4+1.96*$E$8/SQRT($E$16) So, we have 95% confidence that the true mean NPV is 44 somewhere between $9,679 and $14,521.

THE MODEL WITH RANDOM DEMAND It is unlikely that demand will be the same every year. A more realistic model would be one in which demand each year is a sequence of random variables. This model of demand is appropriate when there is a constant base level of demand that is subject to random fluctuations from year to year. Sampling Demand with a Spreadsheet: Assume initially that the demand in a year will be either 8, 9, 10, 11, or 12 units with each value being equally likely to occur. This is an example of a discrete uniform distribution.

45

OTHER DISTRIBUTIONS OF DEMAND Originally, we started with equal mean demands of 10 for each period (year). Then, we allowed for random variation in mean demand (between 8 and 12 units) and discrete distribution.

Now, assume the mean demand will stay the same over the next four years, somewhere between 6 and 14 units a year, with all values being equally likely. This scenario can be modeled as a continuous, uniform distribution between 6 and 14.
In addition, we can explore the impact of different demand distributions on the NPV.
46

MAINTAINANCE PROBLEM

47

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 Replacement Cycle that Begins with Breakdown

Replace a Motor Lost production during replacement Overhaul a motor Total

$2,000 5,000 4,000 48 $11,000

Probability Distribution of Breakdowns

Day 1, 2, 3 4

Probability of a Breakdown 0 0.25

Corresponding Random Numbers 0.0000 to 0.2499

5
6 7 or more

0.5
0.25

0.2500 to 0.7499
0.7500 to 0.9999

49

Computer Simulation of Corrective Maintenance


Breakdown Random Time Since Last Cumulative Number Breakdown Day Cost Cumulative Cost Distribution of Time Between Breakdowns Number Prob Cumu. Prob of Days no. 0.25 0.5 0.25 0 0.25 0.75 $11,000 4 5 6

1 2 3 4 5 6 7 8 9 10 26 27 28 29 30

0.1343 0.1523 0.9091 0.6161 0.6223 0.0026 0.6920 0.6155 0.7805 0.9189 0.6869 0.6415 0.3599 0.1493 0.4700

4 4 6 5 5 4 5 5 6 6 5 5 5 4 5

4 8 14 19 24 28 33 38 44 50 128 133 138 142 147

$11,000 $11,000 $11,000 $11,000 $11,000 $11,000 $11,000 $11,000 $11,000 $11,000 $11,000 $11,000 $11,000 $11,000 $11,000

$11,000 $22,000 $33,000 $44,000 $55,000 $66,000 $77,000 $88,000 $99,000 $110,000 $286,000 $297,000 $308,000 $319,000 $330,000

Breakd own Cost

Average Cost per Day $2,245

50

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 Replacement Cycle that Begins without a Breakdown Replace a motor on overtime Lost production during replacement Overhaul a motor before a breakdown Total $3,000 0 3,000
51

$6,000

Replace Motor on 4 Days


Cycle Random Number Time Until Scheduled Time Event That Cumulative Breakdown Until ReplacementConcludes Cycle Day Cost Cumulative Cost Distribution of Time Between Breakdowns

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

0.3926 0.4904 0.8207 0.6811 0.1084 0.1032 0.5737 0.0718 0.5408 0.9918 0.9948 0.1657 0.1035 0.3365 0.1650 0.4908 0.0267 0.1388 0.9297 0.5908 0.1035 0.6132 0.5361 0.0726 0.0593 0.7241 0.3092 0.4092 0.2356 0.6483

5 5 6 5 4 4 5 4 5 6 6 4 4 5 4 5 4 4 6 5 4 5 5 4 4 5 5 5 4 5

4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4

Replacement Replacement Replacement Replacement Breakdown Breakdown Replacement Breakdown Replacement Replacement Replacement Breakdown Breakdown Replacement Breakdown Replacement Breakdown Breakdown Replacement Replacement Breakdown Replacement Replacement Breakdown Breakdown Replacement Replacement Replacement Breakdown Replacement

4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120

$6,000 $6,000 $6,000 $6,000 $11,000 $11,000 $6,000 $11,000 $6,000 $6,000 $6,000 $11,000 $11,000 $6,000 $11,000 $6,000 $11,000 $11,000 $6,000 $6,000 $11,000 $6,000 $6,000 $11,000 $11,000 $6,000 $6,000 $6,000 $11,000 $6,000

$6,000 $12,000 $18,000 $24,000 $35,000 $46,000 $52,000 $63,000 $69,000 $75,000 $81,000 $92,000 $103,000 $109,000 $120,000 $126,000 $137,000 $148,000 $154,000 $160,000 $171,000 $177,000 $183,000 $194,000 $205,000 $211,000 $217,000 $223,000 $234,000 $240,000

Probability 0.25 0.5 0.25 Breakdown Cost Replacement Cost Replace After

Number Cumulative of Days 0 4 0.25 5 0.75 6 $11,000 $6,000 4 days

52
Average Cost per Day $2,000

Replace Motor After 5 Days


Cycle Random Number Time Until Breakdown Scheduled Time Until Replacement Event That Concludes Cycle Cumulative Day Cost Cumulative Cost Distribution of Time Between Breakdowns

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

0.3543 0.2204 0.0583 0.8282 0.9815 0.4620 0.7658 0.4318 0.8745 0.9448 0.0987 0.5796 0.7489 0.2480 0.5809 0.9055 0.5844 0.0157 0.0949 0.1892 0.9239 0.1051 0.8739 0.5229 0.6667 0.3945 0.7721 0.2253 0.6972 0.5078

5 4 4 6 6 5 6 5 6 6 4 5 5 4 5 6 5 4 4 4 6 4 6 5 5 5 6 4 5 5

5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5

Breakdown Breakdown Breakdown Replacement Replacement Breakdown Replacement Breakdown Replacement Replacement Breakdown Breakdown Breakdown Breakdown Breakdown Replacement Breakdown Breakdown Breakdown Breakdown Replacement Breakdown Replacement Breakdown Breakdown Breakdown Replacement Breakdown Breakdown Breakdown

5 9 13 18 23 28 33 38 43 48 52 57 62 66 71 76 81 85 89 93 98 102 107 112 117 122 127 131 136 141

$11,000 $11,000 $11,000 $6,000 $6,000 $11,000 $6,000 $11,000 $6,000 $6,000 $11,000 $11,000 $11,000 $11,000 $11,000 $6,000 $11,000 $11,000 $11,000 $11,000 $6,000 $11,000 $6,000 $11,000 $11,000 $11,000 $6,000 $11,000 $11,000 $11,000

$11,000 $22,000 $33,000 $39,000 $45,000 $56,000 $62,000 $73,000 $79,000 $85,000 $96,000 $107,000 $118,000 $129,000 $140,000 $146,000 $157,000 $168,000 $179,000 $190,000 $196,000 $207,000 $213,000 $224,000 $235,000 $246,000 $252,000 $263,000 $274,000 $285,000

Probability 0.25 0.5 0.25

Number Cumulative of Days 0 4 0.25 5 0.75 6

Breakdown Cost $11,000 Replacement Cost $6,000 Replace After 5 days

Average Cost per Day $2,021 53

Inventory Problem
The daily demand of an item has the following distribution:
Demand per day (units)
No. of days on which demand occurred

0
4

1
10

2
15

3
39

4
22

5
10

When an order is placed to replenish inventory there is a delivery time lag, which follows the following distribution:
Lead time (days) No. of times of occurrence 2 24 3 12 4 4

The management is of the opinion that proportion of stockouts should not exceed 5%.
54

Queuing Problem

55

Single server queue


A small grocery store with just one checkout counter Interarrival time uniform between 1-8 mins Service time varies between 1-6 mins. Probability distribution given. The problem is to analyze the system by simulating the arrival and service of 20 customers.
56

Given distributions
Service Times (Minutes) 1 2 3 4 5 6 Probability 0.10 0.20 0.30 0.25 0.10 0.05 Cumulative Probability 0.10 0.30 0.60 0.85 0.95 1.00

Interarrival Times (minutes) Minimum 1 Maximum 8

Uniform

57

Simulating of a M/M/1 Queue


Assume a small branch office of a local bank with only one teller. Empirical data gathering indicates that inter-arrival and service times are exponentially distributed.
The average arrival rate = l = 5 customers per hour The average service rate = m = 6 customers per hour

Using our knowledge of queuing theory we obtain


= the server utilization = 5/6 0.83 Lq = the average number of people waiting in line Wq = the average time spent waiting in line
Lq = 0.832/(1-0.83) 4.2 Wq = Lq/ l 4.2/5 0.83

How do we go about simulating this system?


How do the simulation results match the analytical ones?
58

NEWSPAPER BOY PROBLEM

59

Newspaper Boy Problem


Newsvendor sells newspapers on the street Buys for c = $0.55 each, sells for r = $1.00 each Each morning, buys q copies q is a fixed number, same every day Demand during a day: D = max (X, 0) X ~ normal (m = 135.7, s = 27.1), from historical data X rounds X to nearest integer If D q, satisfy all demand, and q D 0 left over, sell for scrap at s = $0.03 each If D > q, sells out (sells all q copies), no scrap But missed out on D q > 0 sales What should q be? 60

Newspaper Boy Problem Formulation


Choose q to maximize expected profit per day q too small sell out, miss $0.45 profit per paper q too big have left over, scrap at a loss of $0.52 per paper Classic operations-research problem Many versions, variants, extensions, applications Much research on exact solution in certain cases But easy to simulate, even in a spreadsheet Profit in a day, as a function of q: W(q) = r min (D, q) + s max (q D, 0) cq
Sales revenue Scrap revenue

Cost

W(q) is a random variable profit varies from day to day Maximize E(W(q)) over nonnegative integers q
61

Steps: Newspaper boy Problem Simulation


Set trial value of q, generate demand D, compute profit for

that day
Then repeat this for many days independently, average to estimate E(W(q)) Also get confidence interval, estimate of P(loss), histogram of W(q) Try for a range of values of q Need to generate demand D = max (X, 0) So need to generate X ~ normal (m = 135.7, s = 27.1) Demands = MAX(ROUND(NORMINV(RAND(),, ), 0)
62

Advantage of Simulation
1. It is particularly well-suited for problems that are difficult or impossible to solve mathematically.
2. It allows an analyst or decision maker to experiment with system behavior in a controlled environment instead of in a real-life setting that has inherent risks. 3. It enables a decision maker to compress time in order to evaluate the long-term effects of various alternatives. 4. It can serve as a mode for training decision makers by enabling them to observe the behavior of a system under different conditions.
63

Limitations of Simulation
1. Probabilistic simulation results are approximations, rather than optimal solutions. 2. Good simulations can be costly and time-consuming to develop properly; they also can be time-consuming to run, especially in cases in which a large number of trials are indicated. 3. A certain amount of expertise is required in order to design a good simulation, and this may not be readily available. 4. Analytical techniques may be available that can provide better answers to problems.
64

THANK YOU

65

Вам также может понравиться