# example only runs if a Redis server is available
if (mlr3misc::require_namespaces(c("rush", "redux", "mirai"), quietly = TRUE) &&
redux::redis_available()) {
# define the objective function
fun = function(xs) {
data.table(
y1 = xs$x1^2 + xs$x2^2,
y2 = (xs$x1 - 2)^2 + (xs$x2 - 1)^2
)
}
# set domain
domain = ps(
x1 = p_dbl(-5, 5),
x2 = p_dbl(-5, 5)
)
# set codomain
codomain = ps(
y1 = p_dbl(tags = "minimize"),
y2 = p_dbl(tags = "minimize")
)
# create objective
objective = ObjectiveRFun$new(
fun = fun,
domain = domain,
codomain = codomain,
properties = "deterministic"
)
# start workers
rush::rush_plan(worker_type = "remote")
mirai::daemons(1)
# initialize instance
instance = oi_async(
objective = objective,
terminator = trm("evals", n_evals = 100))
}
Run the code above in your browser using DataLab