资源简介
鸟群算法源代码,可以直接下载使用,里面包含了基本的算法测试函数和应用框架,在研究生期间研究算法的同学可以尝试下载。
代码片段和文件信息
% ------------------------------------------------------------------------
% Bird Swarm Algorithm (BSA) (demo)
% Programmed by Xian-Bing Meng
% Updated at Jun 19 2015.
% Email: x.b.meng12@gmail.com
%
% This is a simple demo version only implemented the basic idea of BSA for
% solving the unconstrained problem namely Sphere function.
%
% The details about BSA are illustratred in the following paper.
% Xian-Bing Meng et al (2015): A new bio-inspXred optimisation algorithm:
% Bird Swarm Algorithm Journal of Experimental & Theoretical
% Artificial Intelligence DOI: 10.1080/0952813X.2015.1042530
%
% The parameters in BSA are presented as follows.
% FitFunc % The objective function
% M % Maxmimal generations (iterations)
% pop % Population size
% dim % Number of dimensions
% FQ % The frequency of birds‘ flight behaviours
% c1 % cognitive accelerated coefficient
% c2 % social accelerated coefficient
% a1 a2 %two paramters which are related to the indirect and direct
% effect on the birds‘ vigilance bahaviors.
%
% Using the default value BSA can be executed using the following code.
% [ bestX fMin ] = BSA
% ------------------------------------------------------------------------
% Main programs
function b = BSA % function [ bestX fMin ] = BSA( FitFunc M pop dim FQ c1 c2 a1 a2 )
% Display help
% help BSA.m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% set the default parameters
% if nargin < 1
% FitFunc = @Sphere; %函数句柄
M = 1000;
pop = 30;
% dim = 20;
dim = 4;
FQ = 10;
c1 = 1.5;
c2 = 1.5;
a1 = 1;
a2 = 1;
% end
% set the parameters
lb= -100*ones( 1dim ); % Lower bounds
ub= 100*ones( 1dim ); % Upper bounds
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Initialization
for i = 1 : pop
x( i : ) = lb + (ub - lb) .* rand( 1 dim ); %i个体 x位置 i行20列
% y( i : ) = lb + (ub - lb) .* rand( 1 dim );
fit( i ) = f( x( i : )); %i 个体适应度值
% fit( i ) = f( x( i : )y( i : ));
end
% 初始种群适应度值 个体
pFit = fit; % The individual‘s best fitness value 个体以往最优适应度值
pX = x; % The individual‘s best position corresponding to the pFit
% pY = y; % 个体以往最优适应度值对应的位置x
% 全局
[ fMin bestIndex ] = min( pFit );
% [ fMin bestIndex ] = min( fit ); % fMin denotes the global optimum(全局最优解)
% 选出最小的适应度值(全局最优解) 返回最小的适应度函数值和最优位置指标
bestX = pX( bestIndex : );
% bestY = pY( bestIndex : );
% bestX = x( bestIndex : ); % bestX denotes the position corresponding to fMin
% 全局最小适应度值对应的位置x
I = 1;
b(1) = fMin;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Start the iteration.
% for I = 1 : M %iteration 改为 I
while I <= M-1
prob = rand(
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 11002 2017-11-26 11:08 改进鸟群算法源码\BSA.m
文件 9508 2017-10-30 20:06 改进鸟群算法源码\CSO.m
文件 9337 2017-11-26 11:15 改进鸟群算法源码\f.m
文件 1093 2017-11-26 11:08 改进鸟群算法源码\PSO.m
文件 1465 2017-11-26 11:02 改进鸟群算法源码\runtest.m
文件 11970 2017-11-26 11:08 改进鸟群算法源码\UBSA.m
目录 0 2018-01-28 20:59 改进鸟群算法源码
----------- --------- ---------- ----- ----
44375 7
- 上一篇:MSP430F5529 I2C样例程序
- 下一篇:CPU5(success).zip
评论
共有 条评论