scipy.optimize.fmin_slsqp

scipy.optimize.fmin_slsqp(func, x0, eqcons=(), f_eqcons=None, ieqcons=(), f_ieqcons=None, bounds=(), fprime=None, fprime_eqcons=None, fprime_ieqcons=None, args=(), iter=100, acc=1e-06, iprint=1, disp=None, full_output=0, epsilon=1.4901161193847656e-08, callback=None)[源代码]

用序列最小二乘规划法最小化函数

最初由Dieter Kraft实现的SLSQP优化子例程的Python接口函数。

参数
func可调用f(x,*args)

目标函数。必须返回标量。

x0一维浮子阵列

对自变量的初始猜测。

eqcons列表,可选

长度为n的函数的列表,使得等式 [j] 在成功优化的问题中,(X,*args)==0.0。

f_eqcons可调用f(x,*args),可选

返回一个一维数组,其中每个元素在成功优化的问题中都必须等于0.0。如果指定了f_eqcons,则忽略eqcons。

ieqcons列表,可选

长度为n的函数的列表,使得等式 [j] 在成功优化的问题中,(X,*args)>=0.0。

f_ieqcons可调用f(x,*args),可选

返回一维ndarray,其中每个元素在成功优化的问题中必须大于或等于0.0。如果指定了f_ieqcons,则忽略ieqcons。

bounds列表,可选

指定每个自变量的上下限的元组列表 [(xl0,xu0),(xl1,xu1),.] 无限大的值将被解释为大的浮点值。

fPrime :可调用 f(x,*args) ,可选可调用

计算函数的偏导数的函数。

fprime_eqcons :可调用 f(x,*args) ,可选可调用

表单的一个函数 f(x, *args) 它返回相等约束法线的m×n数组。如果未提供,将近似法线。fPrime_eqcons返回的数组大小应为(len(Eqcons),len(X0))。

fprime_ieqcons :可调用 f(x,*args) ,可选可调用

表单的一个函数 f(x, *args) 它返回不等约束法线的m×n数组。如果未提供,将近似法线。fPrime_ieqcons返回的数组大小应为(len(Ieqcons),len(X0))。

args序列,可选

传递给func和fPrime的其他参数。

iter整型,可选

最大迭代次数。

acc浮动,可选

要求准确度。

iprint整型,可选

fmin_slsqp的详细程度:

  • iPrint<=0:静默操作

  • iPrint==1:完成时打印摘要(默认)

  • iPrint>=2:打印每次迭代和汇总的状态

disp整型,可选

覆盖iPrint接口(首选)。

full_output布尔值,可选

如果为false,则仅返回func的最小值(默认值)。否则,输出最终目标函数和汇总信息。

epsilon浮动,可选

有限差分导数估计的步长。

callback可调用,可选

在每次迭代后调用,如 callback(x) ,在哪里 x 是当前参数向量。

退货
outNdarray of Floor(浮子线)

函数的最终极小值。

fx如果full_output为true,则返回浮点数的ndarray

目标函数的最终值。

its如果full_output为true,则返回int

迭代次数。

imode如果full_output为true,则返回int

优化器的退出模式(见下文)。

smode字符串,如果FULL_OUTPUT为TRUE

描述优化器退出模式的消息。

参见

minimize

与多变量函数的最小化算法的接口。请参阅“SLSQP” method 尤其是。

注意事项

退出模式定义如下:

-1 : Gradient evaluation required (g & a)
 0 : Optimization terminated successfully
 1 : Function evaluation required (f & c)
 2 : More equality constraints than independent variables
 3 : More than 3*n iterations in LSQ subproblem
 4 : Inequality constraints incompatible
 5 : Singular matrix E in LSQ subproblem
 6 : Singular matrix C in LSQ subproblem
 7 : Rank-deficient equality constraint subproblem HFTI
 8 : Positive directional derivative for linesearch
 9 : Iteration limit reached

示例

给出了实例 in the tutorial