| bb_optimize {bbotk} | R Documentation | 
Black-Box Optimization
Description
This function optimizes a function or Objective with a given method.
Usage
bb_optimize(
  x,
  method = "random_search",
  max_evals = 1000,
  max_time = NULL,
  ...
)
## S3 method for class ''function''
bb_optimize(
  x,
  method = "random_search",
  max_evals = 1000,
  max_time = NULL,
  lower = NULL,
  upper = NULL,
  maximize = FALSE,
  ...
)
## S3 method for class 'Objective'
bb_optimize(
  x,
  method = "random_search",
  max_evals = 1000,
  max_time = NULL,
  search_space = NULL,
  ...
)
Arguments
x | 
 (  | 
method | 
 (  | 
max_evals | 
 (  | 
max_time | 
 (  | 
... | 
 (named   | 
lower | 
 (  | 
upper | 
 (  | 
maximize | 
 (  | 
search_space | 
Value
list of
-  
"par"- Best found parameters -  
"value"- Optimal outcome -  
"instance"- OptimInstanceBatchSingleCrit | OptimInstanceBatchMultiCrit 
Note
If both max_evals and max_time are NULL, TerminatorNone is used. This
is useful if the Optimizer can terminate itself. If both are given,
TerminatorCombo is created and the optimization stops if the time or
evaluation budget is exhausted.
Examples
# 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)