An R interface to the NEWUOA implementation of Powell
newuoa.RdThe purpose of newuoa is to minimize a function of many variables
by a trust region method that forms quadratic models by interpolation.
Usage
newuoa(par, fn, control = list(), ...)Arguments
- par
A numeric vector of starting estimates.
- fn
A function that returns the value of the objective at the supplied set of parameters
parusing auxiliary data in .... The first argument offnmust bepar.- control
An optional list of control settings. See the details section for the names of the settable control values and their effect.
- ...
Further arguments to be passed to
fn.
Details
Functions fn must return a numeric value.
The control argument is a list; possible named values in the
list and their defaults are:
- npt
The number of points used to approximate the objective function via a quadratic approximation. The value of npt must be in the interval \([n+2,(n+1)(n+2)/2]\) where \(n\) is the number of parameters in
par. Choices that exceed \(2*n+1\) are not recommended. If not defined, it will be set to \(\min(n * 2, n+2)\).- rhobeg
rhobegandrhoendmust be set to the initial and final values of a trust region radius, so both must be positive with0 < rhoend < rhobeg. Typicallyrhobegshould be about one tenth of the greatest expected change to a variable. If the user does not provide a value, this will be set tomax(par) / 2)- rhoend
The smallest value of the trust region radius that is allowed. If not defined, then 1e-6 times the value set for
rhobegwill be used.- iprint
The value of
iprintshould be set to an integer value in0, 1, 2, 3, ..., which controls the amount of printing. Specifically, there is no output ifiprint=0and there is output only at the start and the return ifiprint=1. Otherwise, each new value ofrhois printed, with the best vector of variables so far and the corresponding value of the objective function. Further, each new value of the objective function with its variables are output ifiprint=3. Ifiprint > 3, the objective function value and corresponding variables are output everyiprintevaluations. Default value is0.- maxfun
The maximum allowed number of function evaluations. If this is exceeded, the method will terminate.
Value
A list with components:
- par
The best set of parameters found.
- fval
The value of the objective at the best set of parameters found.
- feval
Number of function evaluations to determine the optimum
- ierr
An integer error code. A value of zero indicates success. Other values (consistent with BOBYQA values) are
- 1
maximum number of function evaluations exceeded
- 2
NPT, the number of approximation points, is not in the required interval
- 3
a trust region step failed to reduce q (Consult Powell for explanation.)
- 5
newuoa detected too much cancellation in denominator (We have not fully understood Powell's code to explain this.)
- msg
A message describing the outcome of UOBYQA
References
M. J. D. Powell, "The NEWUOA software for unconstrained optimization without derivatives", in Large-Scale Nonlinear Optimization, Series: Nonconvex Optimization and Its Applications , Vol. 83, Di Pillo, Gianni; Roma, Massimo (Eds.) 2006, New York: Springer US.
M. J. D. Powell, "Developments of NEWUOA for minimization without derivatives" IMA Journal of Numerical Analysis, 2008; 28: 649-664.
M. J. D. Powell (2007) "Developments of NEWUOA for unconstrained minimization without derivatives" Cambridge University, Department of Applied Mathematics and Theoretical Physics, Numerical Analysis Group, Report NA2007/05, http://www.damtp.cam.ac.uk/user/na/NA_papers/NA2007_05.pdf.
Description was taken from comments in the Fortran code of M. J. D. Powell on which minqa is based.
Examples
fr <- function(x) { ## Rosenbrock Banana function
100 * (x[2] - x[1]^2)^2 + (1 - x[1])^2
}
(x2 <- newuoa(c(1, 2), fr))
#> parameter estimates: 1.00000116212176, 1.00000231682727
#> objective: 1.35602908489591e-12
#> number of function evaluations: 136
## => optimum at c(1, 1) with fval = 0
# check the error exits
# too many iterations
x2e<-newuoa(c(1, 2), fr, control = list(maxfun=50))
str(x2e)
#> List of 5
#> $ par : num [1:2] 1.37 1.89
#> $ fval : num 0.139
#> $ feval: int 50
#> $ ierr : num 1
#> $ msg : chr "newuoa -- maximum number of function evaluations exceeded"
#> - attr(*, "class")= chr [1:2] "newuoa" "minqa"
# Throw an error because npt is too small -- does NOT work as of 2010-8-10 as
# minqa.R seems to force a reset.
x2n<-newuoa(c(2,2), fr, control=list(npt=1))
str(x2n)
#> List of 5
#> $ par : num [1:2] 1 1
#> $ fval : num 1.43e-15
#> $ feval: int 193
#> $ ierr : int 0
#> $ msg : chr "Normal exit from newuoa"
#> - attr(*, "class")= chr [1:2] "newuoa" "minqa"
# To add if we can find them -- examples of ierr = 3 and ierr = 5.