The article presents different approaches to finding the optimal solution for a problem, which extends the classical traveling salesman problem. Takes into consideration the possibility of choosing a toll highway and the standard road between two cities. Describes the experimentation system. Provides mathematical model, results of the investigation, and a conclusion.
best weekend places near delhi where you should visit.pdf
ย
Traveling Eco-Salesman Problem Solved Using Ant Colony Optimization, Nearest Neighbour and God Algorithms
1. 1
Experimentation system for supporting
solving Time and Cost Dependent TSP
Problem
Traveling Eco-Salesman
Adrian Aleksander Strugala
Faculty of Electronics
Wroclaw University of Science and Technology
Wrocลaw, Poland
209227@student.pwr.wroc.edu.pl
Abstractโ The article presents different approaches to finding the optimal solution for a problem, w hich extendsthe classical
traveling salesman problem. Takes into consideration possibility of choosing toll highw ay and the standard road betw een two
cities. Describes experimentation system. Provides mathematical model, results of the investigation, and conclusion.
Index Termsโ Traveling Salesman Problem; Time and Cost dependent; Ant Colony Optimization; Nearest Neighbour; God;
artificialintelligence; AI
โโโโโโโโโโ ๏ต โโโโโโโโโโ
1 INTRODUCTION
Observing the past centuries we can conclude, that
the humanity tends to search for optimal roads.
Merchants, travelers, and explorers were creating more
and more detailed maps [1]. In the digital era, everyone
can use free and open real-time maps found on the
Internet. Some of them provide a feature for finding the
shortest road connecting a set of cities [2], but very few
can answer common question โIs it really worth to pay
for toll highway or should I just stay on the free road?โ A
solution of Traveling Eco-Salesman Problem provides
an answer to this question.
The Traveling Salesman Problem describes a
theoretical problem of finding the least expensive road
(in the meaning of time, money or distance) connecting
given a collection of cities [3] [4].
Traveling Eco-Salesman Problem introduces a new
extension to the classical problem: each of the city can
be connected to each other both by regular โ free road
or toll highway. This is modification inspired by [5].
Following assumptions are made: every city is
connected with each other by free road. Additionally,
cities may be connected by toll highway, but they do not
have to. Cost of traveling toll road is greater than 0 and
time of traveling toll road is shorter than the time of
traveling the corresponding free road. There is given
initial and ending city. Each city has to be visited once
and cannot be visited more than once. The goal is to find
the optimal (based on time and cost of travel) road
connecting all the cities [6].
Four different approaches to cost management are
being taken into consideration:
The first is; only free roads can be chosen. This is
classical TSP.
The second is; toll roads are chosen whenever
possible. The result of this approach is the fastest
possible solution but uses the highest amount of money.
The third is; there is given additional parameter โ limit
of combined cost of all chosen toll roads. The limit must
not be exceeded.
The final is; the computed solution is optimal in the
meaning of minimizing Goal Function (7), where goal
depends on the cost of the chosen roads and time
difference between toll highway and free road for every
chosen toll road.
Three algorithms for solving TSP are implemented
and compared: Ant Colony Optimization, Nearest
Neighbour, and God.
Following sections, covers listed topics. 2 โ statement
of the problem with the introduction of the mathematical
model. 3 โ description of four different approaches to
finding the optimal solution for the problem and
description of three implemented TSP engines. 4 โ
description of experimentation system with examples. 5
โ results of the investigation. 6 - conclusion, and plans
for future work and 7 - references.
2 PROBLEM STATEMENT
The whole system is represented as a directed graph
G(V,E).
Vertices of this graph are a representation of cities.
๐ = ( ๐ฃ0, ๐ฃ1,โฆ , ๐ฃ๐
) (1)
A number of vertices is equal to n.
2. 2
Each edge is represented as a value of time needed
for travel from origin todestination city. They are two sets
of arcs โ one for free roads and one for the toll. They are
collected in matrices. For free roads, it is written as a
matrix ๐๐ nรn. Analogical, distances for toll roads are ๐๐ nรn.
To answer a question when toll road is worth to
choose, a correlation between the cost of the road and
time of traveling this road had to be formulated.
This correlation is a statement of Goal Factor (GP)
(2) for a single path:
๐บ๐ = ๐ถ ร ๐ ร ๐ผ [โฌ ร ๐ ] (2)
Where GP is the value of Goal Factor, C is the cost of
the travel, T is a time of the travel for a single path and I
is practical importance factor based on the value of
saved time.
Empirical meaning of the Goal Factor is to find a road
connecting two cities with the possible minimal time and
cost of the travel.
Following assumptions are made:
1) Time of traveling free road (TF) is always longer
than traveling on the toll road (TT):
โ( ๐ < ๐, ๐ < ๐) ๐๐ ๐,๐
> ๐ ๐ ๐,๐
(3)
2) Cost of traveling free road (CF) is always lower
than traveling on the toll road (CT) :
โ( ๐ < ๐, ๐ < ๐) ๐ถ ๐ ๐,๐
< ๐ถ ๐ ๐,๐
(4)
3) Cost of traveling free road is a cost of gasoline
only (CG). Cost of gasoline is calculated as the
multiplication of distance, average combustion
and price of fuel:
๐ถ ๐น = ๐ถ ๐บ = ๐ ร ๐๐๐๐๐ข๐ ๐ก๐๐๐ ร ๐๐ข๐๐ ๐๐๐๐๐ [โฌ] (5)
4) Cost of traveling toll road is a cost of highway
payment (CP) and gasoline (CG). Combustion on
the highway is 1.25 times higher than on the
national road, because of higher average
velocity:
๐ถ ๐ = ๐ถ ๐บ ร 1.25 + ๐ถ ๐[โฌ] (6)
The final Goal Function (7) is the minimal sum of
Goal Factors for single paths. This is the key function of
the future research:
๐บ = minโ ๐บ ๐(๐,๐)
[โฌ ร ๐ ] (7)
3 SOLUTION TO THE PROBLEM
The basis for solving the problem is to find optimal
route for TSP. This is done by Ant Colony Optimization
algorithm, [6] Nearest Neighbour [9] or God [10]
algorithms. Pseudocode of Ant Colony Optimization is
presented in Figure 1., pseudocode of Nearest
Neighbour is presented in Figure 2. and pseudocode of
God is presented in Figure 3.
Ants are released from the hive. Their goal is to
solve Traveling Salesman Problem. According to a real-
life example, at first, they are choosing the route
randomly and leaving pheromones. The strongest
pheromone trail is left on the most commonly used
route, which is considered as the optimal path.
Figure 1. Pseudocode of Ant Colony Optimization
Nearest Neighbour was one of the first solutions to
TSP problem [9]. The idea is very straightforward.
Starting from the initial city, the program chooses the
nearest city already considered. Then adds it to the path
and marks as visited. City, which is set as an ending
point, is simply added as the last city in the path.
Figure 2. Pseudocode of Attention Whore
God algorithm comes from human considerations
of the beginning of the word and life [10]. One of the
theories says that at beginning of everything God
created our universe. In this theory, God created an
infinite number of universes, with random laws of
physics, rules of chemistry and other rules governing
the world. Universes were collapsing one after another,
and only one of them survived โ with the optimal rules.
This is our universe.
Adjusting God to the TSP is as follows. The program
chooses random route connecting all the cities,
numerous times. It uses all the strengths of parallel
programming โ drawing random routes may occur in the
same. The only limit is a computational power of the
Input: distance matrix, no. of ants, no. of cities
Output: shortest route
1: current shortest route = initial solution;
2: while (ant can chose different path than current shortest)
3: while (ant < no. of ants)
4: while (no. of cities in current path != no. of cities)
5: select city i with probability based on distance and
pheromone matrices;
6: add city i to shortest path for this ant;
7: leave pheromone trial;
8: shortest path in this iteration = compare paths for each ant
and take the shortest;
9: if (shortest path in this iteration < current shortest path)
10: current shortest path = minimum path in this iteration;
11: evaporate pheromone trials;
12: shortest route = current shortest path;
Input: distance matrix, no. of cities
Output: shortest route
1: current shortest route = initial solution;
2: add starting city as the first;
2: for (no. of cities -2)
3: find nearest neighbour (exclude already visited);
4: add nearest neighbour to path;
5: mark nearest neighbour as visited;
6: add ending city as the last;
7: shortest route = found path;
3. 3
computer.
Figure 3. Pseudocode of God
The field of investigations consists of finding the most
optimal, in the meaning of minimizing Goal (7), solution.
This is done by approaching the problem of cost
management in four different ways.
Following scenarios were implemented based on Ant
Colony Optimization algorithm. Each of the scenarios
puts different constraints on the TSP algorithms and
changes its behavior significantly.
Only free roads. The first idea is to answer the
question if choosing toll roads is profitable in any case.
In this scenario the only cost of the travel is the cost of
fuel and importance parameter is equal to 1:
๐ผ = 1 (11)
Toll roads whenever possible. The second idea is
to investigate this scenario: Choosing toll road is always
profitable. This is opposite approach to the first one.
I parameter from equation (2) is calculated as follows:
๐ผ =
๐ถ ๐น
๐ถ ๐
(12)
Cost limit. The third idea is to introduce additional
constraint of limiting overall cost of travel. This is the
most flexible approach and the most practical for future
users.
โ ๐ถ(๐,๐) < ๐ฟ (13)
This scenario goal is to prioritize section of roads with
the highest gain over those the least profitable. The Goal
(7) is strongly dependent on financial capabilities of the
user. This is the most promising approach for future
commercial development.
Evaluation of the cost of time. The fourth and final
idea is to take into consideration the relationship
between cost and time parameters calculated for the
Goal Factors (2). Then, for every part of the road chose
separately if it is worth to use toll or free road.
During execution of the TSP engine, the algorithm
builds path based on this evaluation of the cost of time.
4 EXPERIMENTATION SYSTEM
All the investigations are made in dedicated
experimentation system, named Traveling Eco-
Salesman. Prefix โecoโ comes from economical
approach underlined in solutions presented in this
article.
The program is written in C#, Microsoft object-
oriented programming language and uses REST
protocol to receive information from the Internet in JSON
format. It communicates with Google Maps API to get
real-time information about the time needed to travel
between chosen cities [7]. That information populates
matrices ๐๐ and ๐๐ .
Similarly, matrix CP is filled by actual data of cost
downloaded from Michelin Maps API, ViaMichelin [8].
The program takes a list of cities as an input, for
which user wants to calculate optimal route. The first city
is an origin, last is a final destination.
The initial user interface is represented in Figure 4.
The position of each city is represented by a dot on the
cartographic grid.
The user has an access to 6 different features in form
of solutions described in Section 3 โ four approaches to
cost management and two additional TSP engines.
What is more, the user is given an ability to display the
optimal road on the screen.
Figure 4. Initial user interface
After selecting one of the options, the screen shows
calculated route. Optimal path, considering all factors is
shown in Figure 5. In this example, God TSP engine was
chosen.
Figure 5. Example of God functionality
Input: distance matrix, no. of cities, no. of universes
Output: shortest route
1: current shortest route = initial solution;
2: parallel for (no. no universes)
3: draw random route
4: shortest route = find shortest route in random routes;
4. 4
Section of the road is represented as a continuous
line for free road or dotted line for toll one.
Application displays route between cities, which
specification if a toll or free way is preferable on every
part of the route. The application gives information on
duration of the travel and cost of toll fees. For test
purposes, additionally, the value of Goal Function and
duration of execution of the TES algorithm are visible.
5 INVESTIGATION
The research was done on three various datasets
with unique features. The first was set of cities: Como,
Verona, Florence, Pisa, Turin, Milan, Genoa, and
Bergamo. All the cities are located in northern Italy. This
region is very well communicated and, because of
mountainous terrain, the time difference between
traveling toll and the free road is significant. This set is
named Italy for a shortcut.
The second is set of cities in Poland: Wroclaw,
Gdansk, Krakow, Poznan, Warsaw, and Lublin. This
region is not that well communicated and toll fee is
relatively high. This set is named Poland for a shortcut.
The last set of cities are locations all over Europe:
Moscow, Warsaw, Barcelona, London, Prague,
Budapest, Paris, Amsterdam, Madrid, Oslo, Berlin,
Vienna, Athens, Rome, Stockholm, Istanbul, and Lisbon
Those cities are located in different countries and tests
also connection between different regions in Europe.
This set is named Europe for a shortcut.
The first field of investigation was the influence of
limit (13) in the Limit approach on the value of Goal
Function (7). This investigation was done based on Italy
dataset.
In Table 1. results of the exaction of the TSP with the
limit approach are collected. Based on those results
influence of limit parameter (L) on the value of Goal
Function (7) is clearly visible in Figure 9.
Table 1. Influence of parameter L on the value of Goal Function
Limit [โฌ] Cost [โฌ] Goal [โฌ ร s]
0 0 380.586
7 3.5 388.3
14 12.2 385.553
21 12.2 385.553
28 27.9 313.413
35 27.9 313.413
42 27.9 313.413
49 43.1 270.51
56 43.1 270.51
63 61.2 292.605
70 61.2 292.605
77 61.2 292.605
84 77.8 254.318
Figure 6. Chart showing the influence of parameter L to value of
Goal Function
The general trend is, that with increasing limit of
cost, the value of Goal Function (7) decreases. For
some intervals of the cost, the value of Goal Function
(7) stays on the same level.
The upper limit of research range was the value of
cost received in the approach of using toll roads
whenever possible.
The second field of investigation was an analysis of
the optimal approach to management of the cost.
Dataset used in this comparison is set of cities from
northern Italy. Results collected in Table 2 shows the
best-received results for 30 executions of the program.
Table 2. Comparison of results for different approaches to cost
management
Duration
[hh:mm:ss]
Cost
[โฌ]
Goal [โฌ
ร s]
Time of
execution
[ms]
Free 20:04:25 0 380.586 816
Toll 12:05:01 77.8 254.318 933
Limit 12:05:01 77.8 254.318 610
Evaluation 13:10:16 55.2 223.604 692
Considering the value of Goal Function (7) as a
criterion for choosing the optimal solution to handling
the cost of travel; evaluation of the cost of time is the
most promising approach.
Further research, deciding the most promising TSP
engine were performed based on the very same
mechanism of automatically choosing if travel between
two cities should be done on toll or free road.
Mean values of 30 executions of the program for
0
50
100
150
200
250
300
350
400
450
0 20 40 60 80 100
Goal (L)
5. 5
different TSP engines and different datasets are shown
in Table 3, Table 4 and Table 5.
The key parameter, informing about the performance of
each engine is the value of Goal Function (7).
Table 3. Comparison of results for different TSP engines for Italy
dataset
Italy
Duration
[hh:mm:ss]
Cost
[โฌ]
Goal [โฌ ร
s]
Time of
executio
n [ms]
ACO 14:13:46 93.21 339.804 640
NN 14:13:50 93.60 340.319 0.01
God 13:10:16 55.20 223.600 693
The result of research performed on Italy dataset
shows that outcome of Ant Colony Optimization and
Nearest Neighbour are very similar.
Because of simplicity of implementation, time of
execution of NN engine is significantly shorter. This is a
true statement for every performed experiment.
The best TSP engine used in this experiment was
God algorithm. Value of Goal Function (7) is 33% lower
than in rest of the engines. Hence, time and cost of
travel have also lower values.
Table 4. Comparison of resultsfor different TSP engines for Poland
dataset
Poland
Duration
[hh:mm:ss]
Cost
[โฌ]
Goal [โฌ
ร s]
Time of
execution
[ms]
ACO 22:38:57 10.71 680.569 403
NN 23:15:58 10.26 712.960 0.002
God 18:58:04 0 396.122 747
For Poland dataset, once more, the optimal
algorithm was God. In this experiment value of Goal
Function (7) for God was 42% lower than for Ant Colony
Optimization and 44% lower than for Nearest
Neighbour.
Table 5. Comparison of resultsfor different TSP engines for Europe
dataset
Europ
e
Duration
[hh:mm:ss
]
Cost
[โฌ]
Goal [โฌ ร
s]
Time of
executio
n [ms]
ACO 227:19:36
166.9
2
34132.98
8
2523
NN 233::21:45
176.6
9
37021.90
0
0.01
God 218:20:44 115.58
22331.69
3
548
The third experiment performed on the list of cities
placed in all over Europe confirmed, that God algorithm
provides the optimal results between implemented TSP
engines.
In this case, the result was also drastically better.
Mean value of Goal Function for God was 35% lower
than for ACO and 40% lower than for Nearest
Neighbour.
6 CONCLUSION
The optimal approach for cost management is an
evaluation of the cost of the time performed by the
program, based on values of Goal Factors (2).
The optimal TSP engine implemented in the
Traveling Eco-Salesman program is God algorithm.
This extension to TSP problem provides a number of
possible future investigation fields.
Firstly, the proposition of new formula for Goal
Function (7). Goal presented in this article allows for
finding profitable routes. Reformulation of Goal though
may allow finding even more optimal paths.
Secondly, the proposition of another scenario for
deciding when to how to manage the cost of the travel.
Analogical to presented in Section 3.
Thirdly, implementing another algorithm for solving
TSP problem. Another possible improvement in TSP
engines is calibration of used parameters.
And finally, commercialize Traveling Eco-Salesman
program. The most promising way is to propose it as an
extension of existing Internet maps. It may also succeed
as a standalone application.
7 REFERENCES
[1] Unknown author, Clay tablet containing city map of Nippur, Babylon,
prob. 1400 BC
[2] E. Balais, The traveling salesman problem and its variations, Springer,
2007
[3] G. B. Dantzig, R. Fulkerson, S. Johnson, Solution of a Large-
Scale Travelling-Salesman, Journalof the Operations Research
Society of America, Vol. 2, No. 4, 393-410, 1954
[4] M. Held, R. M. Karp, The Travelling-Salesman Problem and
Minimum Spanning Trees, Operations Research, Vol. 18, No. 6,
1138-1162, 1970
[5] S. Qin, S. Liu, Q. Zhang, The Traveling Salesman Problem with
Profits Considering Time-Dependent Cost and Multi-Trip Mode,
Proc. 36th. Chinese Control Conference, pp. 2899-2903, 2017.
[6] S. Oliveira, M. S. Hussin, A. Roli, M. Dorigo, T. Stรผtzle, Analysis
of the population-based ant colonyoptimization algorithm for
the TSP and the QAP 2017 IEEE Congress of Evolutionary
Computation, pp. 1734-1741, 2017.
[7] https://developers.google.com/maps/documentation/, 2017
[8] http://dev.viamichelin.com/getting-started-rest.html, 2017
[9] G. Gutin, A. Yeo, A. Zverovich, Traveling salesman should not be
greedy: domination analysis of greedy-type heuristics for the
TSP, Discrete Applied Mathematics 117, pp. 81-86, 2002
[10] A. Brรผngger, A. Marzetta, K. Fukuda and J. Nievergelt, The
parallel search bench ZRAM and its applications, Annals of
Operations Research 90, pp. 45โ63., 1999