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

A simple example

Manual simulation of a supermarket checkout line

Simulation

Outline Checkout queue: problem statement Checkout queue model and mode of operation Manual simulation Simulation ideas and simulation algorithm Parameters and metrics Interpretation of simulation results

Simulation

Supermarket Model
Customers come by car which they park at the parking lot- or on foot to the supermarket They shop for a certain average time, some of them visit the butcher, others the info-desk. Then they choose a pay desk, wait their turn in the checkout queue, pay and leave the supermarket.

Simulation

Supermarket Model

Simulation

Checkout queue: Problem statement (1/2) Task: performance evaluation of a checkout counter in a store Objectives: determine

How long do customers have to wait? How many customers are in line? How much of the time is the cashier busy?

Simulation

Checkout queue: Problem statement (2/2)


What are relevant objects?

The person at the counter People waiting in line


How do customers arrive at the queue? How long does it take to serve a customer? How is the queue organized?

What are relevant parameters?

Metrics = objectives in this example

Simulation

Outline Checkout queue: problem statement Checkout queue model and mode of operation Manual simulation Simulation ideas and simulation algorithm Parameters and metrics Interpretation of simulation results

Simulation

Checkout queue: Model


New customers Queue

Server

Customer leave system

Customers in queue

Served customer

Simulation

How does checkout queue work? Server is idle (no customer present)

If customer arrives, customer is serviced

immediately, until completion Server is then busy until customer is completely served

Server is busy

If customer arrives, the customer joins the end


If one or more customer wait in queue, the first customer leaves the queue and is now serviced If no customer in queue, the server becomes idle
Simulation 9

of a queue When server becomes idle (a customer has been finished), server checks the queue

Outline Checkout queue: problem statement Checkout queue model and mode of operation Manual simulation Simulation ideas and simulation algorithm Parameters and metrics Interpretation of simulation results

Simulation

10

Checkout queue simulation (1)


Let us start the simulation at T = 0 Initially, the server is idle, no customers are waiting Observe the model in its operation as customers enter and leave the queue - the model changes its state At some point in time, a customer A arrives, say T =2.1
Clock
0

Arrival of A 2.1

Simulation

11

Checkout queue simulation (2)


Now, at T =2.1, the server is busy Assume this customer needs 1.2 time units to be served
1.2

Clock Departure of A

2.1 3.3 A

At T =3.3, the customer leaves the system The queue is empty, the server becomes idle again
Clock 3.3

Arrival of B 4.5

Simulation

12

Checkout queue simulation (3)


At T = 4.5, the next customer B arrives. The server is idle, the customer begins service immediately, the server is then busy. Assume this customer needs 3.7 time units for service
Clock 4.5
3.7

Arrival of C 8.2 Departure of B 4.9 Departure of B 8.2

At T=4.9, the next customer C arrives at the counter. Server is busy, customer joins the queue Assume this customer will need 1.8 time units for service
Clock
Departure of B 4.9 8.2
1.8 3.7

Simulation

13

Checkout queue simulation (4)


When does the customer C start service? At the time when serviced customer (customer B) will finish B arrived at 4.5, it will take 3.7 time units, so B will leave at T = 4.5 + 3.7 = 8.2 Let us write down the time the currently serviced customer will finish (= time the server can accept the next customer) and the server state Let us assumed that D is planned to arrive at 5.6
Will finish: 8.2
1.8 3.7

Clock

4.9 C B Busy, serving B


Simulation 14

Arrival Departure of B 8.2 of D 5.6 Departure of B 8.2

Checkout queue simulation (5)


Customer D arrives at T =5.6 (requiring 3.5 units of service time)? At that time the server was busy Let us write down the time of this event and the clock

Will finish: 8.2


3.5 1.8 3.7

Clock Departure of B

5.6 8.2

B Busy, serving B

Simulation

15

Checkout queue simulation (6)


The the next customer E will arrive at T = 9.3 But that is only after the second customer has already finished its service So have a look first what happens at T =8.2, then consider the next event At 8.2, customer B leaves system
Will finish: N/A
3.5 1.8

Clock

8.2

B Customer B leaves

Simulation

16

Checkout queue simulation (7)


and customer C is taken to service which will be finished at T = 8.2 + 1.8 = 10 What will happen next? Customer E will arrive or C will leave? Let us write down the time of the next customer arrival Compare the time the current customer will finish with the time the next customer will arrive. Next event that changes the state of the model is the arrival of a new customer at t=9.3
Will finish: 10
Clock 8.2
3.5 1.8

Departure of C 9.3 Arrival of E 10.

C Busy, serving B

Departure of C

10.
Simulation 17

Checkout queue simulation (8)


Set the clock to this time and update the state At T =9.3, customer E arrives and is put into the queue Write down the arrival of the next customer F at T =12.3 Next event to process is finish of customer C service at T=10

Will finish: 10
0.7
3.5 1.8

Clock Departure of C Arrival of F

9.3 10.0 12.3


Simulation

C Busy, serving B
18

Checkout queue simulation (9)


C finishes, remove D from queue and put it on the server Write down the finish time of D. Next event would be at T = 12.2, arrival of a new customer F

Will finish: 13.5


0.7
3.5

Clock Arrival of F

10 12.3 13.5
Simulation

D
Busy, serving D
19

Departure of D

Outline Checkout queue: problem statement Checkout queue model and mode of operation Manual simulation Simulation ideas and simulation algorithm Parameters and metrics Interpretation of simulation results

Simulation

20

Checkout queue : Simulation Ideas (1)


