Queues issue - THE DATA SCIENCE LIBRARY https://sigmaquality.pl/category/econometrics/queues-issue-econometrics/ Wojciech Moszczyński Sun, 02 May 2021 18:11:46 +0000 pl-PL hourly 1 https://wordpress.org/?v=6.8.3 https://sigmaquality.pl/wp-content/uploads/2019/02/cropped-ryba-32x32.png Queues issue - THE DATA SCIENCE LIBRARY https://sigmaquality.pl/category/econometrics/queues-issue-econometrics/ 32 32 Measuring the efficiency of banking transaction systems using Queueing Theory https://sigmaquality.pl/econometrics/queues-issue-econometrics/measuring-the-efficiency-of-banking-transaction-systems-using-queueing-theory-140520200849/ Thu, 14 May 2020 06:54:39 +0000 http://sigmaquality.pl/uncategorized/measuring-the-efficiency-of-banking-transaction-systems-using-queueing-theory-140520200849/ 140520200849 The work speed of three information processing centers carrying out banking transactions was analyzed. Each of the centers has several independent servers processing information. [...]

Artykuł Measuring the efficiency of banking transaction systems using Queueing Theory pochodzi z serwisu THE DATA SCIENCE LIBRARY.

]]>
140520200849

The work speed of three information processing centers carrying out banking transactions was analyzed. Each of the centers has several independent servers processing information. It was found that there is a difference in the work of individual bank servers.

The purpose of the exercise is to indicate the general performance characteristics of the banking information processing system.

Queueing Theory: Bomber landing analysis

The following formulas come from the study: Hillier F.S., Lieberman G.J. Instruction of Operation Research. New York: McGrew Hill 1990 oraz Z. Jędrzejczyk, K.Kukuła, J.Skrzypek, A. Walkosz Badania operacyjne w przykładach i zadaniach, Wydawnictwo Naukowe PWN
obraz.png

Arrival rate: λ

These are transactions arriving within a minute. It is a stream of transaction orders sent from bank customers sent online.

In [1]:
import numpy as np


np.random.seed(148)  
Λ1 = (np.random.random_sample(2354)*4690)
Λ2 = (np.random.random_sample(4899)*2319)
Λ3 = (np.random.random_sample(3511)*5491)

a1= sum(Λ1)
p1= len(Λ1)
λ1 = 1/(p1/a1)

a2= sum(Λ2)
p2= len(Λ2)
λ2 = 1/(p2/a2)

a3= sum(Λ3)
p3= len(Λ3)
λ3 = 1/(p3/a3)


