我用scipy.optimize.basinhopping来求标量函数的极小值。我想知道是否可以禁用scipy.optimize.basinhopping的局部最小化部分?从下面的输出消息可以看出,minimization_failuresnit几乎是一样的,这表明局部最小化部分可能对basinhopping的全局优化过程没有用处——为了效率起见,我想禁用局部最小化部分的原因。

最佳答案

您可以通过使用不执行任何操作的自定义最小化程序来避免运行最小化程序。
参见“自定义最小化”的讨论:

 **Custom minimizers**
It may be useful to pass a custom minimization method, for example
when using a frontend to this method such as `scipy.optimize.basinhopping`
or a different library. You can simply pass a callable as the ``method``
parameter.
The callable is called as ``method(fun, x0, args, **kwargs, **options)``
where ``kwargs`` corresponds to any other parameters passed to `minimize`
(such as `callback`, `hess`, etc.), except the `options` dict, which has
its contents also passed as `method` parameters pair by pair. Also, if
`jac` has been passed as a bool type, `jac` and `fun` are mangled so that
`fun` returns just the function values and `jac` is converted to a function
returning the Jacobian. The method shall return an ``OptimizeResult``
object.
The provided `method` callable must be able to accept (and possibly ignore)
arbitrary parameters; the set of parameters accepted by `minimize` may
expand in future versions and then these parameters will be passed to
the method. You can find an example in the scipy.optimize tutorial.

Basically, you need to write a custom function that returns an OptimizeResult and pass it to basinhopping via the method part of minimizer_kwargs, for example

from scipy.optimize import OptimizeResult
def noop_min(fun, x0, args, **options):
    return OptimizeResult(x=x0, fun=fun(x0), success=True, nfev=1)

...

sol = basinhopping(..., minimizer_kwargs=dict(method=noop_min))

注:我不知道跳过局部极小化如何影响basinhop算法的收敛性。

10-03 00:30