Sie sind auf Seite 1von 36

Computer-based Simulation

Lect-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

Outline

Problem statement Determining events and variables Statistical counters Detailed explanation Simulation output and discussion

Problem statement

Consider a single-server queuing system for which the inter-arrival times A1, A2,are Independent and Identically Distributed (IID) random variables (have the same probability distribution). A customer who arrives and finds the server idle enters service immediately, and the service times S1, S2,of the successive customers are IID random variables that are independent of the interarrival times.

Problem statement

A customer who arrives and finds the server busy joins the end of a single queue. Upon completing service for a customer, the server chooses a customer 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 waits for the arrival of the first customer which occurs at t0 + A1. We wish to simulate this system until a fixed number of customers (n) have completed their delays in the queue.

Problem statement

To measure the performance of this system, we will look at the 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.7 A5 = 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.1 S5 = 3.7 S6 = 0.6 Mean = 0.5

Determining events and variables

There is no completely general way to determine the number and definition of events 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 logical errors.

Determining events and variables

The event-graph method.

Events are represented by nodes. The nodes are connected by directed arrows showing how events can be scheduled from other events/ themselves. One thick arrow indicates that one event at the end of the arrow may be scheduled from the beginning of the arrow in a (possibly) nonzero amount of time (delay). One thin arrow indicates that one event at the end of the arrow may be scheduled from the beginning of the arrow immediately.

Determining events and variables


Arrival Departure

Arrival

Enter Service

Departure

Determining events and variables

The event-graph method.

Strongly-connected components are the node (s) within which it is possible to move from every node to every other node by following the arrows in their directions. In any strongly-connected component of nodes that has no incoming arrows from other event nodes outside the component there must be at least one node that is initially scheduled.

Determining events and variables


Arrival Departure

Arrival

Enter Service

Departure

Determining events and variables

The event-graph method.

For simplicity the event node that has incoming arrows that are thin can be eliminated (enter service node is eliminated). End of-simulation can be introduced as an event node.

Determining events and variables

Arrival

Departure

End of simulation

Statistical counters

For each customer i the delay is denoted by Di. The average delay of n customers is then can be calculated as:
^

d n
Di 0

Di
i 1

^ estimated

Statistical counters

The number of customers j in the queue is donated by Q(t) and this number of customers continued for a period Tj. jT j ^

q n q n
^

j 0

Tn

Q t T
j 0 j

Q j t T j area

Tn

Statistical counters

Server utilization u(n) is the time when the server was busy Tk compared to the total time of simulation T(n)

n k 0 u

BT
Tn

0 idle B 1 busy BTk area

Q(t), B(t)
0.5 1 2 3 1.5 2.5 3.5 0

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
t

Statistical counters

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

Detailed explanation

n = 6 delays in queue desired Hand simulation:


Display system, state variables, clock, event list, statistical counters all after execution 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

Detailed explanation
Arrival event Schedule the next arrival event

Add 1 to the number in queue

Yes

No Server busy? Set delay =0

Store time of arrival of this customer

Add 1 to the customers delayed

Set server = busy

Return

Schedule departure event for this customer

Detailed explanation
Departure event Server = idle Yes No Queue empty?

Subtract 1 from the number in queue

Compute delay for the customer entering service Add 1 to the number of customers delayed Schedule departure event for this customer

Eliminate departure events from consideration

Return

Move each customer in queue up 1 place

Detailed explanation

Interarrival times: Service times:

0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9, 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,

Detailed explanation

Interarrival times: Service times:

0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9, 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,

Detailed explanation

Interarrival times: Service times:

0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9, 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,

Detailed explanation

Interarrival times: Service times:

0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9, 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,

Detailed explanation

Interarrival times: Service times:

0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9, 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,

Detailed explanation

Interarrival times: Service times:

0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9, 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,

Detailed explanation

Interarrival times: Service times:

0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9, 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,

Detailed explanation

Interarrival times: Service times:

0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9, 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,

Detailed explanation

Interarrival times: Service times:

0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9, 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,

Detailed explanation

Interarrival times: Service times:

0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9, 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,

Detailed explanation

Interarrival times: Service times:

0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9, 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,

Detailed explanation

Interarrival times: Service times:

0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9, 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,

Detailed explanation

Interarrival times: Service times:

0.4, 1.2, 0.5, 1.7, 0.2, 1.6, 0.2, 1.4, 1.9, 2.0, 0.7, 0.2, 1.1, 3.7, 0.6,

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)

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 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)

Changes from hand simulation:


Density function

Cumulative distribution function

Program Organization and Logic (contd.)


How to draw (or generate) an observation (variate) from an exponential distribution? Proposal:

Assume a perfect random-number generator that generates IID variates from a continuous uniform distribution on [0, 1] denoted the U(0, 1) distribution see Chap. 7 Algorithm:
1. Generate a random number U 2. Return X = b ln U

Questions and comments

Ask before being asked.

Das könnte Ihnen auch gefallen