Model v1, with call to python

This commit is contained in:
Noah L. Schrick 2023-05-01 15:03:31 -05:00
parent 7ac37f0aea
commit 184be47a33
3 changed files with 27 additions and 30 deletions

BIN
Analysis/SERIDS.pdf Normal file

Binary file not shown.

View File

@ -17,11 +17,11 @@ seirds.f <- function(t, y, k) {
waning = k[7]
# Saying infec rate of S in contact with E same as contact with I
dS <- epsilon - (beta*E + beta*I)*S + waning*R - mu*S
dE <- beta*S*E + beta*S*I - (delta+mu)*E
dI <- delta*E - mu*I - gamma_r*I
dR <- gamma_r*I - (waning+mu)*R
dD <- gamma_d*I
dS <- epsilon - (beta*E + beta*I)*S + waning*R - gamma_d*S
dE <- beta*S*E + beta*S*I - (delta+gamma_d)*E
dI <- delta*E - (1+gamma_d)*I
dR <- (1-mu)*I - (waning+gamma_d)*R
dD <- mu*I
return(as.matrix(c(dS, dE, dI, dR, dD)))
}
@ -33,30 +33,23 @@ library(reticulate)
#conda_install(envname = "r-reticulate", packages="pygraphviz")
source_python('prep_model.py')
# a) a=0.5, b=1, S(0)=0.9, I(0)=0.1, R(0)=0
seirds.params <- c(0.7316455696202532, # beta
0.020253164556962026, # delta
0.09113924050632911, # gamma_r
0.002531645569620253, # gamma_d
0.0034602076124567475, # mu
0.0, # epsilon
0.0) # waning
# Obtained from prep_model.py
seirds.params <- c(beta, # beta
delta, # delta
gamma_r, # gamma_r
gamma_d, # gamma_d
mu, # mu
epsilon, # epsilon
omega) # waning
S <- 62
E <- 8
I <- 288
R <- 36
D <- 1
N <- S+E+I+R+D
S <- S/N
E <- E/N
I <- I/N
R <- R/N
D <- D/N
S <- S/length(color_d)
E <- E/length(color_d)
I <- (I_R+I_D)/length(color_d)
R <- R/length(color_d)
D <- D/length(color_d)
tmin <- 0
tmax <- 7
tmax <- 5
library(pracma)
seirds.ode.sol <- ode45(f = function(t,y){seirds.f(t,y,k=seirds.params)},
@ -86,5 +79,6 @@ plot.seirds <- function(sol, method){
}
plot.seirds(seirds.ode.sol, "ODE45")
print(seirds.ode.sol$y[tmax,1]+seirds.ode.sol$y[tmax,2]+seirds.ode.sol$y[tmax,3]+seirds.ode.sol$y[tmax,4]+seirds.ode.sol$y[tmax,5])
ggsave("SERIDS.pdf")
# Sanity check: Make sure sums to ~1.0
sum(tail(seirds.ode.sol$y,1))

View File

@ -85,12 +85,13 @@ for node in A:
# Params
beta = (I_R+I_D)/len(A) # rate of infec (I/total?)
delta = E/len(A) # symptom appearance rate (E/total?)
#delta = E/len(A) # symptom appearance rate (E/total?)
delta = 1 # incubation period
gamma_r = R/len(A) # recov rate (R/total?)
gamma_d = D/len(A) # death rate (D/total?)
mu = D/(I_R+I_D) # fatality ratio (D/I)
epsilon = ep_tmp/len(A) # infected import rate
omega = 0 # waning immunity rate
omega = 1 # waning immunity rate
print("Model Compartments:")
@ -109,3 +110,5 @@ print("gamma_r:", str(gamma_r))
print("gamma_d:", str(gamma_d))
print("mu:", str(mu))
print("epsilon:", str(epsilon))
print("omega:", str(omega))