Why does this error occur

Disciplined convex programming error:
    Cannot perform the operation: {real affine} .* {positive constant}

出错  *  (第 36 行)
    z = feval( oper, x, y );

出错 F1_Beamforming_Optimization (第 251 行)
[eta_c*(epsilon^(-2))*eye(K),zeros(K, 1) ; zeros(1, K) ,(-1)*eta_c*(epsilon^(-2))*(epsilon^2)+nu_ec*No]-[Ac,Ac*Eve.g_STARS_Eve;Eve.g_STARS_Eve'*Ac,Eve.g_STARS_Eve'*Ac*Eve.g_STARS_Eve]==hermitian_semidefinite(K+1);

The variables are described as follows:
Ac=( diag(STARS.Rphase)* Ruser.equivalent_br)W_c(diag(STARS.Rphase)* Ruser.equivalent_br)';

W_c is a complex positive semidefinite matrix with M rows and M columns
eta_c,nu_ec are variables with one row and one column. The rest are constants

I don’t know what is going on. Please provided a minimum reproducible example.

And make sure you are using CVX 2.2, not CVX 3.0beta.

cvx_begin  %quiet
    cvx_solver mosek
  variable W_c(M, M) complex semidefinite;
     variables r_nu_ec;
        variables eta_c;

        Ac=( diag(STARS.Rphase)* Ruser.equivalent_br)*W_c*(diag(STARS.Rphase)* Ruser.equivalent_br)';
        subject to
        W_c == hermitian_semidefinite(M);


[eta_c*(epsilon^(-2))*eye(K),zeros(K, 1) ; zeros(1, K) ,(-1)*eta_c*(epsilon^(-2))*(epsilon^2)+nu_ec*No]-[Ac,Ac*Eve.g_STARS_Eve;Eve.g_STARS_Eve'*Ac,Eve.g_STARS_Eve'*Ac*Eve.g_STARS_Eve]==hermitian_semidefinite(K+1);


Here’s the code, but since it’s super long, I’ve cut out the key parts

I can’t tell from that. You ought to be able to figure out exactly which two things being multiplied are triggering the error message by typing pieces of it at the command line and see what CVX says.

{real affine} .* {positive constant}
Why should this be an error, it’s just a positive constant, it should be a convex function after multiplication wow

If the code is long then reduce it to a small REPRODUCIBLE example which can be executed, with all the input data, and reproduces the same message. Then we will be able to help. A small reproducible example does not have to be an exact copy of your code, it does not need to have any practical meaning either, as long as it demonstrates the problem you want to demonstrate. Unfortunately we are unable to guess what exactly happens on your machine.

Preparing a small reproducible example is a very helpful debugging technique anyway because it often makes you discover and fix the problem yourself. So I really recommend it. For example it could be the case that the “positive constant” is actually +Inf, or something else of that kind.

1 Like