generateParallelExecuter: Factory to generate a parallel executor of an existing...

View source: R/BayesianSetupGenerateParallel.R

generateParallelExecuterR Documentation

Factory to generate a parallel executor of an existing function


Factory to generate a parallel executor of an existing function


  parallel = F,
  parallelOptions = list(variables = "all", packages = "all", dlls = NULL)



function to be changed to parallel execution


should a parallel R cluster be used or not. If set to T, cores will be detected automatically and n-1 of the available n cores of the machine will be used. Alternatively, you can set the number of cores used by hand


list containing three lists. First "packages" determines the R packages necessary to run the likelihood function. Second "variables" the objects in the global environment needed to run the likelihood function and third "dlls" the DLLs needed to run the likelihood function (see Details).


For parallelization, option T means that an automatic parallelization via R is attempted, or "external", in which case it is assumed that the likelihood is already parallelized. In this case it needs to accept a matrix with parameters as columns. Further you can specify the packages, objects and DLLs that are exported to the cluster. By default a copy of your workspace is exported. However, depending on your workspace this can be very inefficient.

Alternatively you can specify the environments and packages in the likelihood function (e.g. BayesianTools::VSEM() instead of VSEM()).


Can also be used to make functions compatible with library sensitivity


Florian Hartig


testDensityMultiNormal <- generateTestDensityMultiNormal()

parDen <- generateParallelExecuter(testDensityMultiNormal)$parallelFun
x = matrix(runif(9,0,1), nrow = 3)

BayesianTools documentation built on Feb. 16, 2023, 8:44 p.m.