%%Problem
maximize a1log2(1+b1sinr_r)+a2log2(1+b2sinr_t)
s.t. p<=10
a1+a2=1

%% code
noise=-170+10.*log10(180.*1e3);
sigma =10.^((noise)/10);
sinr_r=(abs(H1))^2/sigma;
sinr_t=(abs(H2))^2/sigma;
%%
cvx_begin
variable a1(1)
variable a2(1)
%variable b1
%variable b2
variable p(1)
b1=prod_inv([a1 p]);
b2=prod_inv([a2 p]);
y1=b1.*sinr_r;
y2=b2.*sinr_t;
rate_r=-rel_entr(a1,a1+y1);
rate_t=-rel_entr(a2,a2+y2);
rate=rate_r+rate_t;
maximize(rate)
subject to
p<=10;
a1+a2==1;
cvx_end

%% wrong

pa_good
CVX Warning:
Models involving “rel_entr” or other functions in the log, exp, and entropy
family are solved using an experimental successive approximation method.
This method is slower and less reliable than the method CVX employs for
other models. Please see the section of the user’s guide entitled
The successive approximation method
for more details about the approach, and for instructions on how to
suppress this warning message in the future.

Disciplined convex programming error:
Illegal operation: rel_entr( {real affine}, {convex} ).

rate_r=-rel_entr(a1,a1+y1);

As noted in mu answer 如何编写xlog（1+y/x） - #2 by Mark_L_Stone the 2nd argument of `rel_entr` must be concave. It is not allowed to be convex (except if it is affine, which is a special case of both concave and convex).

I’m not sure exactly what you’re trying to do, but it looks like y1 is a constant divided by a1. Therefore rate_r is basically modeling `constant1*a1*log(1+constant2/a1^2)`, which is neither convex nor concave.

If this is not what you are trying to do, your first step is to prove your optimization problem is convex, if in fact it is.

But if you really are trying to do something like `x*log((1+y/x)` where x and y are both variables (not some other expressions), you can use `-rel_entr(x,x+y)`.

Thank you very much! This has helped me a lot,I will try it again.