資源簡介
有標準布谷鳥算法,自適應布谷鳥算法,模擬退火布谷鳥算法,有注釋很詳細

代碼片段和文件信息
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;????????%設置最大發(fā)現(xiàn)概率
%%?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);????%計算每個鳥窩的目標函數(shù)值得到當前的最優(yōu)函數(shù)值
for?i=1:n
????fitness(i:)=fobj(nest(i:));
end
[fminbestnestnestfitness]=get_best_nest(nestnestfitness);???%計算
N_iter=0;???????%設置一個計數(shù)器
%%?Starting?iterations??????????%開始迭代
%?while?(fmin>Tol)
%?
%?????%?Generate?new?solutions?(but?keep?the?current?best)
%??????new_nest=get_cuckoos(nestbestnestLbUb);?%更新鳥窩位置?產生新解?
%??????[fnewbestnestfitness]=get_best_nest(nestnew_nestfitness);%找出當前最優(yōu)解
%?????%?Update?the?counter??%更新計數(shù)器
%???????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??%找到目前最優(yōu)解
%?%?????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=[];???%存放結果的數(shù)組
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(‘迭代次數(shù)‘)
????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
評論
共有 條評論