Top Banner
%Generic Algorithm for function f(x1,x2,x3,........) optimum UAV Trajectories Allocation over Different Intruder Paths with Random Starting Points. Dx_Time=0; Dx10_Time=0; Dx20_Time=0; Dx30_Time=0; Dx4_Time=0; Dx0_Time=0; Dx11_Time=0; Dx21_Time=0; Dx31_Time=0; Dx41_Time=0; Dx1_Time=0; Dx12_Time=0; Dx22_Time=0; Dx32_Time=0; Dx42_Time=0; Dx2_Time=0; Dx13_Time=0; Dx23_Time=0; Dx33_Time=0; Dx43_Time=0; Dx3_Time=0; Dx14_Time=0; Dx24_Time=0; Dx34_Time=0; Dx44_Time=0; %Parameters mar=40; mar1=50; mar2=50; Size=40; G=5; CodeL=10; W0_max=20000/2; W0_min=10000/2; W1_max=20000/2; W1_min=10000/2; W2_max=20000/2; W2_min=10000/2;
48

Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

Jan 14, 2017

Download

Design

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

%Generic Algorithm for function f(x1,x2,x3,........) optimum UAV Trajectories Allocation over Different Intruder Paths with Random Starting Points. Dx_Time=0;Dx10_Time=0;Dx20_Time=0;Dx30_Time=0;Dx4_Time=0;Dx0_Time=0;Dx11_Time=0;Dx21_Time=0;Dx31_Time=0;Dx41_Time=0;Dx1_Time=0;Dx12_Time=0;Dx22_Time=0;Dx32_Time=0;Dx42_Time=0;Dx2_Time=0;Dx13_Time=0;Dx23_Time=0;Dx33_Time=0;Dx43_Time=0;Dx3_Time=0;Dx14_Time=0;Dx24_Time=0;Dx34_Time=0;Dx44_Time=0; %Parametersmar=40;mar1=50;mar2=50;Size=40; G=5; CodeL=10; W0_max=20000/2; W0_min=10000/2; W1_max=20000/2; W1_min=10000/2; W2_max=20000/2; W2_min=10000/2; W3_max=20000/2; W3_min=10000/2; W4_max=20000/2; W4_min=10000/2; L0_max=100000/2; L0_min=20000/2;

Page 2: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

L1_max=100000/2; L1_min=20000/2; L2_max=100000/2; L2_min=20000/2; L3_max=100000/2; L3_min=20000/2; L4_max=100000/2; L4_min=20000/2; th0_max=pi/3; th0_min=-pi/3; th1_max=pi/3; th1_min=-pi/3; th2_max=pi/3; th2_min=-pi/3; th3_max=pi/3; th3_min=-pi/3; th4_max=pi/3; th4_min=-pi/3; lat0_max=80000; lat0_min=0; lat1_max=80000; lat1_min=0; lat2_max=80000; lat2_min=0; lat3_max=80000; lat3_min=0; lat4_max=80000; lat4_min=0; long0_max=30000; long0_min=10000; long1_max=30000; long1_min=10000; long2_max=30000; long2_min=10000; long3_max=30000; long3_min=10000; long4_max=30000; long4_min=10000; E=round(rand(Size,25*CodeL)); %Initial Code %Main Program

Page 3: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

for k=1:1:G hhh=k time(k)=k; for s=1:1:Size ssss=s clear RTG RTYG RTG1 RTYG1 RTG2 RTYG2 RTG3 RTYG3 RTG4 RTYG4 clear y1=0 y2=0 y3=0 y4=0 y5=0 y6=0 y7=0 y8=0 y9=0 y10=0 y11=0 y12=0 y13=0 y14=0 y15=0 y16=0 y17=0 y18=0 y19=0 y20=0 y21=0 y22=0 y23=0 y24=0 y25=0 m=E(s,:);y1=0;y2=0;y3=0;y4=0;y5=0;y6=0;y7=0;y8=0;y9=0;y10=0;y11=0;y12=0;y13=0;y14=0;y15=0;y16=0;y17=0;y18=0;y19=0;y20=0;y21=0;y22=0;y23=0;y24=0;y25=0; %Uncodingm1=m(1:1:CodeL);for i=1:1:CodeL y1=y1+m1(i)*2^(i-1);endW0=2*round((W0_max-W0_min)*y1/1023+W0_min); m2=m(CodeL+1:1:2*CodeL);for i=1:1:CodeL y2=y2+m2(i)*2^(i-1);endW1=2*round((W1_max-W1_min)*y2/1023+W1_min); m3=m(2*CodeL+1:1:3*CodeL);for i=1:1:CodeL y3=y3+m3(i)*2^(i-1);endW2=2*round((W2_max-W2_min)*y3/1023+W2_min); m4=m(3*CodeL+1:1:4*CodeL);for i=1:1:CodeL y4=y4+m4(i)*2^(i-1);endW3=2*round((W3_max-W3_min)*y4/1023+W3_min); m5=m(4*CodeL+1:1:5*CodeL);for i=1:1:CodeL y5=y5+m5(i)*2^(i-1);endW4=2*round((W4_max-W4_min)*y5/1023+W4_min);

Page 4: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

m6=m(5*CodeL+1:1:6*CodeL);for i=1:1:CodeL y6=y6+m6(i)*2^(i-1);endL0=2*round((L0_max-L0_min)*y6/1023+L0_min); m7=m(6*CodeL+1:1:7*CodeL);for i=1:1:CodeL y7=y7+m7(i)*2^(i-1);endL1=2*round((L1_max-L1_min)*y7/1023+L1_min); m8=m(7*CodeL+1:1:8*CodeL);for i=1:1:CodeL y8=y8+m8(i)*2^(i-1);endL2=2*round((L2_max-L2_min)*y8/1023+L2_min); m9=m(8*CodeL+1:1:9*CodeL);for i=1:1:CodeL y9=y9+m9(i)*2^(i-1);endL3=2*round((L3_max-L3_min)*y9/1023+L3_min); m10=m(9*CodeL+1:1:10*CodeL);for i=1:1:CodeL y10=y10+m10(i)*2^(i-1);endL4=2*round((L4_max-L4_min)*y10/1023+L4_min); m11=m(10*CodeL+1:1:11*CodeL);for i=1:1:CodeL y11=y11+m11(i)*2^(i-1);endth0=(th0_max-th0_min)*y11/1023+th0_min; m12=m(11*CodeL+1:1:12*CodeL);for i=1:1:CodeL y12=y12+m12(i)*2^(i-1);endth1=(th1_max-th1_min)*y12/1023+th1_min; m13=m(12*CodeL+1:1:13*CodeL);for i=1:1:CodeL y13=y13+m13(i)*2^(i-1);end

