Skip to content
Advertisement

Scipy BasinHopping not returning correct global minima

I’m working with the following scipy code.

JavaScript

The global minimum of this function is at 0, but this isn’t what basin hopping returns. Depending on the start position x0, it returns different local minima – not the global one at 0. If we set x_0 = -6, it returns a minima at -7.7, if we set x0 = 1, then it returns a minima at 0, so on.

Why is it not returning the global minima? Why is it returning the local minimum closest to its start position?

Advertisement

Answer

If you increase n_iter to 1000 it works!

The output is

JavaScript

It is a stochastic algorithm and in this case it requires some more attempts, indeed using

JavaScript

prints

JavaScript

Not always the algorithm with n_iter=850 finds the global minimum.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement