From 3f6ce570824616f5be0d6289ed65910d455dd266 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 17 Nov 2016 22:56:30 +0100 Subject: Rebuild --- vignettes/compiled_models.html | 51 +++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'vignettes/compiled_models.html') diff --git a/vignettes/compiled_models.html b/vignettes/compiled_models.html index dc2b2ca7..2cb73ac7 100644 --- a/vignettes/compiled_models.html +++ b/vignettes/compiled_models.html @@ -11,7 +11,7 @@ - + Performance benefit by using compiled model definitions in mkin @@ -216,7 +216,7 @@ div.tocify {

Performance benefit by using compiled model definitions in mkin

Johannes Ranke

-

2016-11-04

+

2016-11-17

@@ -232,6 +232,7 @@ div.tocify {
## Loading required package: minpack.lm
## Loading required package: rootSolve
## Loading required package: inline
+
## Loading required package: methods
## Loading required package: parallel
SFO_SFO <- mkinmod(
   parent = mkinsub("SFO", "m1"),
@@ -241,12 +242,12 @@ div.tocify {
 
library("microbenchmark")
 library("ggplot2")
 mb.1 <- microbenchmark(
-  "deSolve, not compiled" = mkinfit(SFO_SFO, FOCUS_2006_D, 
-                                    solution_type = "deSolve", 
+  "deSolve, not compiled" = mkinfit(SFO_SFO, FOCUS_2006_D,
+                                    solution_type = "deSolve",
                                     use_compiled = FALSE, quiet = TRUE),
-  "Eigenvalue based" = mkinfit(SFO_SFO, FOCUS_2006_D, 
+  "Eigenvalue based" = mkinfit(SFO_SFO, FOCUS_2006_D,
                                solution_type = "eigen", quiet = TRUE),
-  "deSolve, compiled" = mkinfit(SFO_SFO, FOCUS_2006_D, 
+  "deSolve, compiled" = mkinfit(SFO_SFO, FOCUS_2006_D,
                                 solution_type = "deSolve", quiet = TRUE),
   times = 3, control = list(warmup = 0))
## Warning in microbenchmark(`deSolve, not compiled` = mkinfit(SFO_SFO,
@@ -256,21 +257,21 @@ mb.1 <- microbenchmark(
 print(mb.1)
## Unit: milliseconds
 ##                   expr       min        lq      mean    median        uq
-##  deSolve, not compiled 4969.1274 5005.4703 5026.1990 5041.8132 5054.7348
-##       Eigenvalue based  841.6273  843.3144  855.0880  845.0015  861.8183
-##      deSolve, compiled  689.6154  698.2345  710.3162  706.8537  720.6666
+##  deSolve, not compiled 4925.0009 4957.6694 4974.0652 4990.3379 4998.5974
+##       Eigenvalue based  838.9741  839.6651  857.4679  840.3561  866.7149
+##      deSolve, compiled  695.5858  709.3905  717.8062  723.1951  728.9163
 ##        max neval cld
-##  5067.6564     3   c
-##   878.6352     3  b 
-##   734.4795     3 a
+## 5006.8569 3 c +## 893.0736 3 b +## 734.6375 3 a
autoplot(mb.1)
-

-

We see that using the compiled model is by a factor of 7.1 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:

+

+

We see that using the compiled model is by a factor of 6.9 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:

rownames(smb.1) <- smb.1$expr
 smb.1["median"]/smb.1["deSolve, compiled", "median"]
##                         median
-## deSolve, not compiled 7.132754
-## Eigenvalue based      1.195441
+## deSolve, not compiled 6.900403
+## Eigenvalue based      1.162005
 ## deSolve, compiled     1.000000
@@ -281,7 +282,7 @@ smb.1["median"]/smb.1["deSolve, compiled", "median" m1 = mkinsub( "SFO"))
## Successfully compiled differential equation model from auto-generated C code.
mb.2 <- microbenchmark(
-  "deSolve, not compiled" = mkinfit(FOMC_SFO, FOCUS_2006_D, 
+  "deSolve, not compiled" = mkinfit(FOMC_SFO, FOCUS_2006_D,
                                     use_compiled = FALSE, quiet = TRUE),
   "deSolve, compiled" = mkinfit(FOMC_SFO, FOCUS_2006_D, quiet = TRUE),
   times = 3, control = list(warmup = 0))
@@ -291,19 +292,19 @@ smb.1["median"]/smb.1["deSolve, compiled", "median"
smb.2 <- summary(mb.2)
 print(mb.2)
## Unit: seconds
-##                   expr       min        lq      mean    median        uq
-##  deSolve, not compiled 10.998190 11.039105 11.133751 11.080019 11.201531
-##      deSolve, compiled  1.286159  1.286381  1.288394  1.286602  1.289511
-##       max neval cld
-##  11.32304     3   b
-##   1.29242     3  a
+## expr min lq mean median uq +## deSolve, not compiled 10.905262 11.007527 11.335389 11.109791 11.55045 +## deSolve, compiled 1.297428 1.304999 1.327356 1.312569 1.34232 +## max neval cld +## 11.991114 3 b +## 1.372071 3 a
smb.2["median"]/smb.2["deSolve, compiled", "median"]
##   median
 ## 1     NA
 ## 2     NA
autoplot(mb.2)
-

-

Here we get a performance benefit of a factor of 8.6 using the version of the differential equation model compiled from C code!

+

+

Here we get a performance benefit of a factor of 8.5 using the version of the differential equation model compiled from C code!

This vignette was built with mkin 0.9.44.9000 on

## R version 3.3.2 (2016-10-31)
 ## Platform: x86_64-pc-linux-gnu (64-bit)
-- 
cgit v1.2.1