Você está na página 1de 76

BIF3203 Computer Simulation Part II: Analytical Model of queuing

systems

Nicodemus Maingi nmaingi@strathmore.edu Phase II First Floor Staffroom, 3B

The Queuing system


n

Stochastic models associated with the queuing - result when the demands on a process exceed the current capacity of that process. A queuing system:
n n

Consists of one or more servers that provide service of some sort to arriving customers. Arriving customers finding all servers busy, generally join one or more queues (lines) in front of the servers,
n

Hence the name queuing system.

Several examples;,
n n n n n

bank-teller service, computer systems, manufacturing systems, maintenance systems, communications systems etc.

The Queuing system (2)


n

Principal actors in a queuing:


n n

Customers Servers

Components of a Queuing System/model


n

A queuing system is characterized by three components:


n n n

Arrival process Service mechanism Queue discipline

N. Maingi - November 2012

Arrival Process
n n n

n n

Entities arrive to the system according to some arrival pattern Arrivals are independent of preceding arrivals i.e. successive interarrival times are statistically independent and completely random. Arrivals may originate from one or several sources referred to as the calling population. Population of Customers can be considered either limited (closed systems) or unlimited (open systems). An Unlimited population represents a theoretical model of systems with a large number of possible customers (a bank on a busy street, a motorway petrol station). A limited population may be a number of processes to be run (served) by a computer or a certain number of machines to be repaired by a service man.

N. Maingi - November 2012

Arrival Process (2)


n

The term "customer" is taken very generally.


n

Customers may be people, machines of various nature, computer processes, telephone calls, products on an assembly line etc. The arrival process consists of describing how customers arrive to the system. On arrival at the system, they can start service immediately or wait in a queue if the service mechanism is not free. If a customer arrives but fails to enter the system, we say that the customer has balked (leaving without service). The arrival of customers is represented by the time between successive arrivals (called inter-arrival time). If the arrival process is unaffected by the number of customers present, we usually describe the inter-arrival time by specifying a probability distribution.
N. Maingi - November 2012

Most queuing models assume that the population is infinite.


n n

Arrival Process (3)


n

Arrival: defines the way customers enter the system.


n

Mostly the arrivals are random - with random intervals between two adjacent arrivals. Typically the arrival is described by a random distribution of intervals also called Arrival Pattern.

N. Maingi - November 2012

Queue Discipline
n n n

A Queue: represents a certain number of customers waiting for service (of course the queue may be empty). Typically the customer being served is considered not to be in the queue. Sometimes the customers form a queue literally (people waiting in a line for a bank teller).
n n

Sometimes the queue is an abstraction (planes waiting for a runway to land). There are two important properties of a queue:
n n

Maximum Size and Queuing Discipline.

N. Maingi - November 2007

Queue Discipline (2)


n

Maximum Queue Size: (also called System capacity) is the maximum number of customers that may wait in the queue (plus the ones) being served). A Queue is always limited, but some theoretical models assume an unlimited queue length.
n

If the queue length is limited, some customers are forced to renounce without being served.

Queue Discipline: means the rule that a server uses to choose the next customer from the queue (if any) when the server completes the service of the current customer. Queuing Discipline: represents the way the queue is organized (rules of inserting and removing customers to/from the queue).
N. Maingi - November 2007

Queue Discipline (3)


Commonly used queue disciplines are: n FIFO: (First In First Out) also called FCFS (First Come First Serve) - orderly queue. Customers are served on a first-in first-out basis n LIFO: (Last In First Out) also called LCFS (Last Come First Serve) - stack. Customers are served in a last-in first-out manner n SIRO: (Serve In Random Order). n Priority Queue: that may be viewed as a number of queues for various priorities:
n

Customers are served in order of their importance, on the basis of their service requirements.
N. Maingi - November 2012

Queue Discipline (4)


n n

RR: Round robin, each customer receives, in turn, a small time slice of service. Sharing the capacity of the server: PS (Processor sharing), all customers in the queue are receive service simultaneously Many other more complex queuing methods that typically change the customers position in the queue according to
n n n

the time spent already in the queue, expected service duration, and/or priority

Note: These methods are typical for computer multiaccess systems.


N. Maingi - November 2012

Queue Discipline (5)


n n

