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)
Run the code above in your browser using DataLab