-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsimple_queue_reduction.R
More file actions
70 lines (54 loc) · 1.99 KB
/
Copy pathsimple_queue_reduction.R
File metadata and controls
70 lines (54 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
library(ggplot2)
library(scales)
library(BSOLwaitinglist)
library(NHSRwaitinglist)
library(BSOLutils)
q <- 1300
d <- 130
t <- 18
weeks <- 52
compliance <- 1 - exp(-(d * t) / q)
target_q <- calc_target_queue_size(d,t, qexp(0.92))
rel <- calc_relief_capacity(d,
q,
target_q,
weeks-1)
dt <-
data.frame(
weeks = seq(weeks),
demand = d,
capacity = rel,
queue = q
)
for (i in 2:nrow(dt)) {
dt[i,]$queue <- dt[i-1,]$queue + dt[i,]$demand - dt[i,]$capacity
}
#weeks <- 52 / 12
ggplot(dt, aes(x = weeks, y = queue)) +
geom_line(colour = icb_theme_cols("cluster_lightblue"), size = 1) +
geom_hline(yintercept = dt[1,]$queue, colour = icb_theme_cols("cluster_orange"),
linetype= "dashed", linewidth = 1) +
geom_hline(yintercept = dt[1,]$queue, colour = icb_theme_cols("cluster_orange"),
linetype= "dashed", linewidth = 1) +
geom_hline(yintercept = target_q, colour = icb_theme_cols("cluster_green1"),
linetype= "dashed", linewidth = 1) +
#scale_x_continuous(limits = c(0, weeks), expand = expansion(0,0.01)) +
#scale_y_continuous(limits = c(0, weeks), expand = expansion(0,0.01)) +
annotate("text", label = paste0("Target queue size = ", round(target_q) )
, y = target_q , x = 1
, colour = icb_theme_cols("cluster_green1"), vjust = -0.5,
hjust = 0) +
annotate("text", label = paste0("Current queue size = ", round(q) )
, y = q , x = weeks
, colour = icb_theme_cols("cluster_orange"), vjust = 1.3,
hjust = 1) +
scale_y_continuous(labels = comma) +
labs(
title = paste0(
"Factor for ", percent(compliance), "% compliance to waiting list target"
),
subtitle = "Exponential distribution used for queue, assuming 'perfect world'",
x = "Time in Weeks",
y = "Queue Size"
) +
theme_icb()