我正在尝试在必须解决SDP的研究论文中编写一种方法。其中一个约束条件是S成功或等于s * s ^ T。其中S是NXN矩阵,而s是NX1矩阵。 s ^ T是s的转置。
我发现对于半定约束,正半定锥约束的两边都必须是平方矩阵和仿射。这里S和s都是未知的,我们正在根据S和s最小化方程。 S曲率显示未知。
n = 2
np.random.seed(1)
Q = np.random.randn(n, n)
b = np.random.randn(n,1)
S = cp.Variable((n,n))
s = cp.Variable((n,1))
objective = cp.Minimize(cp.trace(Q@S) + 2*b.transpose()@s)
constraints = [cp.trace(S) - one.transpose()@s <= 0, S >> s@s.T]
prob = cp.Problem(objective, constraints)
print("Optimal value", prob.solve())
print("Optimal status", prob.status)
print(s.value) # A numpy ndarray.
这是我收到的错误
文件“ /home/mtech0/18CS60R64/cvxpy/SDP_test.py”,第45行,在 print(“最佳值”,prob.solve())
文件“ /home/mtech0/18CS60R64/anaconda3/envs/mtp/lib/python3.6/site-packages/cvxpy/problems/problem.py”,第289行,已解决 返回resolve_func(自己,* args,** kwargs)
文件“ /home/mtech0/18CS60R64/anaconda3/envs/mtp/lib/python3.6/site-packages/cvxpy/problems/problem.py”,行567,在_solve中 self._construct_chains(solver = solver,gp = gp)
文件“ /home/mtech0/18CS60R64/anaconda3/envs/mtp/lib/python3.6/site-packages/cvxpy/problems/problem.py”,行510,在_construct_chains中 提高e
文件“ /home/mtech0/18CS60R64/anaconda3/envs/mtp/lib/python3.6/site-packages/cvxpy/problems/problem.py”,行499,在_construct_chains中 Construct_intermediate_chain(自己,候选人解析器,gp = gp)
文件“ /home/mtech0/18CS60R64/anaconda3/envs/mtp/lib/python3.6/site-packages/cvxpy/reductions/solvers/intermediate_chain.py”,第56行,位于Construct_intermediate_chain中 引发DCPError(“问题不遵循DCP规则。” +附加)
DCPError:问题不遵循DCP规则。