基本信息
源码名称:IFSA人工鱼群算法
源码大小:4.57KB
文件格式:.zip
开发语言:MATLAB
更新时间:2020-01-05
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
人工鱼群算法是李晓磊等人提出的一种基于动物行为的群体智能优化算法[8],通过模拟鱼类觅食、聚群、追尾随机等行为在搜索范围中寻优。在实际应用中,人工鱼群算法对目标函数的性质、优化参数的初值和参数范围的设定要求不高,并且具有较快的并行寻优能力,也具有一定的全局寻优能力。
clc
clear all
close all
tic
figure(1);
hold on
%%参数设置
fishnum=100;
MAXGEN=50;%最大迭代次数
try_number=100;
visual=2.5;
step=0.3;
delta=0.618;
%初始化鱼群
lb_ub=[-10,10,2];
X=AF_init(fishnum,lb_ub);
LBUB=[];
for i=1:size(lb_ub,1)
LBUB=[LBUB;repmat(lb_ub(i,1:2),lb_ub(i,3),1)];
end
gen=1;
BestY=-1*ones(1,MAXGEN);%每步中最优的函数值
BestX=-1*ones(1,MAXGEN);%每步中最优的自变量
besty=-100;%最优函数值
Y=AF_foodconsistence(X);
while gen<=MAXGEN
fprintf(1,'%d\n',gen)
for i=1:fishnum
[Xi2,Yi2]=AF_follow(X,i,visual,step,delta,try_number,LBUB,Y);%追尾
[Xi1,Yi1]=AF_swarm(X,i,visual,step,delta,try_number,LBUB,Y);%聚群
if Yi1>Yi2
X(:,i)=Xi1;
Y(1,i)=Yi1;
else
X(:,i)=Xi2;
Y(1,i)=Yi2;
end
end
[Ymax,index]=max(Y);
figure(1);
plot(X(1,index),X(2,index),'.','color',[gen/MAXGEN,0,0])
if Ymax>besty
besty=Ymax;
bestx=X(:,index);
BestY(gen)=Ymax;
[BestX(1,gen)]=X(1,index);
[BestX(2,gen)]=X(2,index);
else
BestY(gen)=BestY(gen-1);
[BestX(:,gen)]=BestX(:,gen-1);
end
gen=gen 1;
end
clear all
close all
tic
figure(1);
hold on
%%参数设置
fishnum=100;
MAXGEN=50;%最大迭代次数
try_number=100;
visual=2.5;
step=0.3;
delta=0.618;
%初始化鱼群
lb_ub=[-10,10,2];
X=AF_init(fishnum,lb_ub);
LBUB=[];
for i=1:size(lb_ub,1)
LBUB=[LBUB;repmat(lb_ub(i,1:2),lb_ub(i,3),1)];
end
gen=1;
BestY=-1*ones(1,MAXGEN);%每步中最优的函数值
BestX=-1*ones(1,MAXGEN);%每步中最优的自变量
besty=-100;%最优函数值
Y=AF_foodconsistence(X);
while gen<=MAXGEN
fprintf(1,'%d\n',gen)
for i=1:fishnum
[Xi2,Yi2]=AF_follow(X,i,visual,step,delta,try_number,LBUB,Y);%追尾
[Xi1,Yi1]=AF_swarm(X,i,visual,step,delta,try_number,LBUB,Y);%聚群
if Yi1>Yi2
X(:,i)=Xi1;
Y(1,i)=Yi1;
else
X(:,i)=Xi2;
Y(1,i)=Yi2;
end
end
[Ymax,index]=max(Y);
figure(1);
plot(X(1,index),X(2,index),'.','color',[gen/MAXGEN,0,0])
if Ymax>besty
besty=Ymax;
bestx=X(:,index);
BestY(gen)=Ymax;
[BestX(1,gen)]=X(1,index);
[BestX(2,gen)]=X(2,index);
else
BestY(gen)=BestY(gen-1);
[BestX(:,gen)]=BestX(:,gen-1);
end
gen=gen 1;
end