aboutsummaryrefslogtreecommitdiff
path: root/docs/articles/web_only/compiled_models.html
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2023-04-20 20:17:12 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2023-04-20 20:17:12 +0200
commit7b7c4bf493ba15824ea43bed764661678b4aca03 (patch)
tree48de1e32327c36ee49fc476dc76ece8397ab55c6 /docs/articles/web_only/compiled_models.html
parent842998b688037c007d8876d7e1110c929fe2374c (diff)
parent9ae42bd20bc2543a94cf1581ba9820c2f9e3afbd (diff)
Merge branch 'v1.2.3_pkgdown'
Diffstat (limited to 'docs/articles/web_only/compiled_models.html')
-rw-r--r--docs/articles/web_only/compiled_models.html119
1 files changed, 84 insertions, 35 deletions
diff --git a/docs/articles/web_only/compiled_models.html b/docs/articles/web_only/compiled_models.html
index d17d7aeb..a411dad1 100644
--- a/docs/articles/web_only/compiled_models.html
+++ b/docs/articles/web_only/compiled_models.html
@@ -33,14 +33,14 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../../index.html">mkin</a>
- <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.2.0</span>
+ <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.2.3</span>
</span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
- <a href="../../reference/index.html">Functions and data</a>
+ <a href="../../reference/index.html">Reference</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
@@ -52,6 +52,9 @@
<li>
<a href="../../articles/mkin.html">Introduction to mkin</a>
</li>
+ <li class="divider">
+ </li>
+<li class="dropdown-header">Example evaluations with (generalised) nonlinear least squares</li>
<li>
<a href="../../articles/FOCUS_D.html">Example evaluation of FOCUS Example Dataset D</a>
</li>
@@ -59,22 +62,31 @@
<a href="../../articles/FOCUS_L.html">Example evaluation of FOCUS Laboratory Data L1 to L3</a>
</li>
<li>
- <a href="../../articles/web_only/dimethenamid_2018.html">Example evaluations of dimethenamid data from 2018 with nonlinear mixed-effects models</a>
+ <a href="../../articles/web_only/FOCUS_Z.html">Example evaluation of FOCUS Example Dataset Z</a>
+ </li>
+ <li class="divider">
</li>
+<li class="dropdown-header">Example evaluations with hierarchical models (nonlinear mixed-effects models)</li>
<li>
- <a href="../../articles/web_only/multistart.html">Short demo of the multistart method</a>
+ <a href="../../articles/prebuilt/2022_dmta_parent.html">Testing hierarchical parent degradation kinetics with residue data on dimethenamid and dimethenamid-P</a>
</li>
<li>
- <a href="../../articles/web_only/compiled_models.html">Performance benefit by using compiled model definitions in mkin</a>
+ <a href="../../articles/prebuilt/2022_dmta_pathway.html">Testing hierarchical pathway kinetics with residue data on dimethenamid and dimethenamid-P</a>
</li>
<li>
- <a href="../../articles/web_only/FOCUS_Z.html">Example evaluation of FOCUS Example Dataset Z</a>
+ <a href="../../articles/prebuilt/2022_cyan_pathway.html">Testing hierarchical pathway kinetics with residue data on cyantraniliprole</a>
</li>
<li>
- <a href="../../articles/twa.html">Calculation of time weighted average concentrations with mkin</a>
+ <a href="../../articles/web_only/dimethenamid_2018.html">Comparison of saemix and nlme evaluations of dimethenamid data from 2018</a>
</li>
<li>
- <a href="../../articles/web_only/NAFTA_examples.html">Example evaluation of NAFTA SOP Attachment examples</a>
+ <a href="../../articles/web_only/multistart.html">Short demo of the multistart method</a>
+ </li>
+ <li class="divider">
+ </li>
+<li class="dropdown-header">Performance</li>
+ <li>
+ <a href="../../articles/web_only/compiled_models.html">Performance benefit by using compiled model definitions in mkin</a>
</li>
<li>
<a href="../../articles/web_only/benchmarks.html">Benchmark timings for mkin</a>
@@ -82,6 +94,15 @@
<li>
<a href="../../articles/web_only/saem_benchmarks.html">Benchmark timings for saem.mmkin</a>
</li>
+ <li class="divider">
+ </li>
+<li class="dropdown-header">Miscellaneous</li>
+ <li>
+ <a href="../../articles/twa.html">Calculation of time weighted average concentrations with mkin</a>
+ </li>
+ <li>
+ <a href="../../articles/web_only/NAFTA_examples.html">Example evaluation of NAFTA SOP Attachment examples</a>
+ </li>
</ul>
</li>
<li>
@@ -105,13 +126,15 @@
- </header><script src="compiled_models_files/accessible-code-block-0.0.1/empty-anchor.js"></script><div class="row">
+ </header><div class="row">
<div class="col-md-9 contents">
<div class="page-header toc-ignore">
- <h1 data-toc-skip>Performance benefit by using compiled model definitions in mkin</h1>
- <h4 data-toc-skip class="author">Johannes Ranke</h4>
+ <h1 data-toc-skip>Performance benefit by using compiled model
+definitions in mkin</h1>
+ <h4 data-toc-skip class="author">Johannes
+Ranke</h4>
- <h4 data-toc-skip class="date">2022-11-17</h4>
+ <h4 data-toc-skip class="date">2023-04-20</h4>
<small class="dont-index">Source: <a href="https://github.com/jranke/mkin/blob/HEAD/vignettes/web_only/compiled_models.rmd" class="external-link"><code>vignettes/web_only/compiled_models.rmd</code></a></small>
<div class="hidden name"><code>compiled_models.rmd</code></div>
@@ -123,23 +146,39 @@
<div class="section level2">
<h2 id="how-to-benefit-from-compiled-models">How to benefit from compiled models<a class="anchor" aria-label="anchor" href="#how-to-benefit-from-compiled-models"></a>
</h2>
-<p>When using an mkin version equal to or greater than 0.9-36 and a C compiler is available, you will see a message that the model is being compiled from autogenerated C code when defining a model using mkinmod. Starting from version 0.9.49.9, the <code><a href="../../reference/mkinmod.html">mkinmod()</a></code> function checks for presence of a compiler using</p>
+<p>When using an mkin version equal to or greater than 0.9-36 and a C
+compiler is available, you will see a message that the model is being
+compiled from autogenerated C code when defining a model using mkinmod.
+Starting from version 0.9.49.9, the <code><a href="../../reference/mkinmod.html">mkinmod()</a></code> function
+checks for presence of a compiler using</p>
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
-<code class="sourceCode R"><span><span class="fu">pkgbuild</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/pkgbuild/man/has_compiler.html" class="external-link">has_compiler</a></span><span class="op">(</span><span class="op">)</span></span></code></pre></div>
-<p>In previous versions, it used <code>Sys.which("gcc")</code> for this check.</p>
-<p>On Linux, you need to have the essential build tools like make and gcc or clang installed. On Debian based linux distributions, these will be pulled in by installing the build-essential package.</p>
-<p>On MacOS, which I do not use personally, I have had reports that a compiler is available by default.</p>
-<p>On Windows, you need to install Rtools and have the path to its bin directory in your PATH variable. You do not need to modify the PATH variable when installing Rtools. Instead, I would recommend to put the line</p>
+<code class="sourceCode R"><span><span class="fu">pkgbuild</span><span class="fu">::</span><span class="fu"><a href="https://r-lib.github.io/pkgbuild/reference/has_compiler.html" class="external-link">has_compiler</a></span><span class="op">(</span><span class="op">)</span></span></code></pre></div>
+<p>In previous versions, it used <code>Sys.which("gcc")</code> for this
+check.</p>
+<p>On Linux, you need to have the essential build tools like make and
+gcc or clang installed. On Debian based linux distributions, these will
+be pulled in by installing the build-essential package.</p>
+<p>On MacOS, which I do not use personally, I have had reports that a
+compiler is available by default.</p>
+<p>On Windows, you need to install Rtools and have the path to its bin
+directory in your PATH variable. You do not need to modify the PATH
+variable when installing Rtools. Instead, I would recommend to put the
+line</p>
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/base/Sys.setenv.html" class="external-link">Sys.setenv</a></span><span class="op">(</span>PATH <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/paste.html" class="external-link">paste</a></span><span class="op">(</span><span class="st">"C:/Rtools/bin"</span>, <span class="fu"><a href="https://rdrr.io/r/base/Sys.getenv.html" class="external-link">Sys.getenv</a></span><span class="op">(</span><span class="st">"PATH"</span><span class="op">)</span>, sep<span class="op">=</span><span class="st">";"</span><span class="op">)</span><span class="op">)</span></span></code></pre></div>
-<p>into your .Rprofile startup file. This is just a text file with some R code that is executed when your R session starts. It has to be named .Rprofile and has to be located in your home directory, which will generally be your Documents folder. You can check the location of the home directory used by R by issuing</p>
+<p>into your .Rprofile startup file. This is just a text file with some
+R code that is executed when your R session starts. It has to be named
+.Rprofile and has to be located in your home directory, which will
+generally be your Documents folder. You can check the location of the
+home directory used by R by issuing</p>
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/base/Sys.getenv.html" class="external-link">Sys.getenv</a></span><span class="op">(</span><span class="st">"HOME"</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level2">
<h2 id="comparison-with-other-solution-methods">Comparison with other solution methods<a class="anchor" aria-label="anchor" href="#comparison-with-other-solution-methods"></a>
</h2>
-<p>First, we build a simple degradation model for a parent compound with one metabolite, and we remove zero values from the dataset.</p>
+<p>First, we build a simple degradation model for a parent compound with
+one metabolite, and we remove zero values from the dataset.</p>
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="st"><a href="https://pkgdown.jrwb.de/mkin/">"mkin"</a></span>, quietly <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span><span class="va">SFO_SFO</span> <span class="op">&lt;-</span> <span class="fu"><a href="../../reference/mkinmod.html">mkinmod</a></span><span class="op">(</span></span>
@@ -148,7 +187,12 @@
<pre><code><span><span class="co">## Temporary DLL for differentials generated and loaded</span></span></code></pre>
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">FOCUS_D</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/subset.html" class="external-link">subset</a></span><span class="op">(</span><span class="va">FOCUS_2006_D</span>, <span class="va">value</span> <span class="op">!=</span> <span class="fl">0</span><span class="op">)</span></span></code></pre></div>
-<p>We can compare the performance of the Eigenvalue based solution against the compiled version and the R implementation of the differential equations using the benchmark package. In the output of below code, the warnings about zero being removed from the FOCUS D dataset are suppressed. Since mkin version 0.9.49.11, an analytical solution is also implemented, which is included in the tests below.</p>
+<p>We can compare the performance of the Eigenvalue based solution
+against the compiled version and the R implementation of the
+differential equations using the benchmark package. In the output of
+below code, the warnings about zero being removed from the FOCUS D
+dataset are suppressed. Since mkin version 0.9.49.11, an analytical
+solution is also implemented, which is included in the tests below.</p>
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">require</a></span><span class="op">(</span><span class="va"><a href="http://rbenchmark.googlecode.com" class="external-link">rbenchmark</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span>
<span> <span class="va">b.1</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/rbenchmark/man/benchmark.html" class="external-link">benchmark</a></span><span class="op">(</span></span>
@@ -169,16 +213,20 @@
<span> <span class="fu"><a href="https://rdrr.io/r/base/print.html" class="external-link">print</a></span><span class="op">(</span><span class="st">"R package rbenchmark is not available"</span><span class="op">)</span></span>
<span><span class="op">}</span></span></code></pre></div>
<pre><code><span><span class="co">## test replications relative elapsed</span></span>
-<span><span class="co">## 4 analytical 1 1.000 0.218</span></span>
-<span><span class="co">## 3 deSolve, compiled 1 1.550 0.338</span></span>
-<span><span class="co">## 2 Eigenvalue based 1 1.950 0.425</span></span>
-<span><span class="co">## 1 deSolve, not compiled 1 33.041 7.203</span></span></code></pre>
-<p>We see that using the compiled model is by more than a factor of 10 faster than using deSolve without compiled code.</p>
+<span><span class="co">## 4 analytical 1 1.000 0.103</span></span>
+<span><span class="co">## 3 deSolve, compiled 1 1.291 0.133</span></span>
+<span><span class="co">## 2 Eigenvalue based 1 1.718 0.177</span></span>
+<span><span class="co">## 1 deSolve, not compiled 1 22.136 2.280</span></span></code></pre>
+<p>We see that using the compiled model is by more than a factor of 10
+faster than using deSolve without compiled code.</p>
</div>
<div class="section level2">
<h2 id="model-without-analytical-solution">Model without analytical solution<a class="anchor" aria-label="anchor" href="#model-without-analytical-solution"></a>
</h2>
-<p>This evaluation is also taken from the example section of mkinfit. No analytical solution is available for this system, and now Eigenvalue based solution is possible, so only deSolve using with or without compiled code is available.</p>
+<p>This evaluation is also taken from the example section of mkinfit. No
+analytical solution is available for this system, and now Eigenvalue
+based solution is possible, so only deSolve using with or without
+compiled code is available.</p>
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">require</a></span><span class="op">(</span><span class="va"><a href="http://rbenchmark.googlecode.com" class="external-link">rbenchmark</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span>
<span> <span class="va">FOMC_SFO</span> <span class="op">&lt;-</span> <span class="fu"><a href="../../reference/mkinmod.html">mkinmod</a></span><span class="op">(</span></span>
@@ -199,14 +247,15 @@
<span><span class="op">}</span></span></code></pre></div>
<pre><code><span><span class="co">## Temporary DLL for differentials generated and loaded</span></span></code></pre>
<pre><code><span><span class="co">## test replications relative elapsed</span></span>
-<span><span class="co">## 2 deSolve, compiled 1 1.000 0.510</span></span>
-<span><span class="co">## 1 deSolve, not compiled 1 26.247 13.386</span></span></code></pre>
-<p>Here we get a performance benefit of a factor of 26 using the version of the differential equation model compiled from C code!</p>
-<p>This vignette was built with mkin 1.2.0 on</p>
-<pre><code><span><span class="co">## R version 4.2.2 (2022-10-31)</span></span>
+<span><span class="co">## 2 deSolve, compiled 1 1.000 0.171</span></span>
+<span><span class="co">## 1 deSolve, not compiled 1 24.199 4.138</span></span></code></pre>
+<p>Here we get a performance benefit of a factor of 24 using the version
+of the differential equation model compiled from C code!</p>
+<p>This vignette was built with mkin 1.2.3 on</p>
+<pre><code><span><span class="co">## R version 4.2.3 (2023-03-15)</span></span>
<span><span class="co">## Platform: x86_64-pc-linux-gnu (64-bit)</span></span>
-<span><span class="co">## Running under: Debian GNU/Linux 11 (bullseye)</span></span></code></pre>
-<pre><code><span><span class="co">## CPU model: AMD Ryzen 7 1700 Eight-Core Processor</span></span></code></pre>
+<span><span class="co">## Running under: Debian GNU/Linux 12 (bookworm)</span></span></code></pre>
+<pre><code><span><span class="co">## CPU model: AMD Ryzen 9 7950X 16-Core Processor</span></span></code></pre>
</div>
</div>
@@ -227,7 +276,7 @@
<div class="pkgdown">
<p></p>
-<p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.0.6.</p>
+<p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.0.7.</p>
</div>
</footer>

Contact - Imprint