function [Best_vulture1_F,Best_vulture1_X]=sin_cos_bIAVOA(pop_size,max_iter,dim,fobj)
lower_bound=-6;upper_bound=6;
% initialize Best_vulture1, Best_vulture2
Best_vulture1_X=zeros(1,dim);
Best_vulture1_F=inf;
Best_vulture2_X=zeros(1,dim);
Best_vulture2_F=inf;
%Initialize the first random population of vultures
X=double(initialization(pop_size,dim,1,0)>0.5);
%% Controlling parameter
p1=0.6;
p2=0.4;
p3=0.6;
alpha=0.8;
betha=0.2;
gamma=2.5;
%%Main loop
current_iter=0; % Loop counter
while current_iter < max_iter
for i=1:size(X,1)
S1=cos(X(i,:))/2+0.5;
X1=rand(1,dim)<S1;
ObjVal1=feval(fobj,X1);
S2=sin(X(i,:))/2+0.5;
X2=rand(1,dim)<S2;
ObjVal2=feval(fobj,X2);
XX=[X1;X2];
fiti=[ObjVal1;ObjVal2];
[~,ind]=min(fiti(:,1));
X(i,:)=XX(ind,:);
current_vulture_X = X(i,:);
current_vulture_F=fiti(ind,:);
fit(i,:)=fiti(ind,:);
% Update the first best two vultures if needed and Calculate the fitness of the population
if current_vulture_F(1)<Best_vulture1_F(1)
Best_vulture1_F=current_vulture_F; % Update the first best bulture
Best_vulture1_X=current_vulture_X;
end
if current_vulture_F(1)>Best_vulture1_F(1) && ...
current_vulture_F(1)<Best_vulture2_F(1)
Best_vulture2_F=current_vulture_F; % Update the second best bulture
Best_vulture2_X=current_vulture_X;
end
end
worst=max(fit(:,1));
a=unifrnd(-2,2,1,1)*((sin((pi/2)*(current_iter/max_iter))^gamma)+cos((pi/2)*(current_iter/max_iter))-1);
P1=(2*rand+1)*(1-(current_iter/max_iter))+a;
% Update the location
for i=1:size(X,1)
current_vulture_X = X(i,:); % pick the current vulture back to the population
F=P1*(2*rand()-1);
random_vulture_X=random_select(Best_vulture1_X,Best_vulture2_X,alpha,betha);
if (current_iter<=(1/3*max_iter))
current_vulture_X = exploration(current_vulture_X, random_vulture_X, F, p1, upper_bound, lower_bound);
% Exploitation:
elseif (current_iter>(1/3*max_iter)&& (current_iter<=(2/3*max_iter)))
prob=(fit(i)-worst)/(Best_vulture1_F(1)-worst);
if (prob>0.4)
current_vulture_X= exploitation(current_vulture_X, Best_vulture1_X, Best_vulture2_X, random_vulture_X, F, p2, p3, dim, upper_bound, lower_bound);
else
current_vulture_X = exploration(current_vulture_X, random_vulture_X, F, p1, upper_bound, lower_bound);
end
else
current_vulture_X = exploration(current_vulture_X, random_vulture_X, F, p1, upper_bound, lower_bound);
end
X(i,:) = current_vulture_X; % place the current vulture back into the population
end
current_iter=current_iter+1;
X = boundaryCheck(X, lower_bound, upper_bound);
fprintf('Iteration=%d Best_Fitness(Fitness Function,Accuracy,Precision,Recall,Specificity)=%f,%f,%f,%f,%f\n', current_iter,Best_vulture1_F );
end
end