Page 5: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

th2=(th2_max-th2_min)*y13/1023+th2_min; m14=m(13*CodeL+1:1:14*CodeL);for i=1:1:CodeL y14=y14+m14(i)*2^(i-1);endth3=(th3_max-th3_min)*y14/1023+th3_min; m15=m(14*CodeL+1:1:15*CodeL);for i=1:1:CodeL y15=y15+m15(i)*2^(i-1);endth4=(th4_max-th4_min)*y15/1023+th4_min; m16=m(15*CodeL+1:1:16*CodeL);for i=1:1:CodeL y16=y16+m16(i)*2^(i-1);endlat0=(lat0_max-lat0_min)*y16/1023+lat0_min; m17=m(16*CodeL+1:1:17*CodeL);for i=1:1:CodeL y17=y17+m17(i)*2^(i-1);endlat1=(lat1_max-lat1_min)*y17/1023+lat1_min; m18=m(17*CodeL+1:1:18*CodeL);for i=1:1:CodeL y18=y18+m18(i)*2^(i-1);endlat2=(lat2_max-lat2_min)*y18/1023+lat2_min; m19=m(18*CodeL+1:1:19*CodeL);for i=1:1:CodeL y19=y19+m19(i)*2^(i-1);endlat3=(lat3_max-lat3_min)*y19/1023+lat3_min; m20=m(19*CodeL+1:1:20*CodeL);for i=1:1:CodeL y20=y20+m20(i)*2^(i-1);endlat4=(lat4_max-lat4_min)*y20/1023+lat4_min; m21=m(20*CodeL+1:1:21*CodeL);for i=1:1:CodeL y21=y21+m21(i)*2^(i-1);endlong0=(long0_max-long0_min)*y21/1023+long0_min; m22=m(21*CodeL+1:1:22*CodeL);

Page 6: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

for i=1:1:CodeL y22=y22+m22(i)*2^(i-1);endlong1=(long1_max-long1_min)*y22/1023+long1_min; m23=m(22*CodeL+1:1:23*CodeL);for i=1:1:CodeL y23=y23+m23(i)*2^(i-1);endlong2=(long2_max-long2_min)*y23/1023+long2_min; m24=m(23*CodeL+1:1:24*CodeL);for i=1:1:CodeL y24=y24+m24(i)*2^(i-1);endlong3=(long3_max-long3_min)*y24/1023+long3_min; m25=m(24*CodeL+1:1:25*CodeL);for i=1:1:CodeL y25=y25+m25(i)*2^(i-1);endlong4=(long4_max-long4_min)*y25/1023+long4_min; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%P=0;F_P=0;for P=1:1:50P=P+1;%%%%%Intruder trajectory determinationTs=1;IT_v=15;ds=Ts*IT_v; shift_x=rand(1)*20000;shift_x1=rand(1)*20000;shift_x2=rand(1)*20000;shift_x3=rand(1)*20000;shift_x4=rand(1)*20000;shift_x5=rand(1)*20000; shift_y=5000;shift_y1=20000;shift_y2=45000;shift_y3=55000;shift_y4=80000;shift_y5=93000; a=0.0001;b=0.0001;c=0.0001;

Page 7: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

d=4000;e=4000;g=4000; x0=0;y0=0;f0=0;x(1)=rand(1)*20000;f(1)=d*sin(a*x(1))+shift_y;f1(1)=d*sin(a*x(1))+shift_y; x01=0;y01=0;f01=0;x1(1)=rand(1)*20000;f01(1)=e*sin(b*x1(1))+shift_y1;f11(1)=e*sin(b*x1(1))+shift_y1; x02=0;y02=0;f02=0;x2(1)=rand(1)*20000;f02(1)=g*sin(c*x2(1))+shift_y2;f12(1)=g*sin(c*x2(1))+shift_y2; x03=0;y03=0;f03=0;x3(1)=rand(1)*20000;f03(1)=d*cos(a*x3(1))+shift_y3;f13(1)=d*cos(a*x3(1))+shift_y3; x04=0;y04=0;f04=0;x4(1)=rand(1)*20000;f04(1)=e*cos(b*x4(1))+shift_y4;f14(1)=e*cos(b*x4(1))+shift_y4; x05=0;y05=0;f05=0;x5(1)=rand(1)*20000;f05(1)=g*cos(c*x5(1))+shift_y5;f15(1)=g*cos(c*x5(1))+shift_y5;

Page 8: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

for i=1:1:4000 df=a*d*cos(a*x(i)); dx=cos(atan(df))*ds; x(i+1)=x(i)+dx; f(i+1)=d*sin(a*(i)); f1(i+1)=d*sin(a*x(i+1))+shift_y; df1=b*e*cos(b*x1(i)); dx1=cos(atan(df1))*ds; x1(i+1)=x1(i)+dx1; f01(i+1)=e*sin(b*(i)); f11(i+1)=e*sin(b*x1(i+1))+shift_y1; df2=c*g*cos(c*x2(i)); dx2=cos(atan(df2))*ds; x2(i+1)=x2(i)+dx2; f02(i+1)=g*sin(c*(i)); f12(i+1)=g*sin(c*x2(i+1))+shift_y2; df3=-a*d*sin(a*x3(i)); dx3=cos(atan(df3))*ds; x3(i+1)=x3(i)+dx3; f03(i+1)=d*cos(a*(i)); f13(i+1)=d*cos((a*x3(i+1)))+shift_y3; df4=-b*e*sin(b*x4(i)); dx4=cos(atan(df4))*ds; x4(i+1)=x4(i)+dx4; f04(i+1)=e*cos(b*(i)); f14(i+1)=e*cos((b*x1(i+1)))+shift_y4; df5=-c*g*sin(c*x5(i)); dx5=cos(atan(df5))*ds; x5(i+1)=x5(i)+dx5; f05(i+1)=g*cos(c*(i)); f15(i+1)=g*cos((c*x5(i+1)))+shift_y5; end u=0:1:99;

