Hi.I writting my optimization problem in cvx and running that but i had a error .I attached the program and thats error.please if it is possible help me. I want to transform the objective function to satisfy the constraints of CVX. But I don’t know how to do it.
cvx_begin quiet
variables sm_h(NUM_DUG,NUM_RB) sm_BS(NUM_DUG,NUM_RB) T_h(NUM_DUG,NUM_RB) T_BS(NUM_DUG,NUM_RB)
expressions t_ave
t_ave=0;
for i=1:NUM_DUG
for j=1:NUM_RB
t_ave=t_ave+BW*T_h(i,j)*log2(1+sm_h(i,j)./T_h(i,j).H_D_yong(i,j))…
+BWT_BS(i,j)*log2(1+sm_BS(i,j)./T_BS(i,j).H_B_yong(i,j))…
-lanmuda(sm_h(i,j)+sm_BS(i,j));
end
end
maximize t_ave%+penalty*s
subject to
T_h>=0;
T_h<=1;
T_BS>=0;
T_BS>=0;
sm_h>=0;
sm_h<=Pt_Dm;
sm_BS>=0;
sm_BS<=Pt_Bm;
cvx_end
The error message is as follows:
Disciplined convex programming error:
Cannot perform the operation: {real affine} ./ {real affine}
Error in ./ (line 19)
z = times( x, y, ‘./’ );
Error in cvx_lianhe_821 (line 48)
t_ave=t_ave+BW*T_h(i,j)*log2(1+sm_h(i,j)./T_h(i,j).*H_D_yong(i,j))…
I believe you can re-write this in terms of rel_entr as follows:
Use -rel_entr(x,x+y)/log(2), which is concave and accepted by CVX in place of x*log2(1+y/x) .
I leave the details to you, but this is the basic construct which you should be able to use.
I recommend you don’t use the quiet option until everything is working well and you are confident in the solutions.
I further recommend that you install CVXQUAD, including its exponential.m. replacement, as described in my answer at Failed status and optimal value NAN in convex problem . No further modifications to your program should be required for CVXQUAD to be invoked given that rel_entr is being used
Thanks for your kind and helpful advises.
I have a new error. Is this because there are too many variables?
cvx_begin
variables sm_h(NUM_DUG,NUM_RB) sm_BS(NUM_DUG,NUM_RB) T_h(NUM_DUG,NUM_RB) T_BS(NUM_DUG,NUM_RB)
objfunc=cvx(zeros(NUM_DUG,NUM_RB));
expressions term1 term2
for i=1:NUM_DUG
for j=1:NUM_RB
objfunc(i,j)=BW*rel_entr(T_h(i,j),sm_h(i,j)*H_D_yong(i,j))/log(2)...
+BW*rel_entr(T_BS(i,j),sm_BS(i,j)*H_B_yong(i,j))/log(2)...
-lanmuda*(sm_h(i,j)+sm_BS(i,j));
end
end
maximize sum(sum(objfunc))
subject to
term1=0;
for i=1:NUM_DUG
for j=1:NUM_RB
term1=term1+BW*rel_entr(T_h(i,j),sm_h(i,j)*H_D_yong(i,j))/log(2);
end
end
bai*Size_VI/100000-term1<=0;
term2=0;
for i=1:NUM_DUG
for j=1:NUM_RB
term2=term2+BW*rel_entr(T_BS(i,j),sm_BS(i,j)*H_B_yong(i,j))/log(2);
end
end
(1-bai)*Size_VI/100000-term2<=0;
T_h>=0;
T_h<=1;
T_BS>=0;
T_BS>=0;
sm_h>=0;
sm_h<=Pt_Dm;
sm_BS>=0;
sm_BS<=Pt_Bm;
cvx_end
Error in cvxprob/newobj (line 57)
Disciplined convex programming error:
Cannot maximize a(n) convex expression.
Error in maximize (line 21)
newobj( prob, ‘maximize’, x );
Error in cvx_lianhe_828 (line 21)
maximize sum(sum(objfunc))
Error in main_lianhe (line 100)
cvx_lianhe_828;
You forgot the minus sign before each instance of rel_entr .
Thank you very much for your help.