Evaluation Function Optimization of A

Rev. Téc. Ing. Univ. Zulia. Vol. 39, Nº 4, 105 - 111, 2016
doi:10.21311/001.39.4.14
Evaluation Function Optimization of A-Star Algorithm in Optimal Path
Selection
Dapeng Sun, Min Li
North China University of Water Resources and Electric Power, Zhengzhou 450045, Henan, China
Abstract
In order to improve the efficiency and accuracy of optimal path selection, this paper adopts the improved
evaluation function based on A* algorithm to optimize it by introducing the weighting process, innovatively
designing heuristic function, and making more prominent of the heuristic function, which greatly reduces the
number of nodes in the algorithm and improves the search speed. The simulation experiment of urban public
traffic data verifies the improved A* algorithm is more efficient than the traditional A* algorithm, and can well
solve the optimal path in multiple graph problems.
Key words: Optimal Path Selection, A* Algorithm, Evaluation Function, Weighting, Heuristic Function
1. INTRODUCTION
The optimal path problem is commonly seen in computer communication network, logistics transportation,
car navigation systems, and also in personnel evacuating decision scheme in emergency and rescue time such as
war, earthquake, nuclear power plant disaster etc. (Xue, 2015). The core of the optimal path problem lies in the
optimal path algorithm that is very important in graph theory or network study (Sotnezov, 2009). The optimal
path algorithm has made many achievements, including transportation modes. The rise of computer network and
communication, distributed processing and intelligent transportation system (ITS) has brought a new turn to this
traditional research topic (Long and Zheng, 2014).
The commonly used optimal path algorithm is usually divided into the following two categories: the
optimum algorithm and the heuristic algorithm (Van, Pipeleers and Swevers, 2013). The optimum algorithm can
guarantee the optimum solution of the optimal path problem, but its time complexity increases with the size of
the network exponentially and it requires to redesign the search strategy when applied to the real-time
navigation system (Wang, Shi and Zhang, 2013); heuristic algorithm cannot guarantee the optimal solution, but
it can often find sub-optimal feasible solution in a limited time (Li, 2013). In fact, there are a lot of heuristic
search algorithms, such as local preferential search method (Li and Peng, 2015), the best-first search algorithm
(Zhang and Jiang, 2015) and A* algorithm (Xiong and Liu, 2015). Because local preferential search algorithm
abandons other nodes which may contain the best nodes, the best node is not necessarily the global optimum,
while the best-first search method has higher time complexity (Li and Su, 2015; Wang and Tang and Li, 2015;
Qiu and Li and Yang, 2015). At present, a variety of algorithms about optimal path are ideally designed for
some simple network and simple graph which involves no loops but only one directed edge associating a couple
of vertices(Niu and Zhang, 2015; Zhang and Xu, 2015). These models greatly reduce the difficulty of solving
the shortest path problem at the cost of reducing the range of application of the algorithm designed.
Nowadays the shortest path problem areas are presented in the complex structure of network graph, with
multiple directed edges in the same direction, loops, and even weights in the graph nodes (Siddiqi, Shiraishi and
Sait, 2012). Few researchers have studied the solution of the shortest path problem of complex networks,
especially the solution of the shortest K paths. In view of this optimization problem of the complex network, this
paper studies the algorithms for solving the shortest path problem of multiple graphs and the shortest K paths
problem, focusing on a solution for a fast search of K paths. We first give the analysis of the existing problems
in the path search process of traditional heuristic search algorithm, A-star algorithm, then improve it on the
evaluation function by introducing a weighted approach, creatively design the heuristic function, and finally
well prove the improved algorithm by the experiments.
2. A-STAR ALGORITHM AND ITS BASIC CHARACTERISTICS
A-star (A*) algorithm is one of the best-first algorithms, limited by the constraint conditions (Cui and
Wang and Yang, 2012). It is widely used because it can obtain the optimal solution of state space search in a
fastest way.
2.1. A-star Algorithm
A* algorithm originates from Dijkstra algorithm that improves the search efficiency by evaluating the
surplus distance and reduces the number of irrelevant nodes to the optimal path. A* algorithm employs a
105
Rev. Téc. Ing. Univ. Zulia. Vol. 39, Nº 4, 105 - 111, 2016
Heuristic Estimate function h to predict the surplus distance between current node and ending point (Liu and
Gong, 2011).
If an evaluation function can solve the optimal path, then it is admissible. A* algorithm is an admissible
best-first algorithm. A common evaluation function is equation (1), while h* (n) is equation (2).
f * (n)  g * (n)  h* (n)
h* (n)  (x1  x 2 )2  (y1  y2 )2
(1)
(2)
Here, f * (n) is the evaluation function of node n , representing the cost from starting node to intermediate
node n to a destination node; g * (n) is the cost from starting node to node n in the state space; h* (n) is the cost
evaluation of the optimal path from node n to target node. In conventional A*algorithm, the set evaluation
function h* (n) is the Euclidean distance between two nodes which ensures that the evaluation function value
will not higher than real distance. It can be proved that the evaluation function satisfying these conditions will
yield the optimal path, namely it is admissible.
A* algorithm possesses some advantages like that when an efficient path exists between starting point and
target point, A* is certain to find it, that when h* (n) is admissible, it can find the optimal path. At the same time,
A* algorithm has the minimum search state among the heuristic search algorithms.
2.2. Characteristics of A-star Algorithm
(1) Admissibility
For a solvable state space graph, meaning that there exists path from starting point to target point, if a
search algorithm can terminate in finite steps and find the optimal solution, then it is called admissible.
Otherwise, it is unacceptable.
(2) Optimality
The search efficiency of A* algorithm largely depends on the h(x) . The larger h(x) is, under the premise
of h(x)  h* (x) , the better result is that it carries more heuristic information with less nodes.
If f1 ( x) and f 2 ( x) are two evaluation functions for a same problem,
f1 ( x)  g1 ( x)  h1 ( x)
(3)
f 2 ( x)  g2 ( x)  h2 ( x)
(4)
A1* and A*2 are the A*algorithms based on f1 ( x) and f 2 ( x) respectively. And for the entire target node x ,
there is h1 (x)  h 2 (x) . In this condition, it is proved that the node of A1* is more than that of A*2 , in other words,
the expansion node set of A*2 is the subset of the expansion node set of A1* .
(3) Monotonicity limits of h(x)
Whenever A* expands a node, it requires to check whether its child node is in the OPEN table of CLOSE
table, sometimes to adjust the indicator to the parent node, which increases the search cost.
Here, monotonicity refers h(x) meets two conditions following:
h(Sg )  0
h( xi )  h( x j )  c( xi , x j )
(5)
(6)
x j is an arbitrary child node of node xi ; Sg is the target node; c( xi , x j ) is the edge cost from node xi to its
child node x j .
If the inequality mentioned above is rewritten as
h( xi )  h( x j )  c( xi , x j )
(7)
Then it is apparent that the evaluation of the optimal cost of node xi to target node will be no more than the
addition of edge cost from xi to x j and the cost from x j to target node.
When the heuristic function h(x) of A* algorithm meets the monotonicity constraints, it is easy to come to
two conclusions:
106
Rev. Téc. Ing. Univ. Zulia. Vol. 39, Nº 4, 105 - 111, 2016
If A * algorithm expands from node x n , then
g(x n )  g* (x n )
(8)
The function value f of the expansion node sequence from A* algorithm is non-decreasing.
2.3. Shortcomings of A-star Algorithm
A* algorithm, as a classic optimal heuristic algorithm, is widely used in the routing computation and
optimal path computing in the computer games, path planning for mobile robot and the flight path optimization,
but has a low efficiency in the path selection process of complex network (5). This paper uses a modified A*
algorithm to improve path selection performance in complex networks.
The A* algorithm finds the optimal path from the starting point to the target point search by estimating
function step by step, but there are still some shortcomings:
Firstly, if the search space is large and the entity is irregular, this algorithm is often unfavorable to search
the optimal path, expanding a lot of redundant nodes and consuming much time. According to the third chapter,
therefore, the mechanical components and electrical components require to be processed with the bounding box
to simplify their shape.
Secondly, even though in some cases the algorithm finds the optimal path, but the actual path is not straight
but more curve, or the whole path is ladder shaped, extending in snake or wave shape in the actual path.
Therefore it is unscientific to select the optimal path according to the coordinate of path node only, sometimes
the actual situation of the lines requires to be considered.
3. EASE OF USE OPTIMIZATION OF EVALUATION FUNCTION
Evaluation function plays a role in the optimal path selection algorithm. This paper optimized the
traditional evaluation function partially. Factor addition method is a commonly used improving method, as
shown below.
3.1. Evaluation Factor Addition
In a reference to the experience in the actual path selection, the third evaluation factor p* (n) and the forth
factor q* (n) are added into the evaluation function, where p* (n) denotes the time consuming from starting node
to current node n and q* (n) denotes the path length. Then the evaluation function becomes
f * (n)  g * (n)  h* (n)  p* (n)  q* (n)
(9)
where h* (n) is expressed as
h* (n)  (x 2  x1 )2  (y2  y1 )2  ( z2  z1 ) 2
(10)
In this new evaluation function, h* (n) is expanded from 2-D space to 3-D space, also assigned with
Euclidean distance; p* (n) translates the time consuming to Euclidean distance while q* (n) translates the path to
Euclidean distance. At this condition, these four factors can operate. Due to the variety of complex environment,
the loss of different paths is too different to find an appropriate transfer function. Therefore, that adding the
evaluation factors into the function from two factors to four factors improves the accuracy of the evaluation
function and thereby improves the performance in the optimal path selection to the uttermost.
3.2. Weighted Evaluation Function
This paper put forward a weighted process to the evaluation function. The expression of evaluation
function after weighting is
(11)
f* (n)  (1  ) g* (n)   h* (n)
And
n
g * (n)  [K D D(X k 1 , Ki  KT )]
(12)
K 1
h* (n)  K D D(Xn ,G)  KT
(13)
Where  is the weighting factor, K D is the search weight of node D , D(Xk 1 , Ki  KT ) is the distance
between current node to child node, and D(Xn ,G) represents the distance from current node to target node.
107
Rev. Téc. Ing. Univ. Zulia. Vol. 39, Nº 4, 105 - 111, 2016
The search efficiency of A* algorithm largely depends on the h(x) . The larger h(x) is, under the premise
of h(x)  h* (x) , the better result is that it carries more heuristic information with less nodes. Therefore, the key
of A* algorithm is to construct the h(x) .
It is difficult to select an appropriate heuristic function, because once if the selection is bad, the heuristic
algorithm will not find the optimal solution but increase the amount of calculation. Here, we improve the
function h(x) with weighting approach, designed as follows,
f (x)   g(x)   h(x)
(14)
f ( j )   g ( j )   h( j )
(15)
h(x)  T 
(16)
h( j )  T ij
(17)
For any node j , there is
The heuristic function is designed as
Then for any node j , it becomes
Where 、(
 0< ,  1, + =1)are two parameter factors,   (0.6,0.9) . These two parameters are used