Most queuing models assume FCFS as the queue discipline. Quantitative parameters such as average queue length, average time spent in the system are independent of the queuing discipline. Thats why most models either do not take the queuing discipline into account at all or assume the normal FIFO queue.
n

The only parameter that depends on the queuing discipline is the variance (or standard deviation) of the waiting time.

N. Maingi - November 2012

Service Mechanism
n n

Service: represents some activity that takes time and that the customers are waiting for. It is taken very generally - it may be a real service carried on persons or machines, but it may be a CPU time slice, connection created for a telephone call, being shot down for an enemy plane, etc. A service takes random time.
n

Number of servers:
n n

Theoretical models are based on random distribution of service duration also called Service Pattern.

Systems with one server only are called Single Channel. Systems, systems with more servers are called Multi Channel Systems.
N. Maingi - November 2012

Service Mechanism (2)


n

The service mechanism: the way that customers receive service once they are selected from the front of a queue.
n

A service mechanism is also called a server.

n n

Service time: the amount of time which a customer takes to be served. A statistical distribution is used to model the service time of a server.
n n

Some queuing models assume a single server, some multiple servers. Generally, most queuing models assume that the system has either a single server or allow the number of servers to become a variable. In many cases, the assumption is that the service time distribution is independent of the number of customers present. i.e. the server does not work faster when more customers are present. Output is mostly ignored by most theoretical models, but sometimes the customers leaving the server enter the queue again ("round robin" time-sharing systems). N. Maingi - November 2012

Output: represents the way customers leave the system.


n

Queuing Theory
n

A collection of mathematical models for various queuing systems that take as inputs parameters of the above elements and that provide quantitative parameters describing the system performance.
n

Due to their random nature of the processes involved, the queuing theory is rather demanding and all models are based on very strong assumptions (not always satisfied in practice).

Many systems (especially queuing networks) are not solvable at all, so the only technique that may be applied is simulation.

N. Maingi - November 2007

Queuing Theory (2)


n

Queuing systems are important provide a trade-off between the various costs of providing service and the costs associated with waiting for the service (or leaving the system without being served).
n

High quality, fast service is expensive, but costs caused by customers waiting in the queue should be minimized. Alternatively, long queues may cost a lot because customers (e.g. machines) do not work while waiting in the queue or customers leave because of long queues lose of business. The ultimate is to find an optimum system configuration (e.g. the optimum number of servers)
n

For instance, by applying queuing theory or by simulation.

N. Maingi - November 2012

THE STRUCTURE OF QUEUING SYSTEMS


n

Although there are numerous examples of queuing systems, it is possible to categorize them into one of four main types;
1) 2) 3) 4)

Single channel single phase system Single channel multiphase system Multi channel Single phase system Multi channel multi phase system

N. Maingi - November 2012

Single channel single phase system


n

This is a system where an entity arrives, joins a single queue, is served by one server and finally departs

Example: Supermarkets checkpoints, helpdesk print jobs etc.


N. Maingi - November 2012

Single channel multiphase system


n

This is a system where an entity joins another queue following service from the first.

Some petrol stations are of this type; the driver will queue for a pump and then queue at the payment booth.
N. Maingi - November 2012

Multi channel Single phase system


n

This system is where an entity joins a single queue and is served by the first available server.

N. Maingi - November 2012

Multi channel multi phase system


n

This is a system where an entity joins a single queue and is served by the first available server then joins another queue for another service.

Example: the production system of a manufacturing plant e.g. a bottling plant at a brewery
N. Maingi - November 2012

MODELING THE QUEUING SYSTEM


n

The study of queues determines the measures of performance of a queuing situation, including the average waiting time and the average queue length, among others.
n n

important information to be used to decide on an appropriate level of service for the facility. A decision maker may like to know;
n n n n

What fraction of the time is each server idle? What is the expected number of customers present in the queue? What is the expected time that a customer spends in the queue? What is the probability distribution of the number of customers present in the queue? What is the probability distribution of a customers waiting time?

N. Maingi - November 2012

MODELING THE QUEUING SYSTEM (2)


n

The following conditions are used to determine the performance measures of a queuing system:
n n n n

Probability distribution of arrival times Probability distribution of service times Number of serving channels Queue/Line discipline

