Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

BBoptim

Large=Scale Nonlinear Optimization - A Wrapper for spg()


Description

A strategy using different Barzilai-Borwein steplengths to optimize a nonlinear objective function subject to box constraints.

Usage

BBoptim(par, fn, gr=NULL, method=c(2,3,1), lower=-Inf, upper=Inf, 
  	project=NULL, projectArgs=NULL,
	control=list(), quiet=FALSE, ...)

Arguments

par

A real vector argument to fn, indicating the initial guess for the root of the nonliinear system of equations fn.

fn

Nonlinear objective function that is to be optimized. A scalar function that takes a real vector as argument and returns a scalar that is the value of the function at that point (see details).

gr

The gradient of the objective function fn evaluated at the argument. This is a vector-function that takes a real vector as argument and returns a real vector of the same length. It defaults to NULL, which means that gradient is evaluated numerically. Computations are dramatically faster in high-dimensional problems when the exact gradient is provided. See *Example*.

method

A vector of integers specifying which Barzilai-Borwein steplengths should be used in a consecutive manner. The methods will be used in the order specified.

upper

An upper bound for box constraints. See spg

lower

An lower bound for box constraints. See spg

project

The projection function that takes a point in $R^n$ and projects it onto a region that defines the constraints of the problem. This is a vector-function that takes a real vector as argument and returns a real vector of the same length. See spg for more details.

projectArgs

list of arguments to project. See spg() for more details.

control

A list of parameters governing the algorithm behaviour. This list is the same as that for spg (excepting the default for trace). See details for important special features of control parameters.

quiet

logical indicating if messages about convergence success or failure should be suppressed

...

arguments passed fn (via the optimization algorithm).

Details

This wrapper is especially useful in problems where (spg is likely to experience convergence difficulties. When spg() fails, i.e. when convergence > 0 is obtained, a user might attempt various strategies to find a local optimizer. The function BBoptim tries the following sequential strategy:

  1. Try a different BB steplength. Since the default is method = 2 for dfsane, BBoptim wrapper tries method = c(2, 3, 1).

  2. Try a different non-monotonicity parameter M for each method, i.e. BBoptim wrapper tries M = c(50, 10) for each BB steplength.

The argument control defaults to a list with values maxit = 1500, M = c(50, 10), ftol=1.e-10, gtol = 1e-05, maxfeval = 10000, maximize = FALSE, trace = FALSE, triter = 10, eps = 1e-07, checkGrad=NULL. It is recommended that checkGrad be set to FALSE for high-dimensional problems, after making sure that the gradient is correctly specified. See spg for additional details about the default.

If control is specified as an argument, only values which are different need to be given in the list. See spg for more details.

Value

A list with the same elements as returned by spg. One additional element returned is cpar which contains the control parameter settings used to obtain successful convergence, or to obtain the best solution in case of failure.

References

R Varadhan and PD Gilbert (2009), BB: An R Package for Solving a Large System of Nonlinear Equations and for Optimizing a High-Dimensional Nonlinear Objective Function, J. Statistical Software, 32:4, http://www.jstatsoft.org/v32/i04/

See Also

Examples

# Use a preset seed so test values are reproducable. 
require("setRNG")
old.seed <- setRNG(list(kind="Mersenne-Twister", normal.kind="Inversion",
    seed=1234))

rosbkext <- function(x){
# Extended Rosenbrock function
n <- length(x)
j <- 2 * (1:(n/2))
jm1 <- j - 1
sum(100 * (x[j] - x[jm1]^2)^2 + (1 - x[jm1])^2)
}

p0 <- rnorm(50)
spg(par=p0, fn=rosbkext)
BBoptim(par=p0, fn=rosbkext)

# compare the improvement in convergence when bounds are specified
BBoptim(par=p0, fn=rosbkext, lower=0) 

# identical to spg() with defaults
BBoptim(par=p0, fn=rosbkext, method=3, control=list(M=10, trace=TRUE))

BB

Solving and Optimizing Large-Scale Nonlinear Systems

v2019.10-1
GPL-3
Authors
Ravi Varadhan [aut, cph, trl], Paul Gilbert [aut, cre], Marcos Raydan [ctb] (with co-authors, wrote original algorithms in fortran. These provided some guidance for implementing R code in the BB package.), JM Martinez [ctb] (with co-authors, wrote original algorithms in fortran. These provided some guidance for implementing R code in the BB package.), EG Birgin [ctb] (with co-authors, wrote original algorithms in fortran. These provided some guidance for implementing R code in the BB package.), W LaCruz [ctb] (with co-authors, wrote original algorithms in fortran. These provided some guidance for implementing R code in the BB package.)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.