资源简介
鸡群算法CSO,求最优解,算法程序。。。。。。。。。。。。。。。。。。。。。。。
代码片段和文件信息
% -------------------------------------------------------------------------
% Chicken Swarm Optimization (CSO) (demo)
% Programmed by Xian-Bing Meng
% Updated at Jun 21 2015.
% Email: x.b.meng12@gmail.com
%
% This is a simple demo version only implemented the basic idea of CSO for
% solving the unconstrained problem namely Sphere function.
% The details about CSO are illustratred in the following paper.
% Xian-Bing Meng et al. A new bio-inspired algorithm: Chicken Swarm
% Optimization. The Fifth International Conference on Swarm Intelligence
%
% The parameters in CSO are presented as follows.
% FitFunc % The objective function
% M % Maxmimal generations (iterations)
% pop % Population size
% dim % Dimension
% G % How often the chicken swarm can be updated.
% rPercent % The population size of roosters accounts for “rPercent“
% percent of the total population size
% hPercent % The population size of hens accounts for “hPercent“ percent
% of the total population size
% mPercent % The population size of mother hens accounts for “mPercent“
% percent of the population size of hens
%
% Using the default valueCSO can be executed using the following code.
% [ bestX fMin ] = CSO
% -------------------------------------------------------------------------
%*************************************************************************
% Revision 1
% Revised at May 23 2015
% 1.Note that the previous version of CSO doen‘t consider the situation
% that there maybe not exist hens in a group.
% We assume there exist at least one hen in each group.
% Revision 2
% Revised at Jun 24 2015
% 1.Correct an error at line “100“.
%*************************************************************************
% Main programs
function [ bestX fMin ] = CSO( FitFunc M pop dim G rPercent hPercent mPercent )
% Display help
help CSO.m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% set the default parameters
if nargin < 1
FitFunc = @Sphere;
M = 1000;
pop = 100;
dim = 20;
G = 10;
rPercent = 0.15;
hPercent = 0.7;
mPercent = 0.5;
end
rNum = round( pop * rPercent ); % The population size of roosters
hNum = round( pop * hPercent ); % The population size of hens
cNum = pop - rNum - hNum; % The population size of chicks
mNum = round( hNum * mPercent ); % The population size of mother hens
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 );
fit( i ) = FitFunc( x( i : ) );
end
pFit = fit; % The individual‘s best fitness value
pX = x; % The individual‘s best position correspondi
评论
共有 条评论