%% This function creates random walks |
function X = initialization(SearchAgents_no,dim,ub,lb) |
function [RWs] = Random_walk_around_antlion(Dim,max_iter,lb, ub,antlion,current_iter) |
if size(lb,1) == 1 && size(lb,2) == 1 %Check if the bounds are scalar |
lb = ones(1,Dim)*lb; |
ub = ones(1,Dim)*ub; |
end |
if size(lb,1) > size(lb,2) %Check if boundary vectors are horizontal or vertical |
lb = lb’; |
ub = ub’; |
end |
I = 1; % I is the ratio in Eq. (6) |
if current_iter>max_iter/10 |
I = 1 + 100*(current_iter/max_iter); |
end |
…… |
if current_iter > max_iter*(0.95) |
I = 1 + 1000000*(current_iter/max_iter); |
end |
% Decrease boundaries to converge towards antlion |
% Equation (5) in the paper |
lb = lb/(I); |
ub = ub/(I); |
% Move the interval of [lb ub] around the antlion [lb + anlion ub + antlion] |
% Equation (4) in the paper |
if rand < 0.5 |
lb = lb + antlion; |
end |
if rand >= 0.5 |
ub = ub + antlion; |
else |
ub = −ub + antlion; |
end |
for i = 1:Dim |
X = [0 cumsum(2*(rand(max_iter,1) > 0.5) − 1)’]; % Equation (1) in the paper |
X_norm = ((X − a).*(d − c))./(b − a) + c; % Equation (3) in the paper |
end |