A list,
1 Origin and development history of Ant Colony Algorithm (ACA) Marco Dorigo et al. found that ant colonies can quickly find targets by secreting biohormones called pheromones to communicate foraging information when searching for food. Therefore, in his doctoral dissertation in 1991, he first systematically proposed a new intelligent optimization algorithm “Ant System” (AS for short) based on Ant population. Later, the proposer and many researchers made various improvements to the algorithm and applied it to a wider range of fields. Figure coloring problem, secondary assignment problem, workpiece sequencing problem, vehicle routing problem, job shop scheduling problem, network routing problem, large-scale integrated circuit design and so on. In recent years, M.Dorigo et al. further developed Ant algorithm into a general Optimization technology “Ant Colony Optimization (ACO)”, and called all the algorithms conforming to ACO framework “ACO algorithm”.
Specifically, individual ants start looking for food without first telling them where it is. When an ant finds food, it releases a volatile pheromone (called a pheromone, it evaporates over time and its concentration indicates how far the path is) into the environment that other ants sense as a guide. Generally, when there are pheromones on multiple paths, the ant will preferentially choose the path with high pheromone concentration, so that the pheromone concentration of the path with high pheromone concentration will be higher, forming a positive feedback. Some ants do not repeat the same route as others. They take a different route. If the alternative path is shorter than the original one, gradually more ants are attracted to the shorter path. Finally, after some time of running, there may be a shortest path repeated by most ants. In the end, the path with the highest pheromone concentration is the optimal one selected by the ant.
Compared with other algorithms, ant colony algorithm is a relatively young algorithm, characteristics, such as distributed computing center control and asynchronous indirect communication between individuals, and is easy to be combined with other optimization algorithms, through many healthyenterprise continuously explore, to today has developed a variety of improved ant colony algorithm, but the principle of ant colony algorithm is still the main.
2. Solving principle of ant colony algorithm
Based on the above description of ant colony foraging behavior, the algorithm mainly simulates foraging behavior from the following aspects:
(1) The simulated graph scene contains two pheromones, one representing home and one representing food location, and both pheromones are volatilized at a certain rate.
(2) Each ant can perceive information only in a small part of the area around it. Ants searching for food, if within the scope of the perception, can directly in the past, if is beyond the scope of awareness, will be toward more than pheromones, ants can have a small probability pheromone many places don’t go, and instead, it is very important to the small probability event, represents a way of innovation, is very important to find a better solution.
(3) Ants return to the nest using the same rules as when they find food.
(4) When ants move, they will first follow the guidance of pheromone. If there is no guidance of pheromone, they will follow the direction of their moving inertia, but there is a certain probability of changing direction. Ants can also remember the path they have already walked, so as to avoid repeating the same place.
(5) The ants leave the most pheromones when they find food, and then the farther away they are from the food, the less pheromone they leave. The rules for finding nest pheromones are the same as for food. Ant colony algorithm has the following characteristics: positive feedback algorithm, concurrency algorithm, strong robustness, probabilistic global search, does not rely on strict mathematical properties, long search time, easy to stop phenomenon.
Ant transfer probability formula:
In the formula, is the probability of ant K transferring from city I to city J; α and β were the relative importance of pheromones and heuristic factors, respectively. Is the pheromone quantity on edge (I, j); Is the heuristic factor; The next step for Ant K allows the selection of cities. The above formula is the pheromone update formula in the ant system, and is the pheromone quantity on the edge (I,j). ρ is the evaporation coefficient of pheromone, 0<ρ<1; Is the pheromone quantity left by the KTH ant on the edge (I,j) in this iteration; Q is a normal coefficient; Is the path length of the k ant during this tour.
In ant system, pheromone update formula is:
3. Solving steps of ant colony algorithm:
(1) Initialization parameters At the beginning of calculation, it is necessary to initialize related parameters, such as ant colony size (ant number) m, pheromone importance factor α, heuristic function importance factor β, pheromone will emit money ρ, total pheromone release Q, maximum iteration times iter_max, initial value of iteration times iter=1.
(2) construct solution space and randomly place each ant at different starting points. For each ant k (k=1,2,3… M), calculate the next city to be visited according to (2-1) until all ants have visited all cities.
(3) update information su to calculate the path length of each ant Lk(k=1,2… , m), record the optimal solution (shortest path) in the current iteration number. At the same time, pheromone concentration on the connection path of each city was updated according to Equations (2-2) and (2-3).
(4) Determine whether to terminate if iter<iter_max, set iter=iter+1 to clear the record table of ant paths and return to Step 2; Otherwise, the calculation is terminated and the optimal solution is output.
(5) Determine whether to terminate if iter<iter_max, set iter=iter+1 to clear the record table of ant paths and return to Step 2; Otherwise, the calculation is terminated and the optimal solution is output. 3. Determine whether to terminate. If iter<iter_max, set iter=iter+1 to clear the record table of ant paths and return to Step 2. Otherwise, the calculation is terminated and the optimal solution is output.
Ii. Source code
%% %% C Coordinates of n cities, n x2CLC clear NC_max=200% Maximum number of iterations m=30% Number of ants Alpha =0.2% The parameter Beta= representing the importance of the pheromone10% Parameter Rho= representing the importance of heuristic factors0.8% pheromone evaporation coefficient Q=0.2% pheromone increase intensity coefficient R_best=[] % % Optimal route L_best=[] % optimal route length of each generation % % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % % first step: variable initialization % n = size (C,1); %n indicates the size of the problem (number of cities). global data; globalmap;
D=xlsread('Travel arrangements.xlsx'.'Two changes');
data=xlsread('Ratio.xlsx'.'Normal order');
map=xlsread('Path.xlsx'.'matrix'); % Adjacency matrix of the distance between hotels n=14;
Eta=1./D; %Eta is the inspiration factor, which is set as the reciprocal of distance Tau=ones(n,n); %Tau is the pheromone matrix Tabu= Zeros (m,n); % stores and records path generation NC=1; L_ave=zeros(NC_max,1); % Average length of routes of each generationwhileOne of NC < % = NC_max stop conditions: maximum number of iterations, stop % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % the second step: put m ant in n city on Randpos = []; % Random accessfor i=1: (ceil(m/n))
Randpos=[Randpos,randperm(n)];
end
Tabu(:,1)=(Randpos(1.1:m))'; This sentence is not quite understood? For j=2:n % For I =1:m visited=Tabu(I,1: j-1)); % Record visited cities to avoid repeated access J=zeros(1,(n-j+1)); % City to be visited P=J; % Selection probability distribution of cities to be visited Jc=1; For k=1:n if length(find(visited==k))==0 % J(Jc)=k; Jc=Jc+1; For k=1: Length (J) P(k)=(Tau(visited(end),J(k))^Alpha)*(Eta(visited(end),J(k))^Beta); end P=P/(sum(P)); % Select the next city according to probability principle Pcum=cumsum(P); To_visit =J(Select(1)); Tabu(i,j)=to_visit; end end if NC>=2 Tabu(1,:)=R_best(NC-1,:); End min_d = cell (200, 1); L=zeros(m,1); % for I =1:m R=Tabu(I,:); for j=1:(n-1) L(i)=L(i)+D(R(j),R(j+1)); % the original distance with the first j a city to the cities from the end % j + 1 L (I) = L (I) + D (R (1), R (n)); % Distance traveled after the next round addHotel(I); end index=find(L==L_best(NC)); min_L{NC}=min_dist{index}; pos=find(L==L_best(NC)); R_best(NC,:)=Tabu(pos(1),:); % L_ave(NC)=mean(L); % Average distance after this iteration NC=NC+1 % Continue the iteration %% Step 5: Update the pheromone for I = 1: m for j = 1: (n - 1) Delta_Tau (Tabu (I, j) and Tabu (I, j + 1)) = Delta_Tau (Tabu (I, j), Tabu (I, j + 1)) + Q/L (I); % End Delta_Tau(Tabu(I,n),Tabu(I,1))=Delta_Tau(Tabu(I,n),Tabu(I,1))+Q/L(I); % Pheromone increment on the entire path end Tau=(1-rho).*Tau+Delta_Tau; Function changeTwo() global map; function changeTwo() global map; global dist; global attr; global price; for i=1:18 for a=1:3 start=attr(i,a); for j=i+1:18 for b=1:3 final=attr(j,b); For k=1:41% find(STRCMP (map{k},start)); f=find(strcmp(map{k},final)); For l=1:length(map{k}) start2=map{k}{l}; for l=1:length(map{k}) start2=map{k}{l}; for m=1:41 s2=find(strcmp(map{m},start2)); f=find(strcmp(map{m},final)); If ~ isEmpty (s2) &&isempty (f)% The first transfer station is on this route, and the second destination is not on this routeCopy the code
3. Operation results
Fourth, note
Version: 2014 a