0% found this document useful (0 votes)
12 views

Lecture - 4

Uploaded by

omerfaruk200141
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Lecture - 4

Uploaded by

omerfaruk200141
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 32

Lecture 4: Introduction to Discrete Event Simulation

END 322E System Simulation Mehmet Ali Ergün, Ph.D.

1
Introduction

❖ We will see some simulation examples that can be performed via using a
simulation table
❖ By hand
❖ Spreadsheet
❖ The simulation table provides a systematic method for tracking system state
over time
❖ Provide insights into the methodology of discrete event system simulation
and descriptive statistics

2
Simulation of a Queueing System
❖ Consider a single server queue (ATM)
❖ Infinite calling population and infinite queue capacity
❖ Single server (Only one customer served at a time)
❖ Customers served in First in First out (FIFO) fashion
❖ No departures from the queue (patient customers )
Arrivals

Departures
Population Server

Waiting Line
3
Simulation of a Queueing System
❖ Arrivals occur one at a time in a random fashion
❖ Once they join the waiting line they are eventually served
❖ Service times are of some random length according to a probability distribution

Arrivals

Departures
Population Server

Waiting Line
4
Simulation of a Queueing System
❖ State: Number of units in the system and the status of the server, busy or idle
❖ Event: A circumstance that cause a change in system state
❖ Arrival of a customer
❖ Departure of a customer after service completion
❖ Simulation Clock
Arrivals

Departures
Population Server

Waiting Line
5
Simulating the clock

❖ Obvious choice: Start counting 1,2,3…


❖ But it is inefficient in most cases

❖ Solution:Discrete Event Simulation


❖ Get to the earliest event and update state and simulation clock

6
Simulation of a Queueing System

Arrival Event

No Yes
Server
Busy?

Customers Enters queue


Customers Enters Service for service

7
Simulation of a Queueing System
Departure
Event

No Another Yes
Customer
waiting?
Remove the next
Begin Server Idle customer from the
Time queue

Begin servicing
the customer

8
Simulation of a Queueing System
❖ Events usually occur at random times
❖ The randomness in simulation imitates uncertainty in real life. It is not
known with certainty
❖ When the next customer will arrive to a grocery store
❖ How long for a bank teller will take to complete a transaction
❖ A statistical model developed from historical data

9
Simulation of a Queueing System
❖ For simplicity assume that interarrival times (time between arrivals) are the
result of rolling a die.
❖ 1 to 6 equally likely
❖ Assume that service times are generated from a distribution with four values;
1, 2, 3, 4 minutes. They are equally likely
❖ Assume that there is a customer using the ATM machine (server) at time 0.
❖ State: Number of customers in the system
❖ Let’s simulate this simple system

1
0
Simulation of a Queueing System
❖ Simulation Clock t=0, Number of customers in the system, St=1
❖ Assign service time to the first customer.
❖ 2 minutes (t=2)
❖ Assign interarrival time for next customer (time until next arrival)
❖ 2 minutes (t=2)

Customer Arrival Time Time Service Begins Service Time Time Service Ends
1 0 0

1
1
Simulation of a Queueing System
❖ Simulation Clock t=0, Number of customers in the system, St=1
❖ Assign service time to the first customer.
❖ 2 minutes (t=2)
❖ Assign interarrival time for next customer (time until next arrival)
❖ 2 minutes (t=2)

Customer Arrival Time Time Service Begins Service Time Time Service Ends
1 0 0 2 2

1
2
Simulation of a Queueing System
❖ Simulation Clock t=0, Number of customers in the system, St=1
❖ Assign service time to the first customer.
❖ 2 minutes (t=2)

❖ Assign interarrival time for next customer (time until next arrival)
❖ 2 minutes (t=2)

❖ Advance clock to the closest event time, update state

Customer Arrival Time Time Service Begins Service Time Time Service Ends
1 0 0 2 2
2 2

1
3
Simulation of a Queueing System
❖ Simulation Clock t=2
❖ Customer 1 departs the server, Customer 2 arrives (interarrival time was 2) and starts using
server since the first customer left, St=1
❖ Assign service time for Customer 2: 1 minute (t=3)
❖ Assign interarrival time for Customer 3: 4 minutes (t=6)
❖ Move clock to the nearest event (departure)

Customer Arrival Time Time Service Begins Service Time Time Service Ends
1 0 0 2 2
2 2

1
4
Simulation of a Queueing System
❖ Simulation Clock t=3
❖ Customer 2 departs, no waiting patients in the queue, server is idle, St=0
❖ Advance the clock to the next closest event (arrival)

Customer Arrival Time Time Service Begins Service Time Time Service Ends
1 0 0 2 2
2 2 2 1 3
3 6

1
5
Simulation of a Queueing System
❖ Simulation Clock t=6
❖ Customer 3 arrives, starts using server, St=1
❖ Assign service time for Customer 3: 3 minutes (t=9)
❖ Assign interarrival time for Customer 4: 1 minute (t=7)
❖ Move the clock to nearest event (arrival)

