我试图建立正确的约束最小化目标函数:
fun_SV = lambda x : objective(value_date_2, datos_2,curve,'Svensson',curve_rates,fechas_tenors,x)
我有x
,我只是想约束,其中第一和第二个参数的总和是更大0我想这个参数列表:
cons = {'type':ineq, 'fun': lambda x: x[0] + x [1]}
然后,我尽量减少:
bounds_sv = ((0,15),(-15,30),(-30,30),(-30,30),(0.000000001,30)(0.000000001,30))
res_SV = minimize(fun_SV, x0,method="SLSQP", bounds= bounds_sv, constraints = my_constraints, tol=0.000001,options={'maxiter':50000})
我所得到的是两个两个的总和是0,我只是想x[0] + x[1] > 1
。
SLSQP的形式f(x)>=0
的不平等。所以,如果你想g(x)>1
必须使用:f(x)-1.0001>=0
。你的情况:
cons = {'type':ineq, 'fun': lambda x: x[0] + x [1] - 1.0001 }