| mlr_optimizers_irace {bbotk} | R Documentation |
OptimizerIrace class that implements iterated racing. Calls
irace::irace() from package irace.
instanceslist()
A list of instances where the configurations executed on.
targetRunnerParallelfunction()
A function that executes the objective function with a specific parameter
configuration and instance. A default function is provided, see section
"Target Runner and Instances".
For the meaning of all other parameters, see irace::defaultScenario(). Note
that we have removed all control parameters which refer to the termination of
the algorithm. Use TerminatorEvals instead. Other terminators do not work
with OptimizerIrace.
The irace package uses a targetRunner script or R function to evaluate a
configuration on a particular instance. Usually it is not necessary to
specify a targetRunner function when using OptimizerIrace. A default
function is used that forwards several configurations and instances to the
user defined objective function. As usually, the user defined function has
a xs, xss or xdt parameter depending on the used Objective class.
For irace, the function needs an additional instances parameter.
fun = function(xs, instances) {
# function to evaluate configuration in `xs` on instance `instances`
}
The Archive holds the following additional columns:
"race" (integer(1))
Race iteration.
"step" (integer(1))
Step number of race.
"instance" (integer(1))
Identifies instances across races and steps.
"configuration" (integer(1))
Identifies configurations across races and steps.
The optimization result (instance$result) is the best performing elite of
the final race. The reported performance is the average performance estimated
on all used instances.
This Optimizer can be instantiated via the dictionary
mlr_optimizers or with the associated sugar function opt():
mlr_optimizers$get("irace")
opt("irace")
$optimize() supports progress bars via the package progressr
combined with a Terminator. Simply wrap the function in
progressr::with_progress() to enable them. We recommend to use package
progress as backend; enable with progressr::handlers("progress").
bbotk::Optimizer -> OptimizerIrace
new()Creates a new instance of this R6 class.
OptimizerIrace$new()
clone()The objects of this class are cloneable with this method.
OptimizerIrace$clone(deep = FALSE)
deepWhether to make a deep clone.
Lopez-Ibanez M, Dubois-Lacoste J, Caceres LP, Birattari M, Stuetzle T (2016). “The irace package: Iterated racing for automatic algorithm configuration.” Operations Research Perspectives, 3, 43–58. doi: 10.1016/j.orp.2016.09.002.
library(data.table)
search_space = domain = ps(
x1 = p_dbl(-5, 10),
x2 = p_dbl(0, 15)
)
codomain = ps(y = p_dbl(tags = "minimize"))
# branin function with noise
# the noise generates different instances of the branin function
# the noise values are passed via the `instances` parameter
fun = function(xdt, instances) {
a = 1
b = 5.1 / (4 * (pi ^ 2))
c = 5 / pi
r = 6
s = 10
t = 1 / (8 * pi)
data.table(y = (
a * ((xdt[["x2"]] -
b * (xdt[["x1"]] ^ 2L) +
c * xdt[["x1"]] - r) ^ 2) +
((s * (1 - t)) * cos(xdt[["x1"]])) +
unlist(instances)))
}
objective = ObjectiveRFunDt$new(fun = fun, domain = domain, codomain = codomain)
instance = OptimInstanceSingleCrit$new(
objective = objective,
search_space = search_space,
terminator = trm("evals", n_evals = 1000))
# create instances of branin function
instances = rnorm(10, mean = 0, sd = 0.1)
# load optimizer irace and set branin instances
optimizer = opt("irace", instances = instances)
# modifies the instance by reference
optimizer$optimize(instance)
# best scoring configuration
instance$result
# all evaluations
as.data.table(instance$archive)