% initialize position vector and score for the leader
Leader_pos=zeros(1,dim);
Leader_score=inf; %change this to -inf for maximization problems
%Initialize the positions of search agents
% Positions=initialization(SearchAgents_no,dim,ub,lb);
Positions = repmat(lb, SearchAgents_no, 1)+ialgo(numm,SearchAgents_no,dim) .* repmat((ub-lb), SearchAgents_no, 1);
Convergence_curve=zeros(1,Max_iter);
t=0;% Loop counter
% Main loop
while tfor i=1:size(Positions,1)
% Return back the search agents that go beyond the boundaries of the search space
Flag4ub=Positions(i,:)>ub;
Flag4lb=Positions(i,:)function for each search agent
fitness=fobj(Positions(i,:));
% Update the leader
if fitnessthis to > for maximization problem
Leader_score=fitness; % Update alpha
Leader_pos=Positions(i,:);
end
end