aboutsummaryrefslogtreecommitdiff
path: root/R/mkinpredict.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/mkinpredict.R')
-rw-r--r--R/mkinpredict.R27
1 files changed, 16 insertions, 11 deletions
diff --git a/R/mkinpredict.R b/R/mkinpredict.R
index da013d50..3121f1d7 100644
--- a/R/mkinpredict.R
+++ b/R/mkinpredict.R
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2014 Johannes Ranke
+# Copyright (C) 2010-2015 Johannes Ranke
# Some lines in this code are copyright (C) 2013 Eurofins Regulatory AG
# Contact: jranke@uni-bremen.de
@@ -19,6 +19,7 @@
mkinpredict <- function(mkinmod, odeparms, odeini,
outtimes, solution_type = "deSolve",
+ use_compiled = "auto",
method.ode = "lsoda", atol = 1e-8, rtol = 1e-10,
map_output = TRUE, ...) {
@@ -87,23 +88,27 @@ mkinpredict <- function(mkinmod, odeparms, odeini,
names(out) <- c("time", mod_vars)
}
if (solution_type == "deSolve") {
- mkindiff <- function(t, state, parms) {
+ if (!is.null(mkinmod$compiled) & use_compiled[1] != FALSE) {
+ mkindiff <- mkinmod$compiled
+ } else {
+ mkindiff <- function(t, state, parms) {
- time <- t
- diffs <- vector()
- for (box in names(mkinmod$diffs))
- {
- diffname <- paste("d", box, sep="_")
- diffs[diffname] <- with(as.list(c(time, state, parms)),
- eval(parse(text=mkinmod$diffs[[box]])))
+ time <- t
+ diffs <- vector()
+ for (box in names(mkinmod$diffs))
+ {
+ diffname <- paste("d", box, sep="_")
+ diffs[diffname] <- with(as.list(c(time, state, parms)),
+ eval(parse(text=mkinmod$diffs[[box]])))
+ }
+ return(list(c(diffs)))
}
- return(list(c(diffs)))
}
out <- ode(
y = odeini,
times = outtimes,
func = mkindiff,
- parms = odeparms,
+ parms = odeparms[mkinmod$parms], # Order matters when using compiled models
method = method.ode,
atol = atol,
rtol = rtol,

Contact - Imprint