Page 9: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

%plot(x+shift_x,f1+shift_y,x1+shift_x1,f11+shift_y1,x2+shift_x2,f12+shift_y2,x3+shift_x3,f13+shift_y3,x4+shift_x4,f14+shift_y4,x5+shift_x5,f15+shift_y5)%plot(x,f1,x1,f11,x2,f12,x3,f13,x4,f14,x5,f15)%plot(u,f,x,f1) RT0_x0=0; RT1_x0=0; RT2_x0=0; RT3_x0=0; RT4_x0=0; RT5_x0=0; RT0_y0=0; RT1_y0=0; RT2_y0=0; RT3_y0=0; RT4_y0=0; RT5_y0=0; RT0_v=35; RT1_v=35; RT2_v=35; RT3_v=35; RT4_v=35; RT5_v=35; RT0_D=RT0_v*Ts; RT1_D=RT1_v*Ts; RT2_D=RT2_v*Ts; RT3_D=RT3_v*Ts; RT4_D=RT4_v*Ts; RT5_D=RT5_v*Ts; R0=W0/2;R1=W1/2;R2=W2/2;R3=W3/2;R4=W4/2; Q0=L0/2;Q1=L1/2;Q2=L2/2;Q3=L3/2;Q4=L4/2; RTG=0; RTG1=0; RTG2=0; RTG3=0; RTG4=0; for W=1:1:4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Next location on the first flight path if RT0_y0>=0

Page 10: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

KK=0; T=length(RTG); while Q0-RT0_x0>0.1 && RT0_x0+Q0>0.1|| -RT0_x0+Q0<0.1 KK=KK+1; if RT0_x0>=0 && RT0_x0<=(Q0-R0) RT0_xn=RT0_x0-RT0_D; RT0_yn=R0; else if RT0_x0<0 && RT0_x0>(Q0-R0)*(-1) if (RT0_x0+(Q0-R0))<=mar RT0_xn=-1*(Q0-R0); RT0_yn=R0; else RT0_xn=RT0_x0-RT0_D; RT0_yn=R0; end else if RT0_x0>(Q0-R0) && RT0_x0<Q0 if (RT0_x0-(Q0-R0))<=mar1 RT0_xn=(Q0-R0); RT0_yn=R0; else RT0_xn= R0*cos((RT0_D/R0)+acos(((RT0_x0)-(Q0-R0))/R0))+(Q0-R0); RT0_yn=((R0)^2-(RT0_xn-(Q0-R0))^2)^0.5; end else if RT0_x0<=(-1)*(Q0-R0) && RT0_x0>-Q0 RT0_xn= -R0*cos(((-1)*RT0_D/R0)+acos((((-1)*RT0_x0)-(Q0-R0))/R0))-(Q0-R0); RT0_yn=((R0)^2-((-RT0_xn)-(Q0-R0))^2)^0.5; else end end

Page 11: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

end end RT0_x0=RT0_xn; RT(KK)=RT0_xn; RTY(KK)=RT0_yn; RTG(T+KK-1)=RT(KK); RTYG(T+KK-1)=RTY(KK); RTG(T+KK-1)=(RTG(T+KK-1)*cos(th0)-RTYG(T+KK-1)*tan(th0)*cos(th0))+long0; RTYG(T+KK-1)=(RTG(T+KK-1)*cos(th0)-RTYG(T+KK-1)*tan(th0)*cos(th0))*tan(th0)+RTYG(T+KK-1)/cos(th0)+lat0; if RT0_yn<mar RT0_y0=-1; else end end elseif RT0_y0<0 T=length(RTG);KK=0; while (Q0-RT0_x0>0.1 && RT0_x0+Q0>0.1)|| RT0_x0+Q0<0.1 % for KK=1:1:2928 KK=KK+1; if RT0_x0>=0 && RT0_x0<=(Q0-R0) if (RT0_x0+(Q0-R0))<=mar RT0_xn=(Q0-R0); RT0_yn=-R0; else RT0_xn=RT0_x0+RT0_D; RT0_yn=-R0; end else

Page 12: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

if RT0_x0<0 && RT0_x0>=(Q0-R0)*(-1) RT0_xn=RT0_x0+RT0_D; RT0_yn=-R0; else if RT0_x0>=(Q0-R0) && RT0_x0<Q0 RT0_xn= R0*cos((-RT0_D/R0)+acos(((RT0_x0)-(Q0-R0))/R0))+(Q0-R0); RT0_yn=-((R0)^2-(RT0_xn-(Q0-R0))^2)^0.5; else if RT0_x0<=(-1)*(Q0-R0) && RT0_x0>-Q0 if (RT0_x0+(Q0-R0))>=-mar1 RT0_xn=-(Q0-R0); RT0_yn=-R0; else RT0_xn= -R0*cos((RT0_D/R0)+acos((((-1)*RT0_x0)-(Q0-R0))/R0))-(Q0-R0); RT0_yn=-((R0)^2-((-RT0_xn)-(Q0-R0))^2)^0.5; end else end end end end

Page 13: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

RT0_x0=RT0_xn; RT1(KK)=RT0_xn; RTY1(KK)=RT0_yn; RTG(T+KK-1)=RT1(KK); RTYG(T+KK-1)=RTY1(KK); RTG(T+KK-1)=(RTG(T+KK-1)*cos(th0)-RTYG(T+KK-1)*tan(th0)*cos(th0))+long0; RTYG(T+KK-1)=(RTG(T+KK-1)*cos(th0)-RTYG(T+KK-1)*tan(th0)*cos(th0))*tan(th0)+RTYG(T+KK-1)/cos(th0)+lat0; if RT0_yn>-mar2 RT0_y0=1; else end end end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Next location on the second flight path if RT1_y0>=0 KK=0; T1=length(RTG1); while Q1-RT1_x0>0.1 && RT1_x0+Q1>0.1|| -RT1_x0+Q1<0.1 % for KK=1:1:2928 KK=KK+1; if RT1_x0>=0 && RT1_x0<=(Q1-R1) RT1_xn=RT1_x0-RT1_D; RT1_yn=R1; else if RT1_x0<0 && RT1_x0>(Q1-R1)*(-1) if (RT1_x0+(Q1-R1))<=mar RT1_xn=-1*(Q1-R1); RT1_yn=R1;

