ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1...

57
ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439 [email protected]

description

What is simulation? Wikipedia says: “Simulation is the imitation of the operation of a real-world process or system over time. The act of simulating something first requires that a model be developed; this model represents the key characteristics or behaviors/functions of the selected physical or abstract system or process. The model represents the system itself, whereas the simulation represents the operation of the system over time.” 3

Transcript of ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1...

Page 1: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

ENM 307 Simulation

Department of Industrial EngineeringAnadolu University

SPRING 2016Chapter 1

Basic Simulation Modeling

Onur KayaEND 201, Ext: 6439

[email protected]

Page 2: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

Some questions

• What comes to your mind when you hear the word “simulation”?

2

Page 3: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

What is simulation?

• Wikipedia says:“Simulation is the imitation of the operation of a real-world process or system over time. The act of simulating something first requires that a model be developed; this model represents the key characteristics or behaviors/functions of the selected physical or abstract system or process. The model represents the system itself, whereas the simulation represents the operation of the system over time.”

3

Page 4: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

4

Page 5: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

Some questions

• What comes to your mind when you hear the word “simulation”?

• Have you seen simulations in your life before?

5

Page 6: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

Examples

• Computer games?

6

Page 7: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

Some questions

• What comes to your mind when you hear the word “simulation”?

• Have you seen simulations in your life before?• Why do you think we need simulation in IE?

7

Page 8: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

How would you calculate how much you are going to wait in a queue?

• Any assumptions?• Are they valid?• How can we check their validity?

Page 9: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

How would you calculate how much you are going to wait in queues if you visit

Disneyland?

Page 10: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

A queueing network?

• How to analyze them analytically?• Assumptions?

Page 11: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

More questions on

• If you are a visitor: • How would you calculate how much you are going to

wait in queues?• …

• If you are a manager of Disneyland: • How would you calculate the effect of having one

more attraction point on the queue lengths of all other points?

• If you are a manager of Disneyland: How would you decide on the effects of the entrance prices?

• …

Page 12: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

Other complicated systems?• Hospitals• Factories• Inventory systems• Project Management• Logistics, supply chain and distribution systems• Transportation models and traffic• Biological and cellulary systems• Risk analysis in finance, insurance, options pricing,

portfolio analysis etc.• Call centers• Large scale systems such as internet backbone, wireless

networks etc.• …..• http://wintersim.org

Page 13: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

13

The Nature of Simulation

• Most real-world systems are too complex to allow realistic models to be evaluated analytically. These models are usually studied by means of simulation.

• First, see whether you can solve the problem analytically; if you cannot, then use simulation.

• Simulation is the technique that imitates the operations of a complex real-world system where a computer is generally used to evaluate a model numerically, and data are gathered in order to estimate the desired true characteristics of the model.

Page 14: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

The Nature of Simulation

• Statistical analysis often uses data that is gathered in the past. Simulation is based on statistical analysis of data that is generated on the future observations of a system by imitating its operations.

• Simulation is one of the most widely used techniques in operations research, management science and industrial engineering.

14

Page 15: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

15

Advantages

• Simulation is often the only type of investigation for complex real-world systems with stochastic elements that cannot be analytically evaluated.

• It allows one to estimate the performance of a system under a projected set of operating conditions.

• Alternative proposed system designs or alternative operating policies can be compared via simulation.

• There is better control over experimental conditions in simulation than there is in experimenting with the system itself.

• Simulation allows one to study the system with a long time frame due to time compression.

Page 16: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

16

Page 17: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

17

Page 18: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

18

Page 19: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

19

Page 20: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

20

Disadvantages

• Each run of a simulation run provides an estimate and not the exact value of model characteristics. An analytical model and its solution, if available, is always preferable.

• Simulation models are often expensive and time-consuming to develop.• The large volume of numbers produced or the persuasive impact of a realistic

animation often creates a tendency to place more confidence in the results than it is justified.

Page 21: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

21

Page 22: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

22

Page 23: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

23

Pitfalls

• Failure to have a well-defined set of objectives• Inappropriate level of model detail• Failure to communicate with management• Misunderstanding of the simulation by management• Treating simulation as a computer programming exercise• Lack of simulation methodology and statistics knowledge• Failure to collect good system data• Inappropriate simulation software• Using software packages without knowing what it is really doing• Belief that easy-to-use simulation packages require lower level of

technical competence

Page 24: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

24

Pitfalls

• Misuse of animation• Failure to understand sources of randomness• Using arbitrary distributions• Analyzing the output data from only one simulation run

(replication)• Treating the output values as true values and not

estimates• Comparing alternatives based on one replication• Using the wrong performance measures

Page 25: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

Which is more likely?

• Getting a sum of 7 or 8 when two dice are rolled?• Getting a 1 or 2 when a single die is rolled?

• We can easily find the probability of each event and compare.

• But let’s try to simulate:– We need two dice!

• Since we don’t have a die we need to simulate the dice on a computer.

25

Page 26: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

Which is more likely?

• To estimate probabilities we need to roll the dice several times.

• To estimate the probability exactly we need to roll the die infinitely many times but this is impractical even for a computer.

• We’ll roll a finite number of times and then perform a statistical analysis.

26

Page 27: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

Why are most simulation examples much more complicated?

• The input model is more complicated and requires estimation itself – i.e. number of patients arriving to an emergency room in a certain time interval

• The process is much more complicated– Patients are seen by a nurse and directed to a room (if available)– The best doctor available has to be directed (she may be busy consulting other patients)– The doctor’s exam may take a random amount of time.– The next step depends on the exam…

• We need to emulate the dynamics and then replicate several times for statistical analysis.

27

Page 28: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

28

Examples

