%Butterfly optimization algorithm
% AroraS,SinghS.Butterflyoptimizationalgorithm:Anovel approach for global optimization [J].
% SoftComputing,2019,23 (3):715-734.
function [fmin,best_pos,Convergence_curve]=BOA(n,N_iter,Lb,Ub,dim,fobj)
% n is the population size
% N_iter represnets total number of iterations
p=0.8; % probabibility switch
power_exponent=0.1;
sensory_modality=0.01;
%Initialize the positions of search agents
Sol=initialization(n,dim,Ub,Lb);
for i=1:n
Fitness(i)=fobj(Sol(i,:));
end
% Find the current best_pos
[fmin,I]=min(Fitness);
best_pos=Sol(I,:);
S=Sol;
% Start the iterations -- Butterfly Optimization Algorithm
for t=1:N_iter
for i=1:n% Loop over all butterflies/solutions
%Calculate fragrance of each butterfly which is correlated with objective function
Fnew=fobj(S(i,:));
FP=(sensory_modality*(Fnew^power_exponent));
%Global or local search
if rand<p
dis = rand * rand * best_pos - Sol(i,:); %Eq. (2) in paper
S(i,:)=Sol(i,:)+dis*FP;
else
% Find random butterflies in the neighbourhood
epsilon=rand;
JK=randperm(n);
dis=epsilon*epsilon*Sol(JK(1),:)-Sol(JK(2),:);
S(i,:)=Sol(i,:)+dis*FP; %Eq. (3) in paper
end
% Check if the simple limits/bounds are OK
S(i,:)=simplebounds(S(i,:),Lb,Ub);
% Evaluate new solutions
Fnew=fobj(S(i,:)); %Fnew represents new fitness values
% If fitness improves (better solutions found), update then
if (Fnew<=Fitness(i))
Sol(i,:)=S(i,:);
Fitness(i)=Fnew;
end
% Update the current global best_pos
if Fnew<=fmin
best_pos=S(i,:);
fmin=Fnew;
end
end
Convergence_curve(t,1)=fmin;
%Update sensory_modality
sensory_modality=sensory_modality_NEW(sensory_modality, N_iter);
end
end
% Boundary constraints
function s=simplebounds(s,Lb,Ub)
% Apply the lower bound
ns_tmp=s;
I=ns_tmp<Lb;
ns_tmp(I)=Lb;
% Apply the upper bounds
J=ns_tmp>Ub;
ns_tmp(J)=Ub;
% Update this new move
s=ns_tmp;
end
function y=sensory_modality_NEW(x,Ngen)
y=x+(0.025/(x*Ngen));
end
夜深幻想乡
- 粉丝: 25
- 资源: 160
最新资源
- javaweb毕业生离校管理系统-lw.zip
- Java+swing实现学生信息管理系统源码.zip
- javaweb成绩分析系统.zip
- GitHub在线代码托管与协作平台使用指南
- Javaweb仓库管理系统项目源码.zip
- javaweb超市管理系统-lw.zip
- 创维8R93机芯 42E660E 主程序软件 电视刷机 固件升级包 (7618-T4200L-Y080 T1) VER01.0 SDL420FY(LDF-020)
- javaweb电子相册-lw.zip
- javaweb电影院在线购票系统-lw.zip
- javaweb电子政务网-lw.zip
- javaweb酒店客房预定管理系统.zip
- javaweb酒店客房预定管理系统-lw.zip
- 鱼眼标定资源,鱼眼标定资源,鱼眼标定资源
- javaWeb计算机配件报价系统项目源码.zip
- javaweb日记本-lw.zip
- javaweb人力资源管理系统-lw.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