Begin |
Step 1: Parameter Initialization. Initialize the number of dimensions in the search space p, the |
swarm size of the population S, the number of chemotactic steps Nc, the swimming length Ns, the |
number of reproduction steps Nre, the number of elimination-dispersal events Ned, the |
elimination-dispersal probability Ped, the size of the step C(i) taken in the random direction |
specified by the tumble. |
Step 2: Population Initialization. Calculate chaotic sequence according to Eq. (6). The |
corresponding chaotic bacterial population is calculated according to the original bacterial |
population mapped into the chaotic sequence according to Eq. (7). From the original and its |
corresponding chaotic bacterial populations, S superior individuals are selected as the initial |
solutions of bacterial populations. |
Step 3: for ell=1:Ned /Elimination and dispersal loop/ |
for K=1:Nre /Reproduction loop/ |
for j=1:Nc / chemotaxis loop/ |
Intertime=Intertime+1; / represent the number of iterations/ |
for i=1:s |
/fobj represents calculating the fitness of the ith bacterium at the jth |
chemotactic, Kth reproductive, and lth elimination-dispersal steps./ |
J(i,j,K,ell)=fobj(P(:,i,j,K,ell)); |
/ Jlast stores this value since a cost better than a run may be identified./ |
Jlast=J(i,j,K,ell); |
/ gbest(1,:) stores the current optimal bacterial individual./ |
gbest(1,:)=P(:,i,j,K,ell); |
Tumble according to Eq.(5) |
/Swim (for bacteria that seem to be headed in the right direction)/ |
m=0; / Initialize counter for swim length/ |
while m<Ns |
m=m+1; |
if J(i,j+1,K,ell)<Jlast |
/ Jlast stores this value since a cost better than a run may be identified./ |
Jlast=J(i,j+1,K,ell); |
Tumble according Eq.(5) |
if Jlast<Gbest |
/ Gbest stores the current optimal fitness function value./ |
Gbest = Jlast; |
gbest(1,:)=P(:,i,j+1,K,ell); |
End |
else |
m=Ns; |
End |
Gaussian mutation operation |
Moth_pos_m_gaus=gbest(1,:)(1+randn(1)); |
Moth_fitness_m_gaus=fobj(Moth_pos_m_gaus); |
Moth_fitness_s=fobj(gbest(1,:)); |
Moth_fitness_comb=[Moth_fitness_m_gaus,Moth_fitness_s]; |
[~,mm]=min(Moth_fitness_comb); |
if mm==1 |
gbest(1,:)=Moth_pos_m_gaus; |
end |
fitnessGbest = fobj(gbest(1,:)); |
if fitnessGbest<Gbest |
Gbest = fitnessGbest; |
end |
End |
End /Go to next bacterium/ |
End /Go to the next chemotactic/ |
/Reproduction/ |
Jhealth=sum(J(:,:,K,ell),2); / Set the health of each of the S bacteria/ |
[Jhealth, sortind]=sort(Jhealth); /Sorts the nutrient concentration in order of ascending/ |
/ Rearrange the bacterial population/ |
P(:,:,1,K+1,ell)=P(:,sortind,Nc+1,K,ell); |
/Split the bacteria (reproduction)/ |
for i=1:Sr |
/The least fit do not reproduce, the most fit ones split into two identical copies/ |
P(:,i+Sr,1,K+1,ell)=P(:,i,1,K+1,ell); |
End |
End /Go to next reproduction/ |
/Elimination-Dispersal/ |
for m=1:s |
if Ped>rand /randomly generates a new individual anywhere in the solution space./ |
Reinitialize bacteria m |
End |
End |
End /Go to next Elimination-Dispersal/ |
End |