SlideShare a Scribd company logo
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
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...
 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
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
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.
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
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).
 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
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
{
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)+": ");
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/mu;
System.out.println("Traffic Intensity or The Utilization Rate: "+traffic_intensity);
double total=1-traffic_intensity;
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;
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
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-
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
{
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;
else if(choice!=1 && choice !=0)
{
System.out.println("Please Enter CorrectChoice");
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 forcustomer
"+(queue_len+1)+": ");
sec_arrival[queue_len]=Integer.parseInt(br.readLine());
queue_arrival[queue_len]=hour_arrival[queue_len]*60.0+min_arrival[queue_le
n]+sec_arrival[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]+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);
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;
}
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
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
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
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
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];
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;
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);
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;
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;
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
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
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());
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");
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;
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);
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
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:
…………………………
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

More Related Content

What's hot

QUEUING THEORY
QUEUING THEORYQUEUING THEORY
QUEUING THEORYavtarsingh
 
Queuing Theory - Operation Research
Queuing Theory - Operation ResearchQueuing Theory - Operation Research
Queuing Theory - Operation Research
Manmohan Anand
 
Unit 4 queuing models
Unit 4 queuing modelsUnit 4 queuing models
Unit 4 queuing models
raksharao
 
Queueing theory basics
Queueing theory basicsQueueing theory basics
Queueing theory basicsTala Alnaber
 
Queuing theory and simulation (MSOR)
Queuing theory and simulation (MSOR)Queuing theory and simulation (MSOR)
Queuing theory and simulation (MSOR)
snket
 
Queuing theory network
Queuing theory networkQueuing theory network
Queuing theory network
Amit Dahal
 
QUEUEING NETWORKS
QUEUEING NETWORKSQUEUEING NETWORKS
QUEUEING NETWORKS
RohitK71
 
Queuing theory and simulation (MSOR)
Queuing theory and simulation (MSOR)Queuing theory and simulation (MSOR)
Queuing theory and simulation (MSOR)
snket
 
Queuing theory
Queuing theoryQueuing theory
Queuing theoryAbu Bashar
 
Queuing unit v ppt
Queuing unit v pptQueuing unit v ppt
Queuing unit v ppt
Abilaasha Ganesan
 
Queuing theory .
Queuing theory .Queuing theory .
Queuing theory .
GarimaGoel25
 
Introduction to queueing theory
Introduction to queueing theoryIntroduction to queueing theory
Introduction to queueing theoryPresi
 
queueing problems in banking
queueing problems in bankingqueueing problems in banking
queueing problems in banking
Mani Deep
 
Unit 1 introduction contd
Unit 1 introduction contdUnit 1 introduction contd
Unit 1 introduction contd
raksharao
 
Queing theory and delay analysis
Queing theory and delay analysisQueing theory and delay analysis
Queing theory and delay analysis
Priyanka Negi
 
QUEUEING THEORY
QUEUEING THEORYQUEUEING THEORY
QUEUEING THEORY
srishti jain
 

What's hot (20)

QUEUING THEORY
QUEUING THEORYQUEUING THEORY
QUEUING THEORY
 
Queuing Theory - Operation Research
Queuing Theory - Operation ResearchQueuing Theory - Operation Research
Queuing Theory - Operation Research
 
Unit 4 queuing models
Unit 4 queuing modelsUnit 4 queuing models
Unit 4 queuing models
 
Queue
QueueQueue
Queue
 
Queueing theory basics
Queueing theory basicsQueueing theory basics
Queueing theory basics
 
Queuing theory and simulation (MSOR)
Queuing theory and simulation (MSOR)Queuing theory and simulation (MSOR)
Queuing theory and simulation (MSOR)
 
Queuing theory network
Queuing theory networkQueuing theory network
Queuing theory network
 
Ramniwas final
Ramniwas finalRamniwas final
Ramniwas final
 