N. Maingi - November 2012

THE POISSON PROCESS


n

Queuing systems can often be characterized as having random, independent arrivals with mean arrival rate, .
n

Random arrivals suggests that one cannot predict with certainty the arrival of the next customer, job, etc. into the system. Independent arrivals implies that one arrival has nothing to do with the next arrival.
n

The assumption is an assertion that the external world is not generating jobs in a manner that depends on the previous job. Assumption is valid or at least acceptable for a large number of instances.

Whilst we cannot specify for certain when the next arrival will occur, we can collect statistics over the long term and estimate the mean arrival rate of jobs or customers into the system.
N. Maingi - November 2012

THE POISSON PROCESS (2)


n

We also assume that the jobs or customers that enter the system come from an infinite source population, i.e. the population isn't depleted by the job server(s) that is currently operating within the system.
n

In many cases, the source population is sufficiently large so that this assumption can be made.

N. Maingi - November 2012

THE POISSON PROCESS (3)


n

Given the independence assumption and the average arrival rate, one can characterize the distribution of arrivals by the Poisson process. Using this distribution, we can say that, for an arrival rate (sometimes also called a rate parameter) over a time interval t, the probability that exactly n jobs or customers will have arrived in the system with a probability Pn(t) defined as:

Note that Pn(0) = 0; i.e. the probability of n jobs arriving in the queue is zero if the time interval is zero.
N. Maingi - November 2012

THE POISSON PROCESS (4)


n

Suppose that arrivals occur at a processor at the average rate of 6 per second. What is the probability that no arrivals, one arrival or three arrivals will occur in the next second? For zero arrivals, we have:

1
N. Maingi - November 2012

THE POISSON PROCESS (5)


n

The probabilities of one or three arriving in the next second are:

N. Maingi - November 2012

THE POISSON PROCESS (6)


n n

These could be found directly by looking up the values from the Poisson tables. The values for the Poisson probability distribution for the first eleven values for this case are shown

N. Maingi - November 2012

THE POISSON PROCESS (7)


n

What if we wish to obtain the probabilities of the same number of arrivals as before in the next two seconds? The formulas now become:

N. Maingi - November 2012

Mean and standard Deviation of Poisson Distribution


n

Let E[x] be the mean (average) value, Var[x] the variance, and Std[x] the standard deviation of the random variable x which has a Poisson process:

This gives the interpretation of the constant , that is the average number of arrivals per time unit. Thats why the is called Arrival rate.

Poisson Distribution (2)

N. Maingi - November 2012

Exponential Distribution
n

Is the most important, easiest distribution to use in queuing theory. Used to model the time between events that happen at a constant average rate. Inter-arrival times and services times can often be represented exactly or approximately using exponential distribution. The probability distribution function of an exponential distribution is given by
N. Maingi - November 2012

Exponential Distribution (2)

Used to model Poisson processes - situations in which an object initially in state A can change to state B with constant probability per unit time . The time at which the state actually changes is described by an exponential random variable with parameter .

Exponential Distribution (3)


An Exponential () random variable has the following properties: Mean and variance n The mean or expected value of an exponentially distributed random variable X with rate parameter is given by
n

N. Maingi - November 2012

Exponential Distribution (4)


n

In light of the examples given above, this makes sense: if you receive phone calls at an average rate of 2 per hour, then you can expect to wait half an hour for every call. The variance of X is given by

N. Maingi - November 2012

Kendall Classification of Queuing Systems


The Kendall classification of queuing systems [1953] exists in several modifications. The most comprehensive classification uses 6 symbols: n A/S/m/q/c/p where: n A is the arrival pattern (distribution of intervals between arrivals). n S is the service pattern (distribution of service duration). n m is the number of servers. n q is the queuing discipline (FIFO, LIFO, ...). Omitted for FIFO or if not specified. n c is the system capacity. Omitted for unlimited queues. The parameter c includes both waiting places and service places n p is the population size (number of possible customers). Omitted for open systems.
n

N. Maingi - November 2012

Kendall Classification of Queuing Systems (6)

N. Maingi - November 2012

Queues: Arrival and service patterns


n n

n n n n

