|
4 | 4 | #' design conditions, and number of replications. Results can be saved as temporary files in case of |
5 | 5 | #' interruptions and may be restored by re-running \code{runSimulation}, provided that the respective temp |
6 | 6 | #' file can be found in the working directory. \code{runSimulation} supports parallel |
7 | | -#' and cluster computing, global and local debugging, error handling (including fail-safe |
| 7 | +#' and cluster computing (with the \code{parallel} and \code{future} packages), |
| 8 | +#' global and local debugging, error handling (including fail-safe |
8 | 9 | #' stopping when functions fail too often, even across nodes), provides bootstrap estimates of the |
9 | 10 | #' sampling variability (optional), and automatic tracking of error and warning messages |
10 | 11 | #' and their associated \code{.Random.seed} states. |
|
116 | 117 | #' |
117 | 118 | #' @section A note on parallel computing: |
118 | 119 | #' |
119 | | -#' When running simulations in parallel (either with \code{parallel = TRUE} or \code{MPI = TRUE}) |
| 120 | +#' When running simulations in parallel (either with \code{parallel = TRUE} or \code{MPI = TRUE}, |
| 121 | +#' or when using the \code{future} approach with a \code{plan()} other than sequential) |
120 | 122 | #' R objects defined in the global environment will generally \emph{not} be visible across nodes. |
121 | 123 | #' Hence, you may see errors such as \code{Error: object 'something' not found} if you try to use |
122 | 124 | #' an object that is defined in the work space but is not passed to \code{runSimulation}. |
|
182 | 184 | #' constant global elements (e.g., a constant for sample size) |
183 | 185 | #' |
184 | 186 | #' @param parallel logical; use parallel processing from the \code{parallel} |
185 | | -#' package over each unique condition? Alternatively, if the \code{future} package has |
186 | | -#' been attached prior to executing \code{runSimulation()} then the associated |
187 | | -#' \code{plan()} will be followed |
| 187 | +#' package over each unique condition? |
| 188 | +#' |
| 189 | +#' Alternatively, if the \code{future} package has been attached prior to executing |
| 190 | +#' \code{runSimulation()} then the associated \code{plan()} will be followed instead |
188 | 191 | #' |
189 | | -#' @param cl cluster object defined by \code{\link{makeCluster}} used to run code in parallel. |
| 192 | +#' @param cl cluster object defined by \code{\link{makeCluster}} used to run code in parallel |
| 193 | +#' (ignored if using the \code{future} package approach). |
190 | 194 | #' If \code{NULL} and \code{parallel = TRUE}, a local cluster object will be defined which |
191 | 195 | #' selects the maximum number cores available |
192 | 196 | #' and will be stopped when the simulation is complete. Note that supplying a \code{cl} |
|
199 | 203 | #' \code{plan()} will be followed instead |
200 | 204 | #' |
201 | 205 | #' @param packages a character vector of external packages to be used during the simulation (e.g., |
202 | | -#' \code{c('MASS', 'extraDistr', 'simsem')} ). Use this input when \code{parallel = TRUE} or |
203 | | -#' \code{MPI = TRUE} to use non-standard functions from additional packages, |
| 206 | +#' \code{c('MASS', 'extraDistr', 'simsem')} ). Use this input when running code in |
| 207 | +#' parallel to use non-standard functions from additional packages, |
204 | 208 | #' otherwise the functions must be made available by using explicit |
205 | 209 | #' \code{\link{library}} or \code{\link{require}} calls within the provided simulation functions. |
206 | 210 | #' Alternatively, functions can be called explicitly without attaching the package |
|
411 | 415 | #' something fatally problematic |
412 | 416 | #' is going wrong in the generate-analyse phases. Default is 50 |
413 | 417 | #' |
414 | | -#' @param ncores number of cores to be used in parallel execution. Default uses all available |
| 418 | +#' @param ncores number of cores to be used in parallel execution (ignored if using the |
| 419 | +#' \code{future} package approach). Default uses all available |
415 | 420 | #' |
416 | 421 | #' @param save logical; save the temporary simulation state to the hard-drive? This is useful |
417 | 422 | #' for simulations which require an extended amount of time, though for shorter simulations |
|
769 | 774 | #' library(future) # future structure to be used internally |
770 | 775 | #' # plan(multisession) # specify different plan (default is sequential) |
771 | 776 | #' |
772 | | -#' # note that parallel and cl inputs no longer used, and progressr package |
773 | | -#' # used for progress reporting (disable with progress = FALSE or redefine |
774 | | -#' # using progressr::handlers()) |
| 777 | +#' # note that parallel and cl inputs no longer used, and the progressr package |
| 778 | +#' # is used for progress reporting (disable with progress = FALSE or redefine |
| 779 | +#' # using progressr::handlers(); see below) |
775 | 780 | #' res <- runSimulation(design=Design, replications=1000, |
776 | 781 | #' generate=Generate, analyse=Analyse, summarise=Summarise) |
777 | 782 | #' head(res) |
778 | 783 | #' |
779 | | -#' # re-define progress bar |
| 784 | +#' # re-define progress bar (requires cli) |
780 | 785 | #' library(progressr) |
781 | 786 | #' handlers(handler_pbcol( |
782 | 787 | #' adjust = 1.0, |
|
787 | 792 | #' res <- runSimulation(design=Design, replications=1000, |
788 | 793 | #' generate=Generate, analyse=Analyse, summarise=Summarise) |
789 | 794 | #' |
790 | | -#' # stop using future package internally |
| 795 | +#' # to stop using future package internally use |
791 | 796 | #' detach("package:future") |
792 | 797 | #' |
793 | 798 | #' #################################### |
|
0 commit comments