bbotk - Black-Box Optimization Toolkit

Package website: release

tic CRAN Status Badge CodeFactor

This package provides a common framework for optimization including

Various optimization methods are already implemented e.g. grid search, random search and generalized simulated annealing.

Installation

CRAN version

install.packages("bbotk")

Development version

remotes::install_github("mlr-org/bbotk")

Example

library(bbotk)
library(paradox)

# Define objective function
fun = function(xs) {
  c(y = - (xs[[1]] - 2)^2 - (xs[[2]] + 3)^2 + 10)
}

# Set domain
domain = ParamSet$new(list(
  ParamDbl$new("x1", -10, 10),
  ParamDbl$new("x2", -5, 5)
))

# Set codomain
codomain = ParamSet$new(list(
  ParamDbl$new("y", tags = "maximize")
))

# Create Objective object
obfun = ObjectiveRFun$new(
  fun = fun,
  domain = domain,
  codomain = codomain,
  properties = "deterministic"
)

# Define termination criterion
terminator = trm("evals", n_evals = 20)

# Create optimization instance
instance = OptimInstanceSingleCrit$new(
  objective = obfun,
  terminator = terminator
)

# Load optimizer
optimizer = opt("gensa")

# Trigger optimization
optimizer$optimize(instance)

# View results
instance$result