The following symbols are used for arrival and service patterns: M is the Poisson (Markovian) process with exponential distribution of arrival or service duration respectively. Em is the Erlang distribution of intervals or service duration. D is the symbol for deterministic (known) arrivals and constant service duration. G is a general (any) distribution. GI is a general (any) distribution with independent random values.
N. Maingi - November 2012

Queues: Arrival and service patterns (2)


n n

Examples of queuing systems that can be defined with this convention are: M/M/1:
n n

n n

This is the simplest queuing system to analyze. The arrival and service time are exponentially distributed Poisson processes. The system consists of only one server, Unlimited FIFO or unspecified queue and unlimited customer population. This queuing system applies mostly to a wide variety of problems e.g. a system with a very large number of independent customers. Using a Poisson process for service time however is not applicable in many applications and is only a crude approximation.
N. Maingi - November 2012

Queues: Arrival and service patterns (3)


n

M/D/n:
n

n n

The arrival process is Poisson (Markovian) and the service time distribution is Deterministic. The system has n servers. (e.g. a ticket booking counter with n cashiers.) The service time can be assumed to be same for all customers. Unlimited FIFO or unspecified queue and unlimited customer population.

N. Maingi - November 2012

Queues: Arrival and service patterns (5)


n

M/G/3/20:
n n n n n

The arrival process is Poisson (Markovian), service pattern is from any distribution (G) There are 3 servers in the system, Queue discipline is FIFO Maximum number of customers in system = 20, Unlimited customer population. Deterministic arrivals, Poisson (Markovian) Service pattern One exponential server, The queue is a stack (LIFO) Maximum size of customers in system = 10, Total customers population = 50.
N. Maingi - November 2012

D/M/1/LIFO/10/50:
n n n n n n

The M/M/1 Queuing system


Assumptions for the model n The arrivals are assumed to follow a Poisson distribution (arrival rate = ) n Service process is Poisson (Markovian) with Service rate = n One exponential server n The queuing discipline/mechanism is FIFO n Queue length is not limited n Infinite population: The population from where the arrivals originate is infinite n No balking from the queue n One object/item at most arrives/departs during any time interval n The service times are assumed to follow an exponential distribution

N. Maingi - November 2012

The M/M/1 Queuing system (2)


n

Since both arrival and service are Poisson processes, it is possible to find probabilities of various states of the system, necessary to compute the required quantitative parameters. System state: for this case, the number of customers in the system.
n n n

It may be any non-negative integer number. Let Pn(t) = P[n customers in the system at time t]. Then these processes can be represented by a state transition diagram as shown below:

Single Server Queue State Transition Diagram


N. Maingi - November 2012

The M/M/1 Queuing system (3)


n

An arrival transforms the system from its current state, n, to the next state, n+1. The transition rate from a lower to a higher state (arrival rate) is therefore . Similarly, as customers are served (by the server), the system undergoes transitions from higher states (n) to lower states (n-1), a process often referred to as a departure or a death. The rate at which these departures occur is just the service rate, .
N. Maingi - November 2012

The M/M/1 Queuing system (4)


n

Focus: to determine the basic measure of performance of the system such;


n n n n n

The The The The The

probability that n customers are present in the system (np), expected number of customers in the system (L), expected number of customers in the queue (Lq), average waiting time in the system (W), average waiting time in queue (Wq)

Given the transition diagram for the M/M/1 queuing system, we can determine the performance measures.

N. Maingi - November 2012

The M/M/1 Queuing system (5)


n

At a steady state, what enters the system should be the same as what leaves the system. Therefore if we consider state n, what enters the state should be the same as what leaves the state. That is; pn-1 = pn For n =1, we have p0 = p1

N. Maingi - November 2012

p1= p 0

The M/M/1 Queuing system (6)


For n = 2, we get p1 = p2
n

continuing we obtain:

where Pn= probability that there are n units in the system.


N. Maingi - November 2012

The M/M/1 Queuing system (7)


n

Let the server is processing jobs. Then Pn = np0, 0,1,2,3, to determine the value of P0 and Pn, must satisfy the condition for probability distributions, that is the total probability is unity.

= , The quantity is the fraction of time

N. Maingi - November 2012

The M/M/1 Queuing system (8)

N. Maingi - November 2012

The M/M/1 Queuing system (9)


n n

