小编Mak*_*sov的帖子

罚函数法

我正在尝试实现最小化函数的惩罚函数方法。我需要找到Rosenbrok's function的最小值。

我正在使用这个惩罚函数:

惩罚函数

惩罚函数

首先,我使用scipy.optimize.minimize以下方法找到了最小值:

from scipy.optimize import minimize, rosen
rz = lambda x: (1-x[0])**2 + 100*(x[1] - x[0]**2)**2;
h_1 = lambda x: (x[0] - 2 * x[1] + 2);
h_2 = lambda x: (-x[0] - 2 * x[1] + 6);
h_3 = lambda x: (-x[0] + 2 * x[1] + 2);

x0 = [2.3, 5];
cons = ({'type': 'ineq', 'fun': h_1},
       {'type': 'ineq', 'fun': h_2},
       {'type': 'ineq', 'fun': h_3}) 
minimize(rz, x0, constraints=cons)
Run Code Online (Sandbox Code Playgroud)

答案是xarray([ …

python math

4
推荐指数
1
解决办法
3111
查看次数

标签 统计

math ×1

python ×1