Skip to main content
. 2022 Jan 27;14(3):512. doi: 10.3390/polym14030512
%% This function creates the first random population
function X = initialization(SearchAgents_no,dim,ub,lb)
Boundary_no = size(ub,2); % number of boundaries
% If the boundaries of all variables are equal and user enter a signal
% number for both ub and lb
if Boundary_no == 1
    X = rand(SearchAgents_no,dim).*(ub − lb) + lb;
end
% If each variable has a different lb and ub
if Boundary_no > 1
    for i = 1:dim
        ub_i = ub(i);
        lb_i = lb(i);
        X(:,i) = rand(SearchAgents_no,1).*(ub_i-lb_i) + lb_i;
    end
end