Professional Documents
Culture Documents
Bao Truong
Khoa Vo
Advanced Program in Computer Science Advanced Program in Computer Science Advanced Program in Computer Science
Faculty of Information Technology
Faculty of Information Technology
Faculty of Information Technology
University of Science, VNU - HCM
University of Science, VNU - HCM
University of Science, VNU - HCM
vtdkhoa13@apcs.vn
tmbao@apcs.vn
npnguyen@apcs.vn
I. I NTRODUCTION
A. Problem Statement
Pathfinding, an application of Artificial Intelligence has
proved to be one of the stepping stones for technological
revolutions. Indeed, applications of pathfinding can be found
from real world problems such as finding optimal route in
transportation to the more common usages in video games
industry. In gaming industry, pathfinding is used in determining a moving pattern of an entity through obstacles. For
each of these entities, a suitable route is calculated from the
stating position of the entity to the goal. In addition, the route
must be sensible, and as short as possible [1]. An example of
pathfinding is shown in Figure 1.
Fig. 1. An example of pathfinding in the video game Pacman. The red ghost
has to find the shortest path to Pacman
B. Background
Two main functionalities of pathfinding are finding a route
between two nodes in a unweight graph and computing the
shortest path in the graph with heuristic factor. The shortest
path problem is designed essentially to find a path of minimum length between two specified vertices of a connected
weighted graph.[2] It has many real world applications such
as Very-large-scale integration (VLSI) design [3], etc. One of
the most prominent applications is finding the shortest path
between two locations on a map.
The problem was first introduced in April 1954 at the
Symposium on Information Networks by Shimbel in New
York, in the extend of matrix methods for unit-length shortest
paths, in which the proposed method has the time complexity
of O(n4 ) to find the distances between all pairs of points.
Breadth-first Search was discovered by E.F. Moore(19592003), who implemented the algorithm for finding the shortest
path out of a maze and also independently discovered by C. Y.
Lee as an algorithm for wire routing. A* Search, an extension
of Dijkstra algorithm, was first described by Peter Hart, Nils
Nilsson and Bertram Raphael of Stanford Research Institute
in 1968.
C. Related Works
Many studies has been conducted to make comparisons
between shortest path algorithms. In 2014, Girish P Potdar
and R. C. Thool used 4 algorithms: Hill Climbing, Steepest
Ascent Hill Climbing, Best-fist Search, and A* to find the
shortest path in the dataset of 1000 to 3000 nodes. From the
test results, A* is shown to be the algorithm that produces
the least number of nodes, and also has the least number of
edges[4].
In 2011, Ariel Felner conducted a research to compare two
similar shortest path algoriths: Dijkstra algorithm and Uniform
Cost Search. The results show that Uniform Cost Search is
more superior in term of running time and number of created
vertices. To be specific, the maximum number of vertices in
the queue at a given time and the running time of Uniform
Cost Search is less than that of Dijsktra algorithm[5].
Breadth-first
Search
Yes
Yes*
O(bd )
O(bd )
costs are the same, uniform-cost search is similar to BreadthFirst Search. However, Breadth-first Search ends when the
goal node is generated but Uniform Cost Search continues
to examine all the nodes at the goals depth to see if one has
a lower cost. Thus, Uniform Cost Search cost more time and
space than Breadth-first Search in the worst case scenario.
D. A* Search
The main idea of Best-first search is to follow the best path
available from the current position, rather than always following the depth-first approach. At each node, the algorithm uses
an evaluation function f (n) to estimate the node quality[3].
A, perhaps the most widely known form of best-first search.
It is an algorithm that uses heuristic to guide search while
ensuring that it will compute a path with minimum cost. It
evaluates nodes by combining g(n), the cost to reach the node,
and h(n), the cost to get from the node to the goal. Thus an
evaluation function is created: f (n) = g(n) + h(n), which
estimates total cost of path through n to goal. The authors
observe that A* Search is both optimal and complete.
The first condition we require for optimality is that h(n)
be an admissible heuristic that never overestimates the cost to
reach the goal. Since g(n) is the actual cost to reach n along
the current path to n , and f (n) = g(n) + h(n), it is clear that
f (n) do not overestimates the true cost of a solution along the
current path through n.
The second condition require for optimality is the consistency of h(n). A heuristic is consistent if for every successor
n of a node n generated by any action a, h(n) c(n, a, n0 ) +
h(n0 ). Admissible heuristics are generally consistent: if there
were a route from n to Gn that was cheaper than h(n), that
would violate the property that h(n) is a lower bound on the
cost to reach Gn . This is also called a form of the triangle
inequality as shown in Figure 2.
In general, Uniform Cost Search is optimal. Proving Uniform Cost Searchs optimality using indirect proof by assuming that it is not optimal. Then there must be exists a goal
state with path cost smaller than the goal state which was
found. However, this contradicts the definition of Uniform
Cost Search, which is the smaller cost path must be expanded
first. For that reason, the first goal node selected for expansion
must be the optimal solution.
Uniform Cost Search is directed by path costs instead of
depths; therefore, the complexity of the algorithm is characterized in terms of b and C , the cost of the optimal
solution. Assumed that every action costs at least , then in
the worst case scenario, the time and space complexity are
both O(b1+[C/] ). This is due to the fact that when all step
shortest path as the output. The road networks are built from
55 real world and randomized map data. All algorithms use a
list named trace to store the path traversed. The authors also
provide a simple User interface as in Figure 4:
Arad: 366
Bucharest: 0
Crainova: 160
Dobreta: 242
Eforie: 161
Fagaras: 176
Giurgiu: 77
Hirsova: 151
Iasi: 226
Lugoj: 244
Mehadia: 241
Neamt: 234
Oradea: 280
Pitesti: 100
Rimnicu Vilcea: 193
Sibiu: 253
Timisoara: 329
Urziceni: 80
Vaslui: 199
Zerind: 374
TABLE II
S TRAIGHT- LINE DISTANCE TO B UCHAREST
B. Result
The shortest path from Arad to Bucharest is as followed:
Arad Sibiu Rimnicu Vilcea Pitesti Bucharest
Below here are the results returned by the three algorithm,
the shortest path is visualized as the blue nodes
Neamt
Eforie
87.0
86.0
Iasi
92.0
Hirsova
Vaslui
98
.0
142.
0
Urziceni
85.0
Giu_rgiu
90.0
Bucharest
101.0
.0
1
21
Pitesti
138
97.0
Fagaras
Rimnicu_Vilcea
99.0
.0
146.0
Craiova
80.0
12
0.0
Sibiu
Dobreta
75.0
.0
51
140.0
Mehadia
Oradea
.0
Zerind
75.0
Arad
.0
71
70
118.
0
Timisoara
111.0
Lugoj
Neamt
87.0
Eforie
Vertices
20764
19539
46736
11157
16052
22528
21887
39338
45665
27543
86.0
Iasi
92.0
Hirsova
Vaslui
.0
142.
98
Urziceni
85.0
Giu_rgiu
90.0
Bucharest
101.0
1.0
21
Pitesti
138
97.0
Fagaras
.0
Rimnicu_Vilcea
99.0
146.0
Craiova
80.0
UCS
11270
12613
12622
22664
4297
2446
25354
56760
14526
9931
0.0
75.0
140.0
Mehadia
Oradea
71
.0
Arad
75.0
Zerind
70
.0
118.
111.0
Timisoara
Lugoj
BFS
6214
6224
10135
4781
12425
3692
18644
35448
23589
26884
Dobreta
1.0
15
A*
7036
9235
12131
21439
2913
1858
22411
53837
13013
6875
12
Sibiu
Edges
332224
234468
46736
145041
256832
180224
109435
196690
91330
495774
Rimnicu Vilcea
Pitesti
Vertices
20764
19539
46736
11157
16052
22528
21887
39338
45665
27543
Edges
332224
234468
46736
145041
256832
180224
109435
196690
91330
495774
A*
0.466814041
0.503247976
0.35687995
0.659502983
0.377344847
0.139426947
0.815513134
1.489337921
0.447788
1.011003017
BFS
0.256626129
0.219310999
0.157799959
0.224136829
0.493091106
0.147074223
0.489060879
0.896718025
0.397804976
1.163685083
UCS
0.527646065
0.549454927
0.319380999
0.698724031
0.256123066
0.119521856
0.629976988
1.572528124
0.44672823
0.797452927
Eforie
86.0
Iasi
92.0
Vertices
20764
19539
46736
11157
16052
22528
21887
39338
45665
27543
Hirsova
Vaslui
.0
142.
98
Urziceni
85.0
Giu_rgiu
90.0
Bucharest
101.0
1.0
21
Pitesti
138
97.0
Fagaras
Rimnicu_Vilcea
99.0
.0
146.0
Craiova
80.0
12
0.0
Sibiu
UCS
7699
10804
77514
13361
7343
11349
17726
19992
27844
9338
75.0
.0
Arad
70
71
Zerind
BFS
13406
15303
77514
18222
13727
11349
32538
28560
39050
24598
75.0
Mehadia
Oradea
.0
A*
6799
10804
77514
13361
7343
11349
17726
19992
27844
9338
Dobreta
.0
51
140.0
Edges
332224
234468
46736
145041
256832
180224
109435
196690
91330
495774
118.
Timisoara
111.0
Lugoj