为什么这个 CVXPY 表达式不是 DCP?

Why is this CVXPY expression not DCP?

我有这个简短的样本..

sysclk.value = 320e6

ddsdiv = cp.Variable(integer = True,                    # DDS divisor
         name = 'ddsdiv')
ddsdivpos = cp.Variable(pos = True)                     # Constrain to be positive

ddsclk = cp.Variable(pos = True, name = 'ddsclk')       # Resulting clock

constraints = [
        ddsdiv == ddsdivpos,                            # Constrain DDS divisor to be positive
        sysclk == ddsclk * ddsdiv,                      # Compute DDS clock
        ]
objective = cp.Minimize(cp.abs(ddsclk - 10e6))
prob = cp.Problem(objective, constraints);

prob.solve()
print(ddsclk.value)

然而它说..

DCPError: Problem does not follow DCP rules. Specifically:
The following constraints are not DCP:
sysclk == ddsclk * ddsdiv , because the following subexpressions are not:
|--  ddsclk * ddsdiv

同样,如果我尝试它会失败(越天真)..

        ddsclk == sysclk / ddsdiv,                      # Compute DDS clock

它还会发出 DCPError。

我不明白正数除以正整数怎么可能不是我的凸数(但我的数学不是很好:)

我在 MacOSX 10.14.6 上使用 CVXPY 1.0.25、Python 3.7.5。

谢谢。

假设您的约束是 x * y == 9,其中 xy 是(连续)变量。这个方程的解集需要是 convex set。我们可以通过采用两个解决方案并检查这​​两个解决方案之间的所有点是否也在集合中来测试这是否是凸的。

例如,(1,9) 和(9,1) 都是有效解。但是,这些解决方案 (5,5) 之间的中点 不是 解决方案。我们找到了一个反例,因此这不是一个凸集。

最终,因为这不是凸的,所以不可能满足 DCP。您需要重新表述您的问题,使其成为凸的或其他更适合的东西。