title: Example to understand scipy basin hopping optimization function
body: <p>I came across the <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.basinhopping.html#scipy.optimize.basinhopping" rel="noreferrer">basin hopping algorithm</a> in scipy and created a simple problem to understand how to use it but it doesnt seem to be working correctly for that problem. May be I'm doing something completely wrong.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>import scipy.optimize as spo
  import numpy as np
  minimizer_kwargs = {"method":"BFGS"}    
  f1=lambda x: (x-4)
  def mybounds(**kwargs):
      x = kwargs["x_new"]
      tmax = bool(np.all(x &lt;= 1.0))
      tmin = bool(np.all(x &gt;= 0.0))
      print x
      print tmin and tmax
      return tmax and tmin
  
  
  def print_fun(x, f, accepted):
        print("at minima %.4f accepted %d" % (f, int(accepted)))
  x0=[1.]     
  spo.basinhopping(f1,x0,accept_test=mybounds,callback=print_fun,niter=200,minimizer_kwargs=minimizer_kwargs)
  </code></pre>
  
  <p>The solution it gives is  <code>x: array([ -1.80746874e+08])</code></p>