Sie sind auf Seite 1von 13

Computer Science, Informatik 4

Communication and Distributed Systems

Simulation

“Discrete-Event System Simulation”

Dr. Mesut Güneş


Computer Science, Informatik 4
Communication and Distributed Systems

Chapter 2

Simulation Examples
Computer Science, Informatik 4
Communication and Distributed Systems

Simulation using a Table


Repetition Inputs Response
Introducing simulation by
i xi1 xi2 … xij … xip yi
manually simulating on a table
1
• Can be done via pen-and-paper 2
or by using a spreadsheet :
n

Three steps

1. Determine the characteristics of each inputs to the simulation.

2. Construct a simulation table consisting of


• p inputs xij, j=1,2,…,p
• one response y , i=1,2,…,n
i
3. For each repetition i, generate a value for each of the p inputs xij and
calculate the response yi.

Next some simulation examples using tables.


Chapter 2. Simulation Examples 3 Dr. Mesut Güneş
Computer Science, Informatik 4
Communication and Distributed Systems

Simulation of Queueing Systems

A queueing system is described by


• Calling population

• Arrival rate
• Service mechanism
• System capacity
• Queueing discipline

Calling population

Waiting line Server

Chapter 2. Simulation Examples 4 Dr. Mesut Güneş


Computer Science, Informatik 4
Communication and Distributed Systems

Simulation of Queueing Systems


Single server queue Queueing system state
• Calling population is infinite • System
Arrival rate does not change - Server

• Units are served according FIFO - Units (in queue or being served)
• Arrivals are defined by the - Clock
distribution of the time between • State of the system
arrivals inter-arrival time - Number of units in the system
• Service times are according to - Status of server (idle, busy)
distribution • Events

• Arrival rate must be less than - Arrival of a unit


service rate stable system - Departure of a unit
• Otherwise waiting line will grow
unbounded unstable system

ti+1 ti
Calling population
Arrivals
Waiting line Server
Chapter 2. Simulation Examples 5 Dr. Mesut Güneş
Computer Science, Informatik 4
Communication and Distributed Systems

Simulation of Queueing Systems


Arrival Event
• If server idle unit gets service,
otherwise unit enters queue.

Departure Event
• If queue is not empty begin
servicing next unit, otherwise
server will be idle.

How do events occur?


• Events occur randomly
• Interarrival times ∈ {1,...,6}
• Service times ∈ {1,...,4}

Chapter 2. Simulation Examples 6 Dr. Mesut Güneş


Computer Science, Informatik 4
Communication and Distributed Systems

Simulation of Queueing Systems


The interarrival and service
times are taken from
Customer Interarrival Arrival Time Service distributions!
Time on Clock Time
1 - 0 2
2 2 2 1
3 4 6 3
4 1 7 2
5 2 9 1
6 6 15 4

Customer Arrival Time Time Service Service Time Time Service


Number [Clock] Begins [Clock] [Duration] Ends [Clock]
The simulation run is 1 0 0 2 2
build by meshing 2 2 2 1 3
clock, arrival and 3 6 6 3 9
service times! 4 7 9 2 11
5 9 11 1 12
6 15 15 4 19
Chapter 2. Simulation Examples 7 Dr. Mesut Güneş
Computer Science, Informatik 4
Communication and Distributed Systems

Simulation of Queueing Systems

Chronological ordering of events


Clock Customer Event Number of
Time Number Type customers
0 1 Arrival 1
2 1 Departure 0 Number of customers in the system
2 2 Arrival 1
3 2 Departure 0
6 3 Arrival 1
7 4 Arrival 2
9 3 Departure 1
9 5 Arrival 2
11 4 Departure 1
12 5 Departure 0
15 6 Arrival 1
19 6 Departure 0

Chapter 2. Simulation Examples 8 Dr. Mesut Güneş


Computer Science, Informatik 4
Communication and Distributed Systems

Simulation of Queueing Systems – A Grocery