to adjust the proportion of g ( x) and h( x) in the evaluation function. g(j) is the time consuming from starting
node S to node j consisting of two parts. T refers to the time by the linear distance D jE from j to ending node
E dividing the maximum velocity  max .
D jE
(18)
 max
ij is the included angle between two lines in degrees of arc. One of the lines is determined from starting
node S to E and another is determined by node i and j .  (0<  1) is constant factor for the proportion
adjustment of the ij in h(j) . f (i) is the evaluation of time consuming from S to node i and finally to E .
Therefore, for any node i , the evaluation function of its successor node j becomes,
T=
f ( j )= g (j )+h(j )  f ( j )   g (j)   (T ij )
(19)
3.3. Algorithm Implementation
The improved A* algorithm maintains the two tables, Open and Closed , storing the generated but
undetected nodes and the accessed nodes respectively. The solution has following steps:
Putting starting node S into Open table, and emptying the Closed table. After initialization, g * (S)  0
p* (S)  0 , the evaluation function is expressed as
f * (S)  h* (S)  q* (S)
(20)
LOOP: repeat the following process until the Open table is empty;
Taking the node of minimum value from Open , denoting it by M and putting into Closed ;
If M is the target node, then process ends, tracing the pointer of parent node to obtain the path from
starting node to target node;
Expanding the node M to generate the successor node N , for any N :
a) If N doesn’t appear in Open and Closed , then N is added into Open .
b) If N has been already in Open , then we compare the value of f . If the new f is smaller, it substitutes
the old value and the pointer is adjusted.
c) If N doesn’t appear in Open , but appears in Closed , then we compare the f . If the new f is smaller, it
substitutes the old value and the pointer is adjusted.
(6) Rearranging the Open in a sequence of f from low to high.
(7) Going back to step (2).
When the algorithm finds the target node, we can obtain the optimal path by tracing back to the starting
node.
108
Rev. Téc. Ing. Univ. Zulia. Vol. 39, Nº 4, 105 - 111, 2016
4. SIMULATION EXPERIMENT
In order to test the optimization efficiency of evaluation function in A* algorithm, this paper adopts the city
public traffic network data to construct corresponding multiple graph. The related data information includes
traffic route, line length, speed, departure interval in the mean hour and the peak hour, the departure interval in
the evening, first vehicle hour and last vehicle hour, fare etc.. The data is from nearly 90 bus line, about 400 bus
stations, 230 road intersections, 346 nodes, and 13847 edges.
This paper randomly selected several OD nodes from public transport multi-graph to calculate the shortest
path to test their operating efficiency of the improved A* algorithm, and compared the traditional A* algorithm
evaluation function with evaluation function based on weighting by program. The experiment was developed by
Delphi 7, in a CPU of Athlon3000+ (2.17GHz), under the environment of windows 7.
Experiment results show that the improved A* algorithm has the least nodes when solving the shortest path
under the parameters values of   0.13 ,   0.87,   1 for most OD nodes. Their comparison result is shown
in Table 1.
Table 1. Simulation result comparison of traditional evaluation function and improved one of the A* algorithm.
OD
node pair
Traditional evaluation function
Time consuming (s)
1
2
3
4
5
6
7
8
9
10
Mean value
Weighted evaluation function
  0.13 ,
  0.87,   1
