getIndex {BatchExperiments}R Documentation

Group experiments.

Description

Creates a list of factor to use in functions like tapply, by or aggregate.

Usage

getIndex(
  reg,
  ids,
  by.prob = FALSE,
  by.algo = FALSE,
  by.repl = FALSE,
  by.prob.pars,
  by.algo.pars,
  enclos = parent.frame()
)

Arguments

reg

[ExperimentRegistry]
Registry.

ids

[integer]
If not missing, restict grouping to this subset of experiment ids.

by.prob

[logical]
Group experiments by problem. Default is FALSE.

by.algo

[logical]
Group experiments by algorithm. Default is FALSE.

by.repl

[logical]
Group experiments by replication. Default is FALSE.

by.prob.pars

[R expression]
If not missing, group experiments by this R expression. The expression is evaluated in the environment of problem parameters and converted to a factor using as.factor.

by.algo.pars

[R expression]
If not missing, group experiments by this R expression. The expression is evaluated in the environment of algorithm parameters and converted to a factor using as.factor.

enclos

[environment]
Enclosing frame for evaluation of parameters used by by.prob.pars and by.algo.pars, see eval. Defaults to the parent frame.

Value

[list]. List of factors.

Examples

# create a registry and add problems and algorithms
reg = makeExperimentRegistry("getIndex", file.dir = tempfile(""))
addProblem(reg, "prob", static = 1)
addAlgorithm(reg, "f0", function(static, dynamic) static)
addAlgorithm(reg, "f1", function(static, dynamic, i, k) static * i^k)
ad = list(makeDesign("f0"), makeDesign("f1", exhaustive = list(i = 1:5, k = 1:3)))
addExperiments(reg, algo.designs = ad)
submitJobs(reg)

# get grouped job ids
ids = getJobIds(reg)
by(ids, getIndex(reg, by.prob = TRUE, by.algo = TRUE), identity)
ids = findExperiments(reg, algo.pattern = "f1")
by(ids, getIndex(reg, ids, by.algo.pars = (k == 1)), identity)

# groupwise reduction
ids = findExperiments(reg, algo.pattern = "f1")
showStatus(reg, ids)
f = function(aggr, job, res) aggr + res
by(ids, getIndex(reg, ids, by.algo.pars = k), reduceResults, reg = reg, fun = f)
by(ids, getIndex(reg, ids, by.algo.pars = i), reduceResults, reg = reg, fun = f)

[Package BatchExperiments version 1.4.3 Index]