addExperiments {batchtools} | R Documentation |
Add Experiments to the Registry
Description
Adds experiments (parametrized combinations of problems with algorithms) to the registry and thereby defines batch jobs.
If multiple problem designs or algorithm designs are provided, they are combined via the Cartesian product.
E.g., if you have two problems p1
and p2
and three algorithms a1
, a2
and a3
,
addExperiments
creates experiments for all parameters for the combinations (p1, a1)
, (p1, a2)
,
(p1, a3)
, (p2, a1)
, (p2, a2)
and (p2, a3)
.
Usage
addExperiments(
prob.designs = NULL,
algo.designs = NULL,
repls = 1L,
combine = "crossprod",
reg = getDefaultRegistry()
)
Arguments
prob.designs |
[named list of |
algo.designs |
[named list of |
repls |
[ |
combine |
[ |
reg |
[ |
Value
[data.table
] with ids of added jobs stored in column “job.id”.
Note
R's data.frame
converts character vectors to factors by default in R versions prior to 4.0.0 which frequently resulted in problems using addExperiments
.
Therefore, this function will warn about factor variables if the following conditions hold:
R version is < 4.0.0
The design is passed as a
data.frame
, not adata.table
ortibble
.The option “stringsAsFactors” is not set or set to
TRUE
.
See Also
Other Experiment:
removeExperiments()
,
summarizeExperiments()
Examples
tmp = makeExperimentRegistry(file.dir = NA, make.default = FALSE)
# add first problem
fun = function(job, data, n, mean, sd, ...) rnorm(n, mean = mean, sd = sd)
addProblem("rnorm", fun = fun, reg = tmp)
# add second problem
fun = function(job, data, n, lambda, ...) rexp(n, rate = lambda)
addProblem("rexp", fun = fun, reg = tmp)
# add first algorithm
fun = function(instance, method, ...) if (method == "mean") mean(instance) else median(instance)
addAlgorithm("average", fun = fun, reg = tmp)
# add second algorithm
fun = function(instance, ...) sd(instance)
addAlgorithm("deviation", fun = fun, reg = tmp)
# define problem and algorithm designs
library(data.table)
prob.designs = algo.designs = list()
prob.designs$rnorm = CJ(n = 100, mean = -1:1, sd = 1:5)
prob.designs$rexp = data.table(n = 100, lambda = 1:5)
algo.designs$average = data.table(method = c("mean", "median"))
algo.designs$deviation = data.table()
# add experiments and submit
addExperiments(prob.designs, algo.designs, reg = tmp)
# check what has been created
summarizeExperiments(reg = tmp)
unwrap(getJobPars(reg = tmp))