A brief introduction to biogeographic algorithms
1 Basic IdeasBBO algorithm originated from biogeography. It can solve optimization problems by simulating the distribution, migration and mutation of multiple species in different habitats, and has been widely used in the field of multi-objective planning. A Habitat is considered as an independent area, and different habitats have different HSI (Habitat suitability Index). Habitats with higher HSI have higher species richness, and as the population tends to saturate, the migration rate increases and the migration rate decreases, while habitats with lower HIS, on the contrary, increase and decrease the migration rate. When the habitat of a disaster or pestilence sudden emergencies, such as HIS will then mutation, break the dynamic balance, is the habitat of the low ihs added unpredictability, increases the search target solution chance 2.2 migration and mutation operation migration of species has its specific physical model, most often have a linear model, the quadratic model, cosine model, etc. Taking the linear model in FIG. 3 as an example, when the number of species in a certain habitat is 0, the immigration rate is the highest. At this moment λ = I, with the increasing number of species, the immigration rate decreases and the emigration rate increases due to the limitations of sunlight, water, food and other resources. When the number of habitat species is S0, the dynamic equilibrium is reached, and the emigration rate is the same as the emigration rate. When the habitat reaches saturation state, the number of species reaches the maximum Smax. At this moment, no species will move in, and the migration rate μ = E. Mutation operation is completed based on biogeography statistical formula: Where, MS is the probability of habitat mutation, mmax is the maximum mutation rate, which can be set by users. Ps is the probability of habitat accommodating S species, and pmax is the probability of habitat accommodating the largest population.
Two, some source code
clear all
clc
nMonte = 100; % Number of Monte Carlo runs
DisplayFlag = true; % Whether or not to display results during run
GenFlag = true; % whether or not to exit BBO after population becomes uniform
PopSize = 30; % Population sizes for which to run SBBO
% Choose the test function
% ProblemFunction=@Sphere;
% ProblemFunction=@Ackley;
% ProblemFunction=@Fletcher;
% ProblemFunction=@Griewank;
% ProblemFunction=@Penalty1;
% ProblemFunction=@Penalty2;
ProblemFunction=@Quartic;
% ProblemFunction=@Rastrigin;
% ProblemFunction=@Rosenbrock;
% ProblemFunction=@Schwefel;
% or you objective function
% ProblemFunction=@YourObjectiveFunction;
%Chaotic_map_no=1; %Chebyshev
%Chaotic_map_no=2; %Circle
Chaotic_map_no=3; %Gauss/mouse
%Chaotic_map_no=4; %Iterative
%Chaotic_map_no=5; %Logistic
%Chaotic_map_no=6; %Piecewise
%Chaotic_map_no=7; %Sine
%Chaotic_map_no=8; %Singer
%Chaotic_map_no=9; %Sinusoidal
%Chaotic_map_no=10; %Tent
%You can define the number of search agents and iterations in the Init.m file
Max_iterations=10000; % This should be equalor greater than OPTIONS.Maxgen in Init.m file
ChaosVec=zeros(10,Max_iterations);
%Calculate chaos vector
for i=1:10
ChaosVec(i,:)=chaos(i,Max_iterations,1);
end
% BBO algorithm
[cg_curve0] = BBO(ProblemFunction, DisplayFlag, PopSize, GenFlag);
% BBO with chaotic selection operator
[cg_curve1] = CBBO1_10(ProblemFunction, DisplayFlag, PopSize, GenFlag,ChaosVec(Chaotic_map_no,:));
% BBO with chaotic migration operator
[cg_curve2] = CBBO11_20(ProblemFunction, DisplayFlag, PopSize, GenFlag,ChaosVec(Chaotic_map_no,:));
% BBO with chaotic mutation operator
[cg_curve3] = CBBO21_30(ProblemFunction, DisplayFlag, PopSize, GenFlag,ChaosVec(Chaotic_map_no,:));
% BBO with chaotic selection/migration operators combined
[cg_curve4] = CBBO31_40(ProblemFunction, DisplayFlag, PopSize, GenFlag,ChaosVec(Chaotic_map_no,:));
% BBO with chaotic selection/migration/mutation operators combined
[cg_curve5] = CBBO41_50(ProblemFunction, DisplayFlag, PopSize, GenFlag,ChaosVec(Chaotic_map_no,:));
semilogy(cg_curve0,'Color'.'y')
hold on
semilogy(cg_curve1,'Color'.'k')
semilogy(cg_curve2,'Color'.'b')
semilogy(cg_curve3,'Color'.'g')
semilogy(cg_curve4,'Color'.'r')
semilogy(cg_curve5,'Color'.'c')
xlabel('Iteration');
ylabel('Best score obtained so far');
axis tight
grid on
box on
legend('BBO'['CBBO' num2str(Chaotic_map_no)] , ['CBBO' num2str(Chaotic_map_no+10)] ,['CBBO' num2str(Chaotic_map_no+20)] ,['CBBO' num2str(Chaotic_map_no+30)] ,['CBBO' num2str(Chaotic_map_no+40)])
function [OPTIONS, MinCost, AvgCost, InitFunction, CostFunction, FeasibleFunction, ...
MaxParValue, MinParValue, Population] = Init(DisplayFlag, ProblemFunction, RandSeed)
% Initialize population-based optimization software.
% WARNING: some of the optimization routines will not work if population size is odd.
OPTIONS.popsize = 30; % total population size
OPTIONS.Maxgen = 499; % generation count limit
OPTIONS.numVar = 30; % number of genes in each population member
OPTIONS.pmutate = 0; % mutation probability
if ~exist('RandSeed'.'var')
RandSeed = round(sum(100*clock));
end
%rand('state', RandSeed); % initialize random number generator
if DisplayFlag
disp(['random # seed = ', num2str(RandSeed)]);
end
% Get the addresses of the initialization, cost, and feasibility functions.
[InitFunction, CostFunction, FeasibleFunction] = ProblemFunction();
% Initialize the population.
[MaxParValue, MinParValue, Population, OPTIONS] = InitFunction(OPTIONS);
% Make sure the population does not have duplicates.
Population = ClearDups(Population, MaxParValue, MinParValue);
% Compute cost of each individual
Population = CostFunction(OPTIONS, Population);
% Sort the population from most fit to least fit
Population = PopSort(Population);
% Compute the average cost
AverageCost = ComputeAveCost(Population);
% Display info to screen
MinCost = [Population(1).cost];
AvgCost = [AverageCost];
if DisplayFlag
disp(['The best and mean of Generation # 0 are ', num2str(MinCost(end)), ' and ', num2str(AvgCost(end))]);
end
return;
function O=chaos(index,max_iter,Value)
O=zeros(1,max_iter);
x(1) =0.7;
switch index
%Chebyshev map
case 1
for i=1:max_iter
x(i+1) =cos(i*acos(x(i)));
G(i)=((x(i)+1)*Value)/2;
end
case 2
%Circle map
a=0.5;
b=0.2;
for i=1:max_iter
x(i+1)=mod(x(i)+b-(a/(2*pi))*sin(2*pi*x(i)),1);
G(i)=x(i)*Value;
end
case 3
%Gauss/mouse map
for i=1:max_iter
if x(i)==0
x(i+1) =0;
else
x(i+1)=mod(1/x(i),1);
end
G(i)=x(i)*Value;
end
case 4
%Iterative map
a=0.7;
for i=1:max_iter
x(i+1) =sin((a*pi)/x(i));
G(i)=((x(i)+1)*Value)/2;
end
case 5
%Logistic map
a=4;
for i=1:max_iter
x(i+1)=a*x(i)*(1-x(i));
G(i)=x(i)*Value;
end
case 6
%Piecewise map
P=0.4;
for i=1:max_iter
if x(i)>=0 && x(i)<P
x(i+1)=x(i)/P;
end
if x(i)>=P && x(i)< 0.5x(i+1)=(x(i)-P)/(0.5-P);
end
if x(i)>=0.5 && x(i)<1-P
x(i+1)= (1-P-x(i))/(0.5-P);
end
if x(i)>=1-P && x(i)< 1x(i+1)= (1-x(i))/P;
end
G(i)=x(i)*Value;
end
case 7
%Sine map
for i=1:max_iter
x(i+1) = sin(pi*x(i));
G(i)=(x(i))*Value;
end
case 8
%Singer map
u=1.07;
for i=1:max_iter
x(i+1) = u*(7.86*x(i)23.31*(x(i)^2) +28.75*(x(i)^3)13.302875*(x(i)^4));
G(i)=(x(i))*Value;
end
case 9
%Sinusoidal map
for i=1:max_iter
x(i+1) = 2.3*x(i)^2*sin(pi*x(i));
G(i)=(x(i))*Value;
end
case 10
%Tent map
x(1)=0.6;
for i=1:max_iter
if x(i)<0.7
x(i+1)=x(i)/0.7;
end
if x(i)>=0.7
x(i+1) = (10/3) * (1-x(i));
end
G(i)=(x(i))*Value;
end
end
O=G;
Copy the code
3. Operation results
Matlab version and references
1 matlab version 2014A
[1] Yang Baoyang, YU Jizhou, Yang Shan. Intelligent Optimization Algorithm and Its MATLAB Example (2nd Edition) [M]. Publishing House of Electronics Industry, 2016. [2] ZHANG Yan, WU Shuigen. MATLAB Optimization Algorithm source code [M]. Tsinghua University Press, 2017.