0

Consider the scenario where I define a CVXPY variable, a 4x4 semidefinite matrix, as below

x = cvxpy.Semidef(4)

If I want to write a constraint involving the trace of this, it seems I must use the atomic function

cvxpy.atoms.affine.trace.trace(x)

I would like to enforce a specific constraint on x, namely that it has a positive partial transpose. There is no atomic function like the trace in this case but such a method has already been written (see http://qutip.org/docs/3.1.0/modules/qutip/partial_transpose.html#partial_transpose). Can I get CVXPY to allow me to write a constraint in terms of these non-atomic functions that already exist elsewhere (e.g. numpy, qutip and so on)?

Thanks!

feedMe
  • 3,431
  • 2
  • 36
  • 61
user1936752
  • 756
  • 1
  • 9
  • 25
  • If your question is: can i use numpy / any other function on my cvxpy data-structures? The answer is no: cvxpy is based on it's DCP rules and those are only available for those [functions implemented](https://www.cvxpy.org/tutorial/functions/index.html#). "black-box" usage is impossible. – sascha Feb 11 '19 at 16:16
  • @sascha I see. In this sense, is it the case that MATLAB allows this but not Python? Or are there any CVX solvers in Python that allow blackbox implementation of functions on CVX varibles? – user1936752 Feb 11 '19 at 16:18
  • Matlab has no knowledge of DCP rules. Either cvx (the matlab equivalent and original implementation before cvxpy) supports other functions or there is some other flaw. DCP-based approaches can't work with black-boxes. These are methods by construction to beat the (in general) NP-hard task of proving convexity. Try to mimic the code you refer to with cvxpy's functions. There are a lot of those available (mimicking numpy's). – sascha Feb 11 '19 at 16:20
  • Ah I see. It looks like the partial transpose function (which is linear so is convex) I used in MATLAB is explicitly compatible with CVX but the one I linked is not. – user1936752 Feb 11 '19 at 16:30

0 Answers0