简体   繁体   English

将Hessian定义为零

[英]defining the Hessian as zero

While using scipy.optimize.minimize with the trust-constr method I got this UserWarning: 在通过trust-constr方法使用scipy.optimize.minimize时,我得到了以下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)

I have a linear function so I want to try to set the hessian as zero. 我有一个线性函数,所以我想尝试将hessian设置为零。 But how does this work? 但这如何工作? I tried the easiest way with "hess = None" as parameter. 我尝试了以“ hess = None”作为参数的最简单方法。 Okay, a bad try. 好吧,不好尝试。

This is the line calling the solver: 这是调用求解器的行:

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

When you define the constraint, you want to set 定义约束时,要设置

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

Here n is the dimension of the array. 这里n是数组的维数。 Notice that you can also use a LinearConstraint object 请注意,您还可以使用LinearConstraint对象

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM