l-3 simulation of mm1
TRANSCRIPT
-
8/2/2019 L-3 Simulation of MM1
1/36
Computer-based SimulationLect-3
Simulation of a single-server queuing system
International University for Science and Technology
Faculty of Information Technology
Department of Software Engineering
Muhammad WANNOUS, PhD
-
8/2/2019 L-3 Simulation of MM1
2/36
Outline
Problem statement
Determining events and variables
Statistical counters
Detailed explanation
Simulation output and discussion
-
8/2/2019 L-3 Simulation of MM1
3/36
Problem statement
Consider a single-server queuing systemfor which the inter-arrival times A1,A2,are Independent and IdenticallyDistributed (IID) random variables (have
the same probability distribution). A customer who arrives and finds the
server idle enters service immediately, andthe service times S1, S2,of the
successive customers are IID randomvariables that are independent of the inter-arrival times.
-
8/2/2019 L-3 Simulation of MM1
4/36
Problem statement
A customer who arrives and finds the server busyjoins the end of a single queue. Upon completingservice for a customer, the server chooses acustomer from the queue (if any) in a FIFO manner.
The simulation begins in the empty and idle state(no customers in queue) in t=0 and the server waitsfor the arrival of the first customer which occurs at t0+ A1.
We wish to simulate this system until a fixed numberof customers (n) have completed their delays in thequeue.
-
8/2/2019 L-3 Simulation of MM1
5/36
Problem statement
To measure the performance of this system, we will look atthe estimates of 3 factors:
The average delay in the queue of the n customers d(n)
The average number of customers in the queue q(n)
The utilization of the server u(n)
For simplicity, consider the following values:
A1 = 0.4
A2 = 1.2
A3 = 0.5
A4 = 1.7A5 = 0.2
A6 = 1.6
A7 = 0.2
A8 = 1.4
A9 = 1.9
Mean = 1
S1 = 2.0
S2 = 0.7
S3 = 0.2
S4 = 1.1S5 = 3.7
S6 = 0.6
Mean = 0.5
-
8/2/2019 L-3 Simulation of MM1
6/36
Determining events and variables
There is no completely general way todetermine the number and definition ofevents in general for a model.
It is also difficult to specify the state variables,especially in complex models.
There are some principles and techniques to
help simplify the structure and avoid logicalerrors.
-
8/2/2019 L-3 Simulation of MM1
7/36
Determining events and variables
The event-graphmethod.
Events are represented by nodes.
The nodes are connected by directed arrowsshowinghow events can be scheduled from other events/themselves.
One thick arrow indicates that one event at the end ofthe arrow maybe scheduled from the beginning of thearrow in a (possibly) nonzero amount of time (delay).
One thin arrow indicates that one event at the end ofthe arrow maybe scheduled from the beginning of thearrow immediately.
-
8/2/2019 L-3 Simulation of MM1
8/36
Determining events and variables
Arrival Departure
Arrival DepartureEnterService
-
8/2/2019 L-3 Simulation of MM1
9/36
Determining events and variables
The event-graphmethod.
Strongly-connectedcomponents are the node(s) within which it is possible to move from
every node to every other node by followingthe arrows in their directions.
In any strongly-connected component ofnodes that has no incoming arrows from otherevent nodes outside the component theremust be at least one node that is initiallyscheduled.
-
8/2/2019 L-3 Simulation of MM1
10/36
Determining events and variables
Arrival Departure
Arrival DepartureEnterService
-
8/2/2019 L-3 Simulation of MM1
11/36
Determining events and variables
The event-graphmethod.
For simplicity the event node that hasincoming arrows that are thin can be
eliminated (enter service node is eliminated). Endof-simulation can be introduced as an
event node.
-
8/2/2019 L-3 Simulation of MM1
12/36
Determining events and variables
Arrival Departure
End ofsimulation
-
8/2/2019 L-3 Simulation of MM1
13/36
Statistical counters
For each customer ithe delay is denoted by Di.
The average delay of n customers is then can becalculated as:
estimated
D
n
Di
n
i
n
i
d
^
0
1
^
-
8/2/2019 L-3 Simulation of MM1
14/36
Statistical counters
The number of customersjin the queue is donatedby Q(t) and this number of customers continued fora period Tj.
areaTtQ
T
TtQ
n
T
jT
n
jj
n
j
jj
n
jj
q
q
0
^
0^
-
8/2/2019 L-3 Simulation of MM1
15/36
Statistical counters
Server utilization u(n) is the time when the serverwas busy Tk compared to the total time of simulationT(n)
areaBT
busyidleB
T
BTn
k
n
k
k
u
1
0
0
^
-
8/2/2019 L-3 Simulation of MM1
16/36
Statistical counters
0
0.5
1
1.5
2
2.5
3
3.5
0
0.
3
0.
6
0.
9
1.
2
1.
5
1.
7 2
2.
2
2.
4
2.
7 3
3.
2
3.
5
3.
8 4
4.
3
4.
6
4.
9
5.
1
5.
4
5.
6
5.
8
6.
1
6.
4
6.
7 7
7.
2
7.
5
7.
8
8.
1
8.
4
8.
6
8.
9
t
Q(t),B(t)
-
8/2/2019 L-3 Simulation of MM1
17/36
Detailed explanation
n= 6 delays in queue desired Hand simulation:
Display system, state variables, clock, event list, statistical counters allafterexecution of each event
Use above lists of inter-arrival, service times to drive simulation Stop when number of delays hits n= 6, compute output performance
measures
-
8/2/2019 L-3 Simulation of MM1
18/36
Detailed explanationArrivalevent
Schedule the nextarrival event
Server busy?Add 1 to the
number in queue
Store time of arrivalof this customer
Set delay =0
Add 1 to thecustomers delayed
Set server = busy
Schedule departureevent for this
customerReturn
YesNo
-
8/2/2019 L-3 Simulation of MM1
19/36
Detailed explanationDeparture
event
Queue empty?Server = idle
Eliminate departureevents from
consideration
Subtract 1 from thenumber in queue
Compute delay forthe customer
entering service
Add 1 to thenumber of
customers delayed
Schedule departure
event for thiscustomer
Return
YesNo
Move eachcustomer in queue
up 1 place
-
8/2/2019 L-3 Simulation of MM1
20/36
Detailed explanation
Interarrival times: 0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9,
Service times: 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,
Interarrival times: 0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9,
Service times: 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,
-
8/2/2019 L-3 Simulation of MM1
21/36
Detailed explanation
Interarrival times: 0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9,
Service times: 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,
-
8/2/2019 L-3 Simulation of MM1
22/36
Detailed explanation
Interarrival times: 0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9,
Service times: 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,
-
8/2/2019 L-3 Simulation of MM1
23/36
Detailed explanation
Interarrival times: 0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9,
Service times: 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,
-
8/2/2019 L-3 Simulation of MM1
24/36
Detailed explanation
Interarrival times: 0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9,
Service times: 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,
-
8/2/2019 L-3 Simulation of MM1
25/36
Detailed explanation
Interarrival times: 0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9,
Service times: 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,
-
8/2/2019 L-3 Simulation of MM1
26/36
Detailed explanation
Interarrival times: 0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9,
Service times: 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,
-
8/2/2019 L-3 Simulation of MM1
27/36
Detailed explanation
Interarrival times: 0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9,
Service times: 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,
-
8/2/2019 L-3 Simulation of MM1
28/36
Detailed explanation
Interarrival times: 0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9,
Service times: 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,
-
8/2/2019 L-3 Simulation of MM1
29/36
Detailed explanation
Interarrival times: 0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9,
Service times: 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,
-
8/2/2019 L-3 Simulation of MM1
30/36
Detailed explanation
Interarrival times: 0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9,
Service times: 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,
-
8/2/2019 L-3 Simulation of MM1
31/36
Detailed explanation
Interarrival times: 0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9,
Service times: 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,
-
8/2/2019 L-3 Simulation of MM1
32/36
Detailed explanation
Interarrival times: 0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9,
Service times: 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,
-
8/2/2019 L-3 Simulation of MM1
33/36
Detailed explanation
Interarrival times: 0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9,
Service times: 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,
Final output performance measures:Average delay in queue = 5.7/6 = 0.95 min./cust.
Time-average number in queue = 9.9/8.6 = 1.15 custs.
Server utilization = 7.7/8.6 = 0.90 (dimensionless)
-
8/2/2019 L-3 Simulation of MM1
34/36
Program Organization and Logic
C program to do this model (FORTRAN as well is in book)
Event types: 1 for arrival, 2 for departure
Modularize for initialization, timing, events, library, report, main
Changes from hand simulation:
Stopping rule: n= 1000 (rather than 6) Interarrival and service times drawn from an exponential
distribution (mean b= 1 for interarrivals, 0.5 for service times)
Density function
Cumulative distribution function
-
8/2/2019 L-3 Simulation of MM1
35/36
Program Organization and Logic(contd.)
How to draw (or generate) an observation(variate) from an exponential distribution?
Proposal: Assume a perfect random-number generatorthat
generates IID variates from a continuous uniformdistribution on [0, 1] denoted the U(0, 1)distribution see Chap. 7
Algorithm:
1. Generate a random number U2. Return X=b ln U
-
8/2/2019 L-3 Simulation of MM1
36/36
Questions and comments
Ask before being asked.