Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EIP #144

Merged
merged 1 commit into from
Dec 11, 2023
Merged

EIP #144

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ S3method(compute_terms,cohort)
S3method(compute_terms,human)
S3method(compute_terms,na)
S3method(compute_terms,xde)
S3method(dEIPdt,static)
S3method(dHdt,numeric)
S3method(dHdt,static)
S3method(dLdt,basic)
Expand Down Expand Up @@ -314,6 +315,7 @@ export(compute_kappa_ty)
export(compute_local_frac)
export(compute_terms)
export(compute_terms_steady)
export(dEIPdt)
export(dHdt)
export(dLdt)
export(dMYZdt)
Expand Down
2 changes: 1 addition & 1 deletion R/adult-GeRM.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ dMYZdt.GeRM_dde <- function(t, y, pars, Lambda, kappa) {
dGdt <- f*(M - G) - nu*G - (Omega %*% G)
dYdt <- f*q*kappa*(M - Y) - (Omega %*% Y)
dZdt <- Upsilon %*% diag(f_eip*q_eip*kappa_eip, nPatches) %*% (M_eip - Y_eip) - (Omega %*% Z)
dUdt <- as.vector((Omega_eip - Omega) %*% Upsilon)
dUdt <- as.vector(((1-dEIPdt(t,pars))*Omega_eip - Omega) %*% Upsilon)

return(c(dMdt, dGdt, dYdt, dZdt, dUdt, kappa, f, q, g, sigma))
})
Expand Down
2 changes: 1 addition & 1 deletion R/adult-RM.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ dMYZdt.RM_dde <- function(t, y, pars, Lambda, kappa) {
dPdt <- f*(M - P) - (Omega %*% P)
dYdt <- f*q*kappa*(M - Y) - (Omega %*% Y)
dZdt <- Upsilon %*% (fqkappa_eip * (M_eip - Y_eip)) - (Omega %*% Z)
dUdt <- as.vector((Omega_eip - Omega) %*% Upsilon)
dUdt <- as.vector(((1-dEIPdt(t,pars))*Omega_eip - Omega) %*% Upsilon)

return(c(dMdt, dPdt, dYdt, dZdt, dUdt, f*q*kappa, g, sigma))
})
Expand Down
17 changes: 17 additions & 0 deletions R/eip.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,30 @@ EIP <- function(t, pars) {
UseMethod("EIP", pars$EIPmod)
}

#' @title Compute the derivative of the EIP as a function of time
#' @description This method dispatches on the type of `pars$EIPmod`.
#' @param t current simulation time
#' @param pars a [list]
#' @return [numeric]
#' @export
dEIPdt <- function(t, pars) {
UseMethod("dEIPdt", pars$EIPmod)
}

#' @title Modify parameters due to exogenous forcing by all kinds of control
#' @description Implements [EIP] for the static model (the EIP is constant)
#' @inheritParams EIP
#' @return [list]
#' @export
EIP.static <- function(t, pars) {pars}

#' @title This function computes the negative derivative of the EIP as a function of time
#' @description Implements [EIP] for the static model (the dEIPdt=0)
#' @inheritParams EIP
#' @return [numeric]
#' @export
dEIPdt.static <- function(t, pars){0}

#' @title Set up the static model for control forcing (do nothing)
#' @param pars a [list]
#' @return [list]
Expand Down
6 changes: 4 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,20 @@ get_inits <- function(pars){
#' @export
parse_deout <- function(deout, pars){
varslist = list()
varslist$time = deout[,1]
if ('Lpar' %in% names(pars)) {
varslist$L = parse_deout_L(deout, pars)
varslist$L$time = deout[,1]
}
if ('MYZpar' %in% names(pars)) {
varslist$MYZ = parse_deout_MYZ(deout, pars)
varslist$MYZ$time = deout[,1]
}
if ('Xpar' %in% names(pars)) {
varslist$XH = parse_deout_X(deout, pars)
varslist$XH$time = deout[,1]
}
varslist$terms = compute_terms(varslist, deout, pars)
varslist$terms$time = varslist$time
varslist$terms$time = deout[,1]
varslist$deout = deout
return(varslist)
}
Expand Down
2 changes: 2 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ reference:
contents:
- EIP
- EIP.static
- dEIPdt
- dEIPdt.static
- setup_eip_static
- subtitle: Ztrace
desc: |
Expand Down
19 changes: 19 additions & 0 deletions man/dEIPdt.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions man/dEIPdt.static.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.