如何在scipy.optimize.basinhopping中禁用本地最小化过程?

zel*_*ell 3 python scipy

scipy.optimize.basinhopping 用于找到标量函数的最小值.我想知道是否有可能禁用scipy.optimize.basinhopping的局部最小化部分?正如我们从下面的输出消息中可以看到的那样,minimization_failures并且nit几乎相同,表明局部最小化部分对于流域购物的全局优化过程可能是无用的 - 为什么我想禁用局部最小化部分,为此效率.

在此输入图像描述

pv.*_*pv. 6

您可以通过使用不执行任何操作的自定义最小化程序来避免运行最小化程序.

请参阅minim()文档中有关"自定义最小化器"的讨论:

 **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.

基本上,你需要编写返回一个自定义函数OptimizeResult,并通过它传递给basinhopping method的一部分minimizer_kwargs,例如

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))
Run Code Online (Sandbox Code Playgroud)

注意:我不知道跳过局部最小化如何影响流水线算法的收敛性.