Page 14: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

else RT1_xn=RT1_x0-RT1_D; RT1_yn=R1; end else if RT1_x0>(Q1-R1) && RT1_x0<Q1 if (RT1_x0-(Q1-R1))<=mar1 RT1_xn=(Q1-R1); RT1_yn=R1; else RT1_xn= R1*cos((RT1_D/R1)+acos(((RT1_x0)-(Q1-R1))/R1))+(Q1-R1); RT1_yn=((R1)^2-(RT1_xn-(Q1-R1))^2)^0.5; end else if RT1_x0<=(-1)*(Q1-R1) && RT1_x0>-Q1 RT1_xn= -R1*cos(((-1)*RT1_D/R1)+acos((((-1)*RT1_x0)-(Q1-R1))/R1))-(Q1-R1); RT1_yn=((R1)^2-((-RT1_xn)-(Q1-R1))^2)^0.5; else end end end end RT1_x0=RT1_xn; RT2(KK)=RT1_xn; RTY2(KK)=RT1_yn; RTG1(T1+KK-1)=RT2(KK); RTYG1(T1+KK-1)=RTY2(KK); RTG1(T1+KK-1)=(RTG1(T1+KK-1)*cos(th1)-RTYG1(T1+KK-1)*tan(th1)*cos(th1))+long1; RTYG1(T1+KK-1)=(RTG1(T1+KK-1)*cos(th1)-RTYG1(T1+KK-1)*tan(th1)*cos(th1))*tan(th1)+RTYG1(T1+KK-1)/cos(th1)+lat1;

Page 15: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

if RT1_yn<mar2 RT1_y0=-1; else end end elseif RT1_y0<0 T1=length(RTG1); KK=0; while (Q1-RT1_x0>0.1 && RT1_x0+Q1>0.1)|| RT1_x0+Q1<0.1 % for KK=1:1:2928 KK=KK+1; if RT1_x0>=0 && RT1_x0<=(Q1-R1) if (RT1_x0+(Q1-R1))<=mar RT1_xn=(Q1-R1); RT1_yn=-R1; else RT1_xn=RT1_x0+RT1_D; RT1_yn=-R1; end else if RT1_x0<0 && RT1_x0>=(Q1-R1)*(-1) RT1_xn=RT1_x0+RT1_D; RT1_yn=-R1; else if RT1_x0>=(Q1-R1) && RT1_x0<Q1 RT1_xn= R1*cos((-RT1_D/R1)+acos(((RT1_x0)-(Q1-R1))/R1))+(Q1-R1); RT1_yn=-((R1)^2-(RT1_xn-(Q1-R1))^2)^0.5; else if RT1_x0<=(-1)*(Q1-R1) && RT1_x0>-Q1 if (RT1_x0+(Q1-R1))>=-mar1 RT1_xn=-(Q1-R1);

Page 16: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

RT1_yn=-R1; else RT1_xn= -R1*cos((RT1_D/R1)+acos((((-1)*RT1_x0)-(Q1-R1))/R1))-(Q1-R1); RT1_yn=-((R1)^2-((-RT1_xn)-(Q1-R1))^2)^0.5; end else end end end end RT1_x0=RT1_xn; RT3(KK)=RT1_xn; RTY3(KK)=RT1_yn; RTG1(T1+KK-1)=RT3(KK); RTYG1(T1+KK-1)=RTY3(KK); RTG1(T1+KK-1)=(RTG1(T1+KK-1)*cos(th1)-RTYG1(T1+KK-1)*tan(th1)*cos(th1))+long1; RTYG1(T1+KK-1)=(RTG1(T1+KK-1)*cos(th1)-RTYG1(T1+KK-1)*tan(th1)*cos(th1))*tan(th1)+RTYG1(T1+KK-1)/cos(th1)+lat1; if RT1_yn>-mar2 RT1_y0=1; else end end

Page 17: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Next location on the third flight path if RT2_y0>=0 KK=0; T2=length(RTG2); while Q2-RT2_x0>0.1 && RT2_x0+Q2>0.1|| -RT2_x0+Q2<0.1 % for KK=1:1:2928 KK=KK+1; if RT2_x0>=0 && RT2_x0<=(Q2-R2) RT2_xn=RT2_x0-RT2_D; RT2_yn=R2; else if RT2_x0<0 && RT2_x0>(Q2-R2)*(-1) if (RT2_x0+(Q2-R2))<=mar RT2_xn=-1*(Q2-R2); RT2_yn=R2; else RT2_xn=RT2_x0-RT2_D; RT2_yn=R2; end else if RT2_x0>(Q2-R2) && RT2_x0<Q2 if (RT2_x0-(Q2-R2))<=mar1 RT2_xn=(Q2-R2); RT2_yn=R2; else RT2_xn= R2*cos((RT2_D/R2)+acos(((RT2_x0)-(Q2-R2))/R2))+(Q2-R2); RT2_yn=((R2)^2-(RT2_xn-(Q2-R2))^2)^0.5; end else if RT2_x0<=(-1)*(Q2-R2) && RT2_x0>-Q2

Page 18: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

RT2_xn= -R2*cos(((-1)*RT2_D/R2)+acos((((-1)*RT2_x0)-(Q2-R2))/R2))-(Q2-R2); RT2_yn=((R2)^2-((-RT2_xn)-(Q2-R2))^2)^0.5; else end end end end RT2_x0=RT2_xn; RT4(KK)=RT2_xn; RTY4(KK)=RT2_yn; RTG2(T2+KK-1)=RT4(KK); RTYG2(T2+KK-1)=RTY4(KK); RTG2(T2+KK-1)=(RTG2(T2+KK-1)*cos(th2)-RTYG2(T2+KK-1)*tan(th2)*cos(th2))+long2; RTYG2(T2+KK-1)=(RTG2(T2+KK-1)*cos(th2)-RTYG2(T2+KK-1)*tan(th2)*cos(th2))*tan(th2)+RTYG2(T2+KK-1)/cos(th2)+lat2; if RT2_yn<mar2 RT2_y0=-1; else end end elseif RT2_y0<0 T2=length(RTG2); KK=0; while (Q2-RT2_x0>0.1 && RT2_x0+Q2>0.1)|| RT2_x0+Q2<0.1 % for KK=1:1:2928 KK=KK+1;

