首页 > 解决方案 > scipy.optimize 中的 p_start 是什么?

问题描述

我想了解 scipy.optimize 包的不同参数

x_start = 3.0 * np.ones(len(t))
# bounds on the values :
bounds = tuple((0,20.0) for x in x_start)
constraints = ({'type': 'ineq', 'fun':  lambda x, s_0=s_0: 
constraint_1(x, s_0=s_0)},
    {'type': 'ineq', 'fun':  lambda x: constraint_2(x)},
    {'type': 'ineq', 'fun': lambda x, a=a, b=b: constraint_3(x, a=a, b=b)})
opt_results = optimize.minimize(objective, x_start, args=(a, b, d, t), method='SLSQP', bounds=bounds, constraints=constraints)

请解释一下命令中使用的x_startbounds参数以及optimize.minimize如何根据不同的数据集进行更改。x_startbounds

标签: pythonscipy

解决方案


根据此处的文档:

  • x_start: 初步猜测。大小为 (n,) 的实数元素数组。
  • bounds: 变量SLSQP和 trust-constr 方法的界限。None用于指定无界限。SLSQP 代表顺序最小二乘规划。

有两种方法可以指定边界:

  • Bounds 类的实例就像这里
  • x 中每个元素的 (min, max) 对序列。

推荐阅读