# NOT RUN {
fr <- function(x) { ## Rosenbrock Banana function
x1 <- x[1]
x2 <- x[2]
100 * (x2 - x1 * x1)^2 + (1 - x1)^2
}
p0 <- c(-1.2, 1)
oo <- optim(p0, fr) ## also uses Nelder-Mead by default
o. <- Nelder_Mead(fr, p0)
o.1 <- Nelder_Mead(fr, p0, control=list(verbose=1))# -> some iteration output
stopifnot(identical(o.[1:4], o.1[1:4]),
all.equal(o.$par, oo$par, tolerance=1e-3))# diff: 0.0003865
# }
# NOT RUN {
<!-- %%## but this shows that something "does not work" -->
# }
# NOT RUN {
o.2 <- Nelder_Mead(fr, p0, control=list(verbose=3, XtolRel=1e-15, FtolAbs= 1e-14))
all.equal(o.2[-5],o.1[-5], tolerance=1e-15)# TRUE, unexpectedly
# }
Run the code above in your browser using DataLab