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

2024-09-29 23:28:51 发布

您现在位置:Python中文网/ 问答频道 /正文

我用scipy.optimize.basinhopping来求标量函数的极小值。我想知道是否可以禁用scipy.optimize.basinhopping?从下面的输出消息中我们可以看到,minimization_failures和{}几乎相同,这表明局部最小化部分对于basinhop的全局优化过程可能是无用的——这就是为什么我为了效率而想禁用局部最小化部分的原因。在

enter image description here


Tags: 函数消息过程原因局部scipy全局optimize
2条回答

您可以使用minimizer_kwargs来指定minimize()与局部最小化步骤相比,您更喜欢哪些选项。请参阅docs的专用部分。在

这取决于你要求minimize使用哪种类型的解算器。您可以尝试设置一个更大的tol,使局部最小化步骤提前终止。在

编辑,回复评论“如果我想完全禁用局部最小化部分怎么办?”

文档中的basinhopping算法的工作原理如下:

The algorithm is iterative with each cycle composed of the following features

  • random perturbation of the coordinates
  • local minimization accept or
  • reject the new coordinates based on the minimized function value

如果上述方法是准确的,则无法完全跳过局部极小化步骤,因为算法要求其输出进一步进行,即保留或丢弃新坐标。但是,我不是这个算法的专家。在

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

参见关于“自定义最小化”in the documentation of minimize()的讨论:

 **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,并通过minimizer_kwargsmethod部分将其传递给basinhopping

^{pr2}$

注意:我不知道跳过局部最小化如何影响basinhopping算法的收敛性。在

相关问题 更多 >

    热门问题