Error using cvx/log (line 64) Disciplined convex programming error: Illegal operation: log( {convex} )

Hi,

I’m facing a problem with my code in CVX. I would appreciate it if anyone can help me.
I’m trying to optimize a bunch of variables iteratively with the help of the following algorithm

when I run it for different Inputs, I get “Disciplined convex programming error:
Illegal operation: log( {convex} )” that is because of the term inside the \log, \sqrt{\alpha}, which is a convex function. How can I reformulated the objective in a way that Disciplined convex programming be satisfied?

Many thanks in advance for any tips and hints!

variable alpha
maximize(log(1+sqrt(alpha)))


is accepted by CVX. If the relevant coefficients are >= 0, you should be able to enter the objective function in CVX in a straightforward manner. Are you getting into trouble in a later iteration, perhaps because of coefficients not having the correct sign?

Thank you for your reply. yes the coefficients have the correct signs (0\leq \alpha_k \leq 1). I got different types of error when I run it, first I got this \log\{\text{convex}\} error, and now I get {invalid}.*{concave} error. Can I share my code with you?

You can post the code and output. You need to examine (print out) the relevant coefficient values at the time of error. The issue in question is not the sign of the variable alpha, it’s the input data (which could be from output of previous iteration.

As for invalid, that is probably due to variable value of NaN from a failed optimization in the previous iteration being used as input for the current optimization.

%% algorithm for optimum alpha

%% inputs

P = 10^((30-30)/10);
NN = linspace(5,22,18);% NUMBER OF ANTENNAS
K = 5; % Number of tags
sigma_n = 10^((-70-30)./10); % variance of noise
sigma_SI = 0.01;% power of RSI
iteration =100;
Rate = zeros(iteration,length(NN));

%% SCATTERED POINTS

% %% scattered points
xx0=0; yy0=0; %centre of disk
%Simulate binomial point process
pointsNumber=5;
theta=2pi(rand(pointsNumber,1)); %angular coordinates
%Convert from polar to Cartesian coordinates
[xx,yy]=pol2cart(theta,rho); %x/y coordinates of Poisson points
%Shift centre of disk to (xx0,yy0)
xx=xx+xx0;
yy=yy+yy0;
a = 2.7; % PATH LOSS COEFFICIENT
%Plotting
%scatter(xx,yy);
%xlabel(‘x’);ylabel(‘y’);
%axis square;
d1 = (xx(1)^2+yy(1)^2)^(-a);
d2 = (xx(2)^2+yy(2)^2)^(-a);
d3 = (xx(3)^2+yy(3)^2)^(-a);
d4 = (xx(4)^2+yy(4)^2)^(-a);
d5 = (xx(5)^2+yy(5)^2)^(-a);

for itr=1:iteration
itr
for q=1:length(NN)
N=NN(q);

%channels
h1=sqrt(0.5) * ( randn(N,1) + sqrt(-1)*randn(N,1)) ;
h2=sqrt(0.5) * ( randn(N,1) + sqrt(-1)*randn(N,1)) ;
h3=sqrt(0.5) * ( randn(N,1) + sqrt(-1)*randn(N,1)) ;
h4=sqrt(0.5) * ( randn(N,1) + sqrt(-1)*randn(N,1)) ;
h5=sqrt(0.5) * ( randn(N,1) + sqrt(-1)*randn(N,1)) ;
h_SI=sqrt(0.5) * ( randn(N,N) + sqrt(-1)*randn(N,N)) ;

%precoding and combiner
H = [h1, h2, h3, h4,h5];
G = H*inv(H’H); %[h1, h2, h3, h4,h5];%Hinv(H’*H);
F = conj(H)*inv(transpose(H)*conj(H));%[h1, h2, h3, h4,h5];

e = 10^(-6);

%%

f1 = 0;
f2 = 0;
f3 = 0;
f4 = 0;
f5 = 0;
c_1 = 0;
c_2 = 0;
c_3 = 0;
c_4 = 0;
c_5 = 0;


for i=1:K
f1 =abs(transpose(H(:,1))(F(:,i)))^2+f1;
f2 =abs(transpose(H(:,2))
(F(:,i)))^2+f2;
f3 =abs(transpose(H(:,3))(F(:,i)))^2+f3;
f4 =abs(transpose(H(:,4))
(F(:,i)))^2+f4;
f5 =abs(transpose(H(:,5))*(F(:,i)))^2+f5;

    c_1 =  sigma_SI*abs(G(:,1)'*(F(:,i))).^2+ c_1;
c_2 =  sigma_SI*abs(G(:,2)'*(F(:,i))).^2+ c_2;
c_3 =  sigma_SI*abs(G(:,3)'*(F(:,i))).^2+ c_3;
c_4 =  sigma_SI*abs(G(:,4)'*(F(:,i))).^2+ c_4;
c_5 =  sigma_SI*abs(G(:,5)'*(F(:,i))).^2+ c_5;


end
c1 = (trace(FF’)/P)sigma_nnorm(G(:,1)).^2 + (trace(FF’)/P)c_1;
c2 = (trace(F
F’)/P)sigma_nnorm(G(:,2)).^2 + (trace(FF’)/P)c_2;
c3 = (trace(F
F’)/P)sigma_nnorm(G(:,3)).^2 + (trace(F
F’)/P)c_3;
c4 = (trace(F
F’)/P)sigma_nnorm(G(:,4)).^2 + (trace(FF’)/P)c_4;
c5 = (trace(F
F’)/P)sigma_nnorm(G(:,5)).^2 + (trace(F
F’)/P)*c_5;
Gamma_Tk = [f1,f2,f3,f4,f5];
C = [c1,c2,c3,c4,c5];

a = [0.078;0.078;0.078;0.078;0.078];
w = zeros(1,length(a));
it = 1;
R_s(it) =0;

while 1
for k=1:length(a)
den = [abs(G(:,k)’*H(:,1)).^2, abs(G(:,k)’*H(:,2)).^2, abs(G(:,k)’*H(:,3)).^2, abs(G(:,k)’*H(:,4)).^2,abs(G(:,k)’*H(:,5)).^2 ] ;
w(k) = abs(G(:,k)’*H(:,k))*sqrt(a(k)Gamma_Tk(k))/(transpose(a)(transpose(Gamma_Tk.*den))-a(k)*Gamma_Tk(k)*abs(G(:,k)‘H(:,k)).^2+C(k));
end
it = it+1;
cvx_begin quite
variable b(K);
maximize log(1+2
w(1)*abs(G(:,1)’*H(:,1))sqrt(b(1)Gamma_Tk(1))-(w(1)^2)(transpose(b)(transpose(Gamma_Tk.*den))-b(1)*Gamma_Tk(1)*abs(G(:,1)‘H(:,1)).^2+C(1))) + …
log(1+2
w(2)*abs(G(:,2)’*H(:,2))sqrt(b(2)Gamma_Tk(2))-(w(2)^2)(transpose(b)(transpose(Gamma_Tk.*den))-b(2)*Gamma_Tk(2)*abs(G(:,2)‘H(:,2)).^2+C(2))) + …
log(1+2
w(3)*abs(G(:,3)’*H(:,3))sqrt(b(3)Gamma_Tk(3))-(w(3)^2)(transpose(b)(transpose(Gamma_Tk.*den))-b(3)*Gamma_Tk(3)*abs(G(:,3)‘H(:,3)).^2+C(3))) + …
log(1+2
w(4)*abs(G(:,4)’*H(:,4))sqrt(b(4)Gamma_Tk(4))-(w(4)^2)(transpose(b)(transpose(Gamma_Tk.*den))-b(4)*Gamma_Tk(4)*abs(G(:,4)‘H(:,4)).^2+C(4))) + …
log(1+2
w(5)*abs(G(:,5)’*H(:,5))sqrt(b(5)Gamma_Tk(5))-(w(5)^2)(transpose(b)(transpose(Gamma_Tk.*den))-b(5)*Gamma_Tk(5)*abs(G(:,5)’*H(:,5)).^2+C(5)))
subject to
0.01 <= b <= 1;
cvx_end

a = b;
R_s(it) = cvx_optval;
if ~( e>= (R_s(it)-R_s(it-1)) )
break;
end
`

end

Rate(itr,q) = R_s(it);
end
end
Final_Rate = mean(Rate);
figure;
plot(NN, Final_Rate,‘LineWidth’, 1.5)

The first part is just for the input and defining some parameters. I expand the summation in the algorithm since I’m dealing with 5 users. Sorry If my question is basic, but if the optimization problem failed in the previous iteration does that mean the optimal value of the problem cannot be obtained? What is the strategy in this case?

The strategy is the overall algorithm will fail.

Have you done the diagnosis I suggested in my previous post?

Yes, at the time of error all the coefficients are NAN!

You need to worry about whether the overall algorithm is reliable and converges, and the suitability of the input data and starting values. That is all out of scope of this forum; but there are some numbers in your code which look rather dubious.

I’ll try to figure out all the issues you mention. Thank you so much for your help.