Expanded node
0.5684
1.6052
0.1368
2.2445
2.3205
0.1013
2.6047
2.6397
2.9691
2.7056
1.7866
123
312
27
443
458
20
476
521
586
534
350
Time consuming
(s)
0.1371
0.1373
0.1370
0.1470
0.1471
0.1280
0.1472
0.1472
0.1491
0.1472
0.1424
Same path or not
Expanded node
28
96
27
153
175
12
188
222
326
254
148
same
same
same
same
same
same
same
same
same
same
This paper selected 10 OD nodes to find the optimal path, and run statistics of the time consuming and
expanded nodes respectively. To clearly compare the results of the two algorithms, we adopt a curve graph way
to show the difference between traditional evaluation functions and improved one in the optimal path selection.
3.5
3
Traditional
valuation
function
2.5
2
Time
Improved
valuation
function
1.5
1
0.5
0
1
2
3
4
5
6
7
8
9 10
OD pair
Figure 1. Time consuming comparison between traditional evaluation function and improved one
109
Rev. Téc. Ing. Univ. Zulia. Vol. 39, Nº 4, 105 - 111, 2016
700
600
Expanded nodes
Traditional
valuation
function
500
400
Improved
valuation
function
300
200
100
0
1
2
3
4
5
6
7
8
9 10
OD pair
Figure 2. Expanded nodes comparison between traditional evaluation function and improved one
From figure 1 and figure 2, it is seen that the improved evaluation function based on A* algorithm shows
higher efficiency, especially when the network has much more nodes, than the traditional one which is not stable
and only acceptable under low nodes network.
Experiment results also tell that the improved evaluation function algorithm has higher executive efficiency.
Because the design of evaluation function f ( x) and the use of condition R limits the access of successor nodes,
which greatly reduces the access nodes number during the solution of the optimal path selection. In the
evaluation function, f (x)   g(x)   h(x) , parameter  and  are used to adjust the proportion of g ( x) and
f ( x) in the evaluation function. At the same time,   (0.6,0.9) ensures the larger proportion of heuristic
function. It proves that with the increase of  , the final access nodes decreases overall, as shown in figure 3.
We set the parameters   0.13 and   0.87 to get a good overall effect. In the heuristic function h(x)  T  ,
 adjusts the proportion of included angle in the heuristic information. Under the premise of h(x)  h* (x) ,
