Solving Nonlinear System of Equations - A Wrapper for dfsane()

Share:

Description

A strategy using different Barzilai-Borwein steplengths to solve a nonlinear system of equations.

Usage

1
2
3
  BBsolve(par, fn, method=c(2,3,1), 
	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 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).

Details

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:

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

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

  3. Try with Nelder-Mead initialization. Since the default for 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.

Value

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.

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

BBoptim, dfsane, sane multiStart

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 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(50)
BBsolve(par=p0, fn=broydt)  # this works 
dfsane(par=p0, fn=broydt) # but this is highly unliikely to work.

# this implements the 3 BB steplengths with M = 50, and without Nelder-Mead initialization
BBsolve(par=p0, fn=broydt, control=list(M=50, NM=FALSE))

# this implements BB steplength 1 with M = 50 and 10, and both with and 
#   without Nelder-Mead initialization  
BBsolve(par=p0, fn=broydt, method=1, control=list(M=c(50, 10))) 

# identical to dfsane() with defaults
BBsolve(par=p0, fn=broydt, method=2, control=list(M=10, NM=FALSE))