Page 19: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

if RT2_x0>=0 && RT2_x0<=(Q2-R2) if (RT2_x0+(Q2-R2))<=mar1 RT2_xn=(Q2-R2); RT2_yn=-R2; else RT2_xn=RT2_x0+RT2_D; RT2_yn=-R2; end else if RT2_x0<0 && RT2_x0>=(Q2-R2)*(-1) RT2_xn=RT2_x0+RT2_D; RT2_yn=-R2; else if RT2_x0>=(Q2-R2) && RT2_x0<Q2 RT2_xn= R2*cos((-RT2_D/R2)+acos(((RT2_x0)-(Q2-R2))/R2))+(Q2-R2); RT2_yn=-((R2)^2-(RT2_xn-(Q2-R2))^2)^0.5; else if RT2_x0<=(-1)*(Q2-R2) && RT2_x0>-Q2 if (RT2_x0+(Q2-R2))>=-mar1 RT2_xn=-(Q2-R2); RT2_yn=-R2; else RT2_xn= -R2*cos((RT2_D/R2)+acos((((-1)*RT2_x0)-(Q2-R2))/R2))-(Q2-R2); RT2_yn=-((R2)^2-((-RT2_xn)-(Q2-R2))^2)^0.5; end else end

Page 20: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

end end end RT2_x0=RT2_xn; RT5(KK)=RT2_xn; RTY5(KK)=RT2_yn; RTG2(T2+KK-1)=RT5(KK); RTYG2(T2+KK-1)=RTY5(KK); RTG2(T2+KK-1)=(RTG2(T2+KK-1)*cos(th2)-RTYG2(T2+KK-1)*tan(th2)*cos(th2))+long2; RTYG2(T2+KK-1)=(RTG2(T2+KK-1)*cos(th2)-RTYG2(T2+KK-1)*tan(th2)*cos(th2))*tan(th2)+RTYG2(T2+KK-1)/cos(th2)+lat2; if RT2_yn>-mar2 RT2_y0=1; else end end end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Next location on the fourth flight path if RT3_y0>=0 T3=length(RTG3); KK=0; while Q3-RT3_x0>0.1 && RT3_x0+Q3>0.1|| -RT3_x0+Q3<0.1 % for KK=1:1:2928

Page 21: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

KK=KK+1; if RT3_x0>=0 && RT3_x0<=(Q3-R3) RT3_xn=RT3_x0-RT3_D; RT3_yn=R3; else if RT3_x0<0 && RT3_x0>(Q3-R3)*(-1) if (RT3_x0+(Q3-R3))<=mar RT3_xn=-1*(Q3-R3); RT3_yn=R3; else RT3_xn=RT3_x0-RT3_D; RT3_yn=R3; end else if RT3_x0>(Q3-R3) && RT3_x0<Q3 if (RT3_x0-(Q3-R3))<=mar1 RT3_xn=(Q3-R3); RT3_yn=R3; else RT3_xn= R3*cos((RT3_D/R3)+acos(((RT3_x0)-(Q3-R3))/R3))+(Q3-R3); RT3_yn=((R3)^2-(RT3_xn-(Q3-R3))^2)^0.5; end else if RT3_x0<=(-1)*(Q3-R3) && RT3_x0>-Q3 RT3_xn= -R3*cos(((-1)*RT3_D/R3)+acos((((-1)*RT3_x0)-(Q3-R3))/R3))-(Q3-R3); RT3_yn=((R3)^2-((-RT3_xn)-(Q3-R3))^2)^0.5; else end end end end

Page 22: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

RT3_x0=RT3_xn; RT6(KK)=RT3_xn; RTY6(KK)=RT3_yn; RTG3(T3+KK-1)=RT6(KK); RTYG3(T3+KK-1)=RTY6(KK); RTG3(T3+KK-1)=(RTG3(T3+KK-1)*cos(th3)-RTYG3(T3+KK-1)*tan(th3)*cos(th3))+long3; RTYG3(T3+KK-1)=(RTG3(T3+KK-1)*cos(th3)-RTYG3(T3+KK-1)*tan(th3)*cos(th3))*tan(th3)+RTYG3(T3+KK-1)/cos(th3)+lat3; if RT3_yn<mar2 RT3_y0=-1; else end end elseif RT3_y0<0 T3=length(RTG3); KK=0; while (Q3-RT3_x0>0.1 && RT3_x0+Q3>0.1)|| RT3_x0+Q3<0.1 % for KK=1:1:2928 KK=KK+1; if RT3_x0>=0 && RT3_x0<=(Q3-R3) if (RT3_x0+(Q3-R3))<=mar RT3_xn=(Q3-R3); RT3_yn=-R3; else RT3_xn=RT3_x0+RT3_D; RT3_yn=-R3; end else if RT3_x0<0 && RT3_x0>=(Q3-R3)*(-1) RT3_xn=RT3_x0+RT3_D; RT3_yn=-R3;

Page 23: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

else if RT3_x0>=(Q3-R3) && RT3_x0<Q3 RT3_xn= R3*cos((-RT3_D/R3)+acos(((RT3_x0)-(Q3-R3))/R3))+(Q3-R3); RT3_yn=-((R3)^2-(RT3_xn-(Q3-R3))^2)^0.5; else if RT3_x0<=(-1)*(Q3-R3) && RT3_x0>-Q3 if (RT3_x0+(Q3-R3))>=-mar1 RT3_xn=-(Q3-R3); RT3_yn=-R3; else RT3_xn= -R3*cos((RT3_D/R3)+acos((((-1)*RT3_x0)-(Q3-R3))/R3))-(Q3-R3); RT3_yn=-((R3)^2-((-RT3_xn)-(Q3-R3))^2)^0.5; end else end end end end RT3_x0=RT3_xn; RT7(KK)=RT3_xn; RTY7(KK)=RT3_yn; RTG3(T3+KK-1)=RT7(KK);

Page 24: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

