# 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

1 2 3 4 |

### Arguments

`par` |
A real vector argument to |

`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 |

`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 |

`lower` |
An lower bound for box constraints. See |

`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 |

`projectArgs` |
list of arguments to |

`control` |
A list of parameters governing the algorithm behaviour.
This list is the same as that for |

`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:

Try a different BB steplength. Since the default is

`method = 2`

for`dfsane`

, BBoptim wrapper tries`method = c(2, 3, 1)`

.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

`BBsolve`

,
`spg`

,
`multiStart`

`optim`

`grad`

### Examples

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ```
# 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))
``` |

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker. Vote for new features on Trello.