ERROR! Invalid operation: {real affine} / {real affine}


#1
B1=24e3
B2=24e3
cvx_begin
variable a(2)
variable b(2)
R1= a(1)*B1 + 60000*b(1)*log2(1 +((7.48e3)*(0.7-a(1))*(133.736e-6)/(b(1))));
R2= a(2)*B2 + 60000*b(2)*log2(1 +((7.48e3)*(0.7-a(2))*(133.736e-6)/(b(2))));
maximize(R1 + R2)
 subject to
   sum(a)<= 0.7
   sum(b) <= 0.3
   a >= 0
   b >= 0
cvx_end

(R1 + R2) are concav function but I get this error. What can I do. thank you…


(Mark L. Stone) #2

Use
log2(x) = log(x)/log(2)
to re-write log2 in terms of log

Use the relation
X*log(1+y/x) = -rel_entr(x,x+y)
to reformulate R1 and R2 in terms of rel_entr.

I recommend you install CVXQUAD to solve it more reliably. CVXQUAD: How to use CVXQUAD's Pade Approximant instead of CVX's unreliable Successive Approximation for GP mode, log, exp, entr, rel_entr, kl_div, log_det, det_rootn, exponential cone. CVXQUAD's Quantum (Matrix) Entropy & Matrix Log related functions


#3

Thank you so much. I did as you said and my code worked without errors