RTYG3(T3+KK-1)=RTY7(KK); RTG3(T3+KK-1)=(RTG3(T3+KK-1)*cos(th3)-RTYG3(T3+KK-1)*tan(th3)*cos(th3))+long3; RTYG3(T3+KK-1)=(RTG3(T3+KK-1)*cos(th3)-RTYG3(T3+KK-1)*tan(th3)*cos(th3))*tan(th3)+RTYG3(T3+KK-1)/cos(th3)+lat3; if RT3_yn>-mar2 RT3_y0=1; else end end end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Next location on the fifth flight path if RT4_y0>=0 T4=length(RTG4); KK=0; while Q4-RT4_x0>0.1 && RT4_x0+Q4>0.1|| -RT4_x0+Q4<0.1 % for KK=1:1:2928 KK=KK+1; if RT4_x0>=0 && RT4_x0<=(Q4-R4) RT4_xn=RT4_x0-RT4_D; RT4_yn=R4; else if RT4_x0<0 && RT4_x0>(Q4-R4)*(-1) if (RT4_x0+(Q4-R4))<=mar RT4_xn=-1*(Q4-R4); RT4_yn=R4; else

Page 25: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

RT4_xn=RT4_x0-RT4_D; RT4_yn=R4; end else if RT4_x0>(Q4-R4) && RT4_x0<Q4 if (RT4_x0-(Q4-R4))<=mar1 RT4_xn=(Q4-R4); RT4_yn=R4; else RT4_xn= R4*cos((RT4_D/R4)+acos(((RT4_x0)-(Q4-R4))/R4))+(Q4-R4); RT4_yn=((R4)^2-(RT4_xn-(Q4-R4))^2)^0.5; end else if RT4_x0<=(-1)*(Q4-R4) && RT4_x0>-Q4 RT4_xn= -R4*cos(((-1)*RT4_D/R4)+acos((((-1)*RT4_x0)-(Q4-R4))/R4))-(Q4-R4); RT4_yn=((R4)^2-((-RT4_xn)-(Q4-R4))^2)^0.5; else end end end end RT4_x0=RT4_xn; RT8(KK)=RT4_xn; RTY8(KK)=RT4_yn; RTG4(T4+KK-1)=RT8(KK); RTYG4(T4+KK-1)=RTY8(KK); RTG4(T4+KK-1)=(RTG4(T4+KK-1)*cos(th4)-RTYG4(T4+KK-1)*tan(th4)*cos(th4))+long4; RTYG4(T4+KK-1)=(RTG4(T4+KK-1)*cos(th4)-RTYG4(T4+KK-1)*tan(th4)*cos(th4))*tan(th4)+RTYG4(T4+KK-1)/cos(th4)+lat4; if RT4_yn<mar2

Page 26: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

RT4_y0=-1; else end end elseif RT4_y0<0 T4=length(RTG4); KK=0; while (Q4-RT4_x0>0.1 && RT4_x0+Q4>0.1)|| RT4_x0+Q4<0.1 % for KK=1:1:2928 KK=KK+1; if RT4_x0>=0 && RT4_x0<=(Q4-R4) if (RT4_x0+(Q4-R4))<=mar RT4_xn=(Q4-R4); RT4_yn=-R4; else RT4_xn=RT4_x0+RT4_D; RT4_yn=-R4; end else if RT4_x0<0 && RT4_x0>=(Q4-R4)*(-1) RT4_xn=RT4_x0+RT4_D; RT4_yn=-R4; else if RT4_x0>=(Q4-R4) && RT4_x0<Q4 RT4_xn= R4*cos((-RT4_D/R4)+acos(((RT4_x0)-(Q4-R4))/R4))+(Q4-R4); RT4_yn=-((R4)^2-(RT4_xn-(Q4-R4))^2)^0.5; else if RT4_x0<=(-1)*(Q4-R4) && RT4_x0>-Q4 if (RT4_x0+(Q4-R4))>=-mar1

Page 27: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

RT4_xn=-(Q4-R4); RT4_yn=-R4; else RT4_xn= -R4*cos((RT4_D/R4)+acos((((-1)*RT4_x0)-(Q4-R4))/R4))-(Q4-R4); RT4_yn=-((R4)^2-((-RT4_xn)-(Q4-R4))^2)^0.5; end else end end end end RT4_x0=RT4_xn; RT9(KK)=RT4_xn; RTY9(KK)=RT4_yn; RTG4(T4+KK-1)=RT9(KK); RTYG4(T4+KK-1)=RTY9(KK); RTG4(T4+KK-1)=(RTG4(T4+KK-1)*cos(th4)-RTYG4(T4+KK-1)*tan(th4)*cos(th4))+long4; RTYG4(T4+KK-1)=(RTG4(T4+KK-1)*cos(th4)-RTYG4(T4+KK-1)*tan(th4)*cos(th4))*tan(th4)+RTYG4(T4+KK-1)/cos(th4)+lat4; if RT4_yn>-mar2 RT4_y0=1; else end end

Page 28: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

end end %plot(RT,RTY,RT1,RTY1,RT2,RTY2,RT3,RTY3,RT4,RTY4,RT5,RTY5,RT6,RTY6,RT7,RTY7,RT8,RTY8,RT9,RTY9) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Detection check according to intruder trajectory%%%%%%%%%%%%%%%%%%%%Detection domain radius (r)=2500 m r=5000/2; L_RTG=length(RTG);L_RTG1=length(RTG1);L_RTG2=length(RTG2);L_RTG3=length(RTG3);L_RTG4=length(RTG4); L_x=length(x);L_x1=length(x1);L_x2=length(x2);L_x3=length(x3);L_x4=length(x4); v=0;z=0; clear Dx_Time Dx10_Time Dx20_Time Dx30_Time Dx4_Time Dx0_Time Dx11_Time Dx21_Time Dx31_Time Dx41_Time Dx1_Time Dx12_Time Dx22_Time Dx32_Time Dx42_Time Dx2_Time Dx13_Time Dx23_Time Dx33_Time Dx43_Time Dx3_Time Dx14_Time Dx24_Time Dx34_Time Dx44_Time;clear Dy_Time Dy10_Time Dy20_Time Dy30_Time Dy4_Time Dy0_Time Dy11_Time Dy21_Time Dy31_Time Dy41_Time Dy1_Time Dy12_Time Dy22_Time Dy32_Time Dy42_Time Dy2_Time Dy13_Time Dy23_Time Dy33_Time Dy43_Time Dy3_Time Dy14_Time Dy24_Time Dy34_Time Dy44_Time; %clear Dx_Time Dy_Time Dx10_Time Dy10_Time Dx20_Time Dy20_Time Dx30_Time Dy30_Time Dx4_Time Dy4_TimeDx_Time=0;Dx10_Time=0;Dx20_Time=0;