P = (1-)n = 0,1,2,. Is a Geometric distribution. p0 = the Proportion of time the system is idle. Then the utilization, the proportion of time the server is busy is (1-)
is the fraction of time the server is busy (traffic intensity) and is called systems utilization factor.

N. Maingi - November 2012

Performance Characteristics for the M/M/1 system


Points of interest
n

n n n

Performance of the system: measured by the average waiting time, The average delay on passing through the system, The average number in the queue, etc. Most these results for this system can be calculated directly if we know the value of Pn.

N. Maingi - November 2012

The average number of entities in the system (Ls)


n

n n

Calculating the average number of entities in the system - a parameter of concern. n represents a distribution of a discrete random variable Number of customers in the system (probabilities of all possible random values). It is possible to compute the mean value, that is the average number of customers in the system: Pn = (1) n , n = 0,1,2,. n E[No. of entities in the system] = Ls
N. Maingi - November 2012

The average number of entities in the system (Ls) (2)

Therefore

This is the mean number in the system - including the entity being attended to. This is sometimes referred to as the mean number in the queue though we usually think of the queue as only those waiting. (Americans refer to this as the line. This is very sensible for queue theorists) N. Maingi - November 2012

The average number of entities in the system (Ls) (3)


n

The mean number in the system is greater than 0 even if the load (measured by ) is small. The mean number in the system tends to infinity as tends to 1, even though the service rate is still greater than the arrival rate. Note: that must be less than 1, otherwise the number of customers in the system will grow permanently. The variance of the number in the system, N can be obtained from the geometric distribution.

N. Maingi - November 2012

Average number of entities in the queue (Lq)


n

Assume, the customer being served is not a part of the queue.


n

So n customers in the system means the queue length is n-1.

N. Maingi - November 2012

Average number of entities in the queue (Lq) (2)

Expected queue length = expected entities in the system minus those in service.
N. Maingi - November 2012

Average time an entity spends in system


Littles formula: n Gives the relation between the average number of customers in the system LS and n The average time WS spent in the system and between the average number of customers in the queue LQ and the average time WQ spent in the queue: LS = WS ,LQ = WQ

N. Maingi - November 2012

Average time an entity spends in system (2)


n

Mean number of entities in system = arrival rate x mean response time (average time a entity spends in the system):n

i.e. the average number of customers in the system is the same as number arriving per unit time times the average time each spends in the system

n n

Therefore: Average time in the system = average number of entities in the system times the inter-arrival time

N. Maingi - November 2012

Average time an entity spends in system (3)

Average time in the system = expected time in the queue plus expected service time.

Average time an entity spends in queue The mean time in the line (queue) is the time spent waiting before being served.
This is the mean time in the system minus the mean service time, thus
N. Maingi - November 2012

Average time an entity spends in system (4)


Average time in the queue = Average number of entities in the queue over the arrival rate ( or times the interarrival rate (arrival time)) LQ = WQ i.e. the average number of customers in the queue is the same as number arriving per unit time times the average time each spends in the queue) Therefore N.B Both average time in the queue and average queue length depends on the system utilization factor /.
N. Maingi - November 2012

Average time an entity spends in system (5)

N. Maingi - November 2012

The derivation of Pr{n or more customers are in the system}


n

For m n, we have,

N. Maingi - November 2012

The derivation of Pr{n or more customers are in the system} (2)


Example A telephone attendant receives 110 calls during the busy hour. Each call takes, on average, 30 seconds to process. a) What percentage of the attendant's time is devoted to answering calls? b) How long must people wait, on average, before their call is processed? c) How many people are in the queue, on average?
N. Maingi - November 2012

Solution: Example 1
1)

2)

3)

We know that = 110 calls/hr. = 1.83calls/min. and S = .5 min./call. Thus a = S = (1.83 calls/min.)(.5 min./call) = .92. For an M/M/1 queuing system, we know that a = , so the attendant is busy 92% of the time. Using the data we calculated above, we can see that the waiting time in the queue is Wq = S/(1-), so Wq = (.92)(.5 min/call)/(1 - .92) = 2.5 min./call. People must wait an average of 2.5 minutes to interact with the operator for 30 seconds, hardly reasonable for most applications.
N. Maingi - November 2012

Solution: Example 1 contd


