function [Group_Best_Pos,Group_Best_Score,WAR_curve]=BEO(N,Max_iteration,lb,ub,dim,fobj)
%% parameter setting
ub = ub.*ones(dim,1);
lb = lb.*ones(dim,1);
R=N;
T=Max_iteration;
%% initialization
WAR_curve=zeros(1,R);
x=initialization(R,dim,ub,lb);
for i=1:R
Fitness1(i)=fobj(x(:,i));
end
[F_x,index]=sort(Fitness1);
A_Pos=x(:,index(1));
A_Score=F_x(1);
t=1;
L=0;
A=A_Score;
IT=0;
%% Start iterative updates
while t
=ub;
lb_flag=xnew(:,i)<=lb;
xnew(:,i)=xnew(:,i).*(~(ub_flag+lb_flag))+(2*ub-xnew(:,i)).*ub_flag+(2*lb-xnew(:,i)).*lb_flag;
end
for i=1:3*R
f(i)=fobj(xnew(:,i));
end
[fx,indexf]=sort(f);
A_Pos1=xnew(:,indexf(1));
A_Score1=fx(1);
if A_Score1=0.8*ub(i)||A_Pos(i)<=0.8*lb(i)
center = (ub + lb) / 2;
distance = norm(A_Pos(i) - center(i));
max_distance=norm(ub(i));
min_distance=0.8*norm(ub(i));
distance_normalized=(distance-min_distance)/(max_distance-min_distance);
lambda=distance_normalized*(5-15)+15;
distances = sqrt((x(i,:) - A_Pos(i)).^2);
[~, sorted_indices1] = sort(distances);
xnew3(i,:) = zeros(1,R);
poissrn_values = poissrnd(lambda, 1, R);
for j = 1:R
xnew3(i,j) = A_Pos(i) + (x(i,sorted_indices1(j)) - A_Pos(i)) .* (1 + poissrn_values(j));
end
lambda_normalized=(lambda-5)/(15-5);
bate=sin(lambda_normalized*pi/2)*(0.953-0.89)+0.89;
xnew3(i,:)=xnew3(i,:)+bate*(A_Pos(i)-xnew3(i,:));
x0(i,:)=xnew3(i,:);
end
end
%% hovering
for j=1:R
rotation_angle = rand*2*pi;
rotation_matrix = eye(dim);
for ri = 1:dim-1
rotation_matrix(ri,ri) = cos(rotation_angle);
rotation_matrix(ri,ri+1) = -sin(rotation_angle);
rotation_matrix(ri+1,ri) = sin(rotation_angle);
rotation_matrix(ri+1,ri+1) = cos(rotation_angle);
end
xnew4(:,j) = A_Pos +rotation_matrix * (x(:,j) - A_Pos);
end
for i=1:R
ub_flag=xnew4(:,i)>=ub;
lb_flag=xnew4(:,i)<=lb;
xnew4(:,i)=xnew4(:,i).*(~(ub_flag+lb_flag))+(2*ub-xnew4(:,i)).*ub_flag+(2*lb-xnew4(:,i)).*lb_flag;
f=fobj(xnew4(:,i));
if f0;
xnew(i,:)=xnew5(i,:).*(~flag1)+x0(i,:);
end
for i=1:R
ub_flag=xnew(:,i)>=ub;
lb_flag=xnew(:,i)<=lb;
xnew(:,i)=xnew(:,i).*(~(ub_flag+lb_flag))+(lb+rand(dim,1).*(ub-lb)).*ub_flag+(lb+rand(dim,1).*(ub-lb)).*lb_flag;
f=fobj(xnew(:,i));
if fub;
lb_flag=xnew6(:,i)=0.1*T||L>0.1*T/2
for j=1:R
Fitness(j)=fobj(x(:,j));
z=1/(2*exp(-(A_Score/(Fitness(j)+eps))));
s=-ones(dim,1);
s0=s+2*rand(dim,1);
xnew7(:,j)=A_Pos+z.*s0.*(x(:,j)-(0.4+0.6.*tent_map(rand(dim,1), 0.5)).*A_Pos);
end
for i=1:R
ub_flag=xnew7(:,i)>ub;
lb_flag=xnew7(:,i)=0.3*T||L>0.3*T/2
f = 1./(1*(1+exp(-(14*t/T-9))))+0.3;%0.3-1.3
for j=1:R
if mod(j,2)==1
r5=tent_map(rand(1), 0.5);
xnew8(:,j)=x(:,j)+r5*f*(A_Pos-x(:,j))+rand(dim,1).*cos((pi*j)/R).*(A_Pos-x(:,j));
else
r6=tent_map(rand(1), 0.5);
xnew8(:,j)=x(:,j)+r6*f*(A_Pos-x(:,j))+randn(dim,1).*sin((pi*j)/R).*(A_Pos-x(:,j));
end
end
for i=1:R
ub_flag=xnew8(:,i)>ub;
lb_flag=xnew8(:,i)ub;
lb_flag=xnew9(:,i)