【scipy】scipy.optimize 求解非线性Rosenbrock最优化问题 python
【scipy】scipy.optimize 求解非线性Rosenbrock最优化问题 python利用python软件编程求解非线性Rosenbrock最优化问题minf(x,y)=(1−x)2+100(y−x2)2min f(x, y) = (1-x)^{2}+100(y-x^{2})^{2}minf(x,y)=(1−x)2+100(y−x2)2程序,如下from scipy.optimize
利用python软件编程求解非线性Rosenbrock最优化问题
m
i
n
f
(
x
,
y
)
=
(
1
−
x
)
2
+
100
(
y
−
x
2
)
2
min f(x, y) = (1-x)^{2}+100(y-x^{2})^{2}
minf(x,y)=(1−x)2+100(y−x2)2
− 2 ≤ x ≤ 2 -2\leq x \leq 2 −2≤x≤2
− 1 ≤ y ≤ 3 -1\leq y \leq 3 −1≤y≤3
程序,如下
from scipy.optimize import minimize
fun = lambda x: (1 - x[0]) ** 2 + 100 * (x[1] - x[0] ** 2) ** 2
bnds = ((-2, 2), (-1, 3))
res = minimize(fun, (2, 0), method='SLSQP', bounds=bnds)
print(res.x)
结果
[0.99989094 0.99980692]
更多推荐
所有评论(0)