BBsolve {BB} | R Documentation |
A strategy using different Barzilai-Borwein steplengths to solve a nonlinear system of equations.
BBsolve(par, fn, method=c(2,3,1), 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 system of equation that is to be solved. A vector function that takes a real vector as argument and returns a real vector of the same length. |
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. |
control |
A list of parameters governing the algorithm behaviour.
This list is the same as that for dfsane and sane (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 the algorithms
(dfsane
or sane
) are likely to experience difficulties in
convergence. When these algorithms with default parameters fail, i.e.
when convergence > 0
is obtained, a user might attempt various
strategies to find a root of the nonlinear system. The function BBsolve
tries the following sequential strategy:
method = 2
for dfsane
, the BBsolve wrapper tries method = c(2, 1, 3)
.
M
for each method,
i.e. BBsolve wrapper tries M = c(50, 10)
for each BB steplength.
dfsane
is NM = FALSE
, BBsolve does NM = c(TRUE, FALSE)
.
The argument control
defaults to a list with values
maxit = 1500, M = c(50, 10), tol = 1e-07, trace = FALSE,
triter = 10, noimp = 100, NM = c(TRUE, FALSE)
.
If control
is specified as an argument, only values which are different
need to be given in the list. See dfsane
for more details.
A list with the same elements as returned by dfsane
or sane
. 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
,
dfsane
,
sane
multiStart
# Use a preset seed so test values are reproducable. require("setRNG") old.seed <- setRNG(list(kind="Mersenne-Twister", normal.kind="Inversion", seed=1234)) broydt <- function(x) { n <- length(x) f <- rep(NA, n) h <- 2 f[1] <- ((3 - h*x[1]) * x[1]) - 2*x[2] + 1 tnm1 <- 2:(n-1) f[tnm1] <- ((3 - h*x[tnm1]) * x[tnm1]) - x[tnm1-1] - 2*x[tnm1+1] + 1 f[n] <- ((3 - h*x[n]) * x[n]) - x[n-1] + 1 f } p0 <- rnorm(500) BBsolve(par=p0, fn=broydt) # this works dfsane(par=p0, fn=broydt) # but this is highly unliikely to work. BBsolve(par=p0, fn=broydt, control=list(M=50, NM=FALSE)) # this implements the 3 BB steplengths with M = 50, and without Nelder-Mead initialization BBsolve(par=p0, fn=broydt, method=1, control=list(M=c(50, 10))) # this implements BB steplength 1 with M = 50 and 10, and both with and without Nelder-Mead initialization BBsolve(par=p0, fn=broydt, method=2, control=list(M=10, NM=FALSE)) # identical to dfsane() with defaults