QUEUEING NETWORKS
QUEUEING NETWORKSQUEUEING NETWORKS
QUEUEING NETWORKS
 
Queuing Theory
Queuing TheoryQueuing Theory
Queuing Theory
 
Queueing theory
Queueing theoryQueueing theory
Queueing theory
 
Queuing theory and simulation (MSOR)
Queuing theory and simulation (MSOR)Queuing theory and simulation (MSOR)
Queuing theory and simulation (MSOR)
 
Queuing theory
Queuing theoryQueuing theory
Queuing theory
 
Queuing unit v ppt
Queuing unit v pptQueuing unit v ppt
Queuing unit v ppt
 
Queuing theory .
Queuing theory .Queuing theory .
Queuing theory .
 
Introduction to queueing theory
Introduction to queueing theoryIntroduction to queueing theory
Introduction to queueing theory
 
queueing problems in banking
queueing problems in bankingqueueing problems in banking
queueing problems in banking
 
Unit 1 introduction contd
Unit 1 introduction contdUnit 1 introduction contd
Unit 1 introduction contd
 
Queing theory and delay analysis
Queing theory and delay analysisQueing theory and delay analysis
Queing theory and delay analysis
 
QUEUEING THEORY
QUEUEING THEORYQUEUEING THEORY
QUEUEING THEORY
 

Viewers also liked

unidad de almacenamiento
unidad de almacenamientounidad de almacenamiento
unidad de almacenamiento
yeritzasagitario
 
1 historiadelas computadoras.pdf presentacion
1 historiadelas computadoras.pdf presentacion1 historiadelas computadoras.pdf presentacion
1 historiadelas computadoras.pdf presentacionMarta Alicia Romero
 
Ventajas y desventajas
Ventajas y desventajasVentajas y desventajas
Ventajas y desventajascecitanaula
 
Tablas de contenidos
Tablas de contenidosTablas de contenidos
Tablas de contenidosmariaarce93
 
Activida pedagogica ciencias naturales y educacion ambiental visita
Activida pedagogica ciencias naturales y educacion ambiental visitaActivida pedagogica ciencias naturales y educacion ambiental visita
Activida pedagogica ciencias naturales y educacion ambiental visitatino2013
 
La organizacion grupo Nuñez Wagner
La organizacion grupo Nuñez WagnerLa organizacion grupo Nuñez Wagner
La organizacion grupo Nuñez WagnerWagnerfer
 
Luis macias
Luis maciasLuis macias
Luis maciasluis8520
 
La contracció
La contraccióLa contracció
La contraccióessavinar
 
Diseminacion de conocimiento. loren
Diseminacion de conocimiento. lorenDiseminacion de conocimiento. loren
Diseminacion de conocimiento. loren
Lore Gutierrez
 
Tecnologías de puntas
Tecnologías de puntasTecnologías de puntas
Tecnologías de puntascacatiareke
 
Carnaval de venecia,
Carnaval de venecia,Carnaval de venecia,
Carnaval de venecia,Mari Wence
 

Viewers also liked (20)

unidad de almacenamiento
unidad de almacenamientounidad de almacenamiento
unidad de almacenamiento
 
Guía publicaciones y terminología twitter
Guía publicaciones y terminología twitterGuía publicaciones y terminología twitter
Guía publicaciones y terminología twitter
 
1 historiadelas computadoras.pdf presentacion
1 historiadelas computadoras.pdf presentacion1 historiadelas computadoras.pdf presentacion
1 historiadelas computadoras.pdf presentacion
 
Ventajas y desventajas
Ventajas y desventajasVentajas y desventajas
Ventajas y desventajas
 
Tp n° 6 domótica
Tp n° 6 domóticaTp n° 6 domótica
Tp n° 6 domótica
 
Tablas de contenidos
Tablas de contenidosTablas de contenidos
Tablas de contenidos
 
