**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.
您可以使用
minimizer_kwargs
来指定minimize()
与局部最小化步骤相比,您更喜欢哪些选项。请参阅docs的专用部分。在这取决于你要求
minimize
使用哪种类型的解算器。您可以尝试设置一个更大的tol
,使局部最小化步骤提前终止。在编辑,回复评论“如果我想完全禁用局部最小化部分怎么办?”
文档中的basinhopping算法的工作原理如下:
如果上述方法是准确的,则无法完全跳过局部极小化步骤,因为算法要求其输出进一步进行,即保留或丢弃新坐标。但是,我不是这个算法的专家。在
您可以通过使用不做任何操作的自定义最小化程序来避免运行该最小化程序。在
参见关于“自定义最小化”in the documentation of minimize()的讨论:
基本上,您需要编写一个自定义函数来返回一个OptimizeResult,并通过
^{pr2}$minimizer_kwargs
的method
部分将其传递给basinhopping注意:我不知道跳过局部最小化如何影响basinhopping算法的收敛性。在
相关问题 更多 >
编程相关推荐