Learn R Programming

bbotk (version 1.7.0)

mlr_optimizers_nloptr: Non-linear Optimization

Description

OptimizerBatchNLoptr class that implements non-linear optimization. Calls nloptr::nloptr() from package nloptr.

Arguments

Parameters

algorithm

character(1)
Algorithm to use. See nloptr::nloptr.print.options() for available algorithms.

x0

numeric()
Initial parameter values. Use start_values parameter to create "random" or "center" start values.

start_values

character(1)
Create "random" start values or based on "center" of search space? In the latter case, it is the center of the parameters before a trafo is applied. Custom start values can be passed via the x0 parameter.

approximate_eval_grad_f

logical(1)
Should gradients be numerically approximated via finite differences (nloptr::nl.grad). Only required for certain algorithms. Note that function evaluations required for the numerical gradient approximation will be logged as usual and are not treated differently than regular function evaluations by, e.g., Terminators.

For the meaning of other control parameters, see nloptr::nloptr() and nloptr::nloptr.print.options().

Internal Termination Parameters

The algorithm can terminated with all Terminators. Additionally, the following internal termination parameters can be used:

stopval

numeric(1)
Stop value. Deactivate with -Inf. Default is -Inf.

maxtime

integer(1)
Maximum time. Deactivate with -1L. Default is -1L.

maxeval

integer(1)
Maximum number of evaluations. Deactivate with -1L. Default is -1L.

xtol_rel

numeric(1)
Relative tolerance. Original default is 10^-4. Deactivate with -1. Overwritten with -1.

xtol_abs

numeric(1)
Absolute tolerance. Deactivate with -1. Default is -1.

ftol_rel

numeric(1)
Relative tolerance. Deactivate with -1. Default is -1.

ftol_abs

numeric(1)
Absolute tolerance. Deactivate with -1. Default is -1.

Progress Bars

$optimize() supports progress bars via the package progressr combined with a Terminator. Simply wrap the function in progressr::with_progress() to enable them. We recommend to use package progress as backend; enable with progressr::handlers("progress").

Super classes

bbotk::Optimizer -> bbotk::OptimizerBatch -> OptimizerBatchNLoptr

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage

OptimizerBatchNLoptr$new()


Method clone()

The objects of this class are cloneable with this method.

Usage

OptimizerBatchNLoptr$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

Run this code
# \donttest{
  search_space = domain = ps(x = p_dbl(lower = -1, upper = 1))

  codomain = ps(y = p_dbl(tags = "minimize"))

  objective_function = function(xs) {
    list(y = as.numeric(xs)^2)
  }

  objective = ObjectiveRFun$new(
    fun = objective_function,
    domain = domain,
    codomain = codomain)


  # We use the internal termination criterion xtol_rel
  terminator = trm("none")
  instance = OptimInstanceBatchSingleCrit$new(
    objective = objective,
    search_space = search_space,
    terminator = terminator)


  optimizer = opt("nloptr", algorithm = "NLOPT_LN_BOBYQA")

  # Modifies the instance by reference
  optimizer$optimize(instance)

  # Returns best scoring evaluation
  instance$result

  # Allows access of data.table of full path of all evaluations
  as.data.table(instance$archive)
# }

Run the code above in your browser using DataLab