37
Simulation modelling real processes to make predictions

Simulation modelling real processes to make predictions

Embed Size (px)

DESCRIPTION

D. Goforth, COSC 2006, fall Simulation topics – example Self-serve gas station

Citation preview

Page 1: Simulation modelling real processes to make predictions

Simulation

modelling real processes to make predictions

Page 2: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 2

Simulation topics industrial processes information systems transportation systems environments for people

Page 3: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 3

Simulation topics – exampleSelf-serve gas station

Page 4: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 4

Simulation topics – exampleSelf-serve gas station

service

queue

Page 5: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 5

Simulation topics – exampleSelf-serve gas station 5 services, 3 queues data gathered:

length of queues waiting time

(customers) idle time (servers)

Page 6: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 6

Simulation topics – exampleSelf-serve gas stationhow good is service: average waiting time longest waiting time time pumps idle time cashier idle average queue length maximum queue

length

Page 7: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 7

Simulation topics – exampleSelf-serve gas stationplans: add pumps? add another cash? change layout?

Page 8: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 8

Typical simulation scenario proposal to build new service station:

how many pumps? cashiers? what layout? from market study:

expected customer numbers input to simulation simulation:

try different layouts, number of pumps, cashiers service levels and costs output from simulation

decide station design

Page 9: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 9

Typical simulation dataScenario Avg

serviceMaxservice

pumpsidle

cashiersidle

2 pumps1 cash

14 min 21 min 8% 19%

2 pumps2 cash

13 min 19 min 8% 57%

4 pumps1 cash

8 min 20 min 52% 14%

4 pumps2 cash

6 min 12 min 50% 47%

Page 10: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 10

Designing simulations processing objects (cashiers, pumps) objects to be processed

(customers/cars) queues for objects awaiting

processing (lines of cars, line of people)

what properties do objects need to have?

Page 11: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 11

Designing simulations properties of objects processed

related to timing in simulation: colour of car? NO amount of gas pumped? YES

data to keep about objects processed arrival time (join a queue) begin service time (leave queue, start service) end service time

Page 12: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 12

Designing simulations input required:

data about service (how long to pump n litres, how long to process payment at cash)

rate of arrival of objects to process (how many cars per hour)

litres of gas per car

Page 13: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 13

Designing simulations Running simulation of a time period

randomize activity based on input data: arrival rate of cars size of gas purchase time to pump gas time to pay at cash

Page 14: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 14

Designing simulations Gather data

(simulated) times of events for each object processed and each processing object

(customer arrives, customer starts pumping, cashier starts to process a sale, etc.)

Page 15: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 15

Designing simulations Analyzing data after simulation

cumulative times, average times, extreme times

(total time cashier working, average time customer at station, longest wait before starting to pump gas)

Page 16: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 16

Designing simulations Timing in a simulation

‘clock’ runs for a time interval to simulate a period of operation

events occur at a specific time two models of timing in simulations

‘clock driven’ – every second is simulated

‘event-driven’ – only analyze times when an event happens; skip over other times

Page 17: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 17

Designing simulations models of timing

clock driven

event-driven

Page 18: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 18

Designing simulations What is an event?

‘instantaneous’, not an interval events at beginning and end of interval e.g.: joining a queue is an event

leaving a queue is an eventwaiting in a queue is NOT an event

e.g.: starting to pump gas is an eventfinishing pumping is an eventpumping gas is NOT an event

Page 19: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 19

Designing simulations example of events

events for a customer

arrive at station and join queue

leave queue and

start pumping

gas

finish pumping

and line up to pay

leave queue

and start payment

finish paying

and return to

car leave

station

Page 20: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 20

Another example:Bookstore checkout

one line-up of customers and many cashiers question: how many cashiers should be

working simulate level of service with n = 2,3,4

Page 21: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 21

Bookstore checkout objects

Queue w Customer CashierStation s[i] EventQueue Event

1.2.

3.

w s[2]s[1]s[0]

Page 22: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 22

Bookstore checkout Events:

1. arrival: customer arrives at checkout area (joins queue)

2. beginService(k): customer leaves queue, goes to cashier k

3. endService(k): customer finishes purchase at cashier k and leaves store

1.2.

3.

w s[2]s[1]s[0]

Page 23: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 23

Event arrival create c = new Customer object insert c into Queue schedule arrival event if some s[k] is not busy, schedule

beginService(k)

1.2.

3.

w s[2]s[1]s[0]c

Page 24: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 24

Event beginService(k) getFront cNext from Queue put cNext in s[k] make s[k] busy schedule endService(k) event

1.2.

3.

w s[2]s[1]s[0]

cNext

Page 25: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 25

Event endService(k) remove Customer from s[k] make s[k] idle if (w not empty) schedule

beginService(k) event

1.2.

3.

w s[2]s[1]s[0]

Page 26: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 26

The main algorithm of simulationsimulation (endTime)

EventQueue q;Event f = new Event(arrival)q.insert(f)while ( q not empty and not endTime)

Event e = q.getFront()process(e) // includes scheduling other

eventsanalyze statistics

Page 27: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 27

Bookstore checkout Input data

frequency of customer arrival time for cashier to serve a customer

1.2.

3.

w s[2]s[1]s[0]

Page 28: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 28

Bookstore checkout frequency of customer arrival

simple model – uniform distribution of time between arrivals

e.g. if range is [5, 15] customer arrives between 5 and 15 seconds after previous customerif arrival time of one customer is 432, the next arrival could be scheduled for 432 + 9(random in 5,15) = 441

Page 29: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 29

Bookstore checkout time for cashier to serve a customer

same simple model – uniform distribution of time for service

e.g. if range is [10, 40] customer remains at cashier station for a random time between 10 & 40 secondsif beginService of a customer is at 304, endService could be scheduled for 304 + 29(random in 10,40) = 333

Page 30: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 30

EventQueue manages the sequence of events in

the simulation

duration of simulation

processed events currentevent

events scheduled but not processed yet

Page 31: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 31

EventQueue - exampletwo events on event queuecurrent event: arrival(135)

currentevent

events scheduled but not processed yet

135 141 144

in arrival:• schedule next arrival at 148

• some cashier s[k] is idle soschedule beginService at 135

135 141 144 148

135 141 144 148135

Page 32: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 32

Bookstore checkout analyzing service

arrival beginService

endService

service timefrom inputwaiting?

Page 33: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 33

Data in simulation objects Customer object

goal: analyze ‘experience’ of customer store times:

arrivalTime beginServiceTime endServiceTime

Page 34: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 34

Data in simulation objects Cashier object

goal: analyze ‘busyness’ store data:

currentCustomer totalIdleTime // accumulate time without customer isIdle // boolean, busy or not lastEndServiceTime

// used in beginService to calculate last period of idleness

Page 35: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 35

Data in simulation objects Event object

goal: activity store data:

time eventType // arrival, beginService or endService cashierIndex // which cashier (for service events only)

Page 36: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 36

Data in simulation objects CashierSimulation object (main program)

goal: the big picture store data:

parameters(arrival constants, simulation duration, etc)

customerCount totalWaitTime maxWaitTime queues (next slide)

Page 37: Simulation modelling real processes to make predictions

D. Goforth, COSC 2006, fall 2003 37

Data in simulation objectsqueues: Waiting queue:

Customer objects Event queue

Event objects in time priority