0

I am trying to optimize a function using the mystic library in Python, and have a general question about the gtol parameter.

The parameter space I'm searching in, is of high dimension (30-40), and for this reason, it seemed fitting for me to set gtol = 40000. Strangely, the algorithm seems to stop after 30000 iterations, although I specified the gtol as 40000, which (by my knowledge) means that the algorithm should have 40000 identical iterations before it stops running.

My function call is pretty basic:

stepmon = VerboseLoggingMonitor(1, 1)
result  = diffev2(utilss, x0=[1/value]*value, bounds=[(0,0.2)] * value,  npop=150, gtol=40000, disp=True, full_output=True, itermon=stepmon

I checked the merit function's evolution, and it is flat around the 29000th iteration. The last 1000 iterations are identical, but it already stops there instead of running the rest of the 39000 required gtol iterations.

Am I misinterpreting the gtol parameter? Or what am I missing here?

Thanks in advance.

xzeo
  • 147
  • 4

1 Answers1

1

I'm the mystic author. That is the correct interpretation for gtol, however, you are probably ignoring maxiter (and maxfun) which is the maximum number of iterations (and function evaluations) to perform.

If you don't set maxiter (default is None), then the I believe that the default setting for diffev2 is 10 * nDim * nPop. Try setting maxiter=100000, or something like that.

If the termination message says Warning: Maximum number of iterations has been exceeded, then maxiter caused it to stop.

Mike McKerns
  • 33,715
  • 8
  • 119
  • 139
  • Thank you, Mike McKerns. I'm not sure if your formula for the default setting is right, since nDim * nPop should be 4500 in my case. But still, it explains the outcome, and I do get the termination message. – xzeo Dec 07 '20 at 08:36
  • Update: checked the source code and its defined as: N * self.nPop * iterscale with iterscale = 10, as you said. It's strange then that I'm getting 30000 iterations here. – xzeo Dec 07 '20 at 08:49
  • 1
    well `N` is usually `nDim`, but it's actually `len(self.population[0])`. Regardless, `maxiter` is what you need to set. – Mike McKerns Dec 07 '20 at 15:07
  • Thanks. I just found the actual issue was the default EvaluationsLimit, which was set to 4500000 in my case, which corresponded to 30000 iterations each time (because of the population size). – xzeo Dec 08 '20 at 08:34