multiStart {BB}R Documentation

Nonlinear Optimization or Root-Finding with Multiple Starting Values

Description

Start BBsolve or BBoptim from multiple starting points to obtain multiple solutions and to test sensitivity to starting values.

Usage

  multiStart(par, fn, gr=NULL, action = c("solve", "optimize"), 
        method=c(2,3,1), control=list(), details=FALSE, ...) 
  

Arguments

par A real matrix, each row of which is an argument to fn, indicating initial guesses for solving a nonlinear system fn = 0 or for optimizing the objective function fn.
fn see BBsolve or BBoptim.
gr Only required for optimization. See BBoptim.
action A character string indicating whether to solve a nonlinear system or to optimize. Default is ``solve''.
method see BBsolve or BBoptim.
control See BBsolve and BBoptim.
details Logical indicating if the result should include the full result from BBsolve or BBoptim for each starting value.
... arguments passed fn (via the optimization algorithm).

Details

The optimization or root-finder is run with each row of par indicating initial guesses.

Value

list with elements par, values, and converged. It optionally returns an attribute called ``details'', which is a list as long as the number of starting values, which contains the complete object returned by dfsane or spg for each starting value.

See Also

BBsolve, BBoptim, dfsane, spg

Examples

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

# Finding multiple roots of a nonlinear system
brownlin <- function(x) {
# Brown's almost linear system(A.P. Morgan, ACM 1983)
# two distinct solutions if n is even
# three distinct solutions if n is odd  
        n <- length(x)
        f <- rep(NA, n)
        nm1 <- 1:(n-1)
        f[nm1] <- x[nm1] + sum(x) - (n+1)
        f[n] <- prod(x) - 1 
        f
}

p <- 9
n <- 100
p0 <- matrix(rnorm(n*p), n, p)  # n starting values, each of length p
ans <- multiStart(par=p0, fn=brownlin)
pmat <- ans$par[ans$conv, 1:p] # selecting only converged solutions
ord1 <- order(abs(pmat[,1]))
round(pmat[ord1, ], 3)  # all 3 roots can be seen

# An optimization example
rosbkext <- function(x){
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)

pmat <- matrix(rnorm(500), 100, 5)  # 100 starting values each of length 5 
ans <- multiStart(par=pmat, fn=rosbkext, action="optimize")
ans
attr(ans, "details")[[1]]  # 

pmat <- ans$par[ans$conv, 1:5] # selecting only converged solutions
round(pmat, 3)

[Package BB version 2009.6-1 Index]