資源簡介
蜂群算法作為一種經典的群體智能算法,受到廣泛應用
代碼片段和文件信息
clear?all
clc
%%?初始化開始?%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ant?=?300;
Times?=?80;???????????????%%螞蟻移動次數
Rou?=?0.9;????????????????%%信息素揮發系數
P0?=?0.2;
Lower_1?=?-1;
Upper_1?=?1;
Lower_2?=?-1;
Upper_2?=?1;
%%?設置螞蟻初始位置?%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for?i?=?1:Ant
????X(i1)=(Lower_1+(Upper_1-Lower_1)*rand);
????X(i2)=(Lower_2+(Upper_2-Lower_2)*rand);
????Tau(i)=F(X(i1)X(i2));
end
step?=0.05;
f?=?‘-(x.^4+3*y^4-0.2*cos(3*pi*x)-0.4*cos(4*pi*y)+0.6)‘;
[xy]=meshgrid(Lower_1:step:Upper_1Lower_2:step:Upper_2);
z?=?eval(f);
figure(1);
subplot(121);
mesh(xyz);
hold?on;
plot(X(:1)X(:2)Tau‘k*‘)
hold?on;
text(0.10.8-0.1‘螞蟻的初始分布位置‘);
xlabel(‘x‘);ylabel(‘y‘);zlabel(‘f(xy)‘);
for?T=1:Times
????lamda?=?1/T;
????[Tau_Best(T)BestIndex]=max(Tau);
???
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-10-11?16:01??ACO\
?????文件????????2060??2016-10-11?16:01??ACO\ACO.asv
?????文件????????2060??2016-10-11?16:01??ACO\ACO.m
?????文件??????????83??2016-10-11?16:01??ACO\F.m
- 上一篇:共軛梯度法的程序
- 下一篇:二進制基帶脈沖成形及眼圖的繪制
評論
共有 條評論