aboutsummaryrefslogtreecommitdiff
path: root/R/mkinpredict.R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2023-04-15 08:41:37 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2023-04-15 08:41:37 +0200
commitf20a9d81cbcd514ed629b69364cd85a72ac06e95 (patch)
treecdc0b1480c65a59bdc0862ee4807139a48a36d1f /R/mkinpredict.R
parent19016037302814387799426fc40b318ee54b07f0 (diff)
Make using predefined symbols optional
I got crashes under some circumstances when using symbols stored in the mkinmod object. One such circumstance was the use of a moved DLL in combination with parallel computing on a cluster. As I cannot exactly define at the moment when this happens, it is better to make this an opt in.
Diffstat (limited to 'R/mkinpredict.R')
-rw-r--r--R/mkinpredict.R13
1 files changed, 11 insertions, 2 deletions
diff --git a/R/mkinpredict.R b/R/mkinpredict.R
index 957d5793..8fa41217 100644
--- a/R/mkinpredict.R
+++ b/R/mkinpredict.R
@@ -27,6 +27,8 @@
#' When using compiled code, only lsoda is supported.
#' @param use_compiled If set to \code{FALSE}, no compiled version of the
#' [mkinmod] model is used, even if is present.
+#' @param use_symbols If set to \code{TRUE}, symbol info present in the
+#' [mkinmod] object is used if available for accessing compiled code
#' @param atol Absolute error tolerance, passed to the ode solver.
#' @param rtol Absolute error tolerance, passed to the ode solver.
#' @param maxsteps Maximum number of steps, passed to the ode solver.
@@ -114,6 +116,7 @@ mkinpredict.mkinmod <- function(x,
outtimes = seq(0, 120, by = 0.1),
solution_type = "deSolve",
use_compiled = "auto",
+ use_symbols = FALSE,
method.ode = "lsoda", atol = 1e-8, rtol = 1e-10, maxsteps = 20000L,
map_output = TRUE,
na_stop = TRUE,
@@ -169,12 +172,18 @@ mkinpredict.mkinmod <- function(x,
}
if (solution_type == "deSolve") {
- if (!is.null(x$cf) & !is.null(x$symbols) & use_compiled[1] != FALSE) {
+ if (!is.null(x$cf) & use_compiled[1] != FALSE) {
+
+ if (!is.null(x$symbols) & use_symbols[1] == TRUE) {
+ lsoda_func <- x$symbols
+ } else {
+ lsoda_func <- "diffs"
+ }
out <- deSolve::lsoda(
y = odeini,
times = outtimes,
- func = x$symbols,
+ func = lsoda_func,
initfunc = "initpar",
dllname = x$dll_info[["name"]],
parms = odeparms[x$parms], # Order matters when using compiled models

Contact - Imprint