Page 29: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

Dx30_Time=0;Dx4_Time=0;Dx0_Time=0;Dx11_Time=0;Dx21_Time=0;Dx31_Time=0;Dx41_Time=0;Dx1_Time=0;Dx12_Time=0;Dx22_Time=0;Dx32_Time=0;Dx42_Time=0;Dx2_Time=0;Dx13_Time=0;Dx23_Time=0;Dx33_Time=0;Dx43_Time=0;Dx3_Time=0;Dx14_Time=0;Dx24_Time=0;Dx34_Time=0;Dx44_Time=0; while v<=(L_x-1) v=v+1; U=0; while U<=(L_RTG-1) U=U+1; if (r^2)>=((RTG(U)-x(v))^2+(RTYG(U)-f1(v))^2)&& U==v z=z+1; Dx_Time(z)=RTG(U); Dy_Time(z)=RTYG(U); else end end U=0; while U<=(L_RTG1-1) U=U+1; if (r^2)>=((RTG1(U)-x(v))^2+(RTYG1(U)-f1(v))^2)&& U==v

Page 30: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

z=z+1; Dx10_Time(z)=RTG1(U); Dy10_Time(z)=RTYG1(U); else end end U=0; while U<=(L_RTG2-1) U=U+1; if (r^2)>=((RTG2(U)-x(v))^2+(RTYG2(U)-f1(v))^2)&& U==v z=z+1; Dx20_Time(z)=RTG2(U); Dy20_Time(z)=RTYG2(U); else end end U=0; while U<=(L_RTG3-1) U=U+1; if (r^2)>=((RTG3(U)-x(v))^2+(RTYG3(U)-f1(v))^2)&& U==v z=z+1; Dx30_Time(z)=RTG3(U); Dy30_Time(z)=RTYG3(U); else end end U=0; while U<=(L_RTG4-1) U=U+1;

Page 31: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

if (r^2)>=((RTG4(U)-x(v))^2+(RTYG4(U)-f1(v))^2)&& U==v z=z+1; Dx4_Time(z)=RTG4(U); Dy4_Time(z)=RTYG4(U); else end end end v=0;z=0;while v<=(L_x1-1) v=v+1; U=0; while U<=(L_RTG-1) U=U+1; if (r^2)>=((RTG(U)-x1(v))^2+(RTYG(U)-f11(v))^2)&& U==v z=z+1; Dx0_Time(z)=RTG(U); Dy0_Time(z)=RTYG(U); else end end U=0; while U<=(L_RTG1-1) U=U+1; if (r^2)>=((RTG1(U)-x1(v))^2+(RTYG1(U)-f11(v))^2)&& U==v z=z+1; Dx11_Time(z)=RTG1(U); Dy11_Time(z)=RTYG1(U); else end

Page 32: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

end U=0; while U<=(L_RTG2-1) U=U+1; if (r^2)>=((RTG2(U)-x1(v))^2+(RTYG2(U)-f11(v))^2)&& U==v z=z+1; Dx21_Time(z)=RTG2(U); Dy21_Time(z)=RTYG2(U); else end end U=0; while U<=(L_RTG3-1) U=U+1; if (r^2)>=((RTG3(U)-x1(v))^2+(RTYG3(U)-f11(v))^2)&& U==v z=z+1; Dx31_Time(z)=RTG3(U); Dy31_Time(z)=RTYG3(U); else end end U=0; while U<=(L_RTG4-1) U=U+1; if (r^2)>=((RTG4(U)-x1(v))^2+(RTYG4(U)-f11(v))^2)&& U==v z=z+1; Dx41_Time(z)=RTG4(U); Dy41_Time(z)=RTYG4(U);

Page 33: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

else end end end v=0;z=0;while v<=(L_x2-1) v=v+1; U=0; while U<=(L_RTG-1) U=U+1; if (r^2)>=((RTG(U)-x2(v))^2+(RTYG(U)-f12(v))^2)&& U==v z=z+1; Dx1_Time(z)=RTG(U); Dy1_Time(z)=RTYG(U); else end end U=0; while U<=(L_RTG1-1) U=U+1; if (r^2)>=((RTG1(U)-x2(v))^2+(RTYG1(U)-f12(v))^2)&& U==v z=z+1; Dx12_Time(z)=RTG1(U); Dy12_Time(z)=RTYG1(U); else end end

Page 34: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

U=0; while U<=(L_RTG2-1) U=U+1; if (r^2)>=((RTG2(U)-x2(v))^2+(RTYG2(U)-f12(v))^2)&& U==v z=z+1; Dx22_Time(z)=RTG2(U); Dy22_Time(z)=RTYG2(U); else end end U=0; while U<=(L_RTG3-1) U=U+1; if (r^2)>=((RTG3(U)-x2(v))^2+(RTYG3(U)-f12(v))^2)&& U==v z=z+1; Dx32_Time(z)=RTG3(U); Dy32_Time(z)=RTYG3(U); else end end U=0; while U<=(L_RTG4-1) U=U+1; if (r^2)>=((RTG4(U)-x2(v))^2+(RTYG4(U)-f12(v))^2)&& U==v z=z+1; Dx42_Time(z)=RTG4(U); Dy42_Time(z)=RTYG4(U); else end

Page 35: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

end end v=0;z=0;while v<=(L_x3-1) v=v+1; U=0; while U<=(L_RTG-1) U=U+1; if (r^2)>=((RTG(U)-x3(v))^2+(RTYG(U)-f13(v))^2)&& U==v z=z+1; Dx2_Time(z)=RTG(U); Dy2_Time(z)=RTYG(U); else end end U=0; while U<=(L_RTG1-1) U=U+1; if (r^2)>=((RTG1(U)-x3(v))^2+(RTYG1(U)-f13(v))^2)&& U==v z=z+1; Dx13_Time(z)=RTG1(U); Dy13_Time(z)=RTYG1(U); else end end U=0;

