布谷鸟算法代码
有标准布谷鸟算法,自适应布谷鸟算法,模拟退火布谷鸟算法,有注释很详细
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 917022 2012-04-06 09:46 Adaptive Particle Swarm Optimization.pdf
文件 2884 2012-04-06 09:47 APSO.m
文件 276 2011-05-17 09:36 calfactor.m
文件 651 2011-05-18 20:58 fuzzyclassification.m
文件 121 2011-05-19 08:54 Rastrigrin.m
文件 122 2011-05-17 20:50 rosenbrock.m
文件 193 2011-05-18 21:02 s1.m
文件 193 2011-05-18 21:02 s2.m
文件 124 2011-05-18 21:02 s3.m
文件 123 2011-05-18 21:02 s4.m
----------- --------- ---------- ----- ----
921709 10
function [bestnestfmin]=beita_cuckoo_search(n) %布谷鸟算法主程序
clc;clear all;
if nargin<1
% Number of nests (or different solutions)
n=50; %初始化生成25个鸟巢
end
% Discovery rate of alien eggs/solutions
pa=0.25; %设置最大发现概率
%% Change this if you want to get better results
% Tolerance %精度
%Tol=1.0e-5;
%N_IterTotal=500;
%% Simple bounds of the search domain %设置搜索范围
% Lower bounds
%nd=5;
Lb=[-100 -100]; %上限
% Upper bounds
Ub=[100 100];
% Lb=[0 0 0 0 0 0]; %上限
% % Upper bounds
% Ub=[2460 7500 1100 12000 500 1000]; %下限
% Random initial solutions
for i=1:n %随机产生25个鸟窝的初始位置初始解
nest(i:)=Lb+(Ub-Lb).*rand(size(Lb));
end
% Get the current best
fitness=zeros(n1); %计算每个鸟窝的目标函数值得到当前的最优函数值
for i=1:n
fitness(i:)=fobj(nest(i:));
end
[fminbestnestnestfitness]=get_best_nest(nestnestfitness); %计算
N_iter=0; %设置一个计数器
%% Starting iterations %开始迭代
% while (fmin>Tol)
%
% % Generate new solutions (but keep the current best)
% new_nest=get_cuckoos(nestbestnestLbUb); %更新鸟窝位置 产生新解
% [fnewbestnestfitness]=get_best_nest(nestnew_nestfitness);%找出当前最优解
% % Update the counter %更新计数器
% N_iter=N_iter+n;
% % Discovery and randomization %随机评价是否要淘汰解
% new_nest=empty_nests(nestLbUbpa) ;
%
% % Evaluate this set of solutions
% [fnewbestnestfitness]=get_best_nest(nestnew_nestfitness);
% % plot(N_iterbestnest‘ks‘‘linewidth‘2‘MarkerEdgeColor‘‘k‘‘MarkerFaceColor‘‘g‘‘MarkerSize‘10)
% % Update the counter again
% N_iter=N_iter+n;
% % Find the best objective so far %找到目前最优解
% % plot(N_iterbestnest‘ks‘‘linewidth‘2‘MarkerEdgeColor‘‘k‘‘Marker
% % FaceColor‘‘g‘‘MarkerSize‘10)
% if fnew % fmin=fnew;
% bestnest=best;
% end
% plot(N_iterbestnest‘ks‘‘linewidth‘2‘MarkerEdgeColor‘‘k‘‘MarkerFaceColor‘‘g‘‘MarkerSize‘10)
% end %% End of iterations
flj=[]; %存放结果的数组
Tend=1e-3;
mm=1;
while mm>Tend
N_iter=N_iter+1;
% Generate new solutions (but keep the current best)
new_nest=get_cuckoos(nestbestnestfitness);
% for j=1:n
% if(new_nest(j:)Ub)
% new_nest(j:) = temp;
% end
% end
[fnewbestnestfitness]=get_best_nest(nestnew_nestfitness);
% Update the counter
% Discovery and randomization
new_nest=empty_nests(nestpa) ;
% Evaluate this set of solutions
[fnewbestnestfitness]=get_best_nest(nestnew_nestfitness);
% Update the counter again
% Find the best objective so far
if fnew fmin=fnew;
bestnest=best;
end
flj(N_iter1)=N_iter;
flj(N_iter2)=log10(abs(0-fmin));
plot(flj(:1)flj(:2)‘k‘)
xlabel(‘迭代次数‘)
ylabel(‘适应度值‘)
mm=abs(0-fmin);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 917022 2012-04-06 09:46 Adaptive Particle Swarm Optimization.pdf
文件 2884 2012-04-06 09:47 APSO.m
文件 276 2011-05-17 09:36 calfactor.m
文件 651 2011-05-18 20:58 fuzzyclassification.m
文件 121 2011-05-19 08:54 Rastrigrin.m
文件 122 2011-05-17 20:50 rosenbrock.m
文件 193 2011-05-18 21:02 s1.m
文件 193 2011-05-18 21:02 s2.m
文件 124 2011-05-18 21:02 s3.m
文件 123 2011-05-18 21:02 s4.m
----------- --------- ---------- ----- ----
921709 10
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)