View source: R/generate_parameters.r
make.batch.file.yaml | R Documentation |
This function produces a batch file named batch_file_prefix.sh
with the following contents:
/path/to/executable.exe -f parameter_file1.yaml /path/to/executable.exe -f parameter_file2.yaml /path/to/executable.exe -f parameter_file3.yaml
where parameter_file1.yaml then contains:
param_name1: 0.01 param_name2: 1 param_name3: 1 output_file: output_file_1.csv
If this is all done, you can then run the batch file in any UNIX terminal (e.g., Mac OS X terminal, MSYS2 on Windows) by giving the UNIX terminal the command
bash batch_file_prefix.sh
which causes all simulations to be run sequentially.
make.batch.file.yaml(
parameter_list,
executable_path,
n_replicates = 1,
n_cores = 1,
batch_file_prefix = "batch_file",
output_file_prefix = "output",
yaml_file_prefix = "parameters",
output_file_yaml_key = "base_name"
)
parameter_list |
a list or dataframe with all parameter combinations the order with which a parameter was added to the list will be maintained |
executable_path |
the path to the simulation executable (i.e., the exe file) |
n_replicates |
the number of replicates you'd like to run of each simulation |
n_cores |
the number of cores available. If n_cores>1, simulations can be run in parallel |
batch_file_prefix |
the prefix of the resulting batch file to which all the simulation commands will be written to |
output_file_prefix |
the prefix of the resulting output file to which each simulation will write its output. |
yaml_file_prefix |
the prefix of each individual |
output_file_yaml_key |
the identifier key that a file name has in the
yaml file. Default is |
This function returns NULL
. However,
a file with name batch_file_prefix
will be
written to disk. If the option yaml=TRUE
, this will be accompanied
by one or more .yaml
files.
#initalize a parameter object
parameter_object <- list()
parameter_object$z <- c(0.0,0.01)
parameter_object$b <- 0.1
# call the batch file function
make.batch.file(parameter_list=parameter_object
,executable_path="./my_simulation.exe")
# which produces a file named 'batch_file.sh' in the current directory
# containing:
# ./my_simulation.exe 0.0 0.1 output_file_1
# ./my_simulation.exe 0.001 0.1 output_file_2
# Note that the value of parameter z is
# printed first and then the value of parameter b, followed by the
# name of the output file for this simulation
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.