资源简介
人工鱼群算法,Matlab源代码,绝对没问题,可以跑的
代码片段和文件信息
function AF
clc;clear all; close all;
format long
Visual = 2.5;
Step = 0.3;
N = 50;
Try_number = 50;
a1 = -10; b1 = 10; a2 = -10; b2 = 10; d = []; h = 1e-1;
Friend_number = 50; k = 0; m = 50;
X1 = rand(N1)*(b1-a1)+a1;
X2 = rand(N1)*(b2-a2)+a2;
X = [X1 X2]; % 人工鱼数量
for i = 1:N
www = [X(i1)X(i2)];
d(i) = maxf(www);
end
[wi] = max(d);
maxX = [X(i1)X(i2)]; % 初始公告板记录
maxY = w; % 初始化公告板记录
figurex = []; figurey = []; figurez = [];
figurex(numel(figurex)+1) = maxX(1);
figurey(numel(figurey)+1) = maxX(2);
figurez(numel(figurez)+1) = maxY;
kkk = 0;
while(k for i = 1:N
XX = [X(i1)X(i2)]; % 人工鱼当前状态Xi
nf = 0;
Xc = 0;
for j = 1:N % 聚群行为开始
XXX = [X(j1) X(j2)];
if (norm(XXX-XX) nf = nf+1;
Xc = Xc+XXX;
end
end
Xc = Xc/nf;
if(maxf(Xc) > maxf(XX))
XXnext1 = XX+rand*Step*(Xc-XX)/norm(Xc-XX);
if(XXnext1(1) > b1)
XXnext1(1) = b1;
end
if(XXnext1(1) < a1)
XXnext1(1) = a1;
end
if(XXnext1(2) > b2)
XXnext1(2) = b2;
end
if(XXnext1(2) < a2)
XXnext1(2) = a2;
end
else
XXnext1 = gmjprey(XXTry_numberVisualStep);
if(XXnext1(1) > b1)
XXnext1(1) = b1;
end
if(XXnext1(1) < a1)
XXnext1(1) = a1;
end
if(XXnext1(2) > b2)
XXnext1(2) = b2;
end
if(XXnext1(2) < a2)
XXnext1(2) = a2;
end
end % 聚群行为结束
% maxX = XX; % 追尾行为开始
% maxY = maxf(XX);
for j = 1:Friend_number
XXX = [X(j1)X(j2)];
if(norm(XXX-XX)
相关资源
- 33节点的遗传算法无功优化MATLAB程序
- matlab图像处理gui49054
- 时滞系统的模糊PID控制的matlab/simuli
- 基于matlab异步电机矢量控制
- SLEP工具包
- 基于Matlab随机时间序列预测模型数据
- 快速傅里叶变换算法matlab实现
- 模式识别之线性分类器的matlab实现
- 基于粒子群算法的无功优化MATLAB源代
- rs码编译码的matlab代码
- matlab 整流器模型svpwm
- matlab APF
-
simuli
nk搭建的转速电流双闭环直流调 - 通信信号特征参数的提取matlab代码
- MATLAB图像分割提取算法源代码---车牌
- am调制解调系统仿真matlab代码
- 极值搜索算法程序
- 异步电机矢量控制模型——matlab自带
- 利用Matlab实现PCm编码的A律13折线法量
- l-bfgs的matlab代码
- 三相SVPWM逆变器仿真
- 正则化粒子滤波matlab程序
- Matlab实现灰度图像转换成RGB图像
- MATLAB画三维球体、半球体、圆柱、山
- matlab-logistic图像加密解密-彩色-灰度都
- MATLAB程序设计与应用(刘卫国-第3版)
- RNN-LSTM 卷积神经网络 Matlab 实现,简单
- MATLAB mexopts配置文件.zip
- nurbs曲线matlab程序代码
- matlab与机器学习百度云分享
评论
共有 条评论