Upload
neil-blankenship
View
219
Download
0
Embed Size (px)
DESCRIPTION
D. Goforth, COSC 2006, fall Simulation topics – example Self-serve gas station
Citation preview
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
D. Goforth, COSC 2006, fall 2003 3
Simulation topics – exampleSelf-serve gas station
D. Goforth, COSC 2006, fall 2003 4
Simulation topics – exampleSelf-serve gas station
service
queue
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)
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
D. Goforth, COSC 2006, fall 2003 7
Simulation topics – exampleSelf-serve gas stationplans: add pumps? add another cash? change layout?
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
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%
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?
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
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
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
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.)
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)
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
D. Goforth, COSC 2006, fall 2003 17
Designing simulations models of timing
clock driven
event-driven
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
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
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
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]
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]
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
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
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]
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
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]
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
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
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
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
D. Goforth, COSC 2006, fall 2003 32
Bookstore checkout analyzing service
arrival beginService
endService
service timefrom inputwaiting?
D. Goforth, COSC 2006, fall 2003 33
Data in simulation objects Customer object
goal: analyze ‘experience’ of customer store times:
arrivalTime beginServiceTime endServiceTime
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
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)
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)
D. Goforth, COSC 2006, fall 2003 37
Data in simulation objectsqueues: Waiting queue:
Customer objects Event queue
Event objects in time priority