Aliases: bobyqa
### ** Examples fr <- function(x) { ## Rosenbrock Banana function 100 * (x[2] - x[1]^2)^2 + (1 - x[1])^2 } (x1 <- bobyqa(c(1, 2), fr, lower = c(0, 0), upper = c(4, 4)))
parameter estimates: 0.999999968901681, 0.999999928305543 objective: 9.98796325533312e-15 number of function evaluations: 341
## => optimum at c(1, 1) with fval = 0 str(x1) # see that the error code and msg are returned
List of 5 $ par : num [1:2] 1 1 $ fval : num 9.99e-15 $ feval: int 341 $ ierr : int 0 $ msg : chr "Normal exit from bobyqa" - attr(*, "class")= chr [1:2] "bobyqa" "minqa"
# check the error exits # too many iterations x1e<-bobyqa(c(1, 2), fr, lower = c(0, 0), upper = c(4, 4), control = list(maxfun=50)) str(x1e)
List of 5 $ par : num [1:2] 1.34 1.81 $ fval : num 0.121 $ feval: int 50 $ ierr : num 1 $ msg : chr "bobyqa -- maximum number of function evaluations exceeded" - attr(*, "class")= chr [1:2] "bobyqa" "minqa"
# Throw an error because bounds too tight x1b<-bobyqa(c(4,4), fr, lower = c(0, 3.9999999), upper = c(4, 4))
Warning in bobyqa(c(4, 4), fr, lower = c(0, 3.9999999), upper = c(4, 4)): All upper - lower must be >= 2*rhobeg. Changing rhobeg
str(x1b)
List of 5 $ par : num [1:2] 2 4 $ fval : num 0.999 $ feval: int 92 $ ierr : int 0 $ msg : chr "Normal exit from bobyqa" - attr(*, "class")= chr [1:2] "bobyqa" "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. x1n<-bobyqa(c(2,2), fr, lower = c(0, 0), upper = c(4, 4), control=list(npt=1)) str(x1n)
List of 5 $ par : num [1:2] 1 1 $ fval : num 3.05e-12 $ feval: int 484 $ ierr : int 0 $ msg : chr "Normal exit from bobyqa" - attr(*, "class")= chr [1:2] "bobyqa" "minqa"
# To add if we can find them -- examples of ierr = 3 and ierr = 5.