• Designing and analyzing manufacturing systems• Determining hardware and software requirements for

communications networks• Determining hardware and software requirements for computer

systems• Designing and operating transportation systems like airports,

freeways, ports and subways• Evaluating designs and operations of service systems like

hospitals, call centers, post offices• Reengineering of business processes• Determining ordering policies for inventory systems• Analyzing financial or economic systems

Page 29: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

29

Systems, Models and Simulation

• System: a collection of entities (like people or machines) that act and interact together toward the accomplishment of some logical end.

• State: the collection of variables necessary to describe a system at a particular time. For example, number of customers at 10:30 on a summer day in each attraction point and the ticket box office of Disneyland Paris.

Page 30: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

30

The systems approach

Page 31: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

31

Page 32: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

32

Page 33: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

33

Simulation Model Classification • static if it represents the system at a particular time (often

called Monte Carlo models) or dynamic if it represents a system that changes in time.• The two dice are static

• deterministic if all components are known with certainty or stochastic if there are random components.

A system is said to be • discrete if the state variables change instantaneously at

separated points in time (Number of customers in a service system, number of machines working in a manufacturing system),

• continuous if the state variables change continuously in time (The level of water in a dam, price of a share of stock).

Page 34: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

34

Page 35: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

35

Page 36: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

36

Page 37: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

37

Page 38: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

A static simulation• Simulating the roll of two dice.• Let U be a continuous random variable in the interval

(0,1).• Then 6U is a continuous random variable in the interval

(0,6).• Define FLOOR(x) as the largest integer that is less than

or equal to x.• Then FLOOR(6U)+1 is a discrete random variable that

has the same probability mass function as the number in the roll of a single die!

• Estimate the expected value of the sum of the numbers that show up when two dice are rolled by simulation.

• Estimate the probability of getting a sum of 7.

Page 39: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

Simulating Dynamic Systems

• In dynamic systems, uncertainty has combined or accumulated events over time: this is more complicated to handle.

• Most of this course focuses on modeling and simulating discrete-event dynamic systems where arrivals take place at distinct points in time: arrivals and departures from a queue, arrival of a call to a call center, arrival of an ambulance to an emergency room, process completion of a part in a job-shop etc.

Page 40: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

40

Discrete-Event Simulation

• Discrete-event simulation concerns the modeling of a system as it evolves over time by a representation in which the state variables change instantaneously at separate points in time.

• Examples: Disneyland, hospitals, factories, airports … Many systems that falls into the working interest of IEs

• We will start with one of the simplest such systems: a single server queue…

Page 41: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

41

Page 42: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

42

Page 43: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

43

Page 44: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

44

Simulation Clock

In a simulation, the simulation time or clock can be advanced in two ways:

• Next-event time advance (the clock advances instantaneously to the time of the next possible event)

• Fixed-increment time advance (the clock advances instantaneously for a predetermined fixed amount)

Page 45: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

45

Queueing System Example

For a queuing system, the mathematical model consists of the following variables:

• ti = time of arrival of the ith customer (t0 = 0) • Ai = ti – ti-1 = interarrival time between (i-1)st and

ith customers • Si = service duration of the ith customer • Di = delay in queue of the ith customer • ci = ti + Di + Si = departure time of the ith customer • ei = time of occurrence of the ith event of any type

(ith value of the simulation clock, e0 = 0)

Page 46: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

46

Next-Event Time Advance Illustration

Generated by computer

Page 47: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

47

Page 48: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

48

Page 49: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

49

Page 50: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

A single server queuing system

• Aim: To estimate the expected delay (waiting time) in queue (line) of arriving customers and the utilization of the server.

• The states of this system are:– Status of the server (busy (1) or idle (0))– The number of customers in the queue– The time of arrival of each customer in the queue

• The system state changes due to the following two possible events:– Arrival of a customer– Departure of a customer due to service completion

• This is in general a dynamic stochastic model since the state variables change over time in a random fashion.

Page 51: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

51

Page 52: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

52

Page 53: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

53

A deterministic queue

3 4 7 8 11 12 15 16 t

N(t)

Customers arrive every 4 minutes, each service time is three minutes. Let us assume that at time 0-, the system is empty and that the first arrival takes place at time 0. Let us simulate for 16 minutes.

Page 54: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

54

A deterministic queue: performance measures

12)(16

0

dttN

16

)()(16

00

dttN

T

dttNn

T

3 4 7 8 11 12 15 16 t

N(t)

Average number of customers in the system:

43

1612

n

Page 55: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

55

A deterministic queue: performance measures

416

0}0)({ dtI tN

16

16

0}0)({

0}0)({

0

dtI

T

dtIp

tN

T

tN

3 4 7 8 11 12 15 16 t

N(t)

Percentage of time server is idle:

41

164

p

Page 56: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

56

Adding a small randomness

• Arrivals occur every 4 minutes but the service time is a random variable P{S=1}=1/2 and P{S=5}=1/2.

• The simulation becomes much more difficult. • Q(t) is now a stochastic process.• There are several sample paths that can take place in the first 16 minutes.• In fact, if S were a continuous random variable, there would be infinitely many sample paths.• Generating the next event is not trivial.

Page 57: ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.

57

Generating a sample pathLet S1=5, S2=5, S3=1, S4=5 and simulate for T=15 minutes

Time Event N(t) B(t) Q(t)

0 A1 1 1 0

4 A2 2 1 1

5 D1 1 1 0

8 A3 2 1 1

10 D2 1 1 0

11 D3 0 0 0

12 A4 1 1 0

15 End 1 1 0

1517

15

)(

171)1215(0)1112(1)1011(2)810(1)58(2)45(1)04()(

15

0

15

0

dttNn

dttN