1 简介
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的图像
3 仿真结果
4 参考文献
[1]王依柔、张达敏、樊英. "非均匀变异的互利自适应缎蓝园丁鸟优化算法." 计算机工程与科学 v.42;No.312.12(2020):135-143.
[2]鲁晓艺, 刘升, 韩斐斐,等. 基于自适应权重的缎蓝园丁鸟优化算法[J]. 智能计算机与应用, 2018, 8(6):7.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。