Help!!!New person seeking help!

The first time using CVX to solve a convex optimization problem, I encountered an error and didn’t know how to modify it. The error message is as follows:
Disciplined convex programming error:
Cannot perform the operation: {real affine} .* {convex}
error: test (第 84 行)
R(k,j) = -1.*rel_entr(1,1+(U.*inv_pos(I)));

My code details are as follows:
cvx_begin quiet
cvx_solver mosek
variable p(K,J) nonnegative
expression R
decoding_order = reshape(currentOrder,J,K);
for k=1:K
for j=1:J
I = 0;
Currstream_order = decoding_order(j,k);
[intf_user_m,intf_user_l] = find(decoding_order > Currstream_order);
intf_user_idx = [intf_user_l intf_user_m];
if isempty(intf_user_idx)==0
for temp = 1:size(intf_user_idx,1)
l = intf_user_l(temp); m = intf_user_m(temp);
I = I + p(l,m).*square_abs(h(l).*w(l)) + sigma_2;
end
else
I = sigma_2;
end
U = p(k,j).*square_abs(h(k).*w(k));
R(k,j) = -1.*rel_entr(1,1+(U.*inv_pos(I)));
% R(k,j) = log(1 + inv_pos(interference).*useful).*inv_pos(log(2));
end
end
maximize sum(R)
subject to
sum(p) <= P_max;
cvx_end

R is the log of a linear fractional. Have you shown the problem is convex? If there were only one term in the objective, you could eliminate the log` and get an “equivalent” problem having the same argmax, and solve as a linear fractional problem. But that won’t work because your objective is the sum of log terms.

Also, you need to declare R as an expression of he correct dimensions. Although the program encountered an error before it would have encountered an error from the incorrect expression declaration.

I can write the objective function in the form of log (1+x) (calculating rate, x=SINR), while there is only one variable p in x (SINR), maximizing the sum rate is convex

If you can do it, then do it. Your code doesn’t do that. The argument of log is not affine as written, but appears to be a ratio of affine functions of the variable p.

Yes, it is the ratio of the affine function of variable p, but when optimizing p (k, j) on the numerator, p (l, m) on the denominator is theoretically known.

What does that mean? Either it’s known, i.e., input data, or it’s not. As written, both the numerator and denominator are CVX expressions i.e., involve optimization variables, and are not input data.

Please re-read the link more carefully, including the discussion about proving the optimization problem is convex.