Because of the continuous distribution of service times; we can expect smaller queues and less entities in the system when compared to M/M/1 from this weeks discussion.
# M/G/1 with continuous service time distribution between 0.1 and 1.9
a = 0.1
b = 1.9
es = (a+b)/2 #Also known as 1
sd = sqrt(((b-a)^2)/12) # Thank you textbook
y = 1/1.25 #Reciprocal of interarrival
m = 1/es # Reciprocal of service time
p = y/m
Wq = (y *(sd^2+ (1 / m^2) )) / (2*(1-p))
Lq = Wq * y
W = Wq+es
L = W*y
data.frame('lambda' = y, 'mu' = m, 'p' = p, 'Wq' = Wq, 'W' = W, 'Lq' = Lq, 'L' = L, 'SD' = sd)
## lambda mu p Wq W Lq L SD
## 1 0.8 1 0.8 2.54 3.54 2.032 2.832 0.5196152
When compared with continuous distributions, the triangular distribution will be a more efficient system because of a lower variance.
# M/G/1 with triangularly distrubted service times between 0.1 and 1.9; mode = 1.0
mode = 1
a = .1
b = 1.9
es = (a+m+b)/3 #also known as 1
sd = sqrt( (a^2 + m^2 + b^2 - a*m - a*b - b*m )/18 ) #Thank you textbook
y = 1/1.25
m = 1/es
p = y/m
# Copy paste from previous solution
Wq = (y *(sd^2+ (1 / m^2) )) / (2*(1-p))
Lq = Wq * y
W = Wq+es
L = W*y
data.frame('lambda' = y, 'mu' = m, 'p' = p, 'Wq' = Wq, 'W' = W, 'Lq' = Lq, 'L' = L, 'SD' = sd)
## lambda mu p Wq W Lq L SD
## 1 0.8 1 0.8 2.27 3.27 1.816 2.616 0.3674235
We are going to need this formula from the text
We could type that formula out into R, but the code would be not be pretty; so we take a hint from the textbook here; and get us a package that can compute it.
# M/M/3 Three servers, exponentially distributed arrival and service times.
#Right from the docs, this returns "the mean nubmer of customers in the M/M/c model"
library(queueing)
## create input parameters
i_mmc = NewInput.MMC(lambda=(1/1.25), mu=(1/3), c=3, n=0, method=0)
## Build the model
o_mmc <- QueueingModel(i_mmc)
l = L(o_mmc)
#From here can we use the function to give us everything we want;
#but thats not the point of the exercise. Let us follow the book and apply little's law.
y= 1/1.25
m= 1/3
w = l/y
p = y/m
lq = l-(y/m)
wq = lq/y
data.frame('lambda' = y, 'mu' = m, 'p' = p, 'Wq' = wq, 'W' = w, 'Lq' = lq, 'L' = l)
## lambda mu p Wq W Lq L
## 1 0.8 0.3333333 2.4 3.235955 6.235955 2.588764 4.988764
# mInterarrival time = 6/minutes
# Sign In = M/M/2 - Service time 3/minutes - Probability 1.0
signin = NewInput.MMC(lambda=1/6,mu=1/3,c=2,n=0,method=0)
results = QueueingModel(signin)
signin =data.frame('station'='Sign in','p' = results$Pn,'L'= results$L, 'W' = results$W, 'Lq' = results$Lq, 'Wq' =results$Wq)
# Registration = M/M/1 - Service time 5/minutes - Probability .9
registration = NewInput.MMC(lambda=(1/6)*.9,mu=1/5,c=1,n=0,method=0)
results = QueueingModel(registration)
registration = data.frame('station'='Registration','p' = results$Pn,'L'= results$L, 'W' = results$W, 'Lq' = results$Lq, 'Wq' =results$Wq)
# Trauma = M/M/2 - Service time 90/minutes - Probability .1
trauma = NewInput.MMC(lambda=(1/6)*.1,mu=1/90,c=2,n=0,method=0)
results = QueueingModel(trauma)
trauma = data.frame('station'='Trauma rooms','p' = results$Pn,'L'= results$L, 'W' = results$W, 'Lq' = results$Lq, 'Wq' =results$Wq)
# Exam Rooms = M/M/3 - Service time 16/minutes - Probability .9
exam = NewInput.MMC(lambda=(1/6)*.9,mu=1/16,c=3,n=0,method=0)
results = QueueingModel(exam)
exam = data.frame('station' = 'Exam rooms','p' = results$Pn,'L'= results$L, 'W' = results$W, 'Lq' = results$Lq, 'Wq' =results$Wq)
# Treatment Rooms = M/M/2 - Service time 15/minutes - Probability .9*.6+.1 (Both paths may lead towards here)
treatment = NewInput.MMC(lambda=(1/6)*( (.9*.6)+.1 ),mu=1/15,c=2,n=0,method=0)
results = QueueingModel(treatment)
treatment = data.frame('station' = 'Treatment Rooms','p' = results$Pn,'L'= results$L, 'W' = results$W, 'Lq' = results$Lq, 'Wq' =results$Wq)
results = rbind(signin,registration,trauma,exam,treatment)
results
## station p L W Lq Wq
## 1 Sign in 0.60000000 0.5333333 3.20000 0.03333333 0.20000
## 2 Registration 0.25000000 3.0000000 20.00000 2.25000000 15.00000
## 3 Trauma rooms 0.14285714 3.4285714 205.71429 1.92857143 115.71429
## 4 Exam rooms 0.05617978 4.9887640 33.25843 2.58876404 17.25843
## 5 Treatment Rooms 0.11111111 4.4444444 41.66667 2.84444444 26.66667
System seems to work pretty well, everyone regardless of where they go, exits at a reasonable time; can’t do anything about how long it takes to treat a trauma patient. I would add another server to the treatment rooms station to reduce queue value there.
legend:
y = lambda
m = mu
es = estimated service time