Cannot perform the operation: {real affine} .* {convex},but i don't use the `.*`


(蕭仰恩) #1
%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 FNNK(N,N,K) semidefinite; 
      Fkk=cat(2,FNNK);
          u=0
   for o=1:4
       Fk{o}=Fkk(1:4,o+3*u:4*o)
       u=u+1;
   end 
      
    op2=0;
    for k=1:K
       op2=op2+FNNK(k)
    end
%==========================================
%objected function
    minimize( op2 )
    subject to
%==========================================  
       %c8
        total = 0;
        for k = 1:K
            sumja = 0;
            for j = 1:K
                if j ~= k  
                 sumja = sumja +  h_k{k}' * Fk{j} * h_k{k};
                end
            end
            total = total + sumja;
        end
       
        
       numerator=real(h_k{k}' * Fk{k} * h_k{k}) 
       denominator=inv_pos(real(total)+nois_var_ak_2pow(1) + nois_var_dk_2pow(1)) 
       numerator*denominator>=bar_r(1)
cvx_end

My problem is the last 3 line code (not including cvx_end), the numerator , denominator and bar_r(1) are all a value,and the window said
1.Error using .* (line 173)
Disciplined convex programming error:
Cannot perform the operation: {real affine} .* {convex}
2.Error in f_kI (line 56)
numerator*denominator>=bar_r(1)

I don’t understand the error window said,because in numerator*denominator>=bar_r(1) this line,i didn’t
use the .* ,besides,both numerator and denominator are scalar(value),i don’t need to use .*


Why do i just mutiply two scalar,but the window show me i need a square ,and error using in .*?
(Mark L. Stone) #2

The exact error messages produced by CVX are not necessarily as informative as they could be. But don’t worry about whether the error message says * or .* . In the case of scalar multiplication, they amount to the same thing. CVX produced this error message because you violated CVX’s rules.

However, a simple reformulation solves your problem.
numerator >= bar_r(1) * max((real(total)+nois_var_ak_2pow(1) + nois_var_dk_2pow(1)),0)


(蕭仰恩) #3

after modifying it, the error become

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 51)
       numerator >= max(bar_r(1) * max(real(total)+nois_var_ak_2pow(1) + nois_var_dk_2pow(1)),0)

Why can't the code run if i just modify some variable and formula?
(Mark L. Stone) #4

Here is the code I ran, without error message. I used CVX 2.1.

 cvx_begin
     variable FNNK(N,N,K) semidefinite; 
      Fkk=cat(2,FNNK);
          u=0
   for o=1:4
       Fk{o}=Fkk(1:4,o+3*u:4*o)
       u=u+1;
   end 
      
    op2=0;
    for k=1:K
       op2=op2+FNNK(k)
    end
%==========================================
%objected function
    minimize( op2 )
    subject to
%==========================================  
       %c8
        total = 0;
        for k = 1:K
            sumja = 0;
            for j = 1:K
                if j ~= k  
                 sumja = sumja +  h_k{k}' * Fk{j} * h_k{k};
                end
            end
            total = total + sumja;
        end
       
        
       numerator=real(h_k{k}' * Fk{k} * h_k{k}) 
 numerator >= bar_r(1) * max((real(total)+nois_var_ak_2pow(1) + nois_var_dk_2pow(1)),0)
cvx_end

CVX correctly displays the following:

numerator =

cvx real affine expression (scalar)

Why can't the code run if i just modify some variable and formula?
(蕭仰恩) #5

i know where is difference,the original formula is |f_k|^2,but i rewrite the code as F_k,because the |f_k|^2=F_k


(Mark L. Stone) #6

So is everything now resolved?


(蕭仰恩) #7

yes! thanks for helping