Activida pedagogica ciencias naturales y educacion ambiental visita
Activida pedagogica ciencias naturales y educacion ambiental visitaActivida pedagogica ciencias naturales y educacion ambiental visita
Activida pedagogica ciencias naturales y educacion ambiental visita
 
Presentación1
Presentación1Presentación1
Presentación1
 
La organizacion grupo Nuñez Wagner
La organizacion grupo Nuñez WagnerLa organizacion grupo Nuñez Wagner
La organizacion grupo Nuñez Wagner
 
Luis macias
Luis maciasLuis macias
Luis macias
 
La contracció
La contraccióLa contracció
La contracció
 
Las plantas
Las plantasLas plantas
Las plantas
 
Diseminacion de conocimiento. loren
Diseminacion de conocimiento. lorenDiseminacion de conocimiento. loren
Diseminacion de conocimiento. loren
 
Acero
AceroAcero
Acero
 
Autobiografía
AutobiografíaAutobiografía
Autobiografía
 
Tecnologías de puntas
Tecnologías de puntasTecnologías de puntas
Tecnologías de puntas
 
Acero
AceroAcero
Acero
 
Bunburyyy
BunburyyyBunburyyy
Bunburyyy
 
Carnaval de venecia,
Carnaval de venecia,Carnaval de venecia,
Carnaval de venecia,
 
Resumen 5
Resumen 5 Resumen 5
Resumen 5
 

Similar to Operation Research

Queuing theory
Queuing theoryQueuing theory
Queuing theory
Mufaddal Haidermota
 
Simple queuingmodelspdf
Simple queuingmodelspdfSimple queuingmodelspdf
Simple queuingmodelspdfAnkit Katiyar
 
Operations Research_18ME735_module 4 - queuing systems.pdf
Operations Research_18ME735_module 4 - queuing systems.pdfOperations Research_18ME735_module 4 - queuing systems.pdf
Operations Research_18ME735_module 4 - queuing systems.pdf
RoopaDNDandally
 
Queuing Theory
Queuing TheoryQueuing Theory
Queuing Theory
RenjithVRavi1
 
Queuing theory and its applications
Queuing theory and its applicationsQueuing theory and its applications
Queuing theory and its applications
DebasisMohanty37
 
Simulation chapter 4
Simulation chapter 4Simulation chapter 4
Simulation chapter 4
Hagos Guesh
 
Queuing theory
Queuing theoryQueuing theory
Queuing theory
Amit Sinha
 
SolvingOfWaitingLinesModelsintheBankUsingQueuingTheoryModel.pdf
SolvingOfWaitingLinesModelsintheBankUsingQueuingTheoryModel.pdfSolvingOfWaitingLinesModelsintheBankUsingQueuingTheoryModel.pdf
SolvingOfWaitingLinesModelsintheBankUsingQueuingTheoryModel.pdf
eshetu38
 
Decision Sciences_SBS_9.pdf
Decision Sciences_SBS_9.pdfDecision Sciences_SBS_9.pdf
Decision Sciences_SBS_9.pdf
KhushbooJoshiSBS
 
Queuing Theory
Queuing TheoryQueuing Theory
Queuing Theory
Dallina1
 
Operational research queuing theory
Operational research queuing theoryOperational research queuing theory
Operational research queuing theory
Vidhya Kannan
 
Unit V - Queuing Theory
Unit V - Queuing TheoryUnit V - Queuing Theory
Solving Of Waiting Lines Models in the Bank Using Queuing Theory Model the Pr...
Solving Of Waiting Lines Models in the Bank Using Queuing Theory Model the Pr...Solving Of Waiting Lines Models in the Bank Using Queuing Theory Model the Pr...
Solving Of Waiting Lines Models in the Bank Using Queuing Theory Model the Pr...
IOSR Journals
 
solving restaurent model problem by using queueing theory
solving restaurent model problem by using queueing theorysolving restaurent model problem by using queueing theory
solving restaurent model problem by using queueing theory
Subham kumar
 