1)

Finally, the average number of calls in the queue can be found using Little's Formula: Lq = Wq = (1.83 call/min.)(2.5 min./call) = 4.6.

N. Maingi - November 2012

Problem 1
10000 frames/hr can be expected to flow from one network to the other network. What is the average number of packets expected to flow in one second? The expected service time is the time required to transfer a packet across the network. Therefore the average time required to transmit one packets is 0.1 seconds. a) What is the mean service rate? b) This model can be considered as a single-channel, single-phase queuing model or notated as M/M/1 model. Find the utilization of the service facility in this model.
N. Maingi - November 2012

Problem 1 contd
a) What is the probability that there are no frames in the network? b) For a M/M/1 model, find the mean number of units expected to be in the system. c) What is the queue length in this service model? d) The mean time in the system? e) The time of packet in the queue?

N. Maingi - November 2012

Problem 2
Arrivals to a rail ticket office is poisson with mean of 47 an hour. The service time by the single clerk is exponential with a mean of 45 seconds. Assuming that the M/M/1 model applies, a) Calculate the average number of passengers waiting to be served and the average time in the queue. b) Arrival rate = 2 per hr and service time =2 hours

N. Maingi - November 2012

Problem 3
The arrival of lorries at the Strathmore construction area is random with a mean of one every twenty minutes. The time taken to unload a lorry is 15 minutes on average. With a standard deviation of 3.6 minutes. What is the average number of lorries in the queue and the time lorries spend in the system?

N. Maingi - November 2012

Problem 4
A manufacturing firm has two departments, A and B, each running an NC machine; the machines are named MA and MB, respectively. Each machine can produce 25 parts per day. It is observed that an average of 20 parts per day will arrive to MA while an average of 15 parts per day will arrive to MB. a) For MA and MB, determine the expected length of time from submitting a job to be processed until it is completed. Carefully state your modeling assumptions. b) Suppose that the two machines are grouped into a pool; i.e., each machine is available to process parts from both departments. For this arrangement, determine the expected length of time from submitting a job to be processed until it is completed. Carefully state your modeling assumptions. Compare the results with those for part (a).
N. Maingi - November 2012

Problem 5 and 6
Problem 5: Understanding of basic concepts. a) What is the stability condition for the M/M/1 queue? b) What is the stability condition for a system that consists of two distinct M/M/1 queues arranged in tandem? Problem 6 n For a Poisson process X(t), define Sn as the total time until the nth arrival occurs, where n 1. n Compute the distribution of Sn.
N. Maingi - November 2012

Problem 7
A machine produces parts in such a way that the stream of finished parts is a Poisson process with rate = 10 per hour. a) What is the probability that it produces no finished part in 1 hr? th finished b) What is the expected time at which the 20 part is produced? c) What is the probability that 100 parts are produced in a shift of 8 hr, assuming that the machine works non-stop during the shift?
N. Maingi - November 2012

Problem 8
A manufacturing workstation receives a continuous supply of parts and processes them at a rate of 12 parts per hour with exponentially distributed processing time. However, each part needs to be placed on a special fixture before it can be processed. There are N such fixtures available. When completed at the workstation, a fixture part will be sent to the output buffer instantaneously, and the workstation will start to process a new fixture part (if there is one waiting). One at a time, each processed part on its fixture in the output buffer is unloaded from the fixture by a worker (taking zero time), and the time it takes for the worker to load a new part on the fixture is exponentially distributed with mean 4 min. (Hint: The system can be modeled as an M/M/1/N queue) N. Maingi - November 2012

Problem 8 contd
a)

b)

Determine the greatest number of fixtures such that the average waiting time of a part at the workstation is less than 6 min. Does this number of fixtures satisfy the additional requirement that the utilization of the workstation be at least 80%?

N. Maingi - November 2012

Problem 9
A machine center has unlimited waiting space. Parts arrive at a rate l and service times are exponentially distributed with mean 1/m. The machine center becomes active only when K parts are present. Once active it services one at a time until all K units, and all subsequent arrivals, are serviced. The machine center then switches to another part only when K new arrivals have occurred. a) Define the appropriate state space and write down the balance equations b) What is the average time a customer spends in the queue?
N. Maingi - November 2012

Você também pode gostar