BBoptim {BB} | R Documentation |
A strategy using different Barzilai-Borwein steplengths to optimize a nonlinear objective function subject to box constraints.
BBoptim(par, fn, gr=NULL, method=c(2,3,1), project=NULL, lower=-Inf, upper=Inf, control=list(), quiet=FALSE, ...)
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. |
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. It defaults to NULL .
See *Details*. |
lower |
A vector that defines lower bounds on par .
Defaults to -Inf . |
upper |
A vector that defines upper bounds on par .
Defaults to Inf . |
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). |
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:
method = 2
for dfsane
, BBoptim wrapper tries method = c(2, 3, 1)
.
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), gtol = 1e-05, maxfeval = 10000,
maximize = FALSE, trace = FALSE, triter = 10, eps = 1e-07
.
If control
is specified as an argument, only values which are different
need to be given in the list. See spg
for more details.
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.
BBsolve
,
spg
,
multiStart
optim
grad
# 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(500) spg(par=p0, fn=rosbkext) BBoptim(par=p0, fn=rosbkext) BBoptim(par=p0, fn=rosbkext, lower=0) # compare the improvement in convergence when bounds are specified BBoptim(par=p0, fn=rosbkext, method=3, control=list(M=10, trace=TRUE)) # identical to spg() with defaults