5

I am trying to solve a convex optimization problem wherein the coefficients can be complex. The native implementation in cvxopt QP doest not seem to support that. I always get the following error:

TypeError: 'q' must be a 'd' matrix with one column

Here's the sample code.

Q = 2*cvxopt.matrix([ [2, .5], [.5, 1] ])
p = cvxopt.matrix([(1.0+1.0j), (1.0+2.0j)])
G = cvxopt.matrix([[-1.0,0.0],[0.0,-1.0]])
h = cvxopt.matrix([0.0,0.0])
A = cvxopt.matrix([1.0, 1.0], (1,2))
b = cvxopt.matrix(1.0)
sol=cvxopt.solvers.qp(Q, p, G, h, A, b)

Can there be a workaround to resolve this? Thanks

  • Is using a different package like CVXPY an option? They support complex values: https://www.cvxpy.org/tutorial/advanced/index.html#complex-valued-expressions – David Oct 19 '19 at 16:53

1 Answers1

0

The numeric values in Q are a mixture of integer and float, which may be the issue, mine work when I make sure they're all float.

Also for reference, Q might need to be real, as it is in this example. For matrix types, 'd' = real values (double). So it's likely the int vs float issue here. Best to check https://cvxopt.org/userguide/.