p = The steady-state utilitization of a server
L = The steady-state average number of entities in system
W = The steady-state average time in system
Wq = The steady state average time in queue
Lq = The steady-state average number of entities in queue
require(queueing)
## Warning: package 'queueing' was built under R version 3.3.2
i_mm1 <- NewInput.MM1(lambda=1/1.25, mu=1, n=0)
o_mm1 <- QueueingModel(i_mm1)
q2.6.1<-data.frame(L(o_mm1),W(o_mm1),Wq(o_mm1),Lq(o_mm1),Pn(o_mm1))
MM1<-function(meanInterarrivalTime,meanServerTime){
lambda <- 1/meanInterarrivalTime #in minutes
mu <- 1/meanServerTime #in minutes
es <- 1/mu
p <- lambda / mu
L <- p/(es-p)
W <- L/lambda
Wq <- W-meanServerTime
Lq <- lambda*Wq
df<-data.frame(p,L,W,Wq,Lq)
return (df)
}
MM1(1.25,1)
## p L W Wq Lq
## 1 0.8 4 5 4 3.2
MG1_cont<-function(meanInterarrivalTime,meanServerTime){
sd<-sqrt(((meanServerTime[2]-meanServerTime[1])^2)/12)
lambda <- 1/meanInterarrivalTime #in minutes
es <- (meanServerTime[1]+meanServerTime[2])/2
mu <- 1/es #in minutes
p <- lambda / mu
Wq <- (lambda*((sd^2)+(1/(mu^2))))/(2*(1-(lambda/mu)))
W <- Wq+es
L <- lambda*W
Lq <- lambda*Wq
df<-data.frame(p,L,W,Wq,Lq)
return (df)
}
MG1_cont(1.25,c(0.1,1.9))
## p L W Wq Lq
## 1 0.8 2.832 3.54 2.54 2.032
The p value remains unchanged, however the average number of entities in the system (L) decreases along with the queue value (Lq). This is due to the limited range of wait times expected from the server, reducing the potential for extremely high wait times, shown as W and Wq, both being effected in a similar fashion.
MG1_tri<-function(mit,mst){
es <- (mst[1]+mst[3]+mst[2])/3
sd<-sqrt(((mst[1]^2)+(mst[2]^2)+(mst[3]^2)-(mst[1]*mst[3])-(mst[1]*mst[2])-(mst[2]*mst[3]))/18)
lambda <- 1/mit #in minutes
mu <- 1/es #in minutes
p <- lambda / mu
Wq <- (lambda*((sd^2)+(1/(mu^2))))/(2*(1-(lambda/mu)))
W <- Wq+es
L <- lambda*W
Lq <- lambda*Wq
df<-data.frame(p,L,W,Wq,Lq)
return (df)
}
MG1_tri(1.25,c(0.1,1.9,1))
## p L W Wq Lq
## 1 0.8 2.616 3.27 2.27 1.816
The results of the triangular distribution highlights a reduction in each value which is expected due to the distributions limited range but new random preference towards the mode. This is an incremental improvement upon the previous model.
i_mmc <- NewInput.MMC(lambda=1/1.25, mu=1/3, c=3, n=0, method=0)
o_mmc2 <- QueueingModel(i_mmc)
q2.6.5<-data.frame(L(o_mmc2),W(o_mmc2),Wq(o_mmc2),Lq(o_mmc2),Pn(o_mmc2))
q2.6.5
## L.o_mmc2. W.o_mmc2. Wq.o_mmc2. Lq.o_mmc2. Pn.o_mmc2.
## 1 4.988764 6.235955 3.235955 2.588764 0.05617978
#Local traffic
#mean interarrival time = 6 minutes
#Sign In M/M/2 - 3 minutes
i_signin <- NewInput.MMC(lambda=1/6, mu=1/3, c=2, n=0, method=0)
o_signin <- QueueingModel(i_signin)
signin<-data.frame(L(o_signin),W(o_signin),Wq(o_signin),Lq(o_signin),Pn(o_signin))
signin
## L.o_signin. W.o_signin. Wq.o_signin. Lq.o_signin. Pn.o_signin.
## 1 0.5333333 3.2 0.2 0.03333333 0.6
#Registration M/M/1 - 5 minutes
i_registration <- NewInput.MM1(lambda=(1/6)*0.9, mu=1/5, n=0)
o_registration <- QueueingModel(i_registration)
registration<-data.frame(L(o_registration),W(o_registration),Wq(o_registration),Lq(o_registration),Pn(o_registration))
registration
## L.o_registration. W.o_registration. Wq.o_registration.
## 1 3 20 15
## Lq.o_registration. Pn.o_registration.
## 1 2.25 0.25
#Trauma Rooms M/M/2 - 90 minutes
i_trauma <- NewInput.MMC(lambda=(1/6*0.1), mu=1/90, c=2, n=0, method=0)
o_trauma <- QueueingModel(i_trauma)
trauma<-data.frame(L(o_trauma),W(o_trauma),Wq(o_trauma),Lq(o_trauma),Pn(o_trauma))
trauma
## L.o_trauma. W.o_trauma. Wq.o_trauma. Lq.o_trauma. Pn.o_trauma.
## 1 3.428571 205.7143 115.7143 1.928571 0.1428571
#Exam Rooms M/M/3 - 16 minutes
i_exam <- NewInput.MMC(lambda=(1/6*0.9), mu=1/16, c=3, n=0, method=0)
o_exam <- QueueingModel(i_exam)
exam<-data.frame(L(o_exam),W(o_exam),Wq(o_exam),Lq(o_exam),Pn(o_exam))
exam
## L.o_exam. W.o_exam. Wq.o_exam. Lq.o_exam. Pn.o_exam.
## 1 4.988764 33.25843 17.25843 2.588764 0.05617978
#Treatment Rooms M/M/2 - 15 minutes
i_treatment <- NewInput.MMC(lambda=(1/6)*((0.9*0.6)+0.1), mu=1/15, c=2, n=0, method=0)
o_treatment <- QueueingModel(i_treatment)
treatment<-data.frame(L(o_treatment),W(o_treatment),Wq(o_treatment),Lq(o_treatment),Pn(o_treatment))
treatment
## L.o_treatment. W.o_treatment. Wq.o_treatment. Lq.o_treatment.
## 1 4.444444 41.66667 26.66667 2.844444
## Pn.o_treatment.
## 1 0.1111111
#Normal Exit