利用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)=(1x)2+100(yx2)2

− 2 ≤ x ≤ 2 -2\leq x \leq 2 2x2

− 1 ≤ y ≤ 3 -1\leq y \leq 3 1y3

程序,如下

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]
Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