We observed the model only at the points in time when the state of the model changed These points in time were explicitly represented by the simulation clock variable The state of the model changed due to two different kinds of events:

Arrival of customers Customers finishing service and leaving the server

Both kinds of events were processed/the state was manipulated according to the algorithm describing the model (see. Slide 9)
Simulation 21

Checkout queue : Simulation Ideas (2)


Two variables were used to determine which kind of event is the next one (arrival or departure of customer) We advanced time from one event to the next, checking to see which kind of event would be the next one .This is the essence of the next-event time advance algorithm Time was increment as necessary, not in fixed amounts Result: periods of inactivity are skipped with nextevent algorithms
Simulation 22

Next-event Time-Advance Algorithm


Initialize simulation clock to 0 Determine times of occurrence of future events (might be infinite for some events)

Might be arbitrarily many stored in the future event list Increment the simulation clock to the time of the next, closest event Update the system state as required by the occurrence of this event (usually done by an event routine specific for each kind of event) Compute times for future events
e0 e1 e2 e3 e4 e5

As long as there are events to be processed

events Random customer interarrival times Random Service times

t1

t2

c1

t3

c2

Time

A1

A2

A3

S1 Simulation

S2 23

Simulated Time and Simulation Time Simulated time: The time as measured by the simulation clock, virtual time within the simulated system. Simulation time: Time that is necessary to run a given simulation. Depends on parameters, models, equipment used, accuracy,

Simulation

24

Outline Checkout queue: problem statement Checkout queue model and mode of operation Manual simulation Simulation ideas and simulation algorithm Parameters and metrics Interpretation of simulation results

Simulation

25

Checkout queue: Parameters


Pattern of customer arrival

Stochastic modeling: consider the time between customers as a random variable, choose a suitable distribution for this variable Common case: interarrival time of customers is exponentially distributed, characterized by the distributions mean Principles of the distribution choice and random variable generation will be discussed later in this course

Pattern of service times

Similar to arrival patterns

Speed of the server

Simulation

26

Checkout queue: Metrics


Initial goal was to investigate Utilization of the server (what percentage of time is the server busy) Length of the queue (how much space do we need in the store?)

What does it mean? At most? On average? Again: At most? On average? Weekends?

Waiting time of customers How to capture this information from a simulation?

Simulation

27

Metrics: Server Utilization


1 if the server is busy at time t B(t ) 0 if the server is idle at time t
For n-th run

u(n)

T (n)

B (t )dt

T (n )

Simple to measure the absolute time the server has been busy, and at the end divide it by the total time that has been simulated Think of implementation

Simulation

28

Metrics: Customer Waiting Time


How much time does a customer spend in the queue? When putting customer in queue, mark it with the time this was done When retrieving customer from queue, take difference between current simulation clock and time of entry into queue If customer does not enter queue, waiting time is 0 Build the average

Let Di stand for the delay of customer i (possibly 0) Compute the usual arithmetic average of the Di - s

Simulation

29

Metrics: Queue Length


Discrete-valued function over time, changing at arbitrary points in time (customers joining and leaving) Average it over time
Q(t) 3 2 1 1
e1=t1

0 Arrivals

2
e2=t2 e3=t3

4
e8=t5 e7=t4 e6=c3

7
e12=t8

e11=t7 e10=t6

Departures

e4=c1

e5=c2

e9=c4

e13=c5

Simulation

30

Different kinds of metrics


Average waiting time of customers

Average is taken over a discrete set of individuals Measured value is time Example for discrete-time metric (or statistic) Average is continuously taken over time Measured value is a number, a discrete metric Example for continuous-time metric (or statistic)

Average queue length

Simulation

31

Outline Checkout queue: problem statement Checkout queue model and mode of operation Manual simulation Simulation ideas and simulation algorithm Parameters and metrics Interpretation of simulation results

Simulation

32

Meaning of Measurements
What is the correct interpretation of simulationbased measurements? Waiting time in queue:

Let Di represent the waiting time as measured for customer i This refers to one particular simulation run or to observations on one particular day. For different simulations/on different days, the Di s will be different D are averaged over n customers to obtain aggregate information : average waiting time in queue Other possible aggregations: max, min, percentiles, Both Di s and their aggregate will change from one set of observations to the next
Simulation 33

Meaning of Measurements
Why look at aggregated information of measurements? Aggregated information gives a more concise representation/description of the system under study It is easier to compare aggregated information from different system/simulation runs

The average waiting times in a supermarket on weekdays as opposed to Saturdays is more informative than waiting times of individual customers Variance Percentile

Average not always the best aggregated information

Simulation

34

Meaning of Measurements
Succeeding values might not be distributed in the same way

In the queuing example, D1 is always 0, whereas D2, D3, etc. are not Transient and steady-state periods of simulation

Hence, the average of such values are not the usual statistical average which is usually computed over independent, but identically distributed observations

Simulation

35

Meaning of Measurements
The truly typical (in a statistical sense) behavior of the model can be considered to be the average over all possible behaviors the model can exhibit Weighted by the probabilities of these behaviors
Average ^ Estimates

Di d ( n ) d ( n )
n observations from one run Estimator for true behavior Statistically typical behavior

How to improve the estimation? Will be discussed further in this course


Simulation 36

How long the simulation should be run


Fixed duration: Simulate for a certain fixed amount of simulated time (or a fixed number of events)

Problem: quality of estimations is variable

Variable duration: Simulate as long as it takes for the estimation of the metrics of interest to reach a desired quality level. How long? Stopping rules will be discussed later

Simulation

37

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