# function and bounds
fun = function(xs) {
-(xs[[1]] - 2)^2 - (xs[[2]] + 3)^2 + 10
}
bb_optimize(fun, lower = c(-10, -5), upper = c(10, 5), max_evals = 10)
# function and constant
fun = function(xs, c) {
-(xs[[1]] - 2)^2 - (xs[[2]] + 3)^2 + c
}
bb_optimize(fun, lower = c(-10, -5), upper = c(10, 5), max_evals = 10, c = 1)
# objective
fun = function(xs) {
c(z = -(xs[[1]] - 2)^2 - (xs[[2]] + 3)^2 + 10)
}
# define domain and codomain using a `ParamSet` from paradox
domain = ps(x1 = p_dbl(-10, 10), x2 = p_dbl(-5, 5))
codomain = ps(z = p_dbl(tags = "minimize"))
objective = ObjectiveRFun$new(fun, domain, codomain)
bb_optimize(objective, method = "random_search", max_evals = 10)
Run the code above in your browser using DataLab