In my program i have a loop which computes integer values and put it one after another into an arraylist.
The higher the computetd integer value is, the better it is.
Now i want to continue to compute until it seems to be that there will not come any better integer value. That is, when the computed integer decreases over a range, or it does not change anymore. I’m thinking of, comparing the current computed value with the last x (how much value do i have to concern?) If it is always smaller or equals than any of the last x elements I stop computing. But with this strategy i have no guarantee that this is the global maximum, but just a local….
What is a good strategy to do that?
EDIT:
I know that there can’t be a guarantee to find the global maximum.
But i know a little about the behaviour of the function:
The more values i have already computed the more unlikely it is that the global maximum will appear.
Well, it seems that you need to assume some heuristics to assess when to stop. Since you cannot say “I stop now, as I found my max”, you can proceed in one of the following fashions:
Hope this gives you some idea