aboutsummaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
Diffstat (limited to 'R')
-rw-r--r--R/mkinfit.R14
-rw-r--r--R/mkinmod.R2
-rw-r--r--R/mkinpredict.R6
-rw-r--r--R/saem.R8
4 files changed, 20 insertions, 10 deletions
diff --git a/R/mkinfit.R b/R/mkinfit.R
index b97bc7e2..c851fddb 100644
--- a/R/mkinfit.R
+++ b/R/mkinfit.R
@@ -501,10 +501,15 @@ mkinfit <- function(mkinmod, observed,
}
# Get native symbol before iterations info for speed
+ use_symbols = FALSE
if (solution_type == "deSolve" & use_compiled[1] != FALSE) {
- mkinmod[["symbols"]] <- deSolve::checkDLL(dllname = mkinmod$dll_info[["name"]],
- func = "diffs", initfunc = "initpar",
- jacfunc = NULL, nout = 0, outnames = NULL)
+ mkinmod[["symbols"]] <- try(
+ deSolve::checkDLL(dllname = mkinmod$dll_info[["name"]],
+ func = "diffs", initfunc = "initpar",
+ jacfunc = NULL, nout = 0, outnames = NULL))
+ if (!inherits(mkinmod[["symbols"]], "try-error")) {
+ use_symbols = TRUE
+ }
}
# Get the error model and the algorithm for fitting
@@ -616,8 +621,9 @@ mkinfit <- function(mkinmod, observed,
odeini, outtimes,
solution_type = solution_type,
use_compiled = use_compiled,
+ use_symbols = use_symbols,
method.ode = method.ode,
- atol = atol, rtol = rtol,
+ atol = atol, rtol = rtol,
...)
observed_index <- cbind(as.character(observed$time), as.character(observed$name))
diff --git a/R/mkinmod.R b/R/mkinmod.R
index 29542b71..2f930adb 100644
--- a/R/mkinmod.R
+++ b/R/mkinmod.R
@@ -464,11 +464,11 @@ mkinmod <- function(..., use_of_ff = "max", name = NULL,
silent = TRUE)
if (!inherits(model$cf, "try-error")) {
+ if (!quiet) message("Temporary DLL for differentials generated and loaded")
if (!is.null(dll_dir)) {
model$dll_info <- inline::moveDLL(model$cf, name, dll_dir,
unload = unload, overwrite = overwrite, verbose = !quiet)
}
- if (!quiet) message("Temporary DLL for differentials generated and loaded")
model$dll_info <- inline::getDynLib(model$cf)
}
}
diff --git a/R/mkinpredict.R b/R/mkinpredict.R
index 8fa41217..60456fb2 100644
--- a/R/mkinpredict.R
+++ b/R/mkinpredict.R
@@ -27,8 +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 use_symbols If set to \code{TRUE} (default), 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.
@@ -174,7 +174,7 @@ mkinpredict.mkinmod <- function(x,
if (solution_type == "deSolve") {
if (!is.null(x$cf) & use_compiled[1] != FALSE) {
- if (!is.null(x$symbols) & use_symbols[1] == TRUE) {
+ if (!is.null(x$symbols) & use_symbols) {
lsoda_func <- x$symbols
} else {
lsoda_func <- "diffs"
diff --git a/R/saem.R b/R/saem.R
index 2fa770bb..83de97b0 100644
--- a/R/saem.R
+++ b/R/saem.R
@@ -583,11 +583,15 @@ saemix_model <- function(object, solution_type = "auto",
transform_fractions <- object[[1]]$transform_fractions
# Get native symbol info for speed
+ use_symbols = FALSE
if (solution_type == "deSolve" & !is.null(mkin_model$cf)) {
- mkin_model$symbols <- deSolve::checkDLL(
+ mkin_model$symbols <- try(deSolve::checkDLL(
dllname = mkin_model$dll_info[["name"]],
func = "diffs", initfunc = "initpar",
- jacfunc = NULL, nout = 0, outnames = NULL)
+ jacfunc = NULL, nout = 0, outnames = NULL))
+ if (!inherits(mkin_model$symbols, "try-error")) {
+ use_symbols = TRUE
+ }
}
# Define the model function

Contact - Imprint