% 2023 % % Project Title: Enhanced meta-heuristic optimization of resource % efficiency in multi-relay underground wireless sensor networks % Developer: Mariem Ayedi % % Contact Info: m.ayedi@psau.edu.sa % clear all close all clc format short teb=[];vv=[]; tebii=[]; tebconv=[]; teb_ee=[];teb_se=[]; teb_re=[];tebconv_ee=[]; tebconv_se=[]; tebconv_re=[]; teb_batEr=[]; teb_batEs=[]; teb_relay=[]; teb_Er=[]; teb_Es=[]; tabSNRdB=[ 15]; N=20; iteratio=1000; N0vect=[10^-12]; pu=0.0500 ; % 0.1000 0.1500 0.2000 0.2500 ]; gamma=[ 0.125]; %0.015 0.02 0.025 0.03 0.035 0.04]% 0.1000 0.1500 0.2000 0.2500 ]; % 0.05 - 0.5 nbr=5; bd=[300*10^6 ]; for d=1:length(pu) d som_rate=0; som_teb=0; som_rate_ee=0; som_rate_Es=0; som_rate_Er=0; som_rate_se=0; som_rate_re=0; som_bat_Es=0; som_bat_Er=0; conv_ee=zeros(1,10); conv_se=zeros(1,10); conv_re=zeros(1,10); ii=0; som_BestCost=0; for it=1:1:iteratio EiniS=3; EiniR1=3; EiniR2=3; EiniR3=3; EiniR4=3; EiniR5=3; while EiniS>0.005 && EiniR1 > 0.005 && EiniR2 > 0.005 && EiniR3 > 0.005 && EiniR4 > 0.005 && EiniR5 > 0.005 %for ii=1:2 ii=ii+1; N0=N0vect; Lsr1_db= 36.3154; Lr1d_db= 51.6983 ; Lsr2_db= 34.7410; Lr2d_db= 50.8535; Lsr3_db= 30.3591 ; Lr3d_db= 50.1112 ; Lsr4_db= 28.7797; Lr4d_db= 49.5239; Lsr5_db =28.7797; Lr5d_db = 49.1443; Lsr1=10^(-Lsr1_db/10); Lr1d=10^(-Lr1d_db/10); Lsr2=10^(-Lsr2_db/10); Lr2d=10^(-Lr2d_db/10); Lsr3=10^(-Lsr3_db/10); Lr3d=10^(-Lr3d_db/10); Lsr4=10^(-Lsr4_db/10); Lr4d=10^(-Lr4d_db/10); Lsr5=10^(-Lsr5_db/10); Lr5d=10^(-Lr5d_db/10); hsr1= sqrt(Lsr1/2)*(randn(1)+1i*randn(1)); hsr2= sqrt(Lsr2/2)*(randn(1)+1i*randn(1)); hsr3= sqrt(Lsr3/2)*(randn(1)+1i*randn(1)); hsr4= sqrt(Lsr4/2)*(randn(1)+1i*randn(1)); hsr5= sqrt(Lsr5/2)*(randn(1)+1i*randn(1)); hr1d= sqrt(Lr1d/2)*(randn(1)+1i*randn(1)); hr2d= sqrt(Lr2d/2)*(randn(1)+1i*randn(1)); hr3d= sqrt(Lr3d/2)*(randn(1)+1i*randn(1)); hr4d= sqrt(Lr4d/2)*(randn(1)+1i*randn(1)); hr5d= sqrt(Lr5d/2)*(randn(1)+1i*randn(1)); B=bd; emax=pu(d); beta=2.1; ub =[emax;emax;emax;emax;emax;emax]; lb=[0.005 ; 0.005; 0.005 ; 0.005; 0.005 ; 0.005]; dim=6; Max_iter=10; snr1= @(x) ((1/(x(1)*abs(hsr1)^2+N0))*x(1)*x(2)*abs(hsr1)^2*abs(hr1d)^2) / ( B*N0*((1/(x(1)*abs(hsr1)^2+N0))*x(2)*abs(hr1d)^2 +1) ); snr2= @(x) ((1/(x(1)*abs(hsr2)^2+N0))*x(1)*x(3)*abs(hsr2)^2*abs(hr2d)^2) / ( B*N0*((1/(x(1)*abs(hsr2)^2+N0))*x(3)*abs(hr2d)^2 +1) ); snr3= @(x) ((1/(x(1)*abs(hsr3)^2+N0))*x(1)*x(4)*abs(hsr3)^2*abs(hr3d)^2) / ( B*N0*((1/(x(1)*abs(hsr3)^2+N0))*x(4)*abs(hr3d)^2 +1) ); snr4= @(x) ((1/(x(1)*abs(hsr4)^2+N0))*x(1)*x(5)*abs(hsr4)^2*abs(hr4d)^2) / ( B*N0*((1/(x(1)*abs(hsr4)^2+N0))*x(5)*abs(hr4d)^2 +1) ); snr5= @(x) ((1/(x(1)*abs(hsr5)^2+N0))*x(1)*x(6)*abs(hsr5)^2*abs(hr5d)^2) / ( B*N0*((1/(x(1)*abs(hsr5)^2+N0))*x(6)*abs(hr5d)^2 +1) ); ee= @(x) B * log2( 1+ snr1(x) +snr2(x) + snr3(x)+ snr4(x) + snr5(x) ) / (x(1)+ x(2)+ x(3)+ x(4)+ x(5)+ x(6)); se= @(x) log2( 1+ snr1(x) +snr2(x) + snr3(x)+ snr4(x)+ snr5(x) ) ; re= @(x) ee(x)+ beta*(B/(6*emax))*se(x); z=re; HCSSC; %SSAorig; som_rate_re=som_rate_re+FoodFitness; conv_re=conv_re+Convergence_curve; EiniS= EiniS- FoodPosition(1) ; EiniR1= EiniR1- FoodPosition(2); EiniR2= EiniR2- FoodPosition(3); EiniR3= EiniR3- FoodPosition(4); EiniR4= EiniR4- FoodPosition(5); EiniR5= EiniR5- FoodPosition(6); ub =emax; lb=0.005; % WOA; % som_rate_re=som_rate_re+Leader_score; % EiniS= EiniS- Leader_pos(1) ; % EiniR1= EiniR1- Leader_pos(2); % EiniR2= EiniR2- Leader_pos(3); % EiniR3= EiniR3- Leader_pos(4); % EiniR4= EiniR4- Leader_pos(5); % EiniR5= EiniR5- Leader_pos(6); % abc % som_rate_re=som_rate_re+BestSol.Cost; % EiniS= EiniS- BestSol.Position(1) ; % EiniR1= EiniR1- BestSol.Position(2); % EiniR2= EiniR2- BestSol.Position(3); % EiniR3= EiniR3- BestSol.Position(4); % EiniR4= EiniR4- BestSol.Position(5); % EiniR5= EiniR5- BestSol.Position(6); % DA; % som_rate_re=som_rate_re+Best_score; % EiniS= EiniS- Best_pos(1) ; % EiniR1= EiniR1- Best_pos(2); % EiniR2= EiniR2- Best_pos(3); % EiniR3= EiniR3- Best_pos(4); % EiniR4= EiniR4- Best_pos(5); % EiniR5= EiniR5- Best_pos(6); % % pso; % som_rate_re=som_rate_re+GlobalBest.Cost; % maximum of ee % %conv_re=conv_re+BestCost; % EiniS= EiniS- GlobalBest.Position(1) ; % EiniR1= EiniR1- GlobalBest.Position(2); % EiniR2= EiniR2- GlobalBest.Position(3); % EiniR3= EiniR3- GlobalBest.Position(4); % EiniR4= EiniR4- GlobalBest.Position(5); % EiniR5= EiniR5- GlobalBest.Position(6); %som_bat_Es= som_bat_Es+ EiniS; %som_bat_Er= som_bat_Er+ EiniR1+ EiniR2+ EiniR3+ EiniR4+ EiniR5; end %v(it)=som_rate_re; end avg_conv_ee=conv_ee/iteratio; avg_conv_se=conv_se/iteratio; avg_conv_re=conv_re/iteratio; avg_ii=ii/iteratio; avg_rate_re=som_rate_re/iteratio; teb_re=[teb_re,avg_rate_re]; tebii=[tebii,avg_ii]; tebconv_ee=[tebconv_ee,avg_conv_ee]; tebconv_se=[tebconv_se,avg_conv_se]; tebconv_re=[tebconv_re,avg_conv_re]; end tebconv_re teb_re