![](/img/trans.png)
[英]Meaning of 'minimization_failures' when using scipy.optimize.basinhopping?
[英]How to disable the local minimization process in scipy.optimize.basinhopping?
我正在使用scipy.optimize.basinhopping
来查找标量函数的最小值。 我想知道是否有可能禁用scipy.optimize.basinhopping的局部最小化部分? 正如我们从下面的输出消息中可以看到的, minimization_failures
和nit
几乎相同,表明局部最小化部分对于流域购物的全局优化过程可能是无用的 - 这就是为什么我想禁用局部最小化部分,因为效率的缘故。
您可以通过使用不执行任何操作的自定义最小化程序来避免运行最小化程序。
请参阅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))
注意:我不知道跳过局部最小化如何影响流水线算法的收敛性。
您可以使用minimizer_kwargs
指定minimize()
您喜欢的局部最小化步骤的选项。 请参阅文档的专用部分。
然后由您要求minimize
的求解器类型决定。 您可以尝试设置更大的tol
以使本地最小化步骤更早终止。
编辑,回复评论“如果我想完全禁用本地最小化部分怎么办?”
来自docs的流域购物算法的工作方式如下:
该算法是迭代的,每个循环由以下特征组成
- 随机扰动坐标
- 局部最小化接受或
- 根据最小化的函数值拒绝新坐标
如果以上是准确的,则无法完全跳过局部最小化步骤,因为算法需要其输出继续进行,即保持或丢弃新坐标。 但是,我不是这个算法的专家。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.