问题不符合 CVXPY 中的 DCP 规则



"问题不遵循DCP规则"发生在目标函数中,但在数学上这是凸的(我证明了(,当我将相同的问题应用于CVXOPT时,它起作用了。

我不知道我应该修改什么。

x = cp.Variable(data_length)
obj = cp.Minimize((-mu_hat @ x)**2*cp.quad_form(x, covar))
constraints = [sum(x) == 1,  x <= [bounds[i][1] for i in range(len(bounds))], x >= [bounds[i][0] for i in range(len(bounds))]]
prob = cp.Problem(obj, constraints)
prob.solve()

cvxpy.error.DCPError:问题不符合 DCP 规则。

纪律凸规划不允许将两个凸表达式相乘。你有

(-mu_hat @ x)**2

cp.quad_form(x, covar)

两者都是凸的。也许你打算添加它们?您是如何为 cvxopt 制定问题的?

最新更新