Professional Documents
Culture Documents
Travelling Salesman Problem Using Ant Colonization Optimization
Travelling Salesman Problem Using Ant Colonization Optimization
https://docs.google.com/document/d/19Y9EYzc59DKpRzClZ7JFLILq7a9qHb26NAloZ6jJg0U/edit 1/13
4/9/2019 Travelling salesman problem using Ant Colonization optimization - Google Docs
Abstract:
The ant colony optimization algorithm (ACO) is a probabilistic technique for computing the
best path of a given problem using a weighted graph. In ACO, a set of software agents
called “Artificial ants” search for the optimal route for the given problem. The artificial ants
incrementally build solutions by moving on the graph. The solution construction process is
biased by a pheromone model, or a set of parameters associated with graph components,
either nodes or edges, whose values are modified at runtime by the ants.
The ACO algorithm is a member of swarm intelligence methods, and it constitutes some
metaheuristic optimizations. Swarm intelligence is the discipline that deals with natural and
artificial systems composed of many individuals that coordinate using decentralized control
and self-organization. Swarm intelligence focuses on the collective behaviors of all the
artificial ants that result from the local interactions with each other and with their
environment.
Introduction:
To apply ACO to the TSP, we consider the graph to be associated with the set of cities with
the set of vertices of the graph. In TSP, it is possible to move from any given city to any
other city, the graph is fully connected and the number of vertices is equal to the number of
cities. Now we can infer that the lengths of the edges between the vertices to be
proportional to the distances between the cities represented by these vertices by associating
the pheromone values and heuristic values with the edges or nodes of the graph.
Pheromone values are modified at runtime and represent the accumulated experience of the
ant colony, while heuristic values are problem dependent values, they are set to be the
inverse of the lengths of the edges.
The artificial ants construct the best path as follows. Each ant starts from a randomly
selected city, in any given vertex of the graph, and it moves at each construction step along
the edges of the graph. Each and keeps track the memory of its path, and in subsequent
steps, it chooses among the edges that do not lead to vertices that it has already visited. An
ant has constructed a solution once it has visited all the vertices of the graph. At each
construction step, an ant probabilistically chooses the edge to follow among those that lead
to yet unvisited vertices. The probabilistic rule is biased by pheromone values and heuristic
https://docs.google.com/document/d/19Y9EYzc59DKpRzClZ7JFLILq7a9qHb26NAloZ6jJg0U/edit 2/13
4/9/2019 Travelling salesman problem using Ant Colonization optimization - Google Docs
Information, also the higher the pheromone and the heuristic value associated with an edge,
the higher the probability an ant will choose that particular edge. Once all the ants have
completed their tour, the pheromone on the edges is updated. Each of the pheromone
values is initially decreased by a certain percentage. Each edge then receives an amount of
additional pheromone proportional to the quality of the solutions to which it belongs (there
is one solution per ant). This procedure is repeatedly applied until a termination criterion is
satisfied.
Algorithm:
1. Initialize:
Set time=0 {time is time counter}
For every edge (i, j) set an initial tij = c for trail density and tij = 0.
3. Repeat until s =m
Set s=s + 1
For k=1 to l do
Choose the next city to be visited according to the probability pijk was given by Eq.
(1).
Move the ant k to the selected city.
Insert the selected city in visitedk.
Insert the group of the selected city in tabuk.
4. For k=1 to l do
Move the ant k from visitedk(n) to visitedk(1).
Compute the tour length Lk traveled by ant k.
Update the shortest tour found.
For every edge (i, j) do
For k=1 to l do
Update the pheromone trail density tij according to Eqs.
time=time + 1
https://docs.google.com/document/d/19Y9EYzc59DKpRzClZ7JFLILq7a9qHb26NAloZ6jJg0U/edit 3/13
4/9/2019 Travelling salesman problem using Ant Colonization optimization - Google Docs
Implementation of Code:
Function: ant_tour
function [new_places]=ant_tour(start_places,m,n,h,t,alpha,beta);
for i=1:m
mh=h;
for j=1:n-1
c=start_places(i,j);
mh(:,c)=0;
temp=(t(c,:).^beta).*(mh(c,:).^alpha);
s=(sum(temp));
https://docs.google.com/document/d/19Y9EYzc59DKpRzClZ7JFLILq7a9qHb26NAloZ6jJg0U/edit 4/13
4/9/2019 Travelling salesman problem using Ant Colonization optimization - Google Docs
p=(1/s).*temp;
r=rand;
s=0;
for k=1:n
s=s+p(k);
if r<=s
start_places(i,j+1)=k;
break
end
end
end
end
new_places=start_places;
% End of Function
%--------------------------------------------------------------------------
Function: calculate_cost
function [cost,f]=calculate_cost(m,n,d,at,el);
for i=1:m
s=0;
for j=1:n
s=s+d(at(i,j),at(i,j+1));
end
f(i)=s;
end
cost=f;
f=f-el*min(f);
% End of Function
%--------------------------------------------------------------------------
Program: myAco
% This program is developed to find the shortest path between some cities.
%--------------------------------------------------------------------------
https://docs.google.com/document/d/19Y9EYzc59DKpRzClZ7JFLILq7a9qHb26NAloZ6jJg0U/edit 5/13
4/9/2019 Travelling salesman problem using Ant Colonization optimization - Google Docs
https://docs.google.com/document/d/19Y9EYzc59DKpRzClZ7JFLILq7a9qHb26NAloZ6jJg0U/edit 6/13
4/9/2019 Travelling salesman problem using Ant Colonization optimization - Google Docs
https://docs.google.com/document/d/19Y9EYzc59DKpRzClZ7JFLILq7a9qHb26NAloZ6jJg0U/edit 7/13
4/9/2019 Travelling salesman problem using Ant Colonization optimization - Google Docs
'MarkerSize',10)
xlabel('x (km)');ylabel('y (km)');
title(['minimum cost (total length)= ',num2str(k)]);
end
% End of Program
%--------------------------------------------------------------------------
Function: update_traces
function [t]=update_the_trace(m,n,t,tour,f,e);
for i=1:m
for j=1:n
dt=1/f(i);
t(tour(i,j),tour(i,j+1))=(1-e)*t(tour(i,j),tour(i,j+1))+dt;
end
end
% End of Function
%--------------------------------------------------------------------------
https://docs.google.com/document/d/19Y9EYzc59DKpRzClZ7JFLILq7a9qHb26NAloZ6jJg0U/edit 8/13
4/9/2019 Travelling salesman problem using Ant Colonization optimization - Google Docs
Output:
https://docs.google.com/document/d/19Y9EYzc59DKpRzClZ7JFLILq7a9qHb26NAloZ6jJg0U/edit 9/13
4/9/2019 Travelling salesman problem using Ant Colonization optimization - Google Docs
https://docs.google.com/document/d/19Y9EYzc59DKpRzClZ7JFLILq7a9qHb26NAloZ6jJg0U/edit 10/13
4/9/2019 Travelling salesman problem using Ant Colonization optimization - Google Docs
10
https://docs.google.com/document/d/19Y9EYzc59DKpRzClZ7JFLILq7a9qHb26NAloZ6jJg0U/edit 11/13
4/9/2019 Travelling salesman problem using Ant Colonization optimization - Google Docs
11
https://docs.google.com/document/d/19Y9EYzc59DKpRzClZ7JFLILq7a9qHb26NAloZ6jJg0U/edit 12/13
4/9/2019 Travelling salesman problem using Ant Colonization optimization - Google Docs
12
Conclusion:
In this ACO execution, landing at the best case scenario requires adjusting
exploitation-exploration tradeoff. Setting the evaporation coefficient low makes the
pheromones stay longer. Nonetheless, path bias of the colony extremely high, so they get
the opportunity to investigate more alternatives the route with the highest pheromone
concentration, rather than settling in it. ACO is a lot simpler to control, rather than using
any other swarm methods. There are not many parameters required and the investigation
capacity does not tend to leave control. It likewise helps that the ants are randomly placed
in different areas of the map and allowed to make a “guided” initial tour. This makes the
initial values much lower as compared in the case of Brute Force method where initial costs
are comparable to ACO but the cost of the matrix and the time to find the optimal route
increases.
References:
1. https://ljvmiranda921.github.io/notebook/2017/01/18/ant-colony-optimization-tsp/
2. https://www.codeproject.com/articles/644067/applying-ant-colony-optimization-algo
rithms-to-sol
3. https://ieeexplore.ieee.org/document/7970119
4. https://en.wikipedia.org/wiki/Ant_colony_optimization_algorithms
5. https://www.sciencedirect.com/science/article/pii/S1002007108002736
https://docs.google.com/document/d/19Y9EYzc59DKpRzClZ7JFLILq7a9qHb26NAloZ6jJg0U/edit 13/13