R6::R6Class class to represent a handler for running multiple model
simulations and saving results. This simulation manager bears some
resemblance to the poems::SimulationManager in poems, but differs
in that it can handle multiple dispersal generators, uses a different engine
for parallelization, handles errors differently, and has a different default
data format (.qs2).
poems::GenericClass -> poems::GenericManager -> SimulationHandler
attachedA list of dynamically attached attributes (name-value pairs).
sample_dataA data frame of sampled parameters for each simulation/result.
model_templateA poems::SimulationModel (or inherited class)
object with parameters common to all simulations.
nested_modelA poems::SimulationModel (or inherited class)
object with empty sample parameters and a nested model template common to
all simulations.
generatorsA list of generators (poems::Generator or inherited
class) objects for generating simulation model values.
model_simulatorA poems::ModelSimulator (or inherited class)
object for running the simulations.
parallel_coresNumber of cores for running the simulations in parallel.
results_dirResults directory path.
results_extResult file extension (default is .RData).
results_filename_attributesA vector of: prefix (optional); attribute names (from the sample data frame); postfix (optional); utilized to construct results filenames.
error_messagesA vector of error messages encountered when setting model attributes.
warning_messagesA vector of warning messages encountered when setting model attributes.
new()Initialization method sets any included attributes (sample_data, model_template, generators, model_simulator, parallel_cores, results_dir, results_filename_attributes) and attaches other attributes individually listed.
SimulationHandler$new(model_template = NULL, ...)model_templateA SimulationModel (or inherited class) object with parameters common to all simulations.
...Parameters listed individually.
log_simulation()Summarizes the simulation log and writes it to a text file.
This method takes a nested list of simulation log entries generated by
the run method and summarizes the log. It determines which simulations
were successful, collects any warnings, and writes the summary to a text
file in the results directory.
SimulationHandler$log_simulation(simulation_log)simulation_logA nested list of simulation log entries.
A list containing the summary, indices of failed simulations, indices of simulations with warnings, and the full log.
set_model_sample()Sets the model sample attributes via the sample data frame and the generators.
This method sets the sample attributes of a SimulationModel object based on the specified sample index. It uses the sample data frame and the generators to determine the attribute values.
SimulationHandler$set_model_sample(model, sample_index)modelpoems::SimulationModel (or inherited class) object
(clone) to receive sample attributes.
sample_indexIndex of sample from data frame.
run()Runs the multiple population simulations, stores the results, and creates a simulation log.
This method runs multiple population simulations using the specified model template and sample data. It stores the simulation results in the specified results directory and creates a simulation log. The simulation log contains information about the success or failure of each simulation run.
SimulationHandler$run(results_dir = NULL)results_dirResults directory path where the simulation results will be stored. If not provided, the results directory must be set within the manager class object.
A list representing the simulation log. Each element of the list corresponds to a simulation run and contains information about the success or failure of the run, any error messages, and the path to the saved results file (if applicable).
clone()The objects of this class are cloneable with this method.
SimulationHandler$clone(deep = FALSE)deepWhether to make a deep clone.