I was planning to use Simulated Annealing algorithm (scipy.optimize implementation) to optimise my black-box objective function, but the documentation mentions that the method is

Deprecated in scipy 0.14.0, use basinhopping instead

and proposes to use Basin-hopping algorithm instead. Does it mean that this algorithm outperforms Simulated Annealing in all cases? Why is it claimed to be more performant than SA?

  • 1
    $\begingroup$ Did you read the discussion here ? $\endgroup$ Nov 14, 2019 at 15:05
  • $\begingroup$ Thanks @RobertLong. I did not read it but it does not seem to answer the question why the latter algorithm has better performance. Interestingly, as menionted in the discussion, there exists another, more performant version of SA: Dual Annealing $\endgroup$ Nov 14, 2019 at 16:41
  • 2
    $\begingroup$ According to the No Free Lunch theorem, there is no such thing as an algorithm that outperforms any other algorithm "in all cases". It might be better for a a very practical subset of problems, but over the entire universe of problems, Simulated Annealing, Basin Hopping, and even random selection perform equally well. $\endgroup$ Mar 27, 2020 at 15:42
  • 1
    $\begingroup$ def simulated_annealing(...): scipy.optimize.dual_annealing(..., no_local_search=True,...) $\endgroup$ Sep 28, 2020 at 16:40
  • $\begingroup$ @JamesBowery You should do more than just turn off the local search, at least if you want to recover the Boltzman visiting distribution. That's the point of my answer $\endgroup$ Oct 31, 2020 at 5:20

1 Answer 1


The reason for Simulated Annealing to be Deprecated is not because Basin-hopping outperform it theoretically. Is because the specific implementation done for Simulated Annealing in the library is a special case of the second.

If you want to use a Simulated Annealing algorithm I recomend you to use scipy.optimize.dual_annealing instead, but with $'visit'=q_v=1, \, 'acept'=q_a=1$ (this recover Classical Simulated Annealing, i.e. the temperature decreases logarithmically). Other parameter election leads to more sophisticated Annealing processes, like $'visit'=q_v=2, \, 'acept'=q_a=1$ (which recover the Fast Simulated Annealing, i.e. the temperature decrease up to inverse).

Observation: As @JamesBowery points out in his comment you should turn of the local optimizer.

  • 1
    $\begingroup$ The 'visit' parameter for dual_annealing can be (1, 3] via the docs. I tried 1.0 and got a divide-by-zero error. Make sure you're slightly greater than 1, and the default is 2.62 $\endgroup$
    – mightypile
    Feb 20, 2023 at 3:39
  • $\begingroup$ @mightypile Yes, you are right. I customary use a modification by github.com/Yarapy/Copula_Cosimulation/blob/main/… where they fix this problem; however I see that modifications of the original library have been made last year. I hope they fixed this problem there too $\endgroup$ Feb 22, 2023 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.