资源简介
matlab萤火虫代码,萤火虫搜索算法源代码
代码片段和文件信息
% Group Search Optimizer algorithm in Matlab
% Copyright (C) 2004-2005 Department of Electricity
% Engineering and Electronics The University of Liverpool UK
% Last modifed 12-May-05
function [fbestvalbestmemberhistory] = GSO(fnameMaxIter)
% function [fbestvalbestmember] = GSO(fnameNDimMaxIter)
%
% Run a Group Search Optimizer algorithm
%
% Input Arguments:
% fname - the name of the evaluation .m function
% NDim - dimension of the evalation function
% MaxIter - maximum iteration
close all
tic%计算程序使用时间,与程序结尾的toc相呼应
global NDim Acnumb
flag=0;
iteration = 0;
%-----------------------------
%MaxIter=10;
Best=zeros(MaxIter1);
%fname=‘DShapeweightplane10‘;
Bound=eval(fname);
PopSize=48; % population of members
angle=pi/4.*ones(NDim-1PopSize); % Initialize head angle
%leftangle=angle;
%rightangle=angle;
% Defined lower bound and upper bound.
LowerBound = zeros(NDimPopSize);
UpperBound = zeros(NDimPopSize);
for i=1:PopSize
LowerBound(:i)=Bound(:1);
UpperBound(:i)=Bound(:2);
end
%DResult = 1e-1; % Desired results
%-----------------------------%
vmax = ones(NDimPopSize);
for i=1:NDim
vmax(i:)=(UpperBound(i:)-LowerBound(i:));
end
r=norm(vmax(:1));
distance=r*repmat(ones(1PopSize)NDim1);
a= round(((NDim+1)^.5));
direction=zeros(NDimPopSize);
for j=1:PopSize
direction(1j)=(cos(angle(1j)));
for i=2:NDim-1
direction(ij)=cos(angle(ij)).*prod(sin(angle(i:NDim-1j)));
end
direction(NDimj)=prod(sin(angle(1:NDim-1j)));
end
initialization=1;
while initialization==1
initialization=0;
%---------包含初始设计值-------%
population = rand(NDim PopSize).*(UpperBound-LowerBound) + LowerBound; % Initialize swarm population
%population(:1)
%-----------------------------%
%-----------add---------------%
population(1:Acnumb:)=round(population(1:Acnumb:)*100000)/100000;%
population(Acnumb+1:NDim:)=round(population(Acnumb+1:NDim:)*1000)/1000;%
exexutefunction=strcat(fname‘(population)‘);
% Evaluate initial population
fvalue = eval(exexutefunction);
if min(fvalue) == inf
initialization=1;
end
end
% Finding best member in initial population
[fbestvalindex] = min(fvalue);
bestmember=population(:index);
oldangle=angle;
oldindex=index; %#ok
badcounter=0;
while(flag == 0) && (iteration < MaxIter)
%rand(‘state‘sum(100*clock))
iteration = iteration +1;
for j=1:PopSize
R1=randn(1);
R2=rand(NDim-11);
R3 = rand(NDim 1);
if j==index % Stop and search around
SamplePosition=zeros(NDim4);
SampleAngle=zeros(NDim-14);
SampleValue=zeros(14);
leftangle=(pi/(a^2)).*R2+angle(:j); %trun left the angle range between new and old direction is \in [0pi/a^2]
rightangle=-(pi/(a^2)).*R2+angle(:j); %trun right the angle range between new and old direction is \in [0pi/a^2]
distance(:j)=
- 上一篇:matlab 附和导线平差
- 下一篇:PSNR和归一化相关系数NC值
相关资源
- matlab_OFDM调制解调(来自剑桥大学)
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
评论
共有 条评论