print('Number of transactions:     ', p1)
print('Sume of transactions time: 
print('Arrival_λ1: 
print('-----------------------------------------------')
print('Number of transactions:     ', p2)
print('Sume of transactions time: 
print('Arrival_λ2: 
print('-----------------------------------------------')
print('Number of transactions:     ', p3)
print('Sume of transactions time: 
print('Arrival_λ3: 
print('-----------------------------------------------')
Number of transactions:      2354
Sume of transactions time: 5426818.1
Arrival_λ1: 2305.36 transactions per min
-----------------------------------------------
Number of transactions:      4899
Sume of transactions time: 5678062.6
Arrival_λ2: 1159.02 transactions per min
-----------------------------------------------
Number of transactions:      3511
Sume of transactions time: 9719295.2
Arrival_λ3: 2768.24 transactions per min
-----------------------------------------------

Service rate: μ

This parameter represents the execution time of individual banking transactions by the banking transaction system.Each of the three data centers has a number of servers. A single server is treated as an individual information flow channel.
obraz.png

In [2]:
r1 = 5
r2 = 6
r3 = 8
In [3]:
np.random.seed(148)  
M1 = (np.random.random_sample(2354)*959)
M2 = (np.random.random_sample(4899)*790)
M3 = (np.random.random_sample(3511)*903)

a1= sum(M1)
p1= len(M1)
μ1 = 1/(p1/a1)

a2= sum(M2)
p2= len(M2)
μ2 = 1/(p2/a2)

a3= sum(M3)
p3= len(M3)
μ3 = 1/(p3/a3)


print('Number of transactions:     ', p1)
print('Sume of service time: 
print('Service_μ: 
print('-----------------------------------------------')
print('Number of transactions:     ', p2)
print('Sume of service time: 
print('Service_μ: 
print('-----------------------------------------------')
print('Number of transactions:     ', p3)
print('Sume of service time: 
print('Service_μ: 
print('-----------------------------------------------')
Number of transactions:      2354
Sume of service time: 1109662.8 min
Service_μ: 471.39 transactions per min
-----------------------------------------------
Number of transactions:      4899
Sume of service time: 1934312.0 min
Service_μ: 394.84 transactions per min
-----------------------------------------------
Number of transactions:      3511
Sume of service time: 1598347.0 min
Service_μ: 455.24 transactions per min
-----------------------------------------------

Traffic intensity: ϱ

Traffic intensity is the ratio of arrival rate to service rate.

$$\text{Traffic intensity equation:} \\
\bbox[#f3f3f3,12px,border:1px solid black] {
{ϱ}=\frac{λ}{{μ}*r}
} \qquad (1)
$$
In [4]:
ϱ1 = λ1/(μ1*r1)

if ϱ1 >= 1:
        print("The system is unstable, we do not carry out further calculations!")
        print('Arrival rate λ1 > service rate μ1, ϱ1= 
        
else:     
        print("The system is stable, you can calculate the probabilities!")
        print('Arrival rate λ1 > service rate μ1')
        print('Arrival rate λ1:      
        print('Service rate μ1:      
        print('Traffic intensity ϱ1: 

ϱ2 = λ2/(μ2*r2)


if ϱ2 >= 1:
        print("The system is unstable, we do not carry out further calculations!")
        print('Arrival rate λ2 > service rate μ2 ,ϱ2= 
        
else:     
        print("The system is stable, you can calculate the probabilities!")
        print('Arrival rate λ2 > service rate μ2')
        print('Arrival rate λ2:      
        print('Service rate μ2:      
        print('Traffic intensity ϱ2: 

ϱ3 = λ3/(μ3*r3)


if ϱ3 >= 1:
        print("The system is unstable, we do not carry out further calculations!")
        print('Arrival rate λ3 > service rate μ3, ϱ3= 
        
else:     
        print("The system is stable, you can calculate the probabilities!")
        print('Arrival rate λ3 > service rate μ3')
        print('Arrival rate λ3:      
        print('Service rate μ3:      
        print('Traffic intensity ϱ3: 
The system is stable, you can calculate the probabilities!
Arrival rate λ1 > service rate μ1
Arrival rate λ1:      2305.36 transactions per one minut
Service rate μ1:      471.39 transactions per one minut
Traffic intensity ϱ1: 0.98
The system is stable, you can calculate the probabilities!
Arrival rate λ2 > service rate μ2
Arrival rate λ2:      1159.02 transactions per one minut
Service rate μ2:      394.84 transactions per one minut
Traffic intensity ϱ2: 0.49
The system is stable, you can calculate the probabilities!
Arrival rate λ3 > service rate μ3
Arrival rate λ3:      2768.24 transactions per one minut
Service rate μ3:      455.24 transactions per one minut
Traffic intensity ϱ3: 0.76

Multiple service channel

We assume in this algorithm that the arrival of transactions (arrival rate) has a normal distribution. Transactions are directed to several servers with the same level of service. To maintain system balance, inequality must be maintained:

obraz.png

$\begin{align}
λ < rμ &&\text{where r is the number of service channels} \tag 5\\
\end{align}$

$$\text{The probability that there are no queues at r service stations:} \\
\bbox[#f3f3f3,12px,border:1px solid black] {
p(n=0) = \displaystyle\frac{1}{sum_{n=1}^\infty}
} \qquad (6)
$$

The probability that there are no queues at r service stations.

$$\text{The probability that there is no queue n = 0 in the system:} \\
\bbox[#f3f3f3,12px,border:1px solid black] {
p(n=0) =\frac{1}{\displaystyle\sum_{i=0}^{r-1} \frac{?^i}{i!}+\frac{?^r}{{\left(r-{?}\right)}{\left(r-1\right)!}}}
} \qquad (7)
$$
$$\text{Average number of items waiting in queue:} \\
\bbox[#f3f3f3,12px,border:1px solid black] {
ψ =\frac{{?^{r+1}{p(n=0)}}}{{(r-?)}^2{(r-1)!}}
} \qquad (8)
$$
$$\text{The probability that there is no queue n = 0 in the system:} \\
\bbox[#f3f3f3,12px,border:1px solid black] {p(n) =\begin{cases}
\frac{{ψ^n}{p(n=0)}}{n!}, & \text{if $n\le r$}
\frac{{r^{r-n}}{ψ^n}{p(n=0)}}{r!}, & \text{if $n\gt r$}
\end{cases}
} \qquad (9)
$$

The probability that the system has more than zero elements and elements is more than r channels.

$$\text{The probability that there is no queue n = 0 in the system:} \\
\bbox[#f3f3f3,12px,border:1px solid black] {
p(n>n_0) =\frac{{r^{r-n_{0}}}{?^{n_{0}+1}}{p(n=0)}}{(r-{?})r!}
} \qquad (10)
$$
$$\text{The probability that the waiting time of an item in the queue is longer n that t.:} \\
\bbox[#f3f3f3,12px,border:1px solid black] {
p(t>t_0) ={{p{(n>r-1)}}{e^{μt(r-ψ)}}}
} \qquad (11)
$$
In [5]:
λ=λ1
μ=μ1
r=r1

We check for inequality:

λ<rμ

obraz.png

In [6]:
print('Arrival rate λ:      
print('Service rate μ:      
ϱ = λ/(r*μ)
print('Traffic intensity ϱ: 
Arrival rate λ:      2305.36
Service rate μ:      471.39
Traffic intensity ϱ: 0.98
In [7]:
if ϱ > 1:
        print("The system is unstable, we do not carry out further calculations!")
        print('Arrival rate λ > split service rate μ')
else:
        print("The system is stable, you can calculate the probabilities!")
        print('Arrival rate λ > split service rate μ')
The system is stable, you can calculate the probabilities!
Arrival rate λ > split service rate μ
In [8]:
def factorial(n): 
    return 1 if (n==1 or n==0) else n * factorial(n - 1);  

Since there are two airports, the time to accept the plane is 2*μ

Probability of no queues, pattern no. 7

$${
p(n=0) =\frac{1}{\displaystyle\sum_{i=0}^{r-1} \frac{?^i}{i!}+\frac{?^r}{{\left(r-{?}\right)}{\left(r-1\right)!}}}
}\qquad (7)$$

In [9]:
p7=1/((1+ϱ)+(((ϱ**r)/((r-ϱ)*factorial(r-1)))))
print('Probability of no queues ?(?=0)≈ 
Probability of no queues ?(?=0)≈ 0.50

Probability that you will have to wait in queue, template no. 10

$${
p(n>n_0) =\frac{{r^{r-n_{0}}}{?^{n_{0}+1}}{p(n=0)}}{(r-{?})r!}
} \qquad (10)$$

In [10]:
if ϱ > 1:
        print("The system is unstable, we do not carry out further calculations!")
        print('Arrival rate λ > split service rate μ')
else:
        n0 = 1
        p10 = ((r**(r-n0))*(?**(n0+1))*p7)/((r-?)*factorial(r))
        print('Probability to wait in queue ?(?>?0)≈ 
Probability to wait in queue ?(?>?0)≈ 0.62

Probability of two items in the queue: $p(n>2)$ where $n_0 =2$

In [11]:
n0 = 2
In [12]:
if ϱ > 1:
        print("The system is unstable, we do not carry out further calculations!")
        print('Arrival rate λ > split service rate μ')
else:
        n0 = 2
        p11 = ((r**(r-n0))*(?**(n0+1))*p7)/((r-?)*factorial(r))
        print('Probability of two items in the queue: ?(?>2)≈ 
Probability of two items in the queue: ?(?>2)≈ 0.12

The probability that the item will have to queue over k minutes: $p(t>?_0)$

$${
p(n>n_0) =frac{{r^{r-n_{0}}}{?^{n_{0}+1}}{p(n=0)}}{(r-{?})r!}
} qquad (10)$$$${
p(t>t_0) ={{p{(n>r-1)}}{e^{μt(r-ψ)}}}
} qquad (11)
$$

In [13]:
## time in minutes
t0=0.05
t0=t0/60

print('n - unspecified number of units in the queue')
print('number of channels r =', r)
n - unspecified number of units in the queue
number of channels r = 5

$ p(n>r-1) = p(n>1)$
equation ⟹ 10 for $p(n>1)$

In [14]:
n0=1
p12 = ((r**(r-n0))*(?**(n0+1))*p7)/((r-?)*factorial(r))
p12   
Out[14]:
0.6233845932783932
In [15]:
# wzór 11
if ϱ > 1:
        print("The system is unstable, we do not carry out further calculations!")
        print('Arrival rate λ > split service rate μ')
else:
        p13 = p12*(np.e**(-μ*t0*(r-?)))
        print('The probability that the item will have to queue over n minutes: ?(?>?0)≈ 
The probability that the item will have to queue over n minutes: ?(?>?0)≈ 0.13

What is the average number of transactions  waiting?!

${
ψ =\frac{{?^{r+1}{p(n=0)}}}{{(r-?)}^2{(r-1)!}}
} \qquad (8)$

In [16]:
if ϱ > 1:
        print("The system is unstable, we do not carry out further calculations!")
        print('Arrival rate λ > split service rate μ')
else:
        p14 = ((?**(r+1))*p7)/(((r-?)**2)*factorial(r-1))
        print('The average number of items waiting ψ ≈ 
The average number of items waiting ψ ≈ 0.00
In [17]:
def queueing_test(λ,μ,r):
    
    def factorial(n): 
        return 1 if (n==1 or n==0) else n * factorial(n - 1);  
    
    
    print("-----------------------------------------------------------------------")
    print('Arrival rate λ:      
    print('Service rate μ:      
    ϱ = λ/(μ*r)
    print('Traffic intensity ϱ: 
    print("-----------------------------------------------------------------------")
    if ϱ > 1:
        print("The system is unstable, we do not carry out further calculations!")
        print('Arrival rate λ > split service rate μ')
    else:
        print("The system is stable, you can calculate the probabilities!")
        print('Arrival rate λ > split service rate μ')
    print("-----------------------------------------------------------------------")    
    p7=1/((1+ϱ)+(((ϱ**r)/((r-ϱ)*factorial(r-1)))))
    print('P7 Probability of no queues ?(?=0)≈ 
    print("-----------------------------------------------------------------------")
    n0 = 2
    p11 = ((r**(r-n0))*(?**(n0+1))*p7)/((r-?)*factorial(r))
    print('P11 Probability of two items in the queue: ?(?>2)≈ 
    print("-----------------------------------------------------------------------")
    n0=1
    p12 = ((r**(r-n0))*(?**(n0+1))*p7)/((r-?)*factorial(r))
    

    
    ## time in minutes
    t1=0.0165  ## 1 SEKUNDA PRZESTÓJ
    t1=t1/60
  
    p13A = p12*(np.e**(-μ*t1*(r-?)))
    print('P13 The probability that the item will have to queue over 1.0 SEC: ?(?>?0)≈ 
    
    ## time in minutes
    t0=0.05  ## 3 SEKUNDY PRZESTÓJ
    t0=t0/60
  
    p13B = p12*(np.e**(-μ*t0*(r-?)))
    print('P13 The probability that the item will have to queue over 3.0 SEC: ?(?>?0)≈ 
    
    
    
    ## time in minutes
    t2=0.0834  ## 5 SEKUNDA PRZESTÓJ
    t2=t2/60
  
    p13C = p12*(np.e**(-μ*t2*(r-?)))
    print('P13 The probability that the item will have to queue over 5.0 SEC: ?(?>?0)≈ 
      
      
    print("-----------------------------------------------------------------------")
    p14 = ((?**(r+1))*p7)/(((r-?)**2)*factorial(r-1))
    print('P14 The average number of items waiting ψ ≈ 
    print("-----------------------------------------------------------------------")   
    

First server room

In [18]:
queueing_test(λ1,μ1,r1)
-----------------------------------------------------------------------
Arrival rate λ:      2305.36 items per one minut
Service rate μ:      471.39 items per one minut
Traffic intensity ϱ: 0.98
-----------------------------------------------------------------------
The system is stable, you can calculate the probabilities!
Arrival rate λ > split service rate μ
-----------------------------------------------------------------------
P7 Probability of no queues ?(?=0)≈ 0.50
-----------------------------------------------------------------------
P11 Probability of two items in the queue: ?(?>2)≈ 0.12
-----------------------------------------------------------------------
P13 The probability that the item will have to queue over 1.0 SEC: ?(?>?0)≈ 0.37
P13 The probability that the item will have to queue over 3.0 SEC: ?(?>?0)≈ 0.13
P13 The probability that the item will have to queue over 5.0 SEC: ?(?>?0)≈ 0.04
-----------------------------------------------------------------------
P14 The average number of items waiting ψ ≈ 0.00
-----------------------------------------------------------------------

Second server room

In [19]:
queueing_test(λ2,μ2,r2)
-----------------------------------------------------------------------
Arrival rate λ:      1159.02 items per one minut
Service rate μ:      394.84 items per one minut
Traffic intensity ϱ: 0.49
-----------------------------------------------------------------------
The system is stable, you can calculate the probabilities!
Arrival rate λ > split service rate μ
-----------------------------------------------------------------------
P7 Probability of no queues ?(?=0)≈ 0.67
-----------------------------------------------------------------------
P11 Probability of two items in the queue: ?(?>2)≈ 0.03
-----------------------------------------------------------------------
P13 The probability that the item will have to queue over 1.0 SEC: ?(?>?0)≈ 0.17
P13 The probability that the item will have to queue over 3.0 SEC: ?(?>?0)≈ 0.05
P13 The probability that the item will have to queue over 5.0 SEC: ?(?>?0)≈ 0.02
-----------------------------------------------------------------------
P14 The average number of items waiting ψ ≈ 0.00
-----------------------------------------------------------------------

Third server room

In [20]:
queueing_test(λ3,μ3,r3)
-----------------------------------------------------------------------
Arrival rate λ:      2768.24 items per one minut
Service rate μ:      455.24 items per one minut
Traffic intensity ϱ: 0.76
-----------------------------------------------------------------------
The system is stable, you can calculate the probabilities!
Arrival rate λ > split service rate μ
-----------------------------------------------------------------------
P7 Probability of no queues ?(?=0)≈ 0.57
-----------------------------------------------------------------------
P11 Probability of two items in the queue: ?(?>2)≈ 0.22
-----------------------------------------------------------------------
P13 The probability that the item will have to queue over 1.0 SEC: ?(?>?0)≈ 0.95
P13 The probability that the item will have to queue over 3.0 SEC: ?(?>?0)≈ 0.15
P13 The probability that the item will have to queue over 5.0 SEC: ?(?>?0)≈ 0.02
-----------------------------------------------------------------------
P14 The average number of items waiting ψ ≈ 0.00
-----------------------------------------------------------------------

As you can see above, we tested the performance of three bank information processing centers. The probability of no queue in the first center is p7 = 50

obraz.png

Artykuł Measuring the efficiency of banking transaction systems using Queueing Theory pochodzi z serwisu THE DATA SCIENCE LIBRARY.

]]>
Queueing Theory: Bomber landing analysis https://sigmaquality.pl/econometrics/queues-issue-econometrics/queueing-theory-bomber-landing-analysis-130520201343/ Wed, 13 May 2020 11:45:10 +0000 http://sigmaquality.pl/queueing-theory-bomber-landing-analysis-130520201343/ 130520201343 The issue of queues was developed during World War II. It was about optimizing the landing process at English airports of great bubble squadrons [...]

Artykuł Queueing Theory: Bomber landing analysis pochodzi z serwisu THE DATA SCIENCE LIBRARY.

]]>
130520201343

The issue of queues was developed during World War II. It was about optimizing the landing process at English airports of great bubble squadrons returning from over the Third Reich. There were a lot of planes in relation to a limited number of airports. The formations had several hundred planes. Some of the planes were damaged or injured crew members were on board. Planes that are returning from combat usually had a small amount of fuel, which required immediate landing. This is how queue theory was born.

Queueing Theory is used to evaluate systems that should not be queued in theory. That is, systems in which the number of items per minute (λ) is less than the number of items handled per minute (μ), i.e. λ <μ.
If the number of inflowing elements is greater than the service speed: λ => μ then a queue appears.

In combat conditions, when the planes returned from the front there was no way there was a queue. The methodology described below is used to determine the likelihood that an aircraft will safely land in an environment where theoretically there is no queue.

The following formulas come from the study: Hillier F.S., Lieberman G.J. Instruction of Operation Research. New York: McGrew Hill 1990 oraz Z. Jędrzejczyk, K.Kukuła, J.Skrzypek, A. Walkosz Badania operacyjne w przykładach i zadaniach, Wydawnictwo Naukowe PWN
obraz.png

Arrival rate: λ

These are planes arriving within a minute.
obraz.png

In [47]:
import numpy as np
import numpy as np

np.random.seed(148)  
Λ = (np.random.random_sample(100)*1.0)

a= sum(Λ)
p= len(Λ)
λ = 1/(p/a)
print('Number of planes:     ', p)
print('Sume of landing time: 
print('Arrival_λ: 
Λ[:14]
Number of planes:      100
Sume of landing time: 51.3
Arrival_λ: 0.51 planes per min
Out[47]:
array([0.57540585, 0.14030841, 0.15827272, 0.06244513, 0.57575391,
       0.60640513, 0.22672425, 0.91483505, 0.91555016, 0.89023892,
       0.71296042, 0.56737137, 0.77315872, 0.02221362])

Service rate: μ

In our example, this is the number of aircraft arrived in one minute.

obraz.png

In [48]:
np.random.seed(148)  
M = (np.random.random_sample(100)*1.2)

a= sum(M)
p= len(M)
μ = 1/(p/a)
print('Number of planes:     ', p)
print('Sume of service time: 
print('Service_μ: 
Λ[:14]
Number of planes:      100
Sume of service time: 61.6 min
Service_μ: 0.62 planes per min
Out[48]:
array([0.57540585, 0.14030841, 0.15827272, 0.06244513, 0.57575391,
       0.60640513, 0.22672425, 0.91483505, 0.91555016, 0.89023892,
       0.71296042, 0.56737137, 0.77315872, 0.02221362])

Traffic intensity: ϱ

Traffic intensity is the ratio of arrival rate to service rate.

$$\text{Traffic intensity equation:} \\
\bbox[#f3f3f3,12px,border:1px solid black] {
{ϱ}=\frac{λ}{μ}
} \qquad (1)
$$
In [49]:
ϱ = λ/μ
ϱ

if ϱ > 1:
        print("The system is unstable, we do not carry out further calculations!")
        print('Arrival rate λ > service rate μ')
        
else:     
        print("The system is stable, you can calculate the probabilities!")
        print('Arrival rate λ > service rate μ')
        print('Arrival rate λ:      
        print('Service rate μ:      
        print('Traffic intensity ϱ: 

       
The system is stable, you can calculate the probabilities!
Arrival rate λ > service rate μ
Arrival rate λ:      0.51 plane per one minut
Service rate μ:      0.62 plane per one minut
Traffic intensity ϱ: 0.83

The average number of airplanes waiting in the air for landing ψ:

$$\text{Average number of pending items:} \\
\bbox[#f3f3f3,12px,border:1px solid black] {
ψ = \frac{?^2}{1-{?}}
} \qquad (2)
$$
In [50]:
if ϱ > 1:
        print("The system is unstable, we do not carry out further calculations!")
        print('Arrival rate λ > service rate μ')
else:
        ψ = ?**2/abs(1-?)
        print('Average number of aircraft waiting≈ 
Average number of aircraft waiting≈ 4.17 

Probability of n pending items

The probability that there will be more than n waiting aircraft in the air.

$$\text{Probability of n pending items:} \\
\bbox[#f3f3f3,12px,border:1px solid black] {
p(n>n_0)= {?}^{{n_0}+1}
} \qquad (3)
$$

What is the probability that there are more than 3 planes in the air?

In [5]:
n=3
In [51]:
if ϱ > 1:
        print("The system is unstable, we do not carry out further calculations!")
        print('Arrival rate λ > service rate μ')
else:
        p3 = ?**(n+1)
        print('The probability that there are more than 3 planes in the air≈ 
The probability that there are more than 3 planes in the air≈ 0.48 

Probability of longer waiting than t

The time the aircraft waits for permission to land.

$$\text{Probability of longer waiting than t:} \\
\bbox[#f3f3f3,12px,border:1px solid black] {
p(t>t_0)= {? e}^{-t_0 (μ-λ)}
} \qquad (4)
$$

What is the probability that the plane will wait for a landing over 3 minut?

In [7]:
## time in minutes
t=3
In [53]:
if ϱ > 1:
        print("The system is unstable, we do not carry out further calculations!")
        print('Arrival rate λ > service rate μ')
else:
        p4 = ?*np.e**(-t*(μ-λ))
        print('The probability that there are more than 3 planes in the air ≈ 
The probability that there are more than 3 planes in the air ≈ 0.61 

Multiple service channel

We assume in this algorithm that the arrival of aircraft (arrival rate) has a normal distribution. Planes are directed to several nearby airports with the same level of service. The planes form a joint queue and fly to this airport, where a place has just vacated. To maintain system balance, inequality must be maintained:

$\begin{align}
λ < rμ &&\text{where r is the number of service channels} \tag 5\\
\end{align}$

$$\text{The probability that there are no queues at r service stations:} \\
\bbox[#f3f3f3,12px,border:1px solid black] {
p(n=0) = \displaystyle\frac{1}{sum_{n=1}^\infty}
} \qquad (6)
$$

The probability that there are no queues at r service stations.

$$\text{The probability that there is no queue n = 0 in the system:} \\
\bbox[#f3f3f3,12px,border:1px solid black] {
p(n=0) =\frac{1}{\displaystyle\sum_{i=0}^{r-1} \frac{?^i}{i!}+\frac{?^r}{{\left(r-{?}\right)}{\left(r-1\right)!}}}
} \qquad (7)
$$
$$\text{Average number of items waiting in queue:} \\
\bbox[#f3f3f3,12px,border:1px solid black] {
ψ =\frac{{?^{r+1}{p(n=0)}}}{{(r-?)}^2{(r-1)!}}
} \qquad (8)
$$
$$\text{The probability that there is no queue n = 0 in the system:} \\
\bbox[#f3f3f3,12px,border:1px solid black] {p(n) =\begin{cases}
\frac{{ψ^n}{p(n=0)}}{n!}, & \text{if $n\le r$}
\frac{{r^{r-n}}{ψ^n}{p(n=0)}}{r!}, & \text{if $n\gt r$}
\end{cases}
} \qquad (9)
$$

The probability that the system has more than zero elements and elements is more than r channels.

$$\text{The probability that there is no queue n = 0 in the system:} \\
\bbox[#f3f3f3,12px,border:1px solid black] {
p(n>n_0) =\frac{{r^{r-n_{0}}}{?^{n_{0}+1}}{p(n=0)}}{(r-{?})r!}
} \qquad (10)
$$
$$\text{The probability that the waiting time of an item in the queue is longer n that t.:} \\
\bbox[#f3f3f3,12px,border:1px solid black] {
p(t>t_0) ={{p{(n>r-1)}}{e^{μt(r-ψ)}}}
} \qquad (11)
$$

We check for inequality:

λ<rμ

obraz.png

In [9]:
r=2
λ<r*μ
Out[9]:
True
In [54]:
print('Arrival rate λ:      
print('Service rate μ:      
ϱ = λ/(r*μ)
print('Traffic intensity ϱ: 
Arrival rate λ:      0.51
Service rate μ:      0.62
Traffic intensity ϱ: 0.42
In [55]:
if ϱ > 1:
        print("The system is unstable, we do not carry out further calculations!")
        print('Arrival rate λ > split service rate μ')
else:
        print("The system is stable, you can calculate the probabilities!")
        print('Arrival rate λ > split service rate μ')
The system is stable, you can calculate the probabilities!
Arrival rate λ > split service rate μ
In [56]:
def factorial(n): 
    return 1 if (n==1 or n==0) else n * factorial(n - 1);  

Since there are two airports, the time to accept the plane is 2*μ

Probability of no queues, pattern no. 7

$${
p(n=0) =\frac{1}{\displaystyle\sum_{i=0}^{r-1} \frac{?^i}{i!}+\frac{?^r}{{\left(r-{?}\right)}{\left(r-1\right)!}}}
}\qquad (7)$$

In [57]:
if ϱ > 1:
        print("The system is unstable, we do not carry out further calculations!")
        print('Arrival rate λ > split service rate μ')
else:
        p7=1/((1+ϱ)+(((ϱ**r)/((r-ϱ)*factorial(r-1)))))
        print('Probability of no queues ?(?=0)≈ 
Probability of no queues ?(?=0)≈ 0.66

Probability that you will have to wait in queue, template no. 10

$${
p(n>n_0) =\frac{{r^{r-n_{0}}}{?^{n_{0}+1}}{p(n=0)}}{(r-{?})r!}
} \qquad (10)$$

In [58]:
if ϱ > 1:
        print("The system is unstable, we do not carry out further calculations!")
        print('Arrival rate λ > split service rate μ')
else:
        n0 = 0
        p10 = ((r**(r-n0))*(?**(n0+1))*p7)/((r-?)*factorial(r))
        print('Probability to wait in queue ?(?>?0)≈ 
Probability to wait in queue ?(?>?0)≈ 0.34

Probability of two items in the queue: $p(n>2)$ where $n_0 =2$

In [60]:
n0 = 2
In [61]:
if ϱ > 1:
        print("The system is unstable, we do not carry out further calculations!")
        print('Arrival rate λ > split service rate μ')
else:
        n0 = 2
        p11 = ((r**(r-n0))*(?**(n0+1))*p7)/((r-?)*factorial(r))
        print('Probability of two items in the queue: ?(?>2)≈ 
Probability of two items in the queue: ?(?>2)≈ 0.01

The probability that the item will have to queue over k minutes: $p(t>?_0)$

$${
p(n>n_0) =\frac{{r^{r-n_{0}}}{?^{n_{0}+1}}{p(n=0)}}{(r-{?})r!}
} \qquad (10)$$

$${
p(t>t_0) ={{p{(n>r-1)}}{e^{μt(r-ψ)}}}
} \qquad (11)
$$

In [62]:
## time in minutes
t0=10
t0=t0/60

print('n - unspecified number of units in the queue')
print('number of channels r =', r)
n - unspecified number of units in the queue
number of channels r = 2

$ p(n>r-1) = p(n>1)$
equation ⟹ 10 for $p(n>1)$

In [63]:
n0=1
p12 = ((r**(r-n0))*(?**(n0+1))*p7)/((r-?)*factorial(r))
p12   
Out[63]:
0.0718390804597701
In [64]:
# wzór 11
if ϱ > 1:
        print("The system is unstable, we do not carry out further calculations!")
        print('Arrival rate λ > split service rate μ')
else:
        p13 = p12*(np.e**(-μ*t0*(r-?)))
        print('The probability that the item will have to queue over n minutes: ?(?>?0)≈ 
The probability that the item will have to queue over n minutes: ?(?>?0)≈ 0.06

What is the average number of plane waiting?!

${
ψ =\frac{{?^{r+1}{p(n=0)}}}{{(r-?)}^2{(r-1)!}}
} \qquad (8)$

In [65]:
if ϱ > 1:
        print("The system is unstable, we do not carry out further calculations!")
        print('Arrival rate λ > split service rate μ')
else:
        p14 = ((?**(r+1))*p7)/(((r-?)**2)*factorial(r-1))
        print('The average number of items waiting ψ ≈ 
The average number of items waiting ψ ≈ 0.02

obraz.png

Artykuł Queueing Theory: Bomber landing analysis pochodzi z serwisu THE DATA SCIENCE LIBRARY.

]]>