Berend Hasselman wrote:
If you do
resopt <- optim(-5,f, method="SANN",control=list(fnscale=-1))
you will get the global maximum. SANN: simulated annealing. But starting
in -4 takes you to the local maximum.
So if I understand correctly, this method would also yield the same
sort of result (ie non-guaranteed global max or min over the range
-10 to 10).
But the help for optim recommends optimize for one-dimensional
maximization.
Yes, I recall reading this.
As far as I know there is no general foolproof method for finding a
global optimum except trying different initial points.
No method can really replace one's own knowledge about a function.
Agreed, however, I am testing a genetic algorithm's ability to find the
global maximum/minimum and was looking for another independent tool to
verify the results I am getting for f(x) and f(x, y), ie my various
test functions which will be more complex than the one I posted (and
many will be multi-modal since those present a challenge for any
algorithm). Since R has proven to be quite capable in the past I
thought I would check and see if it could easily do this. I was hoping
to avoid having to plot and re-run various functions repeatedly over
various ranges or starting points.
Thanks again for the help/information, much appreciated.
Esmail
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.