A list,
1. Ant colony algorithm is proposed
Ant Colony Optimization algorithm (ACO), also known as ant algorithm, is a probabilistic algorithm used to find optimal paths. It was proposed by Marco Dorigo in his PhD thesis in 1992 and was inspired by the behavior of ants in finding their way to food. Genetic algorithm has been applied in pattern recognition, neural network, machine learning, industrial optimal control, adaptive control, biological science, social science and so on.
2. Basic principles of the algorithm
Ii. Source code
%% Clean environment CLC; Clear %% obstacle data position = load('barrier.txt');
plot([0.200], [0.200].'. ');
hold on
B = load('barrier.txt');
xlabel('km'.'fontsize'.12)
ylabel('km'.'fontsize'.12)
title('Two dimensional programming space'.'fontsize'.12) %% describe the starting point and ending point S = [20.180];
T = [160.90];
plot([S(1),T(1)],[S(2),T(2)].'. '); % text(S(1) +2,S(2),'S');
text(T(1) +2,T(2),'T'); Fill (position(1:4.1),position(1:4.2),0.0.0]);
fill(position(5:8.1),position(5:8.2),0.0.0]);
fill(position(9:12.1),position(9:12.2),0.0.0]);
fill(position(13:15.1),position(13:15.2),0.0.0]); % download link endpoint data L = load('lines.txt'); V = zeros(size(L));for i=1:20
plot([position(L(i,1),1),position(L(i,2),1)],[position(L(i,1),2)...
,position(L(i,2),2)].'color'.'black'.'LineStyle'.The '-');
v(i,:) = (position(L(i,1),:)+position(L(i,2), :)) /2;
plot(v(i,1),v(i,2),The '*');
text(v(i,1) +2,v(i,2),strcat('v',num2str(i))); End %% sign = load('matrix.txt');
[n,m]=size(sign);
for i=1:n
if i == 1
for k=1:m- 1
if sign(i,k) == 1
plot([S(1),v(k- 1.1)],[S(2),v(k- 1.2)].'color'.'black'.'Linewidth'.2.'LineStyle'.The '-');
end
end
continue;
end
for j=2:i
if i == m
if sign(i,j) == 1
plot([T(1),v(j- 1.1)],[T(2),v(j- 1.2)].'color'.'black'.'Linewidth'.2.'LineStyle'.The '-');
end
else
if sign(i,j) = =1
plot([v(i- 1.1),v(j- 1.1)],[v(i- 1.2),v(j- 1.2)],...
'color'.'black'.'Linewidth'.2.'LineStyle'.The '-');
end
end
end
end
path = DijkstraPlan(position,sign);
j = path(22);
plot([T(1),v(j- 1.1)],[T(2),v(j- 1.2)].'color'.'yellow'.'LineWidth'.3.'LineStyle'.'-');
i = path(22);
j = path(i);
count = 0;
while true
plot([v(i- 1.1),v(j- 1.1)],[v(i- 1.2),v(j- 1.2)].'color'.'yellow'.'LineWidth'.3.'LineStyle'.'-');
count = count + 1;
i = j;
j = path(i);
if i == 1 || j==1
break;
end
end
plot([S(1),v(i- 1.1)],[S(2),v(i- 1.2)].'color'.'yellow'.'LineWidth'.3.'LineStyle'.'-');
count = count+3;
pathtemp(count) = 22;
j = 22;
for i=2:count
pathtemp(count-i+1) = path(j);
j = path(j);
end
path = pathtemp;
path = [1 9 8 7 13 14 12 22]; %% Ant colony algorithm parameter initialization pathCount = length(path)2 -; % Number of line segments pheCacuPara=2; % Pheromone calculation parameter pheThres =0.8; % Pheromone selection threshold pheUpPara=[0.1 0.0003]; % pheromone update parameter QFZ = zeros(pathCount,10); PhePara = ones(pathCount,10)*pheUpPara(2); % pheromone qfzPara1 = ones(10.1) *0.5; % Inspire information parameter qfzPara2 =1.1; % Inspire information parameter m=10; % Population size NC=500; % number of cycles pathk = zeros(pathCount,m); % Search result records shortestPath = zeros(1,NC); % evolution record %% initial shortest path dijpathlen =0;
vv = zeros(22.2);
vv(1,:) = S;
vv(22,:) = T;
vv(2:21,:) = v;
for i=1:pathCount- 1
dijpathlen = dijpathlen + sqrt((vv(path(i),1)-vv(path(i+1),1)) ^2+(vv(path(i),2)-vv(path(i+1),2)) ^2); end LL = dijpathlen; %% lines = zeros(pathCount,4);
for i = 1:pathCount
lines(i,1:2) = B(L(path(i+1)- 1.1), :); lines(i,3:4) = B(L(path(i+1)- 1.2), :); endCopy the code
3. Operation results
Fourth, note
2014a