Thank you for the quick reply. Yes.I have removed some parts here.
The complete question is:

maximize d
subject to
trace(C*X)>=d
trace(X)<=4

with the additional condition that X is a positive semidefinite matrix and X=aa’. a is a 41 complex vector. As I know that aa’ is not allowed in cvx, and trace(aa’)=sum_square_abs(a). I change the original question into the one shown above. By the way, C is a 4*4 complex matrix(diagonal elements have 0 imaginary part). Is there anything I can do here?

I’m confused as to what problem you are trying to solve, and how a comes into play.

If you wish to keep this convex, perhaps the best you can do is a convex relaxation [X a';a 1] == hermitian_semidefinite(n+1) rather than X==a*a' , and enter the constraints you have above

By the way, I checked ‘Semidefinite programming mode’ of cvx users’ guide for the last hour. I have no idea why it should be ‘n+1’ instead of ‘n’ for hermitian_semidefinite . Also, I get an error
’Error using reshape
To RESHAPE the number of elements must not change.’ which I never met before. Do you have any ideas?

In your case, that would be [X a’;a 1] == hermitian_semidefinite(5) . I was implicitly referring to n as being the dimension of X - sorry for confusing you on that.

After that, let me know if you’re still having a reshape error, in which case you should show your complete code for context.

Sorry. That was a typo by me. Should be [X a;a' 1] == hermitian_semidefinite(5) . Believe it or not, I had it correct, posted it, re-read it, decided somehow it was wrong, and quickly edited to the wrong thing.

It doesn’t matter to CVX, but for program consistency, this should be part of the subject to block. But it doesn’t matter because the subject to statement s ignored by CVX, and any CVX constraint is treated is such in whatever order it occurs.

Unfortunately for you. the optimal X is not equal to a*a'. So all you have achieved with this convex relaxation formulation is an upper bound on the true optimal objective. The optimal objective value of the convex relaxation, which winds up being 6.3354, is therefore an upper bound on the optimal objective of your original problem. If that is not adequate for your purposes, I leave any further approaches to benefit from a convex solver to you. Otherwise you may have to deal with this a a non-convex SDP using another solver, such as perhaps PENLAB, which will take you beyond this forum’s scope.

I really appreciate for your patient explanation.It does help me a lot! Unfortunately, the value of ‘a’ which can give me the maximum ‘d’ is the most important thing in my project. Is there any method that I can get ‘a’ which will give the maximum ‘d’ even I will not know what is the value of d. To make it more clear, I only need to know what ‘a’ will give me the maximum value, the value of d is in fact not that vital. If there is no way, I will try to have a look at PENLAB.
Thank you!

Oh, one final question is: you said the optimal X is not equal to a*a’, but is the X shown in the result the one which will give the maximum d? If so, I may try a method to decompose the matrix to find a.

The solution to the convex relaxation does not necessarily provide the optimal d. It may be too optimistic (high).

To get a usable solution from the convex relaxation, you need X to be rank 1, i.e., of the form a*a’. The optimal X I got for the convex relaxation has rank 4 i.e., full (rank). The convex relaxation omits the non-convex rank constraint and then prays it will be satisfied anyway. The prayer didn’t come true in this case.

Hi. I have found a way to get ‘a’ from ‘X’. (I can use randomization follows N~(0,X) ). However, I feel confused that, although I have defined X to be hermitian(complex) and semidefinite, the X found by cvx is the following:

you can see that elements which are not in the diagonal are quite small. Do you have any ideas about what is the cause of that?
my code is the following:

maximize (dd);
subject to
for i=1:60
real(trace(C(:,:,i)*X))>=dd;
end
real(trace(s1*X))*2>=dd;
real(trace(s2*X))*2>=dd;
real(trace(s3*X))*2>=dd;
real(trace(s4*X))*2>=dd;
trace(X)<=4;
cvx_end

C(:,:,i) , s1,s2,s3,s4 are all 4*4 complex matrixes.

I have no idea what your way to get a from X is. What are you doing with randomization? Are you drawing a from a 4D Normal with mean 0 and covariance X? If so, I have no idea why that makes any sense.

I don’t see any relation between X and a in your new code. Your matrix X is within tolerance of being a real diagonal positive definite matrix; in any event, it is within tolerance of being hermitian semidefinite, if not exactly so.

In the new approach, I will find ‘a’ without cvx. All I need is ‘X’. The method is shown in the paper"semidefinite relaxation of quadratic optimization problems" which is a very good paper for this problem. I believe you will be interested in it. The paper gives two methods, ‘randomization’ is the second method proposed. As it is complicated, forgive me not explain it in detail here. What I want to do here is trying to get ‘X’ which is similar to