将 Hessian 矩阵定义为零

defining the Hessian as zero

在使用 scipy.optimize.minimize 和 trust-constr 方法时,我得到了这个 UserWarning:

 scipy\optimize\_hessian_update_strategy.py:187: UserWarning: delta_grad == 0.0. Check if the approximated function is linear. If the function is linear better results can be obtained by defining the Hessian as zero instead of using quasi-Newton approximations. 'approximations.', UserWarning)

我有一个线性函数,所以我想尝试将 hessian 设置为零。但这是如何工作的呢?我用 "hess = None" 作为参数尝试了最简单的方法。好吧,失败的尝试。

这是调用求解器的行:

solution = scopt.minimize(minimizeFunction,initialGuess ,method='trust-constr', constraints=cons,options={'disp':True,'verbose':3},bounds=bnds)

定义约束时,要设置

    hess = lambda x: numpy.zeros((n, n))

这里n是数组的维度。请注意,您还可以使用 LinearConstraint object