W=[350,245;175,90;100,120;160,130;395,290;45,50;240,200;110,200];%地面用户位置
V=[270,70;130,240];%窃听者位置
X=10;%窃听者位置估计误差
Hu=120;He=110;%UAV高度
beta1=10^(-5);beta2=10^(-4);%信道条件
r=10^(-11);%自干扰因数
Pjam=0.1;Puavmax=1;Puemax=0.1;
B=10^(6);T=0.16;Dmin=60*8*1024;
o=10^(-14);%噪声功率
k=10^(-27);%功率消耗因数
D=[37*1024*8,49.69*8*1024,37.88*8*1024,34.64*8*1024];%卸载用户的任务总量
yita=[0.96,0.72,0.94,1];%卸载率
F=1000;%ibit所需CPU周期数
fmaxuav=2*10^(10);f0=2*10^(8);
fiu=fmaxuav/4;
rou=r*Pjam+o;
Pm=[0.05,0.05,0.05,0.05,0.02,0.02,0.02,0.02];
Pl=k*f0*f0*f0;
x=10;y=160;%合法UVA位置
hiu=zeros(1,8);
hiemax=zeros(2,8);
hkemin=zeros(2,8);
for i=1:8
hiu(i)=beta1/(Hu^2+(norm([x,y]-W(i,:)))^2);
for v=1:2
hiemax(v,i)=beta1/(He^2+(norm(W(i,:)-V(v,:))-X)^2);
hkemin(v,i)=beta1/(He^2+(norm(W(i,:)-V(v,:))+X)^2);
end
end
heuminv1=beta2/((Hu-He)^2+(norm([x,y]-V(1,:))+X)^2);
heuminv2=beta2/((Hu-He)^2+(norm([x,y]-V(2,:))+X)^2);
we1=Pjam*heuminv1+o;
we2=Pjam*heuminv2+o;
%-------------------------------------------------optimiaze----------------------------------------------
cvx_begin
variables p1 p2 p3 p4 p5 p6 p7 p8 C0 r0 ;
%--------------------------------------------------I4(i)----------------------------------
b1=hiu(2)*(p2-Pm(2))+hiu(3)*(p3-Pm(3))+hiu(4)*(p4-Pm(4))+hiu(5)*(p5-Pm(5))+hiu(6)*(p6-Pm(6))+hiu(7)*(p7-Pm(7))+hiu(8)*(p8-Pm(8));
a1=Pm(2)*hiu(2)+Pm(3)*hiu(3)+Pm(4)*hiu(4)+Pm(5)*hiu(5)+Pm(6)*hiu(6)+Pm(7)*hiu(7)+Pm(8)*hiu(8)+rou;
I41=log(a1)+b1/(a1*log(2));
b2=hiu(1)*(p1-Pm(1))+hiu(3)*(p3-Pm(3))+hiu(4)*(p4-Pm(4))+hiu(5)*(p5-Pm(5))+hiu(6)*(p6-Pm(6))+hiu(7)*(p7-Pm(7))+hiu(8)*(p8-Pm(8));
a2=Pm(1)*hiu(1)+Pm(3)*hiu(3)+Pm(4)*hiu(4)+Pm(5)*hiu(5)+Pm(6)*hiu(6)+Pm(7)*hiu(7)+Pm(8)*hiu(8)+rou;
I42=log(a2)+b2/(a2*log(2));
b3=hiu(1)*(p1-Pm(1))+hiu(2)*(p2-Pm(2))+hiu(4)*(p4-Pm(4))+hiu(5)*(p5-Pm(5))+hiu(6)*(p6-Pm(6))+hiu(7)*(p7-Pm(7))+hiu(8)*(p8-Pm(8));
a3=Pm(1)*hiu(1)+Pm(2)*hiu(2)+Pm(4)*hiu(4)+Pm(5)*hiu(5)+Pm(6)*hiu(6)+Pm(7)*hiu(7)+Pm(8)*hiu(8)+rou;
I43=log(a3)+b3/(a3*log(2));
b4=hiu(1)*(p1-Pm(1))+hiu(2)*(p2-Pm(2))+hiu(3)*(p3-Pm(3))+hiu(5)*(p5-Pm(5))+hiu(6)*(p6-Pm(6))+hiu(7)*(p7-Pm(7))+hiu(8)*(p8-Pm(8));
a4=Pm(1)*hiu(1)+Pm(2)*hiu(2)+Pm(3)*hiu(3)+Pm(5)*hiu(5)+Pm(6)*hiu(6)+Pm(7)*hiu(7)+Pm(8)*hiu(8)+rou;
I44=log(a4)+b4/(a4*log(2));
%----------------------------------------------------I5-----------------------------------------------------------------
cv1=0;cv2=0;
for i=1:8
cv1=cv1+Pm(i)*hkemin(1,i);
cv2=cv2+Pm(i)*hkemin(2,i);
end
cv1=cv2+we1;
cv2=cv2+we2;
% j=p1*hiu(1)+p2*hiu(2)+p3*hiu(3)+p4*hiu(4)+p5*hiu(5)+p6*hiu(6)+p7*hiu(7)+p8*hiu(8)+rou;
l=zeros(1,4);
for i=1:4
l(i)=D(i)*yita(i)/(B*(T-F*D(i)*yita(i)/fiu));
end
d1=hkemin(1,1)*(p1-Pm(1))+hkemin(1,2)*(p2-Pm(2))+hkemin(1,3)*(p3-Pm(3))+hkemin(1,4)*(p4-Pm(4))+hkemin(1,5)*(p5-Pm(5))+hkemin(1,6)*(p6-Pm(6))+hkemin(1,7)*(p7-Pm(7))+hkemin(1,8)*(p8-Pm(8));
d2=hkemin(2,1)*(p1-Pm(1))+hkemin(2,2)*(p2-Pm(2))+hkemin(2,3)*(p3-Pm(3))+hkemin(2,4)*(p4-Pm(4))+hkemin(2,5)*(p5-Pm(5))+hkemin(2,6)*(p6-Pm(6))+hkemin(2,7)*(p7-Pm(7))+hkemin(2,8)*(p8-Pm(8));
I511=log(Pm(1)*hiemax(1,1)+(cv1-Pm(1)*hkemin(1,1)))+(hiemax(1,1)*(p1-Pm(1))+(d1-hkemin(1,1)*(p1-Pm(1))))/((Pm(1)*hiemax(1,1)+cv1-Pm(1)*hkemin(1,1))*log(2));
I521=log(Pm(2)*hiemax(1,2)+(cv1-Pm(2)*hkemin(1,2)))+(hiemax(1,2)*(p2-Pm(2))+(d1-hkemin(1,2)*(p2-Pm(2))))/((Pm(2)*hiemax(1,2)+cv1-Pm(2)*hkemin(1,2))*log(2));
I531=log(Pm(3)*hiemax(1,3)+(cv1-Pm(3)*hkemin(1,3)))+(hiemax(1,3)*(p3-Pm(3))+(d1-hkemin(1,3)*(p3-Pm(3))))/((Pm(3)*hiemax(1,3)+cv1-Pm(3)*hkemin(1,3))*log(2));
I541=log(Pm(4)*hiemax(1,4)+(cv1-Pm(4)*hkemin(1,4)))+(hiemax(1,4)*(p4-Pm(4))+(d1-hkemin(1,4)*(p4-Pm(4))))/((Pm(4)*hiemax(1,4)+cv1-Pm(4)*hkemin(1,4))*log(2));
I512=log(Pm(1)*hiemax(2,1)+(cv2-Pm(1)*hkemin(2,1)))+(hiemax(2,1)*(p1-Pm(1))+(d2-hkemin(2,1)*(p1-Pm(1))))/((Pm(1)*hiemax(2,1)+cv2-Pm(1)*hkemin(2,1))*log(2));
I522=log(Pm(2)*hiemax(2,2)+(cv2-Pm(2)*hkemin(2,2)))+(hiemax(2,2)*(p2-Pm(2))+(d2-hkemin(2,2)*(p2-Pm(2))))/((Pm(2)*hiemax(2,2)+cv2-Pm(2)*hkemin(2,2))*log(2));
I532=log(Pm(3)*hiemax(2,3)+(cv2-Pm(3)*hkemin(2,3)))+(hiemax(2,3)*(p3-Pm(3))+(d2-hkemin(2,3)*(p3-Pm(3))))/((Pm(3)*hiemax(2,3)+cv2-Pm(3)*hkemin(2,3))*log(2));
I542=log(Pm(4)*hiemax(2,4)+(cv2-Pm(4)*hkemin(2,4)))+(hiemax(2,4)*(p4-Pm(4))+(d2-hkemin(2,4)*(p4-Pm(4))))/((Pm(4)*hiemax(2,4)+cv2-Pm(4)*hkemin(2,4))*log(2));
%--------------------------------------------------------------------------------------------------
maximize C0
subject to
log(p1*hiu(1)+p2*hiu(2)+p3*hiu(3)+p4*hiu(4)+p5*hiu(5)+p6*hiu(6)+p7*hiu(7)+p8*hiu(8)+rou)-I41-r0>=C0;
log(p1*hiu(1)+p2*hiu(2)+p3*hiu(3)+p4*hiu(4)+p5*hiu(5)+p6*hiu(6)+p7*hiu(7)+p8*hiu(8)+rou)-I42-r0>=C0;
log(p1*hiu(1)+p2*hiu(2)+p3*hiu(3)+p4*hiu(4)+p5*hiu(5)+p6*hiu(6)+p7*hiu(7)+p8*hiu(8)+rou)-I43-r0>=C0;
log(p1*hiu(1)+p2*hiu(2)+p3*hiu(3)+p4*hiu(4)+p5*hiu(5)+p6*hiu(6)+p7*hiu(7)+p8*hiu(8)+rou)-I44-r0>=C0;
I511-log(cv1-Pm(1)*hkemin(1,1))<=r0;
I521-log(cv1-Pm(2)*hkemin(1,2))<=r0;
I531-log(cv1-Pm(3)*hkemin(1,3))<=r0;
I541-log(cv1-Pm(4)*hkemin(1,4))<=r0;
I512-log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