简体   繁体   English

python scipy.optimize.minimize “SLSQP求解器”在xo之间添加约束

[英]python scipy.optimize.minimize “SLSQP solver” adding constraint between xo

I would like to optimize function with SLSQP solver.我想用 SLSQP 求解器优化 function。 The function contains 5 parameters, and I would like to add a constraint that x[0] > x[3] . function 包含 5 个参数,我想添加一个约束x[0] > x[3] The following code makes x[0]=x[3] .以下代码使x[0]=x[3] Can you help me to modify it to " x[0] > x[3] "你能帮我把它修改成“ x[0] > x[3]

cons = {'type':'eq', 'fun': lambda x: x[0] - x[3]} 

res = minimize(model_calib, xo, bounds=[(100,8000),(0,650),(0,1),(5,550),(0,3)], method='SLSQP',constraints = cons)

Best regards,此致,

As you mentioned in comment by @Cory Kramer正如你在@Cory Kramer 的评论中提到的那样

cons = {'type':'ineq', 'fun': lambda x: x[0] - x[3]} 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM