I want to solve a simple convex problem that minimizes the power of transmitting devices. I have a supposed that there are 10 devices each communicating with another device. But, when I run the program it gives me this error:

Error using .* (line 173)
Disciplined convex programming error:
Cannot perform the operation: {concave} ./ {real affine}
Error in ./ (line 19)
z = times( x, y, ‘./’ );
Error in testcode4 (line 36)
Rate(i,j) = W*(log(1+(p(i)((distance(i,j)).^(-pathloss)))./log(2))./((NSDW)+I_D(i,j)));

How can I convert the denominator term in the Rate expression, so that the Rate expression can be solved?

distance = rand(10,10);
Rate_min = ones(10,10);
Power_total = 10;
W = 1;
NSD = 1;
pathloss = 1;
cvx_begin
variable p(10,1) nonnegative
minimize norm(p)
subject to
for i = 1:10
for j = 1:10
I_D(i,j) = (p(j))*((distance(i,j)).^(-pathloss));
Rate(i,j) = W*(log(1+(p(i)*((distance(i,j)).^(-pathloss)))./log(2))./((NSD*W)+I_D(i,j)));
end
end
sum(p) <= Power_total;
cvx_end

As per one of the suggestions I gave you at Conversion to double from cvx is not possible , remove all instances of Rate and instead use log(1+(p(i)*((distance(i,j)).^(-pathloss)))) >= Rate_min(i,j)
except that now that you have a denominator term on the left-hand side, move it to the right-hand side (as a multiplicative term), where it will be affine, and therefore accepted by CVX (you can put log(2) where you want).

Or you can change Rate(i,j) to not include the denominator, and proceed in the obvious manner based on the above to include the denominator term as a multiplicative term in the right-hand side of the inequality.

Hi,
I have a kind of similar problem to solve with the constraint here being my objective function. Please advice me if there is a way to solve it in CVX. Its given the same error’'can not perform concave /affine.
max w.r.t p log(A+Bx)/(x+C), where all A,B,C are positive constants.
such that 0<x<1000,

No. The convexity status depends on the values of the constants.

For example, at A = B = C = x = 1, the 2nd derivative is negative. But at A =2, B = C = x = 1, the 2nd derivative is positive.

Please read Why isn't CVX accepting my model? READ THIS FIRST! . You shouldn’t rely on forum readers to do your basic homework of verifying the convexity of your problem before asking for assistance in how to enter it into CVX.

Hello, I’m sorry to disturb you, I also encountered the same error message when I used cvx to solve my problem. Could you please help me suggest how to modify my expression? Thank you very much.
Part of the code in my program is as follows：

cvx_begin
variable t(K);
variable p(K,N);
% J1=0;
% J2=0;
J=0;
expression J_0(1,K);
expression J_1(1,K);
expression J_2(1,K);
expression J_3(1,K);
expression J_4(1,K);
% expression m(1,N);
% expression l_m(1,N);
expression Ra_temp(K,N);
expression Ra(1,K);
for k=1:K
for n=1:N
Ra_temp(k,n)=log(1+(p(k,n)*h(k,n))/(N0*B/N))/log(2);
end
end
Ra=(B/N)*sum(Ra_temp,2);
for k=1:K
**J_0(k)=t(k)*Ra(k);**%offloading bit
J_1(k)=R(k)-J_0(k);%local computing bit
J_2(k)=t(k)*M(k);%energy consumpion of offloading per user
J_3(k)=J_1(k)*C(k)*P(k);%energy consumpion of local computing per user
J_4(k)=J_3(k)+J_2(k);
end

and the error message as follows:
错误使用 .* (line 173)
Disciplined convex programming error:
Cannot perform the operation: {real affine} .*
{concave}

Have you proven this is a convex problem? it looks like you have something which in simplified terms is basically t*log(1+p), where t and p are both optimization variables, which would be neither convex nor concave,

Hello, I am sorry to disturb you again, I have given up the previous optimization problem and established a new optimization model. But the first constraint in this new problem still exists in the form. In order to make it a concave function, I introduced a new variable E to represent the product of the original variable t and p, because r(x) itself is a Concave function, so its projection function x*r(y/x) should also be concave when y>=0 and t>0, right? But this constraint always reports different errors in cvx. Is it because there are restrictions on the interval of the independent variable?Looking forward to receiving your reply, thank you very much

And my optimization model is shown below:

Below is part of my program code ：

cvx_begin
variables E(K,1) t(K,1) l(K,1);
% expression midifier_1(K,1);
for k=1:K
J=J+E(k)+pow_abs(l(k)*c(k),3)*pow_p(T,-2);
end
minimize(J)
subject to
for k=1:K
% E(k)>=0;
% t(k)>=0.0001;
(R(k)-l(k))*log(2)/(B_real(k))<=(t(k)*log(1+(E(k)*inv_pos(t(k))*alpha_opt(k))));
0<=E(k)<=(t(k)*p_max(k));
0<=t(k)<=T;
l(k)<=(T*f_max(k)/c(k));
0<=l(k)<=R(k);
end
sum(t)<=T;
cvx_end

And the error message is as follows
错误使用 .* (line 173)
Disciplined convex programming error:
Cannot perform the operation: {real affine} .* {convex}

BTW, I think if you change the occurrences of / and *
to ./ and .*
and remove all the (k)
including in the rel_entr code I showed,
you can remove the for loop in the constraints, but keep its contents, adjusted as I indicated.

OK, got it! thank you very much! This is the first time I know this formula in cvx. After replacing the right part of the inequality with the formula you suggested, cvx no longer reports an error, but matlab will report the following error:

The function’vec’ corresponding to the input parameter of type’double’ is not defined.

After checking other people’s solutions on the Internet, I moved vec.m in MATLAB to the folder where the current running file is located, but another error will be prompted:

The structure content is referenced from a non-structure array object.

I still don’t know how to solve it. Do you have any suggestions? Many thanks!