Convex - Convex error using CVX

clear on
clc

% Initialization
Nr = 6;
Nt = 1;
device_num = 3;
gamma = randn(device_num);
alpha = 1;
h = [];

for j = 1:1:device_num
    h(:,j) = randn(Nr, Nt) + 1i*randn(Nr, Nt);
    m = h(:,j);
    M = m*m';
end


% subgradient M
v = max_eig(M);
sg_M = v*v';

X = randi([0, 5], device_num, 1);
x_sg = X;


% calculate k-norm
X = sort(X,'descend');
k_norm = 0;
device_index = 0;
number_k = 0;
I = 0;

for k = 1:1:length(X)
    k_norm = k_norm + X(k);
    if norm(X,1) == k_norm
        number_k = k;
        break;
    end
end


% subgradient X
for j = 1:1:length(X)
    abs(X(j));
    abs(X(number_k));
    if abs(X(j)) >= abs(X(number_k))
        value = sign(X(j));
    else
        value = 0;
    end

    x_sg(j,1) = value;
end



% I
for i = 1:1:device_num

    h_hermitian = h';

    if real(trace(M)) - real(gamma(i)*h_hermitian(i,:)*M*h(:,i)) <= X(i) && (real(trace(M)) >= 1) && all(X(:) > 0)
        I = 0;
    else
        I = 100000000;
    end
end

cvx_begin
  variable X(device_num, 1)
  variable M(Nr, Nr) complex semidefinite
  minimize norm(X,1) + real(trace(M)) + I + alpha/2*(norm(X,2) + real(norm(M,2))) - ( trace(x_sg'*X) + alpha*trace(norm(X,2)) + real(trace(sg_M'*M)) + alpha*real(norm(M,2)) )
  subject to
    for i = 1:1:device_num
        real(trace(M)) - real(gamma(i)*h_hermitian(i,:)*M*h(:,i)) <= X(i);
        X(i) >= 0
    end
    real(trace(M)) >= 1;
cvx_end

function value = max_eig(M)

[x,y] = eig(M);
eigenvalue = diag(y);
lamda = max(eigenvalue);

for i=1:length(M)
    if lamda == eigenvalue(i)
        break;
    end
end

y_lamda = x(:,i);
value = y_lamda;

end

Hi, could anyone help me find out why matlab keeps sending me following error :

Disciplined convex programming error:
Illegal operation: {convex} - {convex}

  • ( trace(x_sg’X) + alphatrace(norm(X,2)) + real(trace(sg_M’M)) + alphareal(norm(M,2)) )

This part has some problem, but I do not know why ? Thanks.

I did not read your code carefully,but the DCP error is because CVX do not accept such form ,
convex+convex is still convex,convex-convex ? it is not.
-convex is concave ,you should read the 3.2.4 Section of Convex Optimization (Boyd),

If I’m not mistaken ultimately real(norm(M,2)) appears in your minimization objective with negative coefficient and probably the same for X. Maybe you should check the objective, for instance why write trace(norm(X,2)) ?

The objective function has norms in various norms appearing with positive and negative coefficients. So it would appear to be non-convex. As @Michal_Adamaszek is perhaps suggesting, maybe you should check if your formulation is what you or whatever paper you are trying toi implement, intended. If it is, CVX is not the right tool for the problem.