zell
zell

Reputation: 10204

Understanding the output of scipy.optimize.basinhopping

I am using scipy.optimize.basinhopping to minimize a function. Here is what I get:

Out[96]: 
                  nfev: 162178
 minimization_failures: 2501
                   fun: 4.4702905615653705
                     x: array([-194.7754468])
               message: ['requested number of basinhopping iterations completed successfully']
                  njev: 44057
                   nit: 2500

However, I have difficulties in understanding the output. What are the meaning of these returned parameters:

I guess nfev = number of function evaluation, and nit should correspond to 'number of iteration'. But why are nit != nfev?

Upvotes: 3

Views: 3740

Answers (1)

Pascal Bugnion
Pascal Bugnion

Reputation: 4928

Some of the outputs are documented in scipy.optimize.OptimizeResult:

  • nfev : number of function evaluations
  • njev : number of Jacobian evaluations
  • nit : number of iterations of the algorithm

The other options are less well documented, but you can always look at the Github source to understand. minimization_failures refers to the number of times the local optimizer failed to converge (this might happen if the Monte Carlo step proposes a starting position for the local optimizer that is too far from the local minimum).

nit, the number of iterations of the basin-hopping algorithm, is expected to be much less than nfev, the number of function evaluations. An iteration corresponds to the following steps:

  • propose a new position by displacing randomly around the current position,
  • minimize the function (using a local optimizer) to find the basin minimum,
  • either accept or reject the new basin.

There will be many function evaluations as part of the local minimization procedure, hence we expect nfev to be much bigger than nit.

Upvotes: 8

Related Questions