Solving The Traveling Salesman Problem U
Solving The Traveling Salesman Problem U
LAURIK HELSHANI1
PhD(c), European University of Tirana
Tirana, Albania
Abstract:
The concept of the traveling salesman problem is to seeking a
tour of a specified number of cities (visiting each city exactly once and
returning to the starting point) where the length of the tour is
minimized. The mathematical modeling of this problem has to do with
the theory of graphs.
In this paper, I examine simulated annealing algorithm in the
context of solving the traveling salesman problem. Test-tool
programming is done in JAVA programming language and his work is
displayed graphically using the 2D library.
The whole system is programmed as client-server system using
RESTFul web services, Google-services and Simulated Annealing
Algorithm.
Google services are used to determine the optimum route on
Google map and solve the Travelling Salesman problem.
1
Laurik Helshani is PhD candidate at Faculty of Economics. Profile:
Management Information Systems in European University of Tirana (UET).
His PhD thesis: ―Solving Travelling Salesman Problem using Genetic
Algorithm and programming android smart-phones‖.
2321
Laurik Helshani- Solving the Traveling Salesman Problem using Google
Services and Simulated Annealing Algorithm
I. INTRODUCTION
cij = √ (1)
B. Cost function
If the problem consists of n cities ci, i = 1 … n, any tour can be
represented as a permutation of numbers 1 to n. [3]
d(ci, cj) = d(cj, ci) (2)
You have to add Map API key to your application to access the
Google maps server with the maps API. Register in the Google
APIs Console to get a Map API key.
A. Google maps
Google maps provide an intuitive and highly responsive
mapping interface with aerial imagery and detailed street data.
In addition, map controls and overlays can be added to the map
so that users can have full control over map navigation. Map
panning can also be performed by dragging the map via the
mouse or by using ―arrow‖ keys on a keyboard. Google maps can
be customized according to application specific needs. [4].
B. Geo- coding
GeoCoder is a class for handling geo-coding and reverse geo-
coding. Geo-coding is a process of converting addresses into
geographical coordinates (latitudes and longitudes). Reverse
geo-coding is the process of transforming (latitude, longitude)
into addresses. [4]
C. Over layers
Overlays are objects on the map that are bound to
latitude/longitude coordinates. Google Maps has several types
of overlays:
1) Marker - Single locations on a map. They are used to
identify locations on the map.
D. Directions
The Google Maps Directions API is a service that calculates
directions between locations using an HTTP request.
E. Google Places
The Google Places API Web Service is a service that returns
information about places — defined within this API as
establishments, geographic locations, or prominent points of
interest — using HTTP requests. Place Searches return a list of
places based on a user's location or search string.
A. Strategy
The information processing objective of the technique is to
locate the minimum cost configuration in the search space. The
algorithms plan of action is to probabilistically re-sample the
problem space where the acceptance of new samples into the
currently held sample is managed by a probabilistic function
that becomes more discerning of the cost of samples it accepts
over the execution time of the algorithm. [5]
B. Working of SA
In simulated annealing algorithm, the problem of finding an
optimal solution is analogous to a process of reducing the
overall ―energy" of a system via state transitions. In the
traveling salesman problem, a state is defined as a route, or a
permutation of the cities to be visited. The energy of a state is
the total distance of a route. In every iteration of the algorithm,
a candidate state transition, also known as a neighbor of the
current state, is generated by exchanging. The neighbor route is
then evaluated by an acceptance function that makes the state
transition if the neighbor route has a lower energy or chosen
The
initial
Cooling The length of the route Runtime
#places length Optimization in %
rate after optimization in sec.
of the
route
30 1*e-4 14.9 4.3 345.360 0.04
30 1*e-5 15.2 4.7 323.509 0.335
50 1*e-5 26.1 6.4 405.615 0.441
50 1*e-6 28.1 6.1 459.755 2.974
100 1*e-4 52.5 9.9 530.889 0.167
100 1*e-5 56.3 8.2 690.034 0.656
150 1*e-4 83.9 15.4 543.696 0.069
150 1*e-5 82.2 11.0 747.626 0.915
150 1*e-6 82.6 10.2 808.325 6.635
150 1*e-7 80.1 10.5 763.005 68.051
Tastcases oF SA- Algorithm
As seen from the above table, there are two key variables,
which effects directly to the performance of the simulated
annealing algorithm work, to its termination and to the final
result (optimization of the route of travelling salesman). These
variables are: Number of places to visit (#places) and
temperature step (The degree of cooling temperature). The
EUROPEAN ACADEMIC RESEARCH - Vol. IV, Issue 3 / June 2016
2326
Laurik Helshani- Solving the Traveling Salesman Problem using Google
Services and Simulated Annealing Algorithm
other four columns: The initial length of the route, the length of
the route after optimization, Optimization expressed as a
percentage and runtime in seconds are results of the tool.
Optimization reaches the culmination (~808.325%), if
the temperature decreases with 1*e-6 cooling rate and it
happens in 6.635 seconds.
A. Client side
The system is implemented to solve the Travelling Salesman
problem to determine the optimum route on Google map using
Once the user has chosen places to visit and has select function
"Optimize and map the route", the system derives all the
necessary information from Google Map and packs them into
JSON. JSON data are sent by web application to the server via
HTTP-GET request through JQuery.
B. Server side
Travelling Salesman Problem has been analyzed and Simulated
Annealing has been implemented, in Java, as RESTful web
service, successfully. REST involves the transfer of
resources between clients and servers. This server side system
consumes JSON formatted data, produces XML- formatted data
and is running on tomcat sever.
The server consists of the following classes:
a) Place models a google place. It contains all the
characteristics of a google place: id, name, address,
latitude and longitude
b) Tour stores a candidate tour and is a list of places
(ListArray<Place>)
c) TourManager holds the places of a tour and is a list of
places (ListArray<Place>)
d) SimulatedAnnealing
VII. CONCLUSIONS
ACKNOWLEGMENT
This paper is made possible through the help and support from my family.
REFERENCES