问题不符合CVXPY中的DCP规则 [英] Problem does not follow DCP rules in CVXPY

查看:211
本文介绍了问题不符合CVXPY中的DCP规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

"Problem does not follow DCP rules" happens at the objective function but mathematically this is convex (I proved) and when I applied the same problem to CVXOPT, it worked.

我不知道应该修改什么.

I don't know what I should modify.

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规则.

cvxpy.error.DCPError: Problem does not follow DCP rules.

推荐答案

严格的凸编程不允许两个凸表达式相乘.你有

Disciplined convex programming does not allow multiplying two convex expressions. You have

(-mu_hat @ x)**2

cp.quad_form(x, covar)

都是凸的.也许您打算添加它们?您是如何提出cvxopt问题的?

which are both convex. Maybe you meant to add them? How did you formulate the problem for cvxopt?

这篇关于问题不符合CVXPY中的DCP规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