资源简介
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 附和导线平差
- MATLAB数字信号处理工具箱
- 基于霍夫曼编码实现的图像无损压缩
- matlab可用粒子群工具箱 - PSOt
- matlab资源——NIT工具箱
- 朴素贝叶斯算法matlab实现
- 近邻传播聚类-MATLAB程序
- Camshift跟踪 Matlab实现
- 三种esprit算法实现doa估计
- matlab各种图像压缩源代码
- matlab小波变换合集
- 最大后验概率 MAP 准则matlab源码
- 非线性系统辨识
- 异步电机matlab仿真
- matlab 数字升余弦仿真
- 多重网格法求解微分方程-matlab
- 批量读取温度数据
- MATLAB实现DPCM编码
- lz复杂度计算的matlab程序
- 最小二乘法Matlab代码
- matlab 程序\\\\多项式拟合插值.rar
- matlab水准网平差
- 关于汽车的制动性的MAtlab仿真
- 使用Matlab和CCS设计FIR滤波器
- 用matlab语言实现编解码
- 模拟退火算法进行函数优化 matlab
- 通信原理仿真实验 matlab
- 数学物理方程大作业 matlab
- VIBE-MEX--
- 复化Simpson公式
评论
共有 条评论