MISDP/MISOCP in cvxpy

0

I'm trying to solve the following problem in CVXPY.

The problem is a mixed-integer SDP due to the PSD matrix we're solving. However, according to this list it looks as though none of the solvers can handle such a problem.

Can we use the fact that A is a 2x2 matrix to somehow convert this to a mixed-integer SOCP problem?

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()
1

1

Let's say A=[[x,z], [z,y]], then you can maximize sqrt(det(A)) (which is equivalent to your objective). Note that

det(A) = xy-z^2

so maximizing sqrt(det(A)) is the same as maximizing u subject to

xy - z^2 >= u^2

equivalently

xy >= z^2 + u^2

This is (almost) a rotated second-order cone in the sense of https://docs.mosek.com/modeling-cookbook/cqo.html#rotated-quadratic-cones

I think something like

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-24 09:08:37

And here is some light entertainment related to your problem: twitter.com/mosektw/status/1190259248250445824
Michal Adamaszek

In other languages

This page is in other languages

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................