dispatch_trial_runs: Simulate single trial after setting seed

View source: R/run_trials.R

dispatch_trial_runsR Documentation

Simulate single trial after setting seed

Description

Helper function to dispatch the running of several trials to lapply() or parallel::parLapply(), setting seeds correctly if a base_seed was used when calling run_trials(). Used internally in calls by the run_trials() function.

Usage

dispatch_trial_runs(is, trial_spec, seeds, sparse, cores, cl = NULL)

Arguments

is

vector of integers, the simulation numbers/indices.

trial_spec

trial specification as provided by setup_trial(), setup_trial_binom() or setup_trial_norm().

sparse

single logical, as described in run_trial(); defaults to TRUE when running multiple simulations, in which case only the data necessary to summarise all simulations are saved for each simulation. If FALSE, more detailed data for each simulation is saved, allowing more detailed printing of individual trial results and plotting using plot_history() (plot_status() does not require non-sparse results).

cores

NULL or single integer. If NULL, a default value/cluster set by setup_cluster() will be used to control whether simulations are run in parallel on a default cluster or sequentially in the main process; if a cluster/value has not been specified by setup_cluster(), cores will then be set to the value stored in the global "mc.cores" option (if previously set by ⁠options(mc.cores = <number of cores>⁠), and 1 if that option has not been specified.
If the resulting number of cores = 1, computations will be run sequentially in the primary process, and if cores > 1, a new parallel cluster will be setup using the parallel library and removed once the function completes. See setup_cluster() for details.

cl

NULL (default) for running sequentially, otherwise a parallel cluster for parallel computation if cores > 1.

Value

Single trial simulation object, as described in run_trial().


adaptr documentation built on May 29, 2024, 7:48 a.m.