when   1 , h(x) gets the maximum value, namely the heuristic information covers the maximum proportion in
the evaluation function. The more heuristic information is, the higher the search efficiency of A* algorithm is.
350
300
250
OD pair 1
Access nodes
200
150
OD pair 2
100
OD pair 3
50
0
0.63 0.66 0.69 0.72 0.75 0.78 0.81 0.84 0.87 0.90
Vlaue of 
Figure 3. The relationship between  and access nodes when solving the optimal path
In view of the unreasonable design problems of evaluation function in A* algorithm, this chapter improves
it by introducing the weighting process, innovatively designing heuristic function, and making more prominent
of the heuristic function, which greatly reduces the number of nodes in the algorithm and improves the search
speed. The simulation experiment of city public traffic data verifies the improved A* algorithm is more efficient
than the traditional A* algorithm, and can well solve the optimal path in multiple graph problems.
5. CONCLUSIONS
Considering the optimization problem of the complex network, this paper studies the shortest path and
shortest K paths problems. It proposes an improved A* algorithm to solve the shortest path of multiple graph
and verifies it through the simulation experiment based on urban public transportation data. Experiment results
110
Rev. Téc. Ing. Univ. Zulia. Vol. 39, Nº 4, 105 - 111, 2016
show that the improved algorithm is right and effective, and much more efficient than traditional evaluation
functions.
REFERENCES
Cui Shigang; Wang Hui, Yang Li (2012) “A simulation study of A-star algorithm for robot path planning”, Proc. of 16th
International Conference on Mechatronics Technology, p.p.506-509.
Li Lixiao (2013) “A Catastrophe Operator Based on Logistics Lines Optimization Algorithm”, Bulletin of Science and
Technology, 29(8), p.p.214-216.
Li Xia, Peng Hao (2015) “Load Balancing in Cloud Computing Using Stochastic Hill Climbing-A Approach”, Modem
Computer, 2015(19), p.p.3-7.
Li Weiguang, Su Xia (2015) “AGV path planning based on improved A* algorithm”, Modern Manufacturing
Engineering, 2015(10), p.p.33-36.
Liu Xiang, Gong Daoxiong (2011) “A comparative study of A-star algorithms for search and rescue in perfect maze.
Source”, Proc. of International Conference on Electric Information and Control Engineering, p.p.24-27.
Long Qiong, Zheng Ge (2014) “Personalized optimal route selection based on objective and autonomic decision
method”, Journal of Chang’ an University: Natural Science Edition, 34(5), p.p.146-151.
Niu Liang, Zhang Baoyou (2015) “Reseach on Solving the Shortest Path of Urban Logistics Distribution Based on Cloud
Computing”, Bulletin of Science and Technology, 31(5), p.p.184-188.
Qiu Jigang, Li Wenlong, Yang Jia. (2015) “Path optimization algorithm for team navigation based on multiple point
collaboration”, Journal of Computer Applications, 35(7), p.p. 2093-2095.
R. M. Sotnezov (2009) “Genetic algorithms for problems of logical data analysis in discrete optimization and image
recognition”, Pattern Recognition and Image Analysis, 19(3), p.p. 469-477.
Siddiqi, Umair Farooq, Shiraishi, Yoichi, Sait, Sadiq M (2012) “Multi-objective optimal path selection in electric
vehicles Source”, Artificial Life and Robotics, p.p.1-10.
Van Loock, Pipeleers, Goele, Swevers (2013) “Time-optimal path planning for flat systems with application to a
wheeled mobile robot”, Proc. of 9th International Workshop on Robot Motion and Control”, p.p.192-196.
Wang Xiaojie, Tang Jianguo, Li Juan (2015) “Dynamic Shortest Path Algorithm Based on Variable Weight”, Journal of
Xinjiang University (Science & Engineering), 2015 (3), p.p. 342-346.
Wang Qiuping, Shi Rong, Zhang Qi (2013) “Optimal path selection of slow traffic based on GIS network analysis”,
Journal of Xi’an University of Architecture & Technology, 45(5), p.p. 668-674.
Xiong Renhao, LiuYu (2015) “Improvement and parallelization of A* algorithm”, Journal of Computer Applications,
35(7), p.p.1843-1848.
Xue Ming (2015) “Optimal Path Selection of Vehicle Route Scheduling under Bad Weather Factors”, Computer
Simulationm, 32(3), p.p.210-212.
Zhang Jianxu, Jiang Yan (2015) “Determining Effective Paths Set Based on Reverse Depth-First Search Algorithm”,
Journal of Chongqing Jiaotong University, 34(3), p.p.93-98.
Zhang Wenjin, Xu Aijun (2015) “Cloud computing-based hybrid parallel genetic algorithm for solving shortest path
problem”, Application of Electronic Technique, 41(3), p.p.123-125.
111