The code is here:
clear all;
N=12;T=80;V=3;deta=T/N;h0=10^(-8);alpha=2.2;Ps=1;M=10;N0=10^(-15);Pj_average=1;Pj_k=0.9124;
q_r_0=[100,600];q_j_0=[100,600];q_r_sf=[100,-600];q_j_sf=[100,-600];
w_b=[0,0];w_u=[100,0];w_e=[200,0];
d_ju_0=norm(q_j_0-w_u);d_je_0=norm(q_j_0-w_e);d_b_0=norm(q_r_0-w_b);d_u_0=norm(q_r_0-w_u);d_e_0=norm(q_r_0-w_e);
g_ju=(h0*d_ju_0^(-alpha))^0.5;g_je=(h0*d_je_0^(-alpha))^0.5;
an=Ps*h0^2*M^2/N0/(d_b_0*d_u_0)^alpha;bn=(g_ju^2)/N0;cn=Ps*h0^2*(M^2)/N0/(d_b_0*d_e_0)^alpha;dn=(g_je^2)/N0;
% Pj=zeros(N,1);
for n=1:N
cvx_begin
variable Pj(N)
expression an
expression bn
expression cn
expression dn
expression sum
expression sum_pj
A=-an*bn/log(2)/(bn*Pj_k+1)/(bn*Pj_k+an+1);
R(n)=A*Pj(n)+log2(1-cn*inv_pos(dn*Pj(n)+1));
sum=0;sum_pj=0;
sum=sum+R(n);
sum_pj=sum_pj+Pj(n);
maximize (sum);
subject to
0<=sum_pj<=N*Pj_average;
0<=Pj(n)<=4*Pj_average;
cvx_end
Pj(n)=Pj(n);
cvx_begin
B=h0^2*M^2*Ps/(Pj(n)*g_ju^2+N0);
sum_trj=0;z_l=2;v_l=2;
variable q_r(N,2)
variable z(N)
variable v(N)
sum_trj=sum_trj+log2(1+B*inv_pos(z_l))-B.*(z(n)-z_l)/z_l/(z_l+B)/log(2)+log(1-B*inv_pos(v(n)));
d_b(n)=sum_square(q_r(n,:)-w_b);
d_u(n)=sum_square(q_r(n,:)-w_u);
d_e(n)=sum_square(q_r(n,:)-w_e);
maximize (sum_trj);
subject to
norm(q_r(1,:)-q_r_0)<=V*deta;
norm(q_r(n+1,:)-q_r(n,:))<=V*deta;
q_r(1,:)==q_r_0;
q_r(N,:)==q_r_sf;
z(n)^(2/alpha)>=0.5*((d_b(n)^2+d_u(n)^2)^2-(d_b_0^4+d_u_0^4))-2*d_b_0^2*(q_r_0-w_b)'*(q_r(n,:)-q_r_0)-2*d_u_0^2*(q_r_0-w_u)'*(q_r(n,:)-q_r_0);
v_l^(2/alpha)+2/alpha*v_l^(2/alpha-1)*(v(n)-v_l)<= ...
0.5*((d_b_0^2+d_e_0^2)^2-(d_b(n)^4+d_e(n)^4))+2*d_b_0^2*(2*q_r_0-w_b-w_e)'*(q_r(n,:)-q_r_0)+2*d_e_0^2*(2*q_r_0-w_b-w_e)'*(q_r(n,:)-q_r_0)
cvx_end
end
I want to realize Successive convex approximation.So the Pj is optimized first,Then, q_r,z(N),v(N)is optimized.But the error is "Conversion to double from cvx is not possible"in line “Conversion to double from cvx is not possible”.