From ec574cff822a1238138c0aa69b3d1459bdc3dfa8 Mon Sep 17 00:00:00 2001
From: Johannes Ranke The call to mkinmod returns a degradation model. The differential equations represented in
R code can be found in the character vector $diffs
of the mkinmod
object. If
-the ccSolve
package is installed and functional, the differential equation model
+a compiler (g++) is installed and functional, the differential equation model
will be compiled from auto-generated C code.
-SFO_SFO <- mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"))
## Compiling differential equation model from auto-generated C code...
+
## Compiling differential equation model from auto-generated C++ code...
print(SFO_SFO$diffs)
@@ -312,7 +312,7 @@ using the
plot
method for mkinfit
objects.
mkinparplot(fit)
-
A comprehensive report of the results is obtained using the summary
method for mkinfit
objects.
## mkin version: 0.9.36
## R version: 3.2.0
-## Date of fit: Fri Jun 5 14:20:31 2015
-## Date of summary: Fri Jun 5 14:20:31 2015
+## Date of fit: Fri Jun 19 16:21:21 2015
+## Date of summary: Fri Jun 19 16:21:21 2015
##
## Equations:
## d_parent = - k_parent_sink * parent - k_parent_m1 * parent
## d_m1 = + k_parent_m1 * parent - k_m1_sink * m1
##
-## Model predictions using solution type deSolve
+## Model predictions using solution type odeintr
##
-## Fitted with method Port using 153 model solutions performed in 0.621 s
+## Fitted with method Port using 153 model solutions performed in 0.562 s
##
## Weighting: none
##
@@ -370,7 +370,7 @@ objects.
## parent_0 1.00000 0.6075 -0.06625 -0.1701
## log_k_parent_sink 0.60752 1.0000 -0.08740 -0.6253
## log_k_parent_m1 -0.06625 -0.0874 1.00000 0.4716
-## log_k_m1_sink -0.17006 -0.6253 0.47163 1.0000
+## log_k_m1_sink -0.17006 -0.6253 0.47164 1.0000
##
## Residual standard error: 3.211 on 36 degrees of freedom
##
diff --git a/vignettes/FOCUS_Z.pdf b/vignettes/FOCUS_Z.pdf
index 3174a23a..e2a4baa9 100644
Binary files a/vignettes/FOCUS_Z.pdf and b/vignettes/FOCUS_Z.pdf differ
diff --git a/vignettes/compiled_models.Rmd b/vignettes/compiled_models.Rmd
index bac284c5..b6d54710 100644
--- a/vignettes/compiled_models.Rmd
+++ b/vignettes/compiled_models.Rmd
@@ -15,22 +15,20 @@ output:
```{r, include = FALSE}
library(knitr)
opts_chunk$set(tidy = FALSE, cache = TRUE)
-if (!require("ccSolve"))
- message("Please install the ccSolve package for this vignette to produce sensible output")
-
```
# Benchmark for a model that can also be solved with Eigenvalues
This evaluation is taken from the example section of mkinfit. When using an mkin version
-greater than 0.9-36 and the ccSolve package is installed and functional, you will get a
-message that the model is being compiled when defining a model using mkinmod.
+greater or equal than 0.9-36 and the C++ compiler g++ is installed and functional (on Windows,
+install Rtools), you will get a message that the model is being compiled when
+defining a model using mkinmod.
```{r create_SFO_SFO}
library("mkin")
SFO_SFO <- mkinmod(
parent = list(type = "SFO", to = "m1", sink = TRUE),
- m1 = list(type = "SFO"))
+ m1 = list(type = "SFO"), odeintr_compile = "yes")
```
We can compare the performance of the Eigenvalue based solution against the
@@ -39,28 +37,23 @@ the microbenchmark package.
```{r benchmark_SFO_SFO, echo=-(1:2)}
-# Redefining the model, in order not to confuse the knitr cache which leads to segfaults
-suppressMessages(SFO_SFO <- mkinmod(
- parent = list(type = "SFO", to = "m1", sink = TRUE),
- m1 = list(type = "SFO")))
library("microbenchmark")
mb.1 <- microbenchmark(
- mkinfit(SFO_SFO, FOCUS_2006_D, solution_type = "deSolve", use_compiled = FALSE,
- quiet = TRUE),
- mkinfit(SFO_SFO, FOCUS_2006_D, solution_type = "eigen", quiet = TRUE),
mkinfit(SFO_SFO, FOCUS_2006_D, solution_type = "deSolve", quiet = TRUE),
+ mkinfit(SFO_SFO, FOCUS_2006_D, solution_type = "eigen", quiet = TRUE),
+ mkinfit(SFO_SFO, FOCUS_2006_D, solution_type = "odeintr", quiet = TRUE),
times = 3, control = list(warmup = 1))
smb.1 <- summary(mb.1)[-1]
-rownames(smb.1) <- c("deSolve, not compiled", "Eigenvalue based", "deSolve, compiled")
+rownames(smb.1) <- c("deSolve, not compiled", "Eigenvalue based", "odeintr, compiled")
print(smb.1)
```
-We see that using the compiled model is almost a factor of 8 faster than using the R version
+We see that using the compiled model is more than a factor of 7 faster than using the R version
with the default ode solver, and it is even faster than the Eigenvalue based solution implemented
in R which does not need iterative solution of the ODEs:
```{r}
-smb.1["median"]/smb.1["deSolve, compiled", "median"]
+smb.1["median"]/smb.1["odeintr, compiled", "median"]
```
# Benchmark for a model that can not be solved with Eigenvalues
@@ -73,15 +66,15 @@ FOMC_SFO <- mkinmod(
m1 = list(type = "SFO"))
mb.2 <- microbenchmark(
- mkinfit(FOMC_SFO, FOCUS_2006_D, use_compiled = FALSE, quiet = TRUE),
- mkinfit(FOMC_SFO, FOCUS_2006_D, quiet = TRUE),
+ mkinfit(FOMC_SFO, FOCUS_2006_D, solution_type = "deSolve", quiet = TRUE),
+ mkinfit(FOMC_SFO, FOCUS_2006_D, solution_type = "odeintr", quiet = TRUE),
times = 3, control = list(warmup = 1))
smb.2 <- summary(mb.2)[-1]
-rownames(smb.2) <- c("deSolve, not compiled", "deSolve, compiled")
+rownames(smb.2) <- c("deSolve, not compiled", "odeintr, compiled")
print(smb.2)
-smb.2["median"]/smb.2["deSolve, compiled", "median"]
+smb.2["median"]/smb.2["odeintr, compiled", "median"]
```
Here we get a performance benefit of more than a factor of 8 using the version
-of the differential equation model compiled from C code using the ccSolve package!
+of the differential equation model compiled from C++ code using the odeintr package!
diff --git a/vignettes/compiled_models.html b/vignettes/compiled_models.html
index 2f2a6edb..efdbe20d 100644
--- a/vignettes/compiled_models.html
+++ b/vignettes/compiled_models.html
@@ -77,37 +77,30 @@ img {
-->
Benchmark for a model that can also be solved with Eigenvalues
-This evaluation is taken from the example section of mkinfit. When using an mkin version greater than 0.9-36 and the ccSolve package is installed and functional, you will get a message that the model is being compiled when defining a model using mkinmod.
+This evaluation is taken from the example section of mkinfit. When using an mkin version greater or equal than 0.9-36 and the C++ compiler g++ is installed and functional (on Windows, install Rtools), you will get a message that the model is being compiled when defining a model using mkinmod.
library("mkin")
SFO_SFO <- mkinmod(
parent = list(type = "SFO", to = "m1", sink = TRUE),
- m1 = list(type = "SFO"))
-## Compiling differential equation model from auto-generated C code...
+ m1 = list(type = "SFO"), odeintr_compile = "yes")
+## Compiling differential equation model from auto-generated C++ code...
We can compare the performance of the Eigenvalue based solution against the compiled version and the R implementation of the differential equations using the microbenchmark package.
-library("microbenchmark")
-mb.1 <- microbenchmark(
- mkinfit(SFO_SFO, FOCUS_2006_D, solution_type = "deSolve", use_compiled = FALSE,
- quiet = TRUE),
- mkinfit(SFO_SFO, FOCUS_2006_D, solution_type = "eigen", quiet = TRUE),
- mkinfit(SFO_SFO, FOCUS_2006_D, solution_type = "deSolve", quiet = TRUE),
- times = 3, control = list(warmup = 1))
-smb.1 <- summary(mb.1)[-1]
-rownames(smb.1) <- c("deSolve, not compiled", "Eigenvalue based", "deSolve, compiled")
+smb.1 <- summary(mb.1)[-1]
+rownames(smb.1) <- c("deSolve, not compiled", "Eigenvalue based", "odeintr, compiled")
print(smb.1)
## min lq mean median uq
-## deSolve, not compiled 6192.0125 6195.3470 6211.0309 6198.6816 6220.5401
-## Eigenvalue based 956.7604 1008.7224 1026.2572 1060.6844 1061.0055
-## deSolve, compiled 869.6880 871.9315 883.4929 874.1751 890.3953
+## deSolve, not compiled 5254.1030 5261.3501 5277.1074 5268.5973 5288.6096
+## Eigenvalue based 897.1575 921.6935 930.9546 946.2296 947.8531
+## odeintr, compiled 693.6001 709.0719 719.5530 724.5438 732.5295
## max neval
-## deSolve, not compiled 6242.3986 3
-## Eigenvalue based 1061.3266 3
-## deSolve, compiled 906.6155 3
-We see that using the compiled model is almost a factor of 8 faster than using the R version with the default ode solver, and it is even faster than the Eigenvalue based solution implemented in R which does not need iterative solution of the ODEs:
-smb.1["median"]/smb.1["deSolve, compiled", "median"]
+## deSolve, not compiled 5308.6218 3
+## Eigenvalue based 949.4766 3
+## odeintr, compiled 740.5151 3
+We see that using the compiled model is more than a factor of 7 faster than using the R version with the default ode solver, and it is even faster than the Eigenvalue based solution implemented in R which does not need iterative solution of the ODEs:
+smb.1["median"]/smb.1["odeintr, compiled", "median"]
## median
-## deSolve, not compiled 7.120877
-## Eigenvalue based 1.205328
-## deSolve, compiled 1.000000
+## deSolve, not compiled 7.290796
+## Eigenvalue based 1.370242
+## odeintr, compiled 1.000000
Benchmark for a model that can not be solved with Eigenvalues
@@ -115,25 +108,25 @@ print(smb.1)
FOMC_SFO <- mkinmod(
parent = list(type = "FOMC", to = "m1", sink = TRUE),
m1 = list(type = "SFO"))
-## Compiling differential equation model from auto-generated C code...
+## Compiling differential equation model from auto-generated C++ code...
mb.2 <- microbenchmark(
- mkinfit(FOMC_SFO, FOCUS_2006_D, use_compiled = FALSE, quiet = TRUE),
- mkinfit(FOMC_SFO, FOCUS_2006_D, quiet = TRUE),
+ mkinfit(FOMC_SFO, FOCUS_2006_D, solution_type = "deSolve", quiet = TRUE),
+ mkinfit(FOMC_SFO, FOCUS_2006_D, solution_type = "odeintr", quiet = TRUE),
times = 3, control = list(warmup = 1))
smb.2 <- summary(mb.2)[-1]
-rownames(smb.2) <- c("deSolve, not compiled", "deSolve, compiled")
+rownames(smb.2) <- c("deSolve, not compiled", "odeintr, compiled")
print(smb.2)
## min lq mean median uq
-## deSolve, not compiled 13.297283 13.427702 13.481155 13.558121 13.573092
-## deSolve, compiled 1.486926 1.526887 1.546851 1.566848 1.576813
+## deSolve, not compiled 11.243675 11.324875 11.382415 11.406074 11.451785
+## odeintr, compiled 1.207114 1.209908 1.239989 1.212703 1.256426
## max neval
-## deSolve, not compiled 13.588063 3
-## deSolve, compiled 1.586778 3
-smb.2["median"]/smb.2["deSolve, compiled", "median"]
+## deSolve, not compiled 11.497496 3
+## odeintr, compiled 1.300149 3
+smb.2["median"]/smb.2["odeintr, compiled", "median"]
## median
-## deSolve, not compiled 8.653119
-## deSolve, compiled 1.000000
-Here we get a performance benefit of more than a factor of 8 using the version of the differential equation model compiled from C code using the ccSolve package!
+## deSolve, not compiled 9.405494
+## odeintr, compiled 1.000000
+Here we get a performance benefit of more than a factor of 8 using the version of the differential equation model compiled from C++ code using the odeintr package!
--
cgit v1.2.1