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
%function [bestroute,routelength]=Ant CLC clear tic %'CooCity.txt'); % City network map coordinate data file, given in TXT form NC=length(CooCity); % Number of citiesfor i=1:NC % Calculates the distance between citiesfor j=1:NC
distance(i,j)=sqrt((CooCity(i,2)-CooCity(j,2)) ^2+(CooCity(i,3)-CooCity(j,3)) ^2);
end
end
% distance=xlsread('DistanceCity.xls'); % inter-city distance matrix data file, given in Excel form MAXIT=10; Citystart=[]; % Starting city number tau=ones(NC,NC); % The information trace on each edge at the initial moment is1
rho=0.5; % volatility coefficient alpha=1; % Residual information relative importance beta=5; % Relative importance of predicted values Q=10; % ant ring constant NumAnt=20; % Ant count %bestroute=zeros(1.48); Routelength = INF; % is used to record the optimal path length currently foundfor n=1:MAXIT
for k=1The K ant deltatau=zeros(NC,NC); %[Routek,lengthk]= Path (distance, Tau,alpha,beta,[]); Rate of % without starting point [routek lengthk] = path (short, tau, alpha, beta, Citystart); % specifies the starting pointifLengthk < Routelength % Find a better path routelength=lengthk; bestroute=routek; endfor i=1:NC- 1% Amount of information released by the KTH ant on the path deltatau(Routek (I), Routek (I +1))=deltatau(routek(i),routek(i+1))+Q/lengthk; End %deltatau(routek(NC),1)=deltatau(routek(NC),1)+Q/lengthk; %
end
length_n(n)=routelength; % record path convergence tau=(1-rho).*tau; Pheromone volatilization end % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % costtime = toc; subplot(1.2.1),plot([CooCity(bestroute,2)],[CooCity(bestroute,3)].'- *')
subplot(1.2.2),plot([1:MAXIT],length_n,'- *')
[routelength,costtime]
Copy the code
3. Operation results
Fourth, note
Version: 2014 a