0

我正在尝试解决 CVXPY 中的以下问题。

由于我们正在解决的 PSD 矩阵,问题是混合整数 SDP。然而,根据这个列表,似乎没有一个求解器可以处理这样的问题。

我们可以使用 2x2 矩阵这一事实A以某种方式将其转换为混合整数 SOCP 问题吗?

import cvxpy as cp
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(271828) 
m = 2; n = 50
x = np.random.randn(m,n)

off = cp.Variable(boolean=True)

A = cp.Variable((2,2), PSD=True)
b = cp.Variable(2)
obj = cp.Maximize(cp.log_det(A))
constraints = [ cp.norm(A@x[:,i] + b) <= 1 + 20*off for i in range(n) ]
constraints += [cp.sum(off) <= 20]

prob = cp.Problem(obj, constraints)
optval = prob.solve(solver='XPRESS', verbose=False) # seems to work, although it's not super accurate

print(f"Optimum value: {optval}")

# plot the ellipse and data
angles = np.linspace(0, 2*np.pi, 200)
rhs = np.row_stack((np.cos(angles) - b.value[0], np.sin(angles) - b.value[1]))
ellipse = np.linalg.solve(A.value, rhs)

plt.scatter(x[0,:], x[1,:])
plt.plot(ellipse[0,:].T, ellipse[1,:].T)
plt.xlabel('Dimension 1'); plt.ylabel('Dimension 2')
plt.title('Minimum Volume Ellipsoid')
plt.show()
4

1 回答 1

1

假设A=[[x,z], [z,y]],那么您可以最大化sqrt(det(A)) (这相当于您的目标)。注意

det(A) = xy-z^2

所以最大化与最大化主题sqrt(det(A))相同u

xy - z^2 >= u^2

等效地

xy >= z^2 + u^2

在https://docs.mosek.com/modeling-cookbook/cqo.html#rotated-quadratic-cones的意义上,这(几乎)是一个旋转的二阶锥体

我想像

x >= quad_over_lin([z,u], y)

(haven't tested the syntax) may be the most convenient way to express it in cvxpy.

Note that the definition of the cone and of quad_over_lin also imposes x,y>=0 so you don't need that separately, and the conic constraints automatically guarantees PSDness of A.

于 2021-11-24T09:08:37.980 回答