-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexplore_ABM_pandemic.R
55 lines (46 loc) · 1.9 KB
/
explore_ABM_pandemic.R
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
###
# Group project Laura, Jule and Pascal
# ABM classroom size optimization
# from 04/04/2023 rto 30/05/2023
###
library(ggplot2)
# setwd("~/ABM_classroom_infections")
source("ABM_irchel_pandemic.R")
## simulation
# initialize
# model dimensions
beta <- 1e-1 # only magnitude of .1 seems realistic
no_of_rooms <- 8 # controls total number of classrooms
room_size <- 25 # hyperparameter, square number please
room_spacing <- 0.6 # hyperparameter: MUST BE <=1
days <- 62 # controls number of students
classes_per_day <- 1 # controls randomness
week_init_stu_ratio <- 0.03 # how many students come in sick from weekend
viral_radius <- 2**0.5# viral radius relative to room spacing hardcode to become vrf * 1/spacing
sim <- simulate_university(beta = beta,
viral_radius = viral_radius,
no_of_rooms = no_of_rooms,
room_size = room_size,
room_spacing = room_spacing,
days = days,
classes_per_day = classes_per_day,
week_init_stu_ratio = week_init_stu_ratio)
# sim$result %>%
# mutate_at(c("day", "class", "attendance"), as.numeric) %>%
# filter(class == 1) %>%
# select(-class) %>%
# mutate(athome_per_day = ifelse(c(0, diff(attendance)) > 0, 0, -c(0, diff(attendance)))) %>%
# ggplot() +
# geom_path(mapping = aes(x = day, y = athome_per_day), linetype = "dashed") +
# geom_point(mapping = aes(x = day, y = athome_per_day)) +
# theme_bw()
#
sim$result %>%
mutate_at(c("day", "class", "attendance"), as.numeric) %>%
filter(class == 1) %>%
select(-class) %>%
mutate(athome_per_day = ifelse(c(0, diff(attendance)) > 0, 0, -c(0, diff(attendance)))) %>%
ggplot() +
geom_path(mapping = aes(x = day, y = attendance), linetype = "dashed") +
geom_point(mapping = aes(x = day, y = attendance)) +
theme_bw()