Customer Arrival Time Time Service Begins Service Time Time Service Ends
1 0 0 2 2
2 2 2 1 3
3 6 6 3 9
4 7
1
6
Simulation of a Queueing System
❖ Simulation Clock t=7
❖ Customer 4 arrives, Customer 3 in server, Customer 4 joins the queue, St=2
❖ Assign interarrival time for Customer 5: 2 minutes (t=9)
❖ Advance clock to the nearest event (arrival and departure)
Customer Arrival Time Time Service Begins Service Time Time Service Ends
1 0 0 2 2
2 2 2 1 3
3 6 6 3 9
4 7
5 9
1
7
Simulation of a Queueing System
❖ Simulation Clock t=9
❖ Customer 5 arrives, Customer 3 departs, Customer 4 starts service, customer 5 joins the queue,
St=2
❖ Assign a service time for Customer 4: 2 minutes (t=11)
❖ Assign an interarrival time for Customer 6: 6 minutes (t=15)
Customer Arrival Time Time Service Begins Service Time Time Service Ends
1 0 0 2 2
2 2 2 1 3
3 6 6 3 9
4 7 9 2 11
5 9
6 15
1
8
Simulation of a Queueing System
❖ Simulation Clock t=11
❖ Customer 4 departs, Customer 5 in server starts service, St=1
❖ Assign a service time for Customer 5: 1 minute (t=12)
❖ Arrival for Customer 6 is at t =15
❖ Advance to the next event (departure)
Customer Arrival Time Time Service Begins Service Time Time Service Ends
1 0 0 2 2
2 2 2 1 3
3 6 6 3 9
4 7 9 2 11
5 9 11 1 12
6 15
1
9
Simulation of a Queueing System
❖ Simulation Clock t=12
❖ Customer 5 departs, no customer in the queue, St=0
❖ Advance to arrival of customer 6

Customer Arrival Time Time Service Begins Service Time Time Service Ends
1 0 0 2 2
2 2 2 1 3
3 6 6 3 9
4 7 9 2 11
5 9 11 1 12
6 15
2
0
Simulation of a Queueing System
❖ Simulation Clock t=15
❖ Customer 6 arrives, starts getting service, St=1
❖ Assign a service time for Customer 6: 4 minutes (t=19)
❖ END OF SIMULATION
Customer Arrival Time Time Service Begins Service Time Time Service Ends
1 0 0 2 2
2 2 2 1 3
3 6 6 3 9
4 7 9 2 11
5 9 11 1 12
6 15 15 4 19
2
1
Simulation of a Queueing System

22
Simulation of a Grocery Checkout
❖ A small grocery store has only one checkout counter. Customers arrive
at this checkout at random from 1 to 8 minutes apart. Each possible
value of interarrival time has the same probability of occurrence. The
service time vary from 1 to 6 minutes with the probabilities shown
below. Analyze the system by simulating the arrival of 100 customers.
Service Time Probability Cumulative Probability
1 0.10 0.10
2 0.20 0.30
3 0.30 0.60
4 0.25 0.85
5 0.10 0.95
6 0.05 1.00
23
Simulation of a Grocery Checkout
❖ How can we generate random interarrival times and service times in
accordance with the given distributions?
❖ Generate a uniform random number R, between 0 and 1, then return
service time x, if it falls in the interval (F(x-1),F(x)]
Service Time Probability Cumulative Probability Random Number Interval
1 0.10 0.10 (0-0.10]
2 0.20 0.30 (0.10-0.3] 0.553
3 0.30 0.60 (0.30-0.60]
4 0.25 0.85 (0.60-0.85] Generated
Service
5 0.10 0.95 (0.85-0.95] time 3
6 0.05 1.00 (0.95-1.00] minutes
24
Simulation of a Grocery Checkout
❖ Same idea for interarrival times

IA Time Probability Cumulative Probability Random number interval


1 0.125 0.125 (0.000-0.125]
2 0.125 0.250 (0.125-0.250]
3 0.125 0.375 (0.250-0.375]
4 0.125 0.500 (0.375-0.500]
5 0.125 0.625 (0.500-0.625]
6 0.125 0.750 (0.625-0.750]
7 0.125 0.875 (0.750-0.875]
8 0.125 1.000 (0.875-1.000]

25
Generated Inter-arrival Times

26
Generated Service Times

27
Exercise: Complete the Table
❖ Use the generated numbers given in the previous slides to run the simulation
until the arrival of the 5 customer
th

❖ Use the table template below:


Cust. Arrival Time Service Service Waiting Time Time Time in Server
Time Begins Time in Queue Service system idle time
Ends
1 0 0 0

28
Final Simulated Table

29
Analysis Using the Simulation Results

❖ The average waiting time for a customer is

❖ The average service time is (E[Service Time] =?)

❖ The average time spent in system

(1.74+3.17) 30
❖ The proportion of times that server is idle

❖ The probability that a customer has to wait in the queue

Note: 46 can be found by counting the number of customers who waited in the queue more than 0
minutes. This cannot be directly observed from the table presented in the slides, since the table is not
complete.
31
Excel Time

❖ Now Let’s see how we can simulate this grocery store example in Excel…

32

You might also like