myOpt_N: Optimize in multiple dimensions

Description Usage Arguments Details Value Author(s) Examples

View source: R/myOpt_N.R

Description

This optimization routine performs minimum search in more than one dimension. Variuous optimization algorithms such as (generalized) simmulated annealing, BFGS (Broyden-Fletcher-Goldfarb-Shanno), Rvmmin, (hjkb) Hook-Jeeves and Nelder-Mead are subsequently performed.

Usage

1
2
myOpt_N(candidates, fn, lower, upper, gr = NULL, maxit = 200,
  statusMessages = FALSE)

Arguments

candidates

data frame - With one set of parameters (par) for each row.

fn

function of par - The function that is to be minimized.

lower

Vector of type double - Lower bounds. The variable lower has the same dimension as par (Number of columns of candidates).

upper

Vector of type double - Upper bounds. The variable upper has the same dimension as par (Number of columns of candidates).

gr

A function to return the gradient for BFGS. If set to NULL, finite difference approximations of the gradient are used instead (see documentation of package "optim")

maxit

Maximum amount of iterations for BFGS, RVmmin and general simmulated Annealing.

statusMessage

Boolean - Set to TRUE for more verbose output (default to FALSE).

Details

This function performs adequate error handling. In problematic cases, where optimization fails, the program is not interrupted but may return an empty data frame. Many optimization algorithms perform their tasks, but only those, which do successfully contribute to a column entry in the resulting data frame.

Value

data frame - One column for every successfully performed optimization algorithm. Every row corresponds to an optimized parameter. Last row corresponds to the function value of the resulting optimized parameters.

Author(s)

Philipp van Wickevoort Crommelin

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
install.packages(c("GenSA","dfoptim"))
fn = function(x) x[1]^2+x[2]^2
candidates = data.frame("x" = c(1,-30),
                        "y" = c(-5,10))
lower = c(-100,-100)
upper = c(100,100)

res = myOpt_N(candidates = candidates,
              fn = fn,
              lower = lower,
              upper = upper,
              maxit = 200,
              statusMessages = TRUE)
print(res)# Columns are sorted in increasing order

PhilippVWC/myBayes documentation built on Oct. 2, 2020, 8:25 a.m.