diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2023-04-15 15:35:06 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2023-04-15 15:35:06 +0200 |
commit | b0b710ee9f9bb9bbe9708676d0c5822465e02203 (patch) | |
tree | 537dcf86326ab2e03100a5defb11b264a4b72a17 /inst/rmarkdown/templates | |
parent | 50ea6d11f8c79218c98ee8ae56d8bdcd42cc703a (diff) |
Make predefined symbols safer
We still need to create a parallel processing cluster _after_ creating a
compiled model that is moved to a user defined location, at least I did
not find another way to make it work. This is not a problem with
parallel processing without a cluster, which is not available on
Windows.
Diffstat (limited to 'inst/rmarkdown/templates')
-rw-r--r-- | inst/rmarkdown/templates/hierarchical_kinetics/skeleton/skeleton.Rmd | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/inst/rmarkdown/templates/hierarchical_kinetics/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/hierarchical_kinetics/skeleton/skeleton.Rmd index 38a6bd20..cb328308 100644 --- a/inst/rmarkdown/templates/hierarchical_kinetics/skeleton/skeleton.Rmd +++ b/inst/rmarkdown/templates/hierarchical_kinetics/skeleton/skeleton.Rmd @@ -21,11 +21,18 @@ library(readxl) ```{r n_cores, cache = FALSE} n_cores <- detectCores() -if (Sys.info()["sysname"] == "Windows") { - cl <- makePSOCKcluster(n_cores) -} else { - cl <- makeForkCluster(n_cores) +# We need to start a new cluster after defining a compiled model that is +# saved as a DLL to the user directory, therefore we define a function +# This is used again after defining the pathway model +start_cluster <- function(n_cores) { + if (Sys.info()["sysname"] == "Windows") { + ret <- makePSOCKcluster(n_cores) + } else { + ret <- makeForkCluster(n_cores) + } + return(ret) } +cl <- start_cluster(n_cores) ``` \clearpage @@ -179,6 +186,10 @@ illparms(parent_best_pH_2) parms(parent_best_pH_2, ci = TRUE) |> kable(digits = 3) ``` +```{r} +stopCluster(cl) +``` + \clearpage # Pathway fits @@ -203,6 +214,7 @@ Separate evaluations of all datasets are performed with constant variance and using two-component error. ```{r path-1-sep, dependson = c("path-1-degmod", "ds")} +cl <- start_cluster(n_cores) sforb_sep_const <- mmkin(list(sforb_path = m_sforb_sfo2), ds, cluster = cl, quiet = TRUE) sforb_sep_tc <- update(sforb_sep_const, error_model = "tc") @@ -268,6 +280,10 @@ plot(path_1_refined) parms(path_1_refined, ci = TRUE) |> kable(digits = 3) ``` +```{r} +stopCluster(cl) +``` + \clearpage # Appendix |