compile_optimization_problem: Optimize arbitrary and differentiable functions

Description Usage Arguments Examples

View source: R/optim.R

Description

The function compiles the code to C++ and uses Armadillo and ensmallen to optimize it.

Usage

1
2
3
4
5
6
compile_optimization_problem(
  data = list(),
  evaluate,
  gradient,
  optimizer = optimizer_SA()
)

Arguments

data

a named list of prior data you would like to supply to the evaluate function.

evaluate

a function that is to be minimized. It should return a single numeric.

gradient

optional, a function computing the gradient of evaluate

optimizer

one of the many optimizers

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
optimize <- compile_optimization_problem(
  data = list(),
  evaluate = function(x) {
    return(2 * norm(x)^2)
  },
  optimizer = optimizer_SA()
)

# should be roughly c(0, 0, 0)
result <- optimize(matrix(c(1, -1, 1), ncol = 1))

## End(Not run)

dirkschumacher/armacmp documentation built on Oct. 22, 2021, 7:10 p.m.