1 简介
缎蓝园丁鸟优化算法是一种新型的元启发式优化算法,针对其收敛速度慢,寻优精度低的不足,提出了一种基于自适应t分布变异的缎蓝园丁鸟优化(tSBO)算法.在tSBO算法中引入了自适应t分布变异算子,使用算法的迭代次数作为t分布的自由度参数来增强种群的多样性,避免算法陷入局部最优.通过6个标准测试函数对改进算法与FPA,BA和基本SBO算法进行测试比较,仿真结果表明,改进算法是可行有效的,相比于基本SBO算法,其收敛精度和鲁棒性有了很大程度的提高.
2 部分代码
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Satin Bowerbird Optimizer(SBO)
%%
clc;
clear;
close all;
tic
%% Problem Definition
Function_name='F1';
[lowerbound,upperbound,numbervar,costfcn]=cost_functions(Function_name);
% VarSize=[1 numbervar];
%% SBO Parameters
[MaxIt,nPop,alpha,pMutation,sigma]=SBO_parameters(lowerbound,upperbound);
%% Initialization
[pop,elite,BestCost]=Initialization(nPop,lowerbound,upperbound,numbervar,MaxIt,costfcn);
%% SBO Main Loop
for it=1:MaxIt
newpop=pop;
%Calculating the Fitness of each bower
F=zeros(nPop,1);
for i=1:nPop
if pop(i).Cost>=0
F(i)=1/(1+pop(i).Cost);
else
F(i)=1+abs(pop(i).Cost);
end
end
%Calculating the probability of each bower
P=F/sum(F);
%changes at any bower
for i=1:nPop
for k=1:numbervar
% Select target bower
j=RouletteWheelSelection(P);
% Calculating Step Size
lambda=alpha/(1+P(j));
newpop(i).Position(k)=pop(i).Position(k) ...
+lambda*(((pop(j).Position(k)+elite(k))/2)-pop(i).Position(k));
% Mutation
if rand<=pMutation
newpop(i).Position(k)=newpop(i).Position(k)+(sigma*randn);
end
end
% Evaluation
newpop(i).Cost=costfcn(newpop(i).Position);
end
pop=[pop
newpop
]; %#ok
% Sort Population
[~, SortOrder]=sort([pop.Cost]);
pop=pop(SortOrder);
pop=pop(1:nPop);
% Update Best Solution Ever Found
BestSol=pop(1);
elite=BestSol.Position;
% Store Best Cost Ever Found
BestCost(it)=BestSol.Cost;
% Show Iteration Information
disp(['SBO:: Iteration-> ' num2str(it) '<----->Best Cost = ' num2str(BestCost(it))]);
end
toc
%% Results
disp(['BestSol=' num2str(elite)]);
disp(['BestCost=' num2str(BestSol.Cost)]);
figure;
semilogy(BestCost,'LineWidth',2);
xlabel('Iteration');
ylabel('Best Cost');
img =gcf; %获取当前画图的句柄
print(img, '-dpng', '-r600', './img.png') %即可得到对应格式和期望dpi的图像
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.
- 51.
- 52.
- 53.
- 54.
- 55.
- 56.
- 57.
- 58.
- 59.
- 60.
- 61.
- 62.
- 63.
- 64.
- 65.
- 66.
- 67.
- 68.
- 69.
- 70.
- 71.
3 仿真结果
4 参考文献
[1]韩斐斐, 刘升. 基于自适应t分布变异的缎蓝园丁鸟优化算法[J]. 微电子学与计算机, 2018, 35(8):5.