# A concave maximization problem with Disciplined convex programming error: {invalid} .* {real affine} or {negative constant} .* {real affine}

Hi,*
I have checked that the problem is sure to be concave. For some parameters, it works well. However, when I try to change some parameters to another, it displays like the error. Could you please help me for this?
Disciplined convex programming error:
Cannot perform the operation: {invalid} .* {real affine}*
or
Disciplined convex programming error:
Cannot perform the operation: {negative constant} . {real affine}*

ps: i have read the DCP ruleset and know it well. This is also I use “rel_entr” function in the code. But I just can not solve the above. Thanks.

``````for i=1:5

cvx_begin
variable p0(n)
variable b(i)
variable x(i)
variable w(i)
variable y(i)
maximize ( ( sum( b0.*log(1+ p0.*g0./b0) ) - sum( rel_entr(b,x) ) ) ...
- u*(  sum( p0 )/xi + sum( (x-b)./g )/xi   +  sum( (y-w)./h )/xi  + p_c )  )
subject  to
zeros(n,1) <= p0;
zeros(i,1) <= b;
zeros(i,1) <= ( x - b )./g;
zeros(i,1) <= w;
zeros(i,1) <= ( y-w )./h;

sum( p0 ) + sum( (x-b)./g ) + sum( (y-w)./h ) <= P_max;
b + w <= W_max.*index;
-rel_entr(w,y) >= mu_rmin.*index;
cvx_end
num_dink=num_dink+1;
if cvx_optval<=tolerance
break;
else
u = ( sum( b0.*log(1+ p0.*g0./b0) ) - sum( rel_entr(b,x) ) )...
/( sum( p0 )/xi + sum( (x-b)./g )/xi   +  sum( (y-w)./h )/xi  + p_c );
end
``````

disp(’%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%’)
disp(['try to selecte MU ', num2str(i)])
disp(['the previous SC system EE: ', num2str(ee_sc_temp)])
disp([‘the updated SC system EE: ‘, num2str(ee_sc_update)])
disp(’%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%’)
Error using cvx/times (line 173)
Disciplined convex programming error:
Cannot perform the operation: {negative constant} .* {real affine}

Error in cvx/mtimes (line 36)
z = feval( oper, x, y );

Error in EE10_power_saving (line 176)
maximize ( ( sum( b0.*log(1+ p0.*g0./b0) ) - sum( rel_entr(b,x) ) ) …

This is another display in the command window:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
try to selecte MU 1
the previous SC system EE: 2498634.153
the updated SC system EE: 2561509.6624
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
try to selecte MU 2
the previous SC system EE: 2561509.6624
the updated SC system EE: 2617537.04
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
try to selecte MU 3
the previous SC system EE: 2617537.04
the updated SC system EE: 2666679.5159
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
try to selecte MU 4
the previous SC system EE: 2666679.5159
the updated SC system EE: 2708451.445
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Error using cvx/times (line 173)
Disciplined convex programming error:
Cannot perform the operation: {invalid} .* {real affine}

Error in cvx/mtimes (line 36)
z = feval( oper, x, y );

Error in EE10_power_saving (line 176)
maximize ( ( sum( b0.*log(1+ p0.*g0./b0) ) - sum( rel_entr(b,x) ) ) …

As we can see that in “try to selecte MU 1” “try to selecte MU 2” “try to selecte MU 3” “try to selecte MU 4”, the code works well, but shows a error for “try to selecte MU 5”

I would make absolutely sure that you don’t have some `NaN` or `Inf` values in there.

Thanks for your kind reply. Could you explain “you don’t have some NaN or Inf values in there.”? Actually, I found that the cvx tool in solving the above problem is not stable. I just can not understand why for some parameters, the code does not work. Could you give any more comment?

And also, even the same code, when it runs in the different computers, there are also some errors like the above.

Highly appreciate your help

If possible, I can also send you the code for your text. I’m currently pursuing the PHD degree in Georgia Tech.

I also consulted some other cvx users that the same code may not work well under different versions of matlab.

What I am saying is that some of the numeric quantities inside your model, such as `u`, have invalid values, either `Inf` or `NaN`. I obviously don’t know this for sure, but these kinds of errors do tend to come up in such cases.

The initial value of u is zero. Moreover, ‘u’ is updated by

( sum( b0.*log(1+ p0.*g0./b0) ) - sum( rel_entr(b,x) ) )…
/( sum( p0 )/xi + sum( (x-b)./g )/xi + sum( (y-w)./h )/xi + p_c );

which is actually a transformation of the objective function.

This is a code to solve problem: max (a/b), with its equivalent form: max (a-u*b) where ‘u’ is updated by (a/b) in each iteration. So, I do not know why ‘u’ would become a NAN or Inf.

Why don’t you use rel_entr for the first part of that line too ?

Yes, I can. But b0 is not a optimization variable, it is not necessary to use like that. I think it is the accuracy problem of the cvx tool.