Here’s some code for CVX. The constraint will give us an error. How do we fix this
%-------------------------------------------------------------------------------------------------------------------------

variable p0(M) complex
variable p1(M) complex
variable p2(M) complex
U_0 = p0' * p0;
U_1 = p1' * p1;
%maximize(min(Rc_b1,Rc_b2)-Cc_b+R1_b-C1_b+R2_b-C2_b);%
maximize(min(Rc_b1,Rc_b2)-Cc_b+R1_b-C1_b+R2_b-C2_b);%
subject to
for i = 1:M
U_0(i,i)+U_1(i,i)==1;
end

That is a nonlinear equality constraint, which is non-convex.

You haven’t shown all of your program, so I have no idea what the symbols in the objective function are. However, if p0 and p1 are only used in your program in the form of U_0 and U_1, and don;t appear anywhere else, then you can instead declare U_0 and U_1 to be variables (and never declare p0 or p1), which would make the constraint affine, which CVX would accept.

However, there is more that is strange with your program. Even if you changed == to <= which would cause the constraint to be convex and compliant with CVX’s DCP rules, Y_0 and U_1 are both scalars (created as inner products), and therefore even a <= version of that constraint would result in an illegal indexing message in MATLAB, unless M has value 1.

The variables in the objective function are all scalars, there are many constraints (all related to p0, p1, p2), I have not listed the constraints on p0, p1, p2, and the only error constraint is the one I listed above on the diagonal of the matrix formed by p0, p1.
I understand that you want me to change all the variables into the form of matrix. I wanted to do so before, but I have been unsuccessful in debugging.
Recently, I changed my mind and started to change the variables into the form of column vectors to try debugging.
Thank you very much for your answer ~