Page 36: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

while U<=(L_RTG2-1) U=U+1; if (r^2)>=((RTG2(U)-x3(v))^2+(RTYG2(U)-f13(v))^2)&& U==v z=z+1; Dx23_Time(z)=RTG2(U); Dy23_Time(z)=RTYG2(U); else end end U=0; while U<=(L_RTG3-1) U=U+1; if (r^2)>=((RTG3(U)-x3(v))^2+(RTYG3(U)-f13(v))^2)&& U==v z=z+1; Dx33_Time(z)=RTG3(U); Dy33_Time(z)=RTYG3(U); else end end U=0; while U<=(L_RTG4-1) U=U+1; if (r^2)>=((RTG4(U)-x3(v))^2+(RTYG4(U)-f13(v))^2)&& U==v z=z+1; Dx43_Time(z)=RTG4(U); Dy43_Time(z)=RTYG4(U); else end end

Page 37: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

end v=0;z=0;while v<=(L_x4-1) v=v+1; U=0; while U<=(L_RTG-1) U=U+1; if (r^2)>=((RTG(U)-x4(v))^2+(RTYG(U)-f14(v))^2)&& U==v z=z+1; Dx3_Time(z)=RTG(U); Dy3_Time(z)=RTYG(U); else end end U=0; while U<=(L_RTG1-1) U=U+1; if (r^2)>=((RTG1(U)-x4(v))^2+(RTYG1(U)-f14(v))^2)&& U==v z=z+1; Dx14_Time(z)=RTG1(U); Dy14_Time(z)=RTYG1(U); else end end U=0; while U<=(L_RTG2-1) U=U+1;

Page 38: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

if (r^2)>=((RTG2(U)-x4(v))^2+(RTYG2(U)-f14(v))^2)&& U==v z=z+1; Dx24_Time(z)=RTG2(U); Dy24_Time(z)=RTYG2(U); else end end U=0; while U<=(L_RTG3-1) U=U+1; if (r^2)>=((RTG3(U)-x4(v))^2+(RTYG3(U)-f14(v))^2)&& U==v z=z+1; Dx34_Time(z)=RTG3(U); Dy34_Time(z)=RTYG3(U); else end end U=0; while U<=(L_RTG4-1) U=U+1; if (r^2)>=((RTG4(U)-x4(v))^2+(RTYG4(U)-f14(v))^2)&& U==v z=z+1; Dx44_Time(z)=RTG4(U); Dy44_Time(z)=RTYG4(U); else end end end

Page 39: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

F_P=F_P+((length(Dx_Time)+length(Dx10_Time)+length(Dx20_Time)+length(Dx30_Time)+length(Dx4_Time)))*((length(Dx0_Time)+length(Dx11_Time)+length(Dx21_Time)+length(Dx31_Time)+length(Dx41_Time)))*((length(Dx1_Time)+length(Dx12_Time)+length(Dx22_Time)+length(Dx32_Time)+length(Dx42_Time)))*((length(Dx2_Time)+length(Dx13_Time)+length(Dx23_Time)+length(Dx33_Time)+length(Dx43_Time)))*((length(Dx3_Time)+length(Dx14_Time)+length(Dx24_Time)+length(Dx34_Time)+length(Dx44_Time)))/(1000000000); %clear Dx_Time Dy_Time Dx10_Time Dy10_Time Dx20_Time Dy20_Time Dx30_Time Dy30_Time Dx4_Time Dy4_Time end F(s)=F_P;h(s)=1/F(s); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% end Ji=1./(F+1e-10);%****** Step 1 : Evaluate BestJ ******BestJ(k)=min(Ji); fi=F; %Fitness Function[Oderfi,Indexfi]=sort(fi); %Arranging fi small to biggerBestfi=Oderfi(Size); %Let Bestfi=max(fi)

Page 40: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

BestS=E(Indexfi(Size),:); %Let BestS=E(m), m is the Indexfi belong to max(fi)bfi(k)=Bestfi; %****** Step 2 : Select and Reproduct Operation****** fi_sum=sum(fi); fi_Size=(Oderfi/fi_sum)*Size; fi_S=floor(fi_Size); %Selecting Bigger fi value kk=1; for i=1:1:Size for j=1:1:fi_S(i) %Select and Reproduce TempE(kk,:)=E(Indexfi(i),:); kk=kk+1; %kk is used to reproduce end end %************ Step 3 : Crossover Operation ************pc=0.60;n=ceil(250*rand);for i=1:2:(Size-1) temp=rand; if pc>temp %Crossover Condition for j=n:1:250 TempE(i,j)=E(i+1,j); TempE(i+1,j)=E(i,j); end endendTempE(Size,:)=BestS;E=TempE; %************ Step 4: Mutation Operation **************%pm=0.001;%pm=0.001-[1:1:Size]*(0.001)/Size; %Bigger fi, smaller Pm%pm=0.0; %No mutationpm=0.1; %Big mutation for i=1:1:Size for j=1:1:25*CodeL temp=rand; if pm>temp %Mutation Condition if TempE(i,j)==0 TempE(i,j)=1; else TempE(i,j)=0; end end end end %Guarantee TempPop(30,:) is the code belong to the best individual(max(fi))TempE(Size,:)=BestS;

Page 41: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.

E=TempE; W0(k)=W0;W1(k)=W1;W2(k)=W2;W3(k)=W3;W4(k)=W4;L0(k)=L0;L1(k)=L1;L2(k)=L2;L3(k)=L3;L4(k)=L4;th0(k)=th0;th1(k)=th1;th2(k)=th2;th3(k)=th3;th4(k)=th4;lat0(k)=lat0;lat1(k)=lat1;lat2(k)=lat2;lat3(k)=lat3;lat4(k)=lat4;long0(k)=long0;long1(k)=long1;long2(k)=long2;long3(k)=long3;long4(k)=long4; end Max_Value=BestfiBestS figure(1);plot(time,BestJ); xlabel('Times');ylabel('Best J');figure(3);plot(time,bfi);xlabel('times');ylabel('Best F');

Page 42: Inferring the Optimum UAV's Trajectories Configuration Over Definite Intruder Paths with Multiple Random Starting Points Via Genetic Algorithm.