The document discusses different queuing models for analyzing efficiency at railway ticket windows. It summarizes four models: 1) M/M/1 queue with infinite capacity, 2) M/M/1 queue with finite capacity N, 3) M/M/S queue with infinite capacity, and 4) M/M/S queue with finite capacity N. The document provides sample data of arrival and service times over 1 hour and outlines the methodology and assumptions used, including Poisson arrivals and exponential service times. It then shows the manual calculations and Java code for the M/M/1 infinite queue model to find values like average number of customers and waiting times.
This slide was prepared as a part of presentation in a course work of Master in IT, IIT, University of Dhaka. The main slide was prepared by Dr. Sam Labi of Purdue University and Dr. Fred of MIT.
This slide was prepared as a part of presentation in a course work of Master in IT, IIT, University of Dhaka. The main slide was prepared by Dr. Sam Labi of Purdue University and Dr. Fred of MIT.
El compartir esta información es con la finalidad de compartir los conocimientos e inquietudes que van surgiendo cuando emprendes un proyecto, es por ello que al ser participante en CURSERA, me surge la necesidad de compartir mi trabajo para poder obtener sugerencias y recomendaciones que coadyuven con el fortalecimiento de mi labor profesional.
Queuing theory: What is a Queuing system???
Waiting for service is part of our daily life….
Example:
we wait to eat in restaurants….
We queue up in grocery stores…
Jobs wait to be processed on machine…
Vehicles queue up at traffic signal….
Planes circle in a stack before given permission to land at an airport….
Unfortunately, we can not eliminate waiting time without incurring expenses…
But, we can hope to reduce the queue time to a tolerable levels… so that we can avoid adverse impact….
Why study???? What analytics can be drawn??? Analytics means ---- measures of performance such as
1. Average queue length
2. Average waiting time in the queue
3. Average facility utilization….
Talks about what is Queuing and its application, practical life usage, with a complex problem statement with its solution. Pre-emptive and non-preemptive queue models and its algorithm.
Waiting Line Model is one of the decision line model.Waiting Line Model is one of the decision line model.Waiting Line Model is one of the decision line model.Waiting Line Model is one of the decision line model.
Solving Of Waiting Lines Models in the Bank Using Queuing Theory Model the Pr...IOSR Journals
Waiting lines and service systems are important parts of the business world. In this article we describe several common queuing situations and present mathematical models for analyzing waiting lines following certain assumptions. Those assumptions are that (1) arrivals come from an infinite or very large population, (2) arrivals are Poisson distributed, (3) arrivals are treated on a FIFO basis and do not balk or renege, (4) service times follow the negative exponential distribution or are constant, and (5) the average service rate is faster than the average arrival rate. The model illustrated in this Bank for customers on a level with service is the multiple-channel queuing model with Poisson Arrival and Exponential Service Times (M/M/S). After a series of operating characteristics are computed, total expected costs are studied, total costs is the sum of the cost of providing service plus the cost of waiting time. Finally we find the total minimum expected cost.
1. Different Types of Queuing Models -
Implementation
Under the Guidance of Prof. Soumen Pal
MEE437 – Operations Research
Team Members:
Ujjwal Rangarh (13BCE0014)
Joshua Itty
Rohan Bedi
Ashutosh Khushu
Aravind Raj
2. Abstract
This project contains the analysis of the four queuing models for Railway Ticket window as
an example. One of the expected gains from studying queuing systems is to review the
efficiency of the models in terms of utilization and waiting time, hence increasing the number
of queues so passengers will not have to wait longer for their ticket. We may use queuing
theory to obtain a sample performance result.
This project does a queuing simulation for the four queuing models given. This project
includes the answers of both the manual calculations and the programming. The
programming has been done in the JAVA. For each model, a separate program has been
constructed and each program in itself is a stand-alone program. We have the code, input and
output of each queuing model. This study requires an empirical data which may include the
variables like, arrival time in the queue of checkout operating unit, departure time, service
time, etc. This model is developed for minimize the Passengers waiting time in queue at
Railway Ticket Window.
Definition of a Queuing System
A Queueing System can be defined as follows:
"Customers arrive for a given service, wait if the service cannot start immediately and
leave after being served."
A queuing system consists of one or more servers that provide service of some sort to
arriving customers. Customers who arrive to find all servers busy generally join one or more
queues (lines) in front of the servers, hence the name queuing systems. There are several
everyday examples that can be described as queuing systems, such as bank-teller service,
computer systems, manufacturing systems, maintenance systems, communications systems
and so on.
Queueing theory deals with one of the most unpleasant experiences of life, waiting.
The term "customer" can be men, products, machines...
3. The formation of waiting is a common phenomenon which occurs whenever the
current demand for a service exceeds the current capacity to provide that service.
History of Queuing Theory
• The theory of queueing systems was developed to provide models for forecasting
behaviors of systems subject to random demand.
• The first problems addressed concerned congestion of telephone traffic (Erlang, "the
theory of probabilities and telephone conversations ", 1909)
• Erlang observed that a telephone system can be modeled by Poisson customer arrivals
and exponentially distributed service times
• Molina, Pollaczek, Kolmogorov, Khintchine, Palm, Crommelin followed the track
Notationof Kendall
The following is a standard notation system of queueing systems
T/X/C/K/P/Z with
– T: probability distribution of inter-arrival times
– X: probability distribution of service times
– C: Number of servers
– K: Queue capacity
– P: Size of the population
– Z: service discipline
Customer Arrival Process (T)
• T can take the following values:
– M : markovian (i.e. exponential)
– G : general distribution
– D : deterministic
– Ek : Erlang distribution
• If the arrivals are grouped in lots, we use the notation T[X] where X is the random variable
indicating the number of customers at each arrival epoch
– P{X=k} = P{k customers arrive at the same time}
• Some arriving customers can leave if the queue is too long
4. Service Times (X)
• X can take the following values:
– M : markovian (i.e. exponential)
– G : general distribution
– D : deterministic
– Ek : Erlang distribution
k exponential servers with parameter m
Number
of
Servers
(C)
In simple queueing systems, servers are identical.
Queue Capacity (K)
Loss of Customers if the queue is full
Capacity K
5. Size of the Population
The size of the population can be either finite or infinite. For a finite population, the customer
arrival rate is a function of the number of customers in the system: l(n).
Service Discipline
Z can take the following values:
• FCFS or FIFO : First Come First Served
• LCFS or LIFO : Last Come First Served
• RANDOM : service in random order
• HL (Hold On Line) : when an important customer arrives, it takes the head of the
queue
• PR ( Preemption) : when an important customer arrives, it is served immediately and
the customer under service returns to the queue
• PS (Processor Sharing) : All customers are served simultaneously with service rate
inversely proportional to the number of customers
• GD (General Discipline)
Components of a Queuing System
A queuing system is characterised by three components:
- Arrival Process
- Service Mechanism
- Queue Discipline
Arrival Process
Arrivals may originate from one or several sources referred to as the calling population. The
calling population can be limited or 'unlimited'. An example of a limited calling population
may be that of a fixed number of machines that fail randomly. The arrival process consists of
describing how customers arrive to the system. If Ai is the interarrival time between the
arrivals of the (i-1)th and ith customers, we shall denote the mean (or expected) inter-arrival
time by E(A) and call it (λ ); = 1/(E(A) the arrival frequency.
6. Service Mechanism
The service mechanism of a queuing system is specified by the number of servers (denoted
by s), each server having its own queue or a common queue and the probability distribution
of customer's service time. let Si be the service time of the ith customer, we shall denote the
mean service time of a customer by E(S) and µ = 1/(E(S) the service rate of a server.
Queue Discipline
Discipline of a queuing system 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.
Commonly used queue disciplines are:
FIFO - Customers are served on a first-in first-out basis.
LIFO - Customers are served in a last-in first-out manner.
Priority - Customers are served in order of their importance on the basis of their service
requirements.
Classification of Queuing Models
Queuing Models, on the basis of their components, can be classified into following four
models:
1. Model I:- (M/M/1) : (FCFS/∞/∞)
2. Model II:- (M/M/1) : (FCFS/N/∞)
3. Model III:- (M/M/S) : (FCFS/∞/∞)
4. Model IV:- (M/M/S) : (FCFS/N/∞)
Sample Data
As sample data, we will be using the arrival and service provided to the customers for a
period of around 1 hour, from 9 a.m. to 10 a.m. The columns in the table are:
1. Serial Number: It basically depicts the number of customers in the queue
2. Arrival Time: The arrival time of customer in the queue
3. Inter Arrival Time: The time between the arrival of two consequent customers
4. Departure Time: The time between the departure of two consequent customers
7. 5. Service Time: The time taken by the person sitting at the counter to provide service to
the customer
S. No. Arrival Time Inter Arrival Time Departure Time Service Time
1 9:01 0:00 9:03 0:02
2 9:04 0:03 9:05 0:01
3 9:05 0:01 9:07 0:02
4 9:05 0:00 9:09 0:04
5 9:06 0:01 9:10 0:04
6 9:07 0:01 9:11 0:04
7 9:10 0:03 9:14 0:04
8 9:13 0:03 9:16 0:03
9 9:15 0:02 9:18 0:03
10 9:16 0:01 9:19 0:03
11 9:16 0:00 9:20 0:04
12 9:19 0:03 9:21 0:02
13 9:21 0:02 9:22 0:01
14 9:22 0:01 9:23 0:01
15 9:25 0:03 9:26 0:01
16 9:27 0:02 9:29 0:02
17 9:28 0:01 9:30 0:02
18 9:30 0:02 9:30 0:00
19 9:30 0:00 9:32 0:02
20 9:33 0:03 9:34 0:01
21 9:35 0:02 9:36 0:01
22 9:35 0:00 9:38 0:03
23 9:36 0:01 9:39 0:03
24 9:38 0:02 9:41 0:02
25 9:40 0:02 9:43 0:01
26 9:42 0:02 9:44 0:02
27 9:43 0:01 9:44 0:01
23 9:45 0:02 9:45 0:00
24 9:46 0:01 9:47 0:01
25 9:48 0:02 9:49 0:01
26 9:50 0:02 9:51 0:01
27 9:51 0:01 9:53 0:02
28 9:52 0:01 9:55 0:03
29 9:54 0:02 9:57 0:03
30 9:58 0:04 9:59 0:01
Methodology
The term queuing system is used to indicate a collection of one or more waiting lines along
with collection of servers that provide service to these waiting lines. The example of Railway
Station is taken for queuing system discussed in this section include:
A single waiting line and 2 servers.
All results are presented assuming that FCFS(First Come First Serve).
8. Arrival rate of Passengers in a queuing system and service rate per busy server are
constants.
ASSUMPTIONS
Arrivals of Passengers follow a Poisson process
Inter arrival times of a Poisson process are exponentially distributed
Service times are exponentially distributed.
Identical service facilities (same sales checkout service on each server)
No Passenger leaves the queue without being served
FCFS (First Come First Serve)
ModelI: Single Server Infinite Capacity (M/M/1): (FCFS/∞/∞)
Poisson Arrivals, Exponential Service, Single Server, First Come First Serve, Infinite
Capacity and Infinite Population (source). As the Poisson and exponential distributions are
related to each other, both of them are denoted by the symbol “M” due to Markovian property
of exponential distribution.
Manual Calculations
1. Mean Arrival Rate (λ) = 31.579
2. Mean Service Rate (µ)=32.143
3. Traffic Intensity (ρ) or the Utilization Factor = λ/ µ = 0.982
4. Value of P0 = 1 – λ/ µ = 0.018
5. Value of Pn = for n=3, Pn = 0.017
6. Expected (average) number of customers in the system (Ls) =
= 55.99
7. Expected (average) number of customers in the queue (Lq) =
= 55.008
9. 8. Expected time a customer spends in the system (Ws) = Ls/ λ = 1/( µ - λ) = 1.773
9. Expected waiting time per customer in the queue (Wq) = Lq/ λ = 1.742
CODE
import java.io.*;
import java.math.*;
public class Queuing_Model
{
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
double[]queue_arrival=new double[200];
int[]hour_arrival=new int[200];
int[]min_arrival=new int[200];
int[]sec_arrival=new int[200];
double[]queue_departure=new double[200];
int[]hour_departure=new int[200];
int[]min_departure=new int[200];
int[]sec_departure=new int[200];
int queue_len=0;
do
{
10. System.out.print("Enter 1 to add a customer and 0 to stop: ");
int choice=Integer.parseInt(br.readLine());
if(choice==0)
break;
else if(choice!=1 && choice !=0)
{
System.out.println("Please Enter Correct Choice");
continue;
}
System.out.println("Enter Arrival Details");
System.out.print("Enter arrival hours for customer "+(queue_len+1)+": ");
hour_arrival[queue_len]=Integer.parseInt(br.readLine());
System.out.print("Enter arrival minutes for customer "+(queue_len+1)+": ");
min_arrival[queue_len]=Integer.parseInt(br.readLine());
System.out.print("Enter arrival seconds for customer "+(queue_len+1)+": ");
sec_arrival[queue_len]=Integer.parseInt(br.readLine());
queue_arrival[queue_len]=hour_arrival[queue_len]*60.0+min_arrival[queue_len]+sec_arriva
l[queue_len]/60.0;
System.out.println("Enter Departure Details");
System.out.print("Enter departure hours for customer "+(queue_len+1)+": ");
hour_departure[queue_len]=Integer.parseInt(br.readLine());
System.out.print("Enter departure minutes for customer "+(queue_len+1)+": ");
min_departure[queue_len]=Integer.parseInt(br.readLine());
System.out.print("Enter departure seconds for customer "+(queue_len+1)+": ");
12. double pn=Math.pow(traffic_intensity,nval)*total;
System.out.println("The Value of Pn is "+pn);
double ls=lambda*1.0/(mu-lambda);
System.out.println("Expected (Average) number of customers in the system (Ls) = "+ls);
double lq=ls-traffic_intensity;
System.out.println("Expected (Average) number of customers waiting in the queue (Lq)
= "+lq);
double ws=ls/lambda;
double wq=lq/lambda;
System.out.println("Expected (Average) time a customer spends in the system = "+ws);
System.out.println("Expected (Average) waiting time of a customer in the queue =
"+wq);
}
}
Output
Enter 1 to add a customer and 0 to stop: 1
Enter Arrival Details
Enter arrival hours for customer 2: 9
Enter arrival minutes for customer 2: 4
13. Enter arrival seconds for customer 2: 0
Enter Departure Details
Enter departure hours for customer 2: 9
Enter departure minutes for customer 2: 5
Enter departure seconds for customer 2: 0
Enter 1 to add a customer and 0 to stop: 1
Enter Arrival Details
Enter arrival hours for customer 3: 9
Enter arrival minutes for customer 3: 5
Enter arrival seconds for customer 3: 0
……………
Number of Customers in the System: 30
Mean Arrival Rate of Customers: 31.578947368421055
Mean Service Rate of Individual Channel 32.14285714285714
Traffic Intensity or The Utilization Rate: 0.9824561403508774
The value of P0 is: 0.01754385964912264
Enter the value of n for Pn: 3
The Value of Pn is 0.016636603198502766
Expected (Average) number of customers in the system (Ls) = 56.00000000000063
Expected (Average) number of customers waiting in the queue (Lq) = 55.017543859649756
Expected (Average) time a customer spends in the system = 1.7733333333333532
Expected (Average) waiting time of a customer in the queue = 1.742222222222242
ModelII: Single Server Finite Capacity (M/M/1): (FCFS/N/∞)
In this model, the capacity of the system is limited to N (say). In this model when the number
of customers in the system becomes N, no new arrivals can be accommodated, so therefore
for this model we have-
14. Manual Calculations
1. Mean Arrival Rate (λ) = 31.579
2. Mean Service Rate (µ)=32.143
3. Limit of the Counter (System) (N) = 10
4. Traffic Intensity (ρ) or the Utilization Factor = λ/ µ = 0.982
5. Value of P0 = = 0.09938
6. Value of Pn = P0* ρ ^n for n=3, Pn = 0.094
7. Expected (average) number of customers in the system (Ls) =
= 4.818
8. Expected (average) number of customers in the queue (Lq) =
= 3.9175
9. Expected time a customer spends in the system (Ws)
= 0.1664
10. Expected waiting time per customer in the queue (Wq)
= 0.1353
CODE
import java.io.*;
import java.math.*;
public class Queuing_Model2
{
public static void main(String args[])throws IOException
15. {
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
System.out.print("Enter the limit of the counter (system): ");
int n=Integer.parseInt(br.readLine());
double[]queue_arrival=new double[200];
int[]hour_arrival=new int[200];
int[]min_arrival=new int[200];
int[]sec_arrival=new int[200];
double[]queue_departure=new double[200];
int[]hour_departure=new int[200];
int[]min_departure=new int[200];
int[]sec_departure=new int[200];
int queue_len=0;
do
{
System.out.print("Enter 1 to add a customer and 0 to stop:");
int choice=Integer.parseInt(br.readLine());
if(choice==0)
break;
17. min_departure[queue_len]=Integer.parseInt(br.readLine());
System.out.print("Enter departure seconds for customer
"+(queue_len+1)+": ");
sec_departure[queue_len]=Integer.parseInt(br.readLine());
queue_departure[queue_len]=hour_departure[queue_len]*60.0+min_departure[
queue_len]+sec_departure[queue_len]/60.0;
++queue_len;
}while(true);
double lambda,mu;
lambda=queue_len*1.0/((queue_arrival[queue_len-1]-queue_arrival[0])/60);
mu=queue_len*1.0/((queue_departure[queue_len-1]-
queue_departure[0])/60);
System.out.println("nnnnNumber of Customers in the System:
"+queue_len);
System.out.println("Mean Arrival Rate of Customers: "+lambda);
System.out.println("Mean Service Rate of Individual Channel "+mu);
double traffic_intensity=lambda*1.0/mu;
System.out.println("Traffic Intensity or The Utilization Rate:
"+traffic_intensity);
18. double total=(1-traffic_intensity)*1.0/(1-
Math.pow(traffic_intensity,(n+1)));
System.out.println("The Vaue of P0 is "+total);
System.out.print("Enter the value of n for Pn: ");
int nval=Integer.parseInt(br.readLine());
double pn=Math.pow(traffic_intensity,nval)*total;
System.out.println("The Value of Pn is "+pn);
double ls=0.0;
for(int i=1;i<=n;++i)
{
ls=ls+i*Math.pow(traffic_intensity,i)*total;
}
System.out.println("Expected (Average) number of customers in the
system (Ls) = "+ls);
double val1=0.0;
for(int i=1;i<=n;++i)
{
val1=val1+Math.pow(traffic_intensity,i)*total;
}
19. double lq=ls-val1;
System.out.println("Expected (Average) number of customers waiting in
the queue (Lq) = "+lq);
double lambda_dash=lambda*1.0*(1-
(Math.pow(traffic_intensity,n)*total));
System.out.println("The Value of Lambda Dash: "+lambda_dash);
double ws=ls/lambda_dash;
double wq=lq/lambda_dash;
System.out.println("Expected (Average) time a customer spends in the
system = "+ws);
System.out.println("Expected (Average) waiting time of a customer in the
queue = "+wq);
}
}
Output
Enter the limit of the counter (system): 10
Enter 1 to add a customer and 0 to stop: 1
Enter Arrival Details
20. Enter arrival hours for customer 1: 9
Enter arrival minutes for customer 1: 1
Enter arrival seconds for customer 1: 0
Enter Departure Details
Enter departure hours for customer 1: 9
Enter departure minutes for customer 1: 3
Enter departure seconds for customer 1: 0
Enter 1 to add a customer and 0 to stop: 1
Enter Arrival Details
Enter arrival hours for customer 2: 9
Enter arrival minutes for customer 2: 4
Enter arrival seconds for customer 2: 0
Enter Departure Details
Enter departure hours for customer 2: 9
Enter departure minutes for customer 2: 5
Enter departure seconds for customer 2: 0
Enter 1 to add a customer and 0 to stop: 1
Enter Arrival Details
Enter arrival hours for customer 3: 9
Enter arrival minutes for customer 3: 5
Enter arrival seconds for customer 3: 0
Enter Departure Details
Enter departure hours for customer 3: 9
Enter departure minutes for customer 3: 7
Enter departure seconds for customer 3: 0
Enter 1 to add a customer and 0 to stop: 1
Enter Arrival Details
21. Enter arrival hours for customer 4: 9
Enter arrival minutes for customer 4: 5
Enter arrival seconds for customer 4: 0
Enter Departure Details
Enter departure hours for customer 4: 9
Enter departure minutes for customer 4: 9
Enter departure seconds for customer 4: 0
Enter 1 to add a customer and 0 to stop: 1
Enter Arrival Details
Enter arrival hours for customer 5: 9
Enter arrival minutes for customer 5: 6
Enter arrival seconds for customer 5: 0
Enter Departure Details
Enter departure hours for customer 5: 9
Enter departure minutes for customer 5: 10
Enter departure seconds for customer 5: 0
………………….
Number of Customers in the System: 30
Mean Arrival Rate of Customers: 31.578947368421055
Mean Service Rate of Individual Channel 32.14285714285714
Traffic Intensity or The Utilization Rate: 0.9824561403508774
The Vaue of P0 is 0.09916568281925206
Enter the value of n for Pn: 3
The Value of Pn is 0.09403746661043225
Expected (Average) number of customers in the system (Ls) = 4.823116872328931
Expected (Average) number of customers waiting in the queue (Lq) = 3.9222825551481826
The Value of Lambda Dash: 28.955388766524038
22. Expected (Average) time a customer spends in the system = 0.1665706135469002
Expected (Average) waiting time of a customer in the queue = 0.13545950243578908
ModelIII: Multi Server Infinite Capacity(M/M/c): (FCFS/∞/∞)
In this model customers arrive in a Poisson fashion with mean arrival rate λ. There are ‘c’
(fixed) numbers of service stations arranged in parallel, and a customer can go to any of the
free counters for his service. The service time at each counter is identical and follows the
same exponential distribution law. Service discipline is FCFS and customers are taken from a
single queue i.e. any empty channel is filled by the next customer in line.
Manual Calculations
1. Number of Counters (c) = 2
2. Mean Arrival Rate (λ) = 31.579
3. Mean Service Rate (µ)=32.143
4. Limit of the Counter (System) (N) = 10
5. Traffic Intensity (ρ) or the Utilization Factor = λ/c µ = 0.49
6. Value of P0 = = 0.341
7. Value of Pn = for n=3, Pn = 6.026E-10
8. Expected (average) number of customers in the system (Ls) =
= 1.29
9. Expected (average) number of customers in the queue (Lq) =
= 0.31
10. Expected time a customer spends in the system (Ws) = Ls/ λ = 0.041
23. 11. Expected waiting time per customer in the queue (Wq) = Lq/ λ = 0.009
12. Probability that the customer has to wait (P (n>=c)) =
= 0.323
13. Probability that the customer enters the service without waiting = 1- Probability that
the customer has to wait = 0.67
14. Expected number of idle Counters at any specified time = c – [average number of
customers served] = 1.017
CODE
import java.io.*;
import java.math.*;
public class Queuing_Model3
{
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the number of counters: ");
int server=Integer.parseInt(br.readLine());
double[]queue_arrival=new double[200];
int[]hour_arrival=new int[200];
int[]min_arrival=new int[200];
int[]sec_arrival=new int[200];
double[]queue_departure=new double[200];
int[]hour_departure=new int[200];
int[]min_departure=new int[200];
24. int[]sec_departure=new int[200];
int queue_len=0;
do
{
System.out.print("Enter 1 to add a customer and 0 to stop: ");
int choice=Integer.parseInt(br.readLine());
if(choice==0)
break;
else if(choice!=1 && choice !=0)
{
System.out.println("Please Enter Correct Choice");
continue;
}
System.out.println("Enter Arrival Details");
System.out.print("Enter arrival hours for customer "+(queue_len+1)+": ");
hour_arrival[queue_len]=Integer.parseInt(br.readLine());
System.out.print("Enter arrival minutes for customer "+(queue_len+1)+": ");
min_arrival[queue_len]=Integer.parseInt(br.readLine());
System.out.print("Enter arrival seconds for customer "+(queue_len+1)+": ");
sec_arrival[queue_len]=Integer.parseInt(br.readLine());
queue_arrival[queue_len]=hour_arrival[queue_len]*60.0+min_arrival[queue_len]+sec_arriva
l[queue_len]/60.0;
25. System.out.println("Enter Departure Details");
System.out.print("Enter departure hours for customer "+(queue_len+1)+": ");
hour_departure[queue_len]=Integer.parseInt(br.readLine());
System.out.print("Enter departure minutes for customer "+(queue_len+1)+": ");
min_departure[queue_len]=Integer.parseInt(br.readLine());
System.out.print("Enter departure seconds for customer "+(queue_len+1)+": ");
sec_departure[queue_len]=Integer.parseInt(br.readLine());
queue_departure[queue_len]=hour_departure[queue_len]*60.0+min_departure[queue_len]+s
ec_departure[queue_len]/60.0;
++queue_len;
}while(true);
double lambda,mu;
lambda=queue_len*1.0/((queue_arrival[queue_len-1]-queue_arrival[0])/60);
mu=queue_len*1.0/((queue_departure[queue_len-1]-queue_departure[0])/60);
System.out.println("nnnnNumber of Customers in the System: "+queue_len);
System.out.println("Mean Arrival Rate of Customers: "+lambda);
System.out.println("Mean Service Rate of Individual Channel "+mu);
double traffic_intensity=lambda*1.0/server/mu;
System.out.println("Traffic Intensity or The Utilization Rate: "+traffic_intensity);
26. double val1=lambda*1.0/mu;
double total=1;
for(int j=1;j<server;++j)
total=total+Math.pow(val1,j)*1.0/fact(j);
total=total+Math.pow(val1,server)/fact(server)*(server*mu/(server*mu-lambda));
total=1/total;
System.out.println("The Vaue of P0 is "+total);
System.out.print("Enter the value of n for Pn: ");
int nval=Integer.parseInt(br.readLine());
double pn=Math.pow(val1,nval)*total/Math.pow(server,(queue_len-
server))/fact(server);
System.out.println("The Value of Pn is "+pn);
double val2=Math.pow((server*mu-lambda),2);
double val3=mu*lambda*Math.pow(val1,server);
double ls=val3/fact(server-1)/val2*total+val1;
System.out.println("Expected (Average) number of customers in the system (Ls) = "+ls);
double lq=ls-val1;
System.out.println("Expected (Average) number of customers waiting in the queue (Lq)
= "+lq);
double ws=ls/lambda;
double wq=lq/lambda;
27. System.out.println("Expected (Average) time a customer spends in the system = "+ws);
System.out.println("Expected (Average) waiting time of a customer in the queue =
"+wq);
double prob=mu*Math.pow(val1,server)/fact(server-1)/(server*mu-lambda)*total;
System.out.println("Probability that the Customer has to Wait: "+prob);
System.out.println("Probability that the customer enters the service without waiting:
"+(1-prob));
int val6=server-1;
double val4=total*server;
for(int i=1;i<server;++i)
{
double val31=Math.pow(val1,i)*total*1.0/fact(i);
val31=val6*val31;
--val6;
val4=val4+val31;
}
System.out.println("Expected number of Idle Counters at any Specified time :" + val4);
}
public static int fact(int n)
{
int total=1;
28. for(int i=n;i>=1;--i)
total=total*i;
return total;
}
}
Output
Enter the number of counters: 2
……….
Enter 1 to add a customer and 0 to stop: 1
Enter Arrival Details
Enter arrival hours for customer 29: 9
Enter arrival minutes for customer 29: 54
Enter arrival seconds for customer 29: 0
Enter Departure Details
Enter departure hours for customer 29: 9
Enter departure minutes for customer 29: 57
Enter departure seconds for customer 29: 0
Enter 1 to add a customer and 0 to stop: 1
Enter Arrival Details
Enter arrival hours for customer 30: 9
Enter arrival minutes for customer 30: 58
Enter arrival seconds for customer 30: 0
Enter Departure Details
Enter departure hours for customer 30: 9
Enter departure minutes for customer 30: 59
Enter departure seconds for customer 30: 0
29. Enter 1 to add a customer and 0 to stop: 0
Number of Customers in the System: 30
Mean Arrival Rate of Customers: 31.578947368421055
Mean Service Rate of Individual Channel 32.14285714285714
Traffic Intensity or The Utilization Rate: 0.4912280701754387
The Vaue of P0 is 0.3411764705882352
Enter the value of n for Pn: 3
The Value of Pn is 6.026271749753577E-10
Expected (Average) number of customers in the system (Ls) = 1.294929006085193
Expected (Average) number of customers waiting in the queue (Lq) = 0.31247286573431565
Expected (Average) time a customer spends in the system = 0.04100608519269778
Expected (Average) waiting time of a customer in the queue = 0.009894974081586662
Probability that the Customer has to Wait: 0.32363261093911255
Probability that the customer enters the service without waiting: 0.6763673890608874
Expected number of Idle Counters at any Specified time :1.0175438596491226
ModelIV: Single ServerFinite Capacity and Limited Population (M/M/1):
(FCFS/n/M)
In some situations, customers arrive from a limited pool of potential customers. Once a unit
joins the queue, there is one less unit which could arrive and, therefore, the probability of an
arrival is lowered. When a unit is served, it re-joins the pool of potential customers, and the
probability of an arrival is, thereby, increased.
In this model, the probability of an arrival depends upon the number of potential customers
available to enter the system. Thus, if the total customers’ population is M and n represents
the number of customers already in the queuing system, any arrival must come from M-n
number that is not yet in the system.
Manual Calculations
1. Maximum number of customers that the person in the window can serve = 10
2. Mean Arrival Rate (λ) = 31.579
30. 3. Mean Service Rate (µ)=32.143
4. Value of P0 = = 1.193E-7
5. Value of Pn = for n=3, Pn = 8.13E-5
6. Expected (average) number of customers in the system (Ls) =
= 8.982
7. Expected (average) number of customers in the queue (Lq) = 7.982
=
8. Expected time a customer spends in the system (Ws) = Ls/ λ = 0.2844
9. Expected time a customer spends in the system (Wq) = Lq/ λ = 0.252
CODE
import java.io.*;
import java.math.*;
public class Queuing_Model4
{
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the number of limited pool of potential customers (M)i.e., nthe
amount of customers that the person sitting at the counter can serve: ");
int m=Integer.parseInt(br.readLine());
System.out.print("Enter the maximum number of customers possible (n): ");
int n=Integer.parseInt(br.readLine());
31. double[]queue_arrival=new double[200];
int[]hour_arrival=new int[200];
int[]min_arrival=new int[200];
int[]sec_arrival=new int[200];
double[]queue_departure=new double[200];
int[]hour_departure=new int[200];
int[]min_departure=new int[200];
int[]sec_departure=new int[200];
int queue_len=0;
do
{
System.out.print("Enter 1 to add a customer and 0 to stop: ");
int choice=Integer.parseInt(br.readLine());
if(choice==0)
break;
else if(choice!=1 && choice !=0)
{
System.out.println("Please Enter Correct Choice");
continue;
}
System.out.println("Enter Arrival Details");
32. System.out.print("Enter arrival hours for customer "+(queue_len+1)+": ");
hour_arrival[queue_len]=Integer.parseInt(br.readLine());
System.out.print("Enter arrival minutes for customer "+(queue_len+1)+": ");
min_arrival[queue_len]=Integer.parseInt(br.readLine());
System.out.print("Enter arrival seconds for customer "+(queue_len+1)+": ");
sec_arrival[queue_len]=Integer.parseInt(br.readLine());
queue_arrival[queue_len]=hour_arrival[queue_len]*60.0+min_arrival[queue_len]+sec_arriva
l[queue_len]/60.0;
System.out.println("Enter Departure Details");
System.out.print("Enter departure hours for customer "+(queue_len+1)+": ");
hour_departure[queue_len]=Integer.parseInt(br.readLine());
System.out.print("Enter departure minutes for customer "+(queue_len+1)+": ");
min_departure[queue_len]=Integer.parseInt(br.readLine());
System.out.print("Enter departure seconds for customer "+(queue_len+1)+": ");
sec_departure[queue_len]=Integer.parseInt(br.readLine());
queue_departure[queue_len]=hour_departure[queue_len]*60.0+min_departure[queue_len]+s
ec_departure[queue_len]/60.0;
++queue_len;
}while(true);
double lambda,mu;
33. lambda=queue_len*1.0/((queue_arrival[queue_len-1]-queue_arrival[0])/60);
mu=queue_len*1.0/((queue_departure[queue_len-1]-queue_departure[0])/60);
System.out.println("nnnnNumber of Customers in the System: "+queue_len);
System.out.println("Mean Arrival Rate of Customers: "+lambda);
System.out.println("Mean Service Rate of Individual Channel "+mu);
double traffic_intensity=lambda*1.0/mu;
double total=0.0;
for(int i=0;i<=m;++i)
{
double val=fact(m)*1.0/fact(m-i)*Math.pow(traffic_intensity,i);
total=total+val;
}
total=1/total;
System.out.println("The Value of P0 is "+total);
System.out.print("Enter the value of n for Pn: ");
int nval=Integer.parseInt(br.readLine());
double pn=Math.pow(traffic_intensity,nval)*total*fact(m)/fact(m-nval);;
System.out.println("The Value of Pn is "+pn);
double val2=mu/lambda*1.0*(1-total);
double ls=m-val2;
System.out.println("Expected (Average) number of customers in the system (Ls) = "+ls);
34. double val3=(1-total)*1.0/lambda*(mu+lambda);
double lq=m-val3;
System.out.println("Expected (Average) number of customers waiting in the queue (Lq)
= "+lq);
double ws=ls/lambda;
double wq=lq/lambda;
System.out.println("Expected (Average) time a customer spends in the system = "+ws);
System.out.println("Expected (Average) waiting time of a customer in the queue =
"+wq);
}
public static int fact(int n)
{
int total=1;
for(int i=n;i>=1;--i)
total=total*i;
return total;
}
}
Output
Enter the number of limited pool of potential customers (M)i.e.,
the amount of customers that the person sitting at the counter can serve: 10
Enter the maximum number of customers possible (n): 10
Enter 1 to add a customer and 0 to stop: 1
35. Enter Arrival Details
Enter arrival hours for customer 1: 9
Enter arrival minutes for customer 1: 1
Enter arrival seconds for customer 1: 0
Enter Departure Details
Enter departure hours for customer 1: 9
Enter departure minutes for customer 1: 3
Enter departure seconds for customer 1: 0
Enter 1 to add a customer and 0 to stop: 1
Enter Arrival Details
Enter arrival hours for customer 2: 9
Enter arrival minutes for customer 2: 4
Enter arrival seconds for customer 2: 0
Enter Departure Details
Enter departure hours for customer 2: 9
Enter departure minutes for customer 2: 5
Enter departure seconds for customer 2: 0
Enter 1 to add a customer and 0 to stop: 1
Enter Arrival Details
Enter arrival hours for customer 3: 9
Enter arrival minutes for customer 3: 5
Enter arrival seconds for customer 3: 0
Enter Departure Details
Enter departure hours for customer 3: 9
Enter departure minutes for customer 3: 7
Enter departure seconds for customer 3: 0
Enter 1 to add a customer and 0 to stop:
36. …………………………
Number of Customers in the System: 30
Mean Arrival Rate of Customers: 31.578947368421055
Mean Service Rate of Individual Channel 32.14285714285714
The Value of P0 is 1.1886541705856777E-7
Enter the value of n for Pn: 2
The Value of Pn is 1.0325815731181957E-5
Expected (Average) number of customers in the system (Ls) = 8.982142978130872
Expected (Average) number of customers waiting in the queue (Lq) = 7.982143096996289
Expected (Average) time a customer spends in the system = 0.2844345276408109
Expected (Average) waiting time of a customer in the queue = 0.2527678647382158