Unit 3 des
Unit 3 desUnit 3 des
Unit 3 des
DevaKumari Vijay
 
chapter11 liner model programing.pptx
chapter11 liner model programing.pptxchapter11 liner model programing.pptx
chapter11 liner model programing.pptx
JAMESFRANCISGOSE
 

Similar to Operation Research (20)

QUEUING THEORY
QUEUING THEORY QUEUING THEORY
QUEUING THEORY
 
Queuing theory
Queuing theoryQueuing theory
Queuing theory
 
Simple queuingmodelspdf
Simple queuingmodelspdfSimple queuingmodelspdf
Simple queuingmodelspdf
 
Operations Research_18ME735_module 4 - queuing systems.pdf
Operations Research_18ME735_module 4 - queuing systems.pdfOperations Research_18ME735_module 4 - queuing systems.pdf
Operations Research_18ME735_module 4 - queuing systems.pdf
 
Queuing Theory
Queuing TheoryQueuing Theory
Queuing Theory
 
Queuing theory and its applications
Queuing theory and its applicationsQueuing theory and its applications
Queuing theory and its applications
 
Simulation chapter 4
Simulation chapter 4Simulation chapter 4
Simulation chapter 4
 
Queuing theory
Queuing theoryQueuing theory
Queuing theory
 
Tps04
Tps04Tps04
Tps04
 
SolvingOfWaitingLinesModelsintheBankUsingQueuingTheoryModel.pdf
SolvingOfWaitingLinesModelsintheBankUsingQueuingTheoryModel.pdfSolvingOfWaitingLinesModelsintheBankUsingQueuingTheoryModel.pdf
SolvingOfWaitingLinesModelsintheBankUsingQueuingTheoryModel.pdf
 
Decision Sciences_SBS_9.pdf
Decision Sciences_SBS_9.pdfDecision Sciences_SBS_9.pdf
Decision Sciences_SBS_9.pdf
 
Queuing Theory
Queuing TheoryQueuing Theory
Queuing Theory
 
Operational research queuing theory
Operational research queuing theoryOperational research queuing theory
Operational research queuing theory
 
Unit V - Queuing Theory
Unit V - Queuing TheoryUnit V - Queuing Theory
Unit V - Queuing Theory
 
Traffic analysis
Traffic analysisTraffic analysis
Traffic analysis
 
Solving Of Waiting Lines Models in the Bank Using Queuing Theory Model the Pr...
Solving Of Waiting Lines Models in the Bank Using Queuing Theory Model the Pr...Solving Of Waiting Lines Models in the Bank Using Queuing Theory Model the Pr...
Solving Of Waiting Lines Models in the Bank Using Queuing Theory Model the Pr...
 
solving restaurent model problem by using queueing theory
solving restaurent model problem by using queueing theorysolving restaurent model problem by using queueing theory
solving restaurent model problem by using queueing theory
 
Unit 3 des
Unit 3 desUnit 3 des
Unit 3 des
 
Chapter 14R
Chapter 14RChapter 14R
Chapter 14R
 
chapter11 liner model programing.pptx
chapter11 liner model programing.pptxchapter11 liner model programing.pptx
chapter11 liner model programing.pptx
 

Operation Research

  • 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)+": ");
  • 11. 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/mu; System.out.println("Traffic Intensity or The Utilization Rate: "+traffic_intensity); double total=1-traffic_intensity; 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());
  • 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;
  • 16. else if(choice!=1 && choice !=0) { System.out.println("Please Enter CorrectChoice"); 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 forcustomer "+(queue_len+1)+": "); sec_arrival[queue_len]=Integer.parseInt(br.readLine()); queue_arrival[queue_len]=hour_arrival[queue_len]*60.0+min_arrival[queue_le n]+sec_arrival[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)+": ");
  • 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