您对 Gram 矩阵 的东北项有严格的不等式约束Q := W.T * W
,它是对称的和半正定的。因此,请改为使用 Gram 矩阵Q
,然后引入严格的不等式约束Q[0,2] > 1
。
例如,这是一个零目标的半定规划(SDP):
>>> from cvxpy import *
>>> Q = Semidef(3)
>>> objective = Minimize(0)
>>> constraints = [ Q[0,2] > 1 ]
>>> prob = Problem(objective,constraints)
>>> prob.solve()
0.0
>>> Q.value
matrix([[ 2.33101529e+00, 2.57980002e-30, 1.76709537e+00],
[ 2.57980002e-30, 2.57740598e-15, -2.00304682e-30],
[ 1.76709537e+00, -2.00304682e-30, 2.33101529e+00]])
请注意,东北入口是1.76709537e+00 > 1
. W
要从Gram 矩阵恢复矩阵Q
,请使用 Cholesky 分解并附加一行零以获得 4 x 3 矩阵,如下所示:
>>> import numpy as np
>>> L = np.linalg.cholesky(Q.value)
>>> W = (np.insert(L, 3, np.array([0,0,0]), axis=1)).T
>>> W
matrix([[ 1.52676628e+00, 1.68971508e-30, 1.15741053e+00],
[ 0.00000000e+00, 5.07681591e-08, -7.79768444e-23],
[ 0.00000000e+00, 0.00000000e+00, 9.95698832e-01],
[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00]])
让我们验证一下:
>>> W.T * W - Q.value
matrix([[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
[ 0.00000000e+00, 0.00000000e+00, 7.00649232e-46],
[ 0.00000000e+00, 7.00649232e-46, 0.00000000e+00]])