【发布时间】:2016-05-27 17:27:26
【问题描述】:
我正在解决以下优化问题:
使用此 Python 代码:
from scipy.optimize import minimize
import math
def f(x):
return math.log(x[0]**2 + 1) + x[1]**4 + x[0]*x[2]
x0 = [0, 0, 0]
cons=({'type': 'ineq',
'fun': lambda x: x[0]**3 - x[1]**2 - 1},
{'type': 'ineq',
'fun': lambda x: x[0]},
{'type': 'ineq',
'fun': lambda x: x[2]})
res = minimize(f, x0, constraints=cons)
print res
我遇到了一个错误
消息:'不等式约束不兼容'
什么会导致这个错误?
【问题讨论】:
-
FWIW,在另一个问题stackoverflow.com/questions/55543140/… 我发现降低容忍度以帮助
options={'ftol':1e-15}但在这里似乎没有帮助。但是在你的情况下,我确实发现初始值确实很重要,当初始值太远时,SLSQP或trust-const都不适合我。
标签: python optimization scipy mathematical-optimization