Interarrival Probability Cumulative
Analysis of a small grocery store Time Probability
• One checkout counter
1 0.125 0.125
2 0.125 0.250
• Customers arrive at random times
from {1,2,…,8} minutes
3 0.125 0.375
4 0.125 0.500
• Service times vary from {1,2,…,6}
minutes
5 0.125 0.625
6 0.125 0.750
• Consider the system for 100
customers
7 0.125 0.875
8 0.125 1.000
Problems/Simplifications
• Sample size is too small to be able Service Probability Cumulative
Time Probability
to draw reliable conclusions
1 0.10 0.10
• Initial condition is not considered
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
Chapter 2. Simulation Examples 9 Dr. Mesut Güneş
Computer Science, Informatik 4
Communication and Distributed Systems

Simulation of Queueing Systems – A Grocery


Customer Interarrival Arrival Time Service Time Time Waiting Time Idle Time
Time [Clock] Time Service Service Time in Customer of Server
[Minutes] [Minutes] Begins Ends Queue in System [Minutes]
[Clock] [Clock] [Minutes] [Minutes]
1 - 0 4 0 4 0 4 0
2 1 1 2 4 6 3 5 0
3 1 2 5 6 11 4 9 0
4 6 8 4 11 15 3 7 0
5 3 11 1 15 16 4 5 0
6 7 18 5 18 23 0 5 2
...
100 5 415 2 416 418 1 3 0
Total 415 317 174 491 101

Chapter 2. Simulation Examples 10 Dr. Mesut Güneş


Computer Science, Informatik 4
Communication and Distributed Systems

Simulation of Queueing Systems – A Grocery


Average waiting time w=
∑ Waiting time in queue = 174 = 1.74 min
Number of customers 100

Probability that a customer has to wait p( wait ) =


Number of customer who wait 46
= = 0.46
Nunber of customers 100

Porpotion of server idle time


p(idle server) =
∑ Idle time of server = 101 = 0.24
Simulation run time 418

Average service time


s=
∑ Service time =
317
= 3.17 min
Number of customers 100

∑ s ⋅ p(s) = 0.1⋅10 + 0.2 ⋅ 20 + L + 0.05 ⋅ 6 = 3.2 min



E (s ) =
s=0

λ =∑
Average time between arrivals Times between arrivals 415
= = 4.19 min
Number of arrivals - 1 99
a + b 1+ 8
E (λ ) = = = 4.5 min
2 2

Average waiting time of those who wait


wwaited =
∑ Waiting time in queue =
174
= 3.22 min
Number of customers that wait 54

Average time a customer spends in system


t=
∑ Time customers spend in system = 491 = 4.91min
Number of customers 100

t = w + s = 1.74 + 3.17 = 4.91 min

Chapter 2. Simulation Examples 11 Dr. Mesut Güneş


Computer Science, Informatik 4
Communication and Distributed Systems

Simulation of Queueing Systems – A Grocery

Interesting results for a Average of 50 Trials


manager, but
Histogram for the Average Customer Waiting Time
• longer simulation run would
increase the accuracy
18 17

16 15

Occurrences (No. of Trials)


14

12
Some interpretations 10

• Average waiting time is not 8 7

6 5
high
4
2 2
• Server hast not undue amount 2 1 1
0 0 0
of idle time, it is well loaded ;-)
0
0 0,5 1 1,5 2 2,5 3 3,5 4 4,5 >4.5
Average customer waiting time [min]
• Nearly half of the customers
have to wait (46%)

Chapter 2. Simulation Examples 12 Dr. Mesut Güneş


Computer Science, Informatik 4
Communication and Distributed Systems

Summary

This chapter introduced simulation concepts my means of


examples
Example simulation were performed on a table manually
• Use a spreadsheet for large experiments (Excel, OpenOffice)

• Input data is important


• Random variables can be used
• Output analysis important and difficult
• The used tables were of ad hoc, a more methodic approach is
needed

Chapter 2. Simulation Examples 13 Dr. Mesut Güneş

Das könnte Ihnen auch gefallen