Why can't the code run if i just modify some variable and formula?

At first,i wrote the code here,and thx for Mark_L_Stone to help me solve the problem,that question link is as below:

But now i modify the some of code,and the total code become

%declare
K=4;
N=4;
L=5;%distance between RX & TX
nois_var_hk_2pow=0.1*(L^(-2.05))
nois_var_ak_2pow=[10^-10 10^-10 10^-10 10^-10 ];
nois_var_dk_2pow=[10^-8 10^-8 10^-8 10^-8 ];
bar_r=[10 10 10 10];
P_T=10;
h_1=sqrt(nois_var_hk_2pow/2)*(randn(N,1)+1i*randn(N,1));
h_2=sqrt(nois_var_hk_2pow/2)*(randn(N,1)+1i*randn(N,1));
h_3=sqrt(nois_var_hk_2pow/2)*(randn(N,1)+1i*randn(N,1));
h_4=sqrt(nois_var_hk_2pow/2)*(randn(N,1)+1i*randn(N,1));
h_kk=cat(2,h_1 ,h_2 ,h_3, h_4)
 for n=1:4
    h_k{n}=h_kk(1:4 , n);
    n=n+1;
 end
%===========================================================

cvx_begin
     variable f_kiii(N,1,K); 
     f_kii=cat(2, f_kiii)
   for o=1:4
      f_ki{o}=f_kii(1:4,o) 
   end
   
   op2=0;
   for k=1:K
       op2=op2+f_ki{k}'*f_ki{k};         
   end
   
%==========================================
%objected function
    minimize( op2 ) 
    subject to
%==========================================  
       %c8
        total = 0;
        for k = 1:K
            sub_denominator = 0;
            for j = 1:K
                if j ~= k  
                    c=h_k{k}' * f_ki{j};
                    %sub_denominator = sub_denominator=pow_abs(c,2)
                 sub_denominator = sub_denominator +  square_abs(h_k{k}' * f_ki{j});
                end
            end
            total = total + sub_denominator;
        end
   
       numerator=square_abs(h_k{k}' * f_ki{j})
       numerator >= max(bar_r(1) * max(real(total)+nois_var_ak_2pow(1) + nois_var_dk_2pow(1)),0)
cvx_end

The main difference are thay i modify FNNK(N,N,K) to f_kiii(N,1,K) and modify h_k{k}' * Fk{j} * h_k{k} to square_abs(h_k{k}' * f_ki{j}),i want to write |h_k{k}’ * f_ki{j}|^2,but the window show me that

Error using cvxprob/newcnstr (line 192)
Disciplined convex programming error:
Invalid constraint: {convex} >= {convex}

Error in >= (line 21)
b = newcnstr( evalin( ‘caller’, ‘cvx_problem’, ‘’ ), x, y, ‘>=’ );

Error in f_kI (line 54)
numerator >= max(bar_r(1) * max(real(total)+nois_var_ak_2pow(1) + nois_var_dk_2pow(1)),0)

Does anyone know how do i modify the code to let the code run?

CVX does not allow {convex} >= anything . You have violated that, whereas the version in my last post in Cannot perform the operation: {real affine} .* {convex},but i don't use the `.*` obeys CVX’s rules.

If you changed
numerator=square_abs(h_k{k}' * f_ki{j})
to
numerator=real(h_k{k}' * f_ki{k} * h_k{k})
which is the same as the previous thread except for using f_ki instead of Fk, the program would be accepted by CVX. even with the change made in your posit in this thread to how total is calculated.

Have you proven that your new version, specifically, how numerator is now defined, results in a convex constraint? That is your responsibility. I will mark it as non-convex unless and until you show it is convex.

Please carefully read Why isn't CVX accepting my model? READ THIS FIRST! and the CXV Users’ Guide http://cvxr.com/cvx/doc/ .

but the window has show me {convex} >= {convex},doesn’t it mean that my numerator is convex now?

Yes, your numerator is convex and not affine. Therefore you can not have numerator >= anything. That might be non-convex. In your previous version, numerator is affiine, which can be on either side of an unequality (or equality).

Can you tell me which condition i didn’t obey now?
I have seen the guide :

  • a valid constant expression;
  • a declared variable;
  • a valid call to a function in the atom library with an affine result;
  • the sum or difference of affine expressions;
  • the product of an affine expression and a constant.

which condition that i didn’t obey now?i think i have obey the first three condition,but about the last two condition,i am not very sure that wheather i obey or not and how to modify it to “affine”,i have modify the code to numerator=real(square_abs(h_k{k}' * f_ki{j})) but it seems that this change did’t modify numerator to “affine”

The Basics — CVX Users' Guide
The following constraint types are supported in CVX:

Equality == constraints, where both the left- and right-hand sides are affine expressions.
Less-than <= inequality constraints, where the left-hand expression is convex, and the right-hand expression is concave.
Greater-than >= constraints, where the left-hand expression is concave, and the right-hand expression is convex 

Think of affine as meaning “linear”, i.e., not nonlinear. The expression for numerator in your previous thread is affine, i.e., linear with respect to the CVX variables. The expression for numerator in this thread is not affine; you are squaring a CVX variable, which is not on that list.

1 Like

I know your meaning,but i don’t know how do i rewrite the formula to let the numerator become affine
because the formula is ||f_k||^2,but ||f_k||^2=f_k’ * f_k,so i can’t not use the F_k,
because F_k=f_k * f_k’,they are different

As I wrote above

Have you proven that your new version, specifically, how numerator is now defined, results in a convex constraint? That is your responsibility. I will mark it as non-convex unless and until you show it is convex.

Please carefully read Why isn’t CVX accepting my model? READ THIS FIRST! and the CXV Users’ Guide http://cvxr.com/cvx/doc/ .

But as i wrote before,after running the code,window have showed my numerator is convex,so i don’t need to prove the numerator is convex again

As I wrote before, you are in violation of this
http://cvxr.com/cvx/doc/basics.html#constraints
The following constraint types are supported in CVX:

Equality == constraints, where both the left- and right-hand sides are affine expressions.
Less-than <= inequality constraints, where the left-hand expression is convex, and the right-hand expression is concave.
Greater-than >= constraints, where the left-hand expression is concave, and the right-hand expression is convex.

At this point, if you are unwilling to read, or unable to understand, the links I provided, you appear to be in need of extensive tutorial help, for which this forum is not suited,

In order to understand why the ruiles are as they are, please read and solve many of the exercises in http://web.stanford.edu/~boyd/cvxbook/ .