Why does this SDP not work?

(Andy Ye) #1

I have got a bunch of linear constraints for a positive semidefinite matrix rho like Tr(rho*Gamma{i})=gamma(i), where Gamma is a set of Povm operators, and gamma is the corresponding array of expectation values. I want to get a rho which is close enough to that which satisfies these constraints. And here y is the benchmark
of closeness.

function [rho,y]=closest(dim,Gamma,gamma)

cvx_begin sdp quiet
  cvx_precision best
  variable rho(dim,dim) hermitian 
  variable y=(n,1)
  minimize norm(y,1)
  for i=1:n


Error using variable (line 57)
Invalid structure specification: y=(n,1)
Error in closest (line 6)
variable rho(dim,dim) hermitian y=(n,1)

(Mark L. Stone) #2

I think that instead of
variable rho(dim,dim) hermitian y=(n,1)
you want

variable rho(dim,dim) hermitian
variable  y(n,1)

Please re-read http://cvxr.com/cvx/doc/basics.html#variables .


Also, I presume you have indexing errors(s) in

  for i=1:n

Do you mean to have



Also, I recommend you not use quiet until you are confident your program is working correctly and you trust the results. If quiet is not used, all solver and CVX output will be displayed on the screen; whereas if quiet is used, none of it will be.

(Andy Ye) #3

Thank you very much for your nice reply. Yeah, I made a mistake for the index when typing. But it still doesn’t work even though I revise the indexing and add up another variable claim. I don’t know why.

(Mark L. Stone) #4

You have not provided a mathematical description of the problem you wish to solve. You have not provided the input data. You have not said what you mean by “it doesn’t work”. You have not shown us the results of running it, and why that constitutes not working. Until you provide some of these items, you are unlikely to get useful assistance from readers of the forum, other than my guess in the next paragraph.

The thread title refers to SDP, but your program has no SDP constraints. Do you require rho to be semidefinite? If so, you must declare it as such, or add an explicit semidefinite constraint. The easiest way to do so is to change
variable rho(dim,dim) hermitian
variable rho(dim,dim) hermitian semidefinite

Edit: I see that your first post mentions “positive semidefinite matrix rho”. So it appears my guess above is correct. Either declare rho hermitian semidefinite or hermitian semidefinite, depending on whether you want to allow complex elements in rho.

I recommend you carefully read or re-read the entirety of the CVX Users’ Guide http://cvxr.com/cvx/doc/