Sunteți pe pagina 1din 5

Fast Heuristic Algorithm for Travelling Salesman

Problem
Nana Rahmana Syambas Shasa Salsabila Galura Muhammad Suranegara
School of Electrical Engineering School of Electrical Engineering School of Electrical Engineering
and Informatics and Informatics and Informatics
Institut Teknologi Bandung Institut Teknologi Bandung Institut Teknologi Bandung
Indonesia Indonesia Indonesia
nana@stei.itb.ac.id Shasa.salsabila81@students.itb.ac.id galurams@students.itb.ac.id

Abstract— The Optimization of a large-scale Traveling of all visited nodes and the computation time required by the
Salesman Problem (TSP) especially in telecommunication program.
networks, which is a well-known NP-hard problem in
combinatorial optimization, is a time-consuming problem. In this The performance of proposed algorithm is measured by
paper, the proposed heuristic algorithm is designed for fast comparing it with other algorithm with two keys component,
computing. The result will be compared with two keys the total cost and the computational time. This proposed
parameter, accuracy and computation time. Proposed algorithm algorithm was compared with other algorithms that are
has been compared with brute force and Ant colony optimization commonly used, brute force and Ant Colony Optimization
(ACO) which known as an algorithm that is used to determine (ACO). Ant colony optimization (ACO) which known as an
the shortest path and best cost at minimum iterations possible for algorithm that is used to determine the shortest path and best
a random data set on the basis of Euclidean distance formula. cost at minimum iterations possible for a random data set on
Proposed algorithm takes only 0.0074 seconds to provide shortest the basis of Euclidean distance formula [8].
path solution with 50 nodes combination. The proposed
algorithm has 5% less accuracy from brute force and provide
6.69 % better solution from ACO for 33 nodes through 50 nodes. II. RELATED WORK
Brute force is known as the best algorithm to decide
Keywords— travelling salesman problem; shortest path value; smallest minimum total cost (value). Basically, brute force
ring topology; brute force; ant colony; heuristic algorithm; the calculates every single possible combination and compares its
shortest route value. So brute force can solve TSP with exactly the minimum
cost desired. However, brute force has limitation with its
I. INTRODUCTION computational time. The computational time of brute force is
Traveling salesman problem (TSP) is a problem that has raising exponentially with the number of nodes combination.
widely observed [1][2][3] even there is an implementation on So, it is needed a new heuristic algorithm to develop. This new
robotic using Genetic Algorithm in TSP [4]. The point of TSP heuristic algorithm must able to solve TSP problem with good
in telecommunication networks is to find the smallest value of total minimum value and fast computational time.
all nodes combinations that have been visited. So, the nodes are There are many other algorithms that have been developed
connected to form a ring topology. This ring topology will be to solve TSP problem, among them Ant Colony Optimization
considered to be used as the initial design of a network. [1], Genetic Algorithm [2], Swarm Intelligence [3], Bee
The main challenge of TSP is how to determine the Colony [5], Maximum Entropy [6], Penguin Search [7] etc.
combination of vertices (nodes) with smallest cost (value) of Even the hybrid method has been done by combining most of
each visited nodes and fast computational time. popular algorithm together such as [2][8]. The logical
consequence of this combination is raised its computational
In this paper, TSP problem with random assigned link cost time but end with better expected results.
and symmetric values will be solved using proposed algorithm.
Where the value of node A to node B is always the same as the Today most widely used heuristic algorithm for solving
value of node B to node A and not allowing loop. Therefore, TSP problems is Ant Colony Optimization (ACO). Therefore,
the loop value in each node is always zero. So, in this case this paper will compare the capabilities of the proposed
symmetric matrix is used as comparation between each algorithm with brute force and ACO for cost accuracy and
algorithm. computation time.

To solve the problem, we designed an algorithm and then The algorithm we created, is designed as simple as possible
write it into code in Python programming language. The output to aim the fastest computation time but still consider the
of this program is the combination of the nodes, the total cost accuracy cost of the resulting ring topology.
III. PROPOSED ALGORITHM After all the step above there are three nodes connected
This proposed algorithm is made with the aim to find the already, assuming A wrote on the center, the two smallest
best combination with minimum value to solve symmetrical nodes wrote on its left and right side. And then the next node
TSP with fast computation time so the result can be must be decided connected to the left or right side. The
implemented as a design for ring topology in decision made by counting the smallest node both side and
telecommunication networks. compare the result and then the smallest value is picked by
discarding the bigger ones. After that, the counting is continued
To find out the performance of proposed algorithm, we until the nodes remains three left. The last three nodes then
compared the result with brute force and ACO Algorithm. counted with brute force by counting one by one and compare
Brute force and ACO algorithms are available for free and can the result and the pick the minimum value. The pseudocode for
be accessed online via GitHub [9] [10]. proposed algorithm and the flowchart for TSP is shown below:
Proposed algorithm coded with Python 2.7 language and
running on Ubuntu 16.04 platform. In the experiment of
finding algorithm to get the minimum distance/weight/cost to
form ring topology is by analyzing the distance/cost matrix.
First approach is connecting some nodes (vertices) with two
minimum distance elements. Table 1 is 12 x 12 sample
distance matrix we used to test proposed algorithm:

TABLE I. DISTANCE MATRIX

The initial node decided by finding two smallest vertices of


each node (horizontally on matrix) and then write sum result
of that two smallest nodes beside the matrix. After that the
process is continued by comparing the sum result vertically
and take the smallest result as initial.
Assuming node G is picked as initial, continue to finds two
smallest vertices on node G horizontally and connecting A
with that two smallest nodes. However, write the code
statically. Figure 1 shows the initial vertices (first step) only
pick initial node: Fig. 3. Flowchart

Algorithm : Proposed algorithm to solve TSP


G Data : Read matrix of cost/weight od nodes/cities
1. Initialization
2. int n (n is variable for numbers of nodes)
Fig. 1. Initial node
3. int left (left node choosen)
4. int right (right node choosen)
Figure 2 shows first connected vertices on both side:
5. int nn (nn is variable for next/destination node)
6. prevNode =(previous node that has been visited)
7. minval[i] = [ ] (array of sum two minima each node)
8. linkNode[i]=[ ] (linkNodes[i] is list variable to store
connected
Fig. 2. Initial node connected with two minimum vertices
9. leftarray = [](array of node left)
10. rightarray = [](array of node right) value of visited node, node combination and computational
11. nextArray[i]= (nextArray[i] store array of node picked) time required. Normal data that have a different scale of values,
12. while i < n each of data have matrix 50x50 (50 nodes). The sample data
minval[i]=min[0](nonzero(data[i])+min[1](nonzero(da generated using MS Excel with a Gaussian Function Random
ta[i])) Variable [11].
//sum two minimum nodes (non-zero) values row [i]
i=i+0
13. nn = index (min(minval)) A. Proposed Algorithm versus Brute force
14. linkNode = [bg]
15. left = index (min[0](data[i])) //first min nonzero data rows
Brute force algorithm is an algorithm that count every
nn
16. right = index (min[1](data[i])) //second min nonzero data
single possibility and then select the minimum cost of it.
rows nn Brute force also called as an algorithm to solve TSP problem
17. linkNode = linkNode+[right] //append right to tail of that try all ring combination to get an absolute minimum path
linkNode value [11].
18. linkNode = [left]+linkNode //insert [left] in head of Brute force always has the absolute minimum value
linkNode because of its way to count, after all have been counted this
19. prevNode = nn algorithm only compare all of its results and then compare it
20. while i < n in order to select the minimum value. The only limitation is
data[nn, :] = 0 its computational time. Biggest node trial is 14 nodes,
data[:,nn] = 0 running with free source code which available online on
i=i+0 github coded with Python [10]. This table below shown
data[left,right] = 0 proposed algorithm simulation value/cost result compared
data[right,left] = 0 with brute force:
//assign rows and column of [prevNode] with zero
21. leftarray = data[left] //assign left array with data row [left]
TABLE II. COMPARISON OF PROPOSED ALGORITHM WITH BRUTE
22. rightarray = data[right] //assign left array with data row FORCE
[right]
23. for j in range n-3 do
left = index(min(nonzero(leftarray))) Minimum Value
right = index(min(nonzero(right index))) Number of Nodes Brute force Proposed
if (min(nonzero(leftarray)<min(nonzero(rightarray)) Algorithm
prevNode = left
nn = index(min(nonzero(leftarray)) 7 4501
4154
left = nn 8 4901
linkNode= [nn] + linkNode 4554
else 9
4750
4770
prevNode = right
10 4772
nn = index(min(nonzero(rightarray)) 4649
right = nn 11 5153
4472
linkNode= linkNode + [nn]
12 5494
4766
while i < n 13 5809
data[nn, :] = 0 5147
data[:,nn] = 0 14
5015
5561
i=i+0
data[left,right] = 0
data[right,left] = 0 Proposed algorithm can solve for minimum seven nodes.
From the table above it can be concluded, the average
24. l = 0
while l < 3 nodes left:
minimum value error of proposed algorithm compared to
sum of all nodes (excluded 3 last nodes) + all brute force is 8.44 %.
possibility of each 3 nodes, take the minimum result
end.

IV. IMPLEMENTATION AND RESULT


Simulation of the proposed algorithm is coded with Python 2.7
and run on a notebook with i5 processor 2.2 GHz and 16 GB
Random Access Memory installed. The platform used is
Ubuntu 16.04 with Anaconda installed. The output is total
know that proposed algorithm weak point is on 25 through 29
which generate bigger gaps from other nodes.
To find shortest path on 50 nodes combination, ACO need
197.88 seconds while proposed algorithm only need 0.0074
second. Figure 6 shows proposed algorithm comparison on
computation time with ACO:

Fig. 4. Initial Node Computation Time Comparison Between Brute Force


And Proposed Algorithm

The figure 4 above shows brute force and the proposed


algorithm comparison. To find shortest path on 14 nodes
combination, brute force algorithm need more than 16 hours
but the proposed algorithm only need 0.000614882 second.
Fig. 6. Computation time comparison between ACO and proposed
algorithm
B. Proposed Algorithm versus Ant Colony Optimization Figure 6 showed that both ACO computation time and
proposed algorithm need more time to solve bigger node.
Ant colony optimization (ACO) which known as an Here is the detailed computation time of proposed algorithm.
algorithm that is used to determine the shortest path and best
cost at minimum iterations possible for a random data set on
the basis of Euclidean distance formula [8]. Ant colony
optimization algorithm is applied in many applications like
travelling salesman problem, quadratic assignment problem
and knapsack problem. They [8] used travelling salesman
problem in which the goal is to find the travelling salesman
problem to find the shortest round-trip tour to link a series of
cities. There is ACO algorithm that is used as reference to
compare our algorithm [9]. This figure below shown
proposed algorithm simulation value/cost result compared
with ACO:

Fig. 7. Proposed algorithm computation time

V. CONCLUSION

The proposed algorithm achieves better shortest path solution


compared with Ant Colony Optimization (ACO) on nodes 33
through 50 but less effective below nodes 33. Proposed
algorithm can solve 50 nodes only for 0.0074 second while
ACO need 197.88 seconds to provide the shortest path. From
node 33 through 50, proposed algorithm achieves 6.69 %
better solution compared to ACO.
Fig. 5. Minimum value comparison between ACO and proposed
algorithm
REFERENCES

From figure 5 smaller shortest path cost can be found by [1] Dorigo, Marco., Gambardella, L.M., “Ant Colony System : A
proposed algorithm compared to the Ant colony optimization Cooperative Learning Approach to the Traveling Salesman Problem,”
(ACO) starts from nodes 33. For nodes number below 33 we
IEEE Transactions on Evolutionary Computation, Vol 1, No. 1, April [7] Mzili, I., Bouzidi, M., Riffi M.E., “A Novel Hybrid Penguins Search
1997. Optimization Algorithm to Solve Travelling Salesman Problem,” IEEE
Third World Conference on Complex Systems (WCCS), November
[2] Ansari, A.Q., Ibraheem., Katiyar, S.,“Comparison and Analysis of 2015.
Solving Travelling Salesman Problem Using GA, ACO and Hybrid of
ACO with GA and CS,” IEEE Workshop on Computational Intelligence: [8] Jaiswal, K., Nagar, S., “Estimation of Cost Rate Percentage for
Theories, Applications and Future Directions (WCI), December 2015. Travelling Salesman Problem Using Hybridized ACO Algorithm,” IEEE
International Conference on Recent Advances and Innovations in
[3] Cao, Y., Xiao, M.H., Zhang, J., “Dynamic Swarm Intelligence Engineering (ICRAIE), December 2016.
Algorithms with Reuse Strategy for Dynamic Travelling Salesman
Problem,” IEEE 7th International Conference on Information Science and [9] Trevlovett, "https://github.com," 31 October 2012. [Online]. Available:
Technology, Vietnam, April 2017. https://github.com/trevlovett/Python-Ant-Colony-TSP-Solver. [Accessed
7 October 2017].
[4] Nelson, A.S.O., Fernando, D.L.R.R., “Path Planning and Following
using Genetic Algorithms to Solve the Multi-Travel Salesman Problem [10] Westphahl, https://gist.github.com/westphahl/432876. [Accessed online
in Dynamic Scenarios,” Proceedings of the 2017 18 th International 7 October 2017].
Conference on Advanced Robotics (ICAR), Hong Kong, China, July
2017. [11] Supriadi, B., Budi, B., “Comparison of Proposed Algorithm to Ant
Colony Optimization Algorithm to Form a Ring Topology with
[5] Shi, P., Jia, S., “A Hybrid Artificial Bee Colony Algorithm Combined Minimum Path Value,” IEEE International Conference on Recent
with Simulated Annealing Algorithm for Traveling Salesman Problem,” Advances and Innovations in Engineering (ICRAIE), December 2016.
IEEE International Conference on Information Science and Cloud
Computing Companion, 2013.

[6] Baranwal, M., Roehl, B., Salapaka, S.M., “Multiple Traveling Salesmen
and Related Problems: A Maximum-Entropy Principle based Approach,”
American Control Conference,USA, May 2017.

S-ar putea să vă placă și