資源簡介
布谷鳥求解函數的最小值,這是布谷鳥算法與萊維飛行的詳細講解(https://blog.csdn.net/zyqblog/article/details/80905019) 。

代碼片段和文件信息
%?script?布谷鳥算法,求解函數最小值
%?@author?zhaoyuqiang?
%#ok<*SAGROW>?Remove?hints?of?syntax
%#ok<*CLALL>
%#ok<*FNDSB>
clear?all?;?
close?all?;
clc?;
N?=?25;?% Number?of?nests(The?scale?of?solution)
D?=?10?;?%??Dimensionality?of?solution
T?=?200?;?%?Number?of?iterations
Xmax?=?20?;
Xmin?=?-20?;
Pa?=?0.25?;?%?Probability?of?building?a?new?nest(After?host?bird?find?exotic?bird?eggs)
nestPop?=?rand(ND)*(Xmax-Xmin)+Xmin?;??%?Random?initial?solutions
for?t=1:T
????levy_nestPop?=??func_levy(nestPopXmaxXmin)?;?%?Generate?new?solutions?by?Levy?flights
????nestPop?=?func_bestNestPop(nestPoplevy_nestPop);??%?Choose?a?best?nest?among??new?and?old?nests?????
????rand_nestPop?=?func_newBuildNest(nestPopPaXmaxXmin);?%?Abandon(Pa)?worse?nests?and?build?new?nests?by?(Preference?random?walk?)
????nestPop?=?func_bestNestPop(nestPoprand_nestPop)?;?%?Choose?a?best?nest?among??new?and?old?nests
????[~index]?=?max(func_fitness(nestPop))?;?%?Best?nests
????trace(t)?=?func_objValue(nestPop(index:))?;?
end
figure?
plot(trace);
xlabel(‘迭代次數‘)?;
ylabel(‘適應度值‘)?;
title(‘適應度進化曲線‘)?;
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-07-03?13:51??CS\
?????文件????????1128??2018-07-03?08:40??CS\CSMain.m
?????文件?????????224??2018-06-26?08:15??CS\func_fitness.m
?????文件?????????159??2018-06-26?07:27??CS\func_objValue.m
?????文件?????????658??2018-07-03?08:22??CS\func_levy.m
?????文件?????????239??2018-07-03?05:19??CS\func_bestNestPop.m
?????文件?????????485??2018-07-03?08:38??CS\func_newBuildNest.m
- 上一篇:粒子群算法求解函數極值 matlab
- 下一篇:matlab層次聚類算法
評論
共有 條評論