Genetic_algorithms_for_solving_shortest_path_problems (1)
Genetic_algorithms_for_solving_shortest_path_problems (1)
Path Problems
Mitsuo Gent, Runwei Cheng', and Dingwei Wang*
Abstract- In this study, we investigated the possibility of feature of these problems is that they may be solved, ei-
using genetic algorithms to solve shortest path problems. ther exactly or approximately, by identifying shortest path.
The most thorny and critical task for developing a genetic
algorithm to this problem is how to encode a path in a graph
Therefore, this studies will provide a base for constructing
into a chromosome. A priority-based encoding method is efficient solution procedures for shortest path-based net-
proposed which can potentially represent all possible paths work optimization problems.
in a graph. Because a variety of network optimisation prob-
lems may be solved, either exactly or approximately, by
The most thorny problem when applying genetic algo-
identifying shortest path, this studies will provide a base for rithms to this problem is how to encode a path in a graph
constructing efficient solution procedures for shortest path- into a chromosome. In this paper, we proposed a priority-
based network optimisation problems. The proposed a p based encoding method, which can potentially represent
proach has been tested on three randomly generated prob-
lems with different siae from 6 nodes to 70 nodes and from all possible paths in a graph. The proposed algorithms
10 edges to 211 edges. The experiment results are very en- was tested on random generated shortest path problems.
couraging: it can find the known optimum very rapidly with The experimental results are very encouraging and show
very high probability. It can be believed that genetic algo-
rithms may hopefully be a new approach for such kinds of that genetic algorithms may hopefully be a new approach
difficult-to-solveproblems. for shortest path-based network optimization problems.
Keywo&- Genetic algorithms, priority-based encoding
method, shortest path problems, network optimisation 11. SHORTEST
PATHPROBLEM
problem.
I. INTRODUCTION An undirected graph G = (V, E) comprises a set of nodes
V = { v i } and a set of edges E E V x V connecting nodes
One of the most common problems encountered in analy- in V. Corresponding to each edge, there is a nonnega-
sis of networks is shortest path problem: finding a path be- tive number w;j representing the cost (distance, transit
tween two designated nodes having minimum total length times, or others of interesting) from node vi to node v j .
or cost. It is a fundamental problem that appears in many A path from node vi to node v j is a sequence of edges
applications involving transportation, routing and commu- (vi,vl), ( v l , ~ , ) , . . ., ( v k , v j ) from E in which no node ap-
nications. Several good methods have been proposed to pears more than once. A path can also be equivalently
solve the problem to optimality [I]. represented as a sequence of nodes ( v i , v l , v,, . ..,v k , v j ) .
This study provides an interesting alternative: using ge- For the example given in Figure 1, (1,4),(4,3), (3,5) and
netic algorithms to find out a shortest path. The purpose (5,6) is a path from node 1 to node 6. The node repre-
is not, of course, t o compare the genetic algorithms with sentation is (1,4,3,5,6). The problem is to find a path
conventional algorithms, because genetic algorithms w i l l be between two given nodes having minimum total cost.
unable to compete [2,3]. Shortest path problem forms an Let 1 denote the initial node and n denote the end node
important base for other relevant problems, such as mul- of the path. Let z;, be an indicator variable defined as
tiple objective shortest path problems, nonlinear objective follows:
shortest path problems, multiple fuzzy objective shortest
path problem, network flow problems, and shortest path-
based network analysis and optimization problems. These 2;j = { 1, if edge (i, j ) is included in the path
0, otherwise
problems are difficult to solve in general and there is no ex-
act optimal solution method known yet [4-6]. A common The integer programming model is formulated as follows
0-7803-3949-5/97/$10.0001997 IEEE 40 1
Authorized licensed use limited to: INDIAN INSTITUTE OF TECHNOLOGY KANPUR. Downloaded on September 02,2024 at 05:32:32 UTC from IEEE Xplore. Restrictions apply.
1 2 3 4 5 6 position:nodeID
13151416/2111 vdue:prionty
402
Authorized licensed use limited to: INDIAN INSTITUTE OF TECHNOLOGY KANPUR. Downloaded on September 02,2024 at 05:32:32 UTC from IEEE Xplore. Restrictions apply.
that extends the path from the terminal node of the path. For a given partial path P,", we can define a mesh matrix
The tricky part is, of course, finding a set of eligible edges. M ( k ) as follows:
The following definitions and theorems give us a better
understanding about how to make such a set of eligible 0, if i E V, V j E V,
edges and how the path growth procedure works. q j = 1, otherwise (9)
Let G = (V,E) be a connected and undirected graph
with a real-valued weight function defined on E . Let P: Then we can define a new adjacent matrix A ( k ) accord-
be a partial path under growing, which contains k 1 nodes + ing to a given partial path P: as follows:
with the terminal node t. The definition of eligible edge is Definition 2:(dynamic adjacent matrix) The dynamic
given as follows: adjacent matrix A ( k ) with respect to a given partial path
Definition 1: (eligible edge) An edge is eligible for the P: is given by the following boolean intersection of matrix:
path P: if it can extend the path without forming a cycle
with the edges in P:. A(k) = A n M(k) (10)
Let V, V be the set of nodes existing in the partial
path P:. Let Vq = V - V, be the complement set of V,. We will show that the dynamic adjacent matrix A(k) re-
moves all edges incident to the nodes in partial path p:.
Let C ( V , , V q )= { ( i , j ) I i E V,,j E V,} be the cut of
In the other words, it just contains the adjacent relation
the graph [9]. Let Tt = { ( t , j ) 1 j E V} be the set of
with respect to the eligible edges. Because such adjacent
edges incident with the terminal node t. Then we have the
relation varies as the path P," grows, we call it the dynamic
following lemma.
adjacent matrix.
Lemma 1: (eligible edge) An edge e is eligible for the
We further define a matrix U ( k ) according to the path
path P: if and only if (1) e E C(V,, Vq) and (2) e E Tt.
Proof. If an edge e belongs to the cut C(V,, Vq), it is P: as follows:
incident to one node in V, and the other node in V,. It
means that the edge will never form a cycle with the edges
in P,". If the edge also belongs to Tt, it is incident to the
u;j = { 0, if V i E V and j
1, otherwise
=t
(11)
terminal node of the partial path P,",that is, the edge Then we can have the following recursive equation of the
will extend the path by introducing a new node adjacent mesh matrix and the dynamic adjacent matrix with respect
to the terminal node of the path. Therefore, for a given to step k :
partial path P:, if an edge satisfies conditions (1) and (2)
simultaneously, it is eligible for the path P:. M ( k ) = M ( k - 1) n U ( k ) , M ( 0 ) = [lInxn(12)
Assume that there is a n eligible edge which only satisfies
A ( k ) = A(k - 1) n U ( k ) = A(k - 1) n M ( k )
the condition (2), then its two incident nodes must be in V,.
It means that the edge will form a cycle with the edges in = A n M ( k ) , A(0) = A (13)
P:, which is a contradiction to the definition of an eligible
edges. Assume that there is an eligible edge which satisfies Theorem 1: (eligible edge set) Let E ( k ) = { ( t , j ) I
the condition (l),then it must be incident to any node in a t j ( k ) = 1 , V j E V}, we have
V, except for the terminal node of the path. It means that
the edge wiU form a tree with other edges in P,", but not E( k) = Eqt (14)
a path, which is a contradiction. w
Proof. Given a partial path P: with t # n. For any
For a given partial path P,", we can define two sets Ept =
node j E V,, its corresponding column vector in the mesh
{ ( t , j ) I j E 5 )and E,: = { ( t , j ) I j E Vq}. It is easy to
matrix M ( k ) is set as a zero vector. Any adjacent relation
verify that Tt = EPt U Eqt and EPt n Eqt = 0 . Then we among nodes in V, has been removed from the mesh ma-
have: trix. According to Equation (10) we know that only the
Corollary 1: (eligible edge set) For a given partial path
adjacent relation between node in V, and node in Vq is kept
P:, the set of eligible edges Eqt is given as follows: unchanged in A ( k ) with respect to the path P:. That is, if
Eqt = Tt n C(V,, Vq) (7) aij(k) = 1, the edge ( i , j ) belongs to the cut set C(V,,Vq).
Further, by Lemma IV we know that, if the node i = t ,
Proof.
then the edge ( t , j ) is an eligible edge for path P:. There-
Tt n qV,, Vq) = (Ept U Eqt) n qv,, Vq) fore, the set E ( k ) contains as the same edges as the set Eqt.
= ((Ept n cp,, Vq)) U (Eqt n qv,,Vq)) w
= Eqt n C ( 5 ,Vq) The set E ( k ) can be easily obtained from A ( k ) which
= Eqt takes recursive form and easy for programming. The basic
idea of path growth procedure is to extend the path P:
Now we consider how to find the set of Eqt. For a con- by adding a new edge from set E ( k ) at each step. We may
nected and undirected graph G = (VI E ) , the adjacency take a risk that the path developed with this approach may
matrix A is the n x n matrix given by suspend a t a node, that is, we can not reach to the final
1, if ( i , j ) E E end node n from this node. Such a node is called a pendant
aij =
0, otherwise node.
403
Authorized licensed use limited to: INDIAN INSTITUTE OF TECHNOLOGY KANPUR. Downloaded on September 02,2024 at 05:32:32 UTC from IEEE Xplore. Restrictions apply.
Definition 3: (pendant node) For a given partial path Then we have the following theorem for identifying a dead
P/ with t # n, if the terminal node t is a pendant node node.
if all of its directly adjacent nodes belong t o set V,. The Theorem 2: (dead node) For a given partial path P / ,
following lemma gives the condition to identify a pendant a node i in set V, is a dead node if and only if ? i n ( k ) = 0.
node. Proof. G ( k ) is a subgraph of graph G which contains
L e m m a 2: (pendant node) For a given partial path P,", only the nodes in V, and the edges incident to the nodes in
the terminal node t is a pendant node if and only if (1) V,. The reachability matrix R(k ) with respect to subgraph
E ( k ) = 8 and (2) t # n. G ( k )describes the adjacent relation between any two nodes
Proof. If E ( k ) is an empty set, by Theorem IV we know in graph G ( k ) that if they are adjacent each other a t most
that there is no eligible edge incident to the node t. That n - k - 2 order (For a given partial path P,", only other
is, the path could not be extend anymore from the node. n - k - 1 nodes in V, a t most are needed to complete the
In such a case, if t = n, we have got a complete path and path). For a given node i in the graph, if T i n ( k ) = 0, there
the node is a normal terminal node; if not, the node is a does not exist a path with a length of n - k - 2 at most
pendant node. from node i to node n. Therefore, node i is a dead node.
Suppose that there is a pendant node with E ( k ) # 8, Assume that there is a dead node i with rin(k) = 1, then
then there exists at least one edge (t,i), i E V,,this is a we can make a path from node i to node n, denoted by p ; .
contradiction to the definition of pendant node. Subsequently, we have V,; 6 V, and V, n Vpi = 8. This is
In fact, there are some special nodes in V,, which are a contradiction to the definition of dead node.
essentially not reachable to the final end node n. If one of For a given path P," in a connected and undirected graph
such nodes is appended into the partial path, it must mis- G = (V,E ) , let v d = {i I rin(k) = 0 , V i E V,}, which is
lead the path t o a pendant node. The following definitions formed with all dead nodes and E d = ((i, j ) I i E v d , j E
and theorems give us a means to distinguish such kind of V } , which is formed with all edges incident to dead nodes.
nodes from V,. We can define a subgraph of G as G, = (V - vd,E - E d ) .
Definition 4: (dead node) Given a partial path P," with Then we have the following theorem:
t # n. For a node i E V,, let P ( i ) denote the set of all Theorem 3: (feasible path) Let P," be a partial path
possible paths from node i to the final end node n. The under growing. We have a subgraph G , according to P,".
node i is a dead node if Let V, is the complement set of V, with respect to G , .
C(V,,V,) be a cut of graph G , . The eligible edge set can
V, n Vpi# 0 , Vpi E P ( i ) (15) be determined by Corollary IV. If a new edge is selected
from the set Eqt a t each step of the path growing, we can
In the other words, a node is a dead node if any of possible generate a complete path from node 1 to node n. Proof.
paths from it to node n must contain a t least one node in G , is a subgraph of graph G by removal of all dead nodes v d
VP. and all the edges incident t o the nodes in v d . Any node in
The dead node can be identified by means of reachability V, with respect to G , and P/ is incident to node n at most
matrix [lo]. Let A be an adjacent matrix for a given graph n - k - 2 order. At each step of path growth, a new node
G = (V, E ) . The k order adjacent matrix of A is defined from V, is introduced into the path. After each step of path
by the following boolean multiplication: growth, the mesh matrix M ( k ) is updated, accordingly, the
dynamic adjacent matrix A ( k ) ,the subgraphs G ( k )and G , .
=A ~ - ~ A AO , = I (16) Then the reachability of each node in V, can be guaranteed.
The k order adjacent matrix describes the relation between Therefore, we can develop a complete path from node 1 to
two nodes i and j that they are not directly connected but node n.
we can reach node j from i through a path with the length Theoretically, we can check if a node is a dead node with
of k - 1. Node i is k order adjacent to node j if ufj = 1. Theorem IV a t each step as the procedure progresses and
Let Ep = ( ( i , j ) I i E V p , jE V } , which is the set of all remove all dead nodes from set V . For large size problem,
edges incident to nodes in P,". We can define the graph such checking is computational cost. As we know that evo-
G ( k ) = (V - V,,E - E,), which is a subgraph of graph G lutionary approach has the advantage that which allows in-
with removal of all nodes in Vpand all edges incident to Vp. feasible chromosomes enter the population pool and evolve
The reachability matrix R ( k ) for the graph G ( k ) is defined with feasible one by some penalty mechanism. The infea-
as follows: sible chromosomes may provide some useful genes to the
Definition 5:(reachability matrix) The reachability ma- evolution. So we do not check the dead nodes a t each step,
trix R ( k ) with respect to graph G ( k ) is given as follows: instead of this, we simply make a virtual connection be-
tween the terminal dead node and the final end node n
R(H) = [A(K) + K <n -2 (17) with either a mild penalty or a severe penalty. The follow-
ing implementation of path growth procedure is based on
where I is the identity matrix and A ( k ) is the dynamic this consideration.
adjacent matrix with respect to path P,". The reachability Path g r o w t h procedure
matrix describes the relation between any two nodes that Step 1: (initialization) Let k + 0, %h +- {I}, and
if they are adjacent each other at most n - k - 2 order. A ( k ) +- A , tk + 1.
404
Authorized licensed use limited to: INDIAN INSTITUTE OF TECHNOLOGY KANPUR. Downloaded on September 02,2024 at 05:32:32 UTC from IEEE Xplore. Restrictions apply.
Step 2: (termination test) I f t h = n, go t o step 9; other- J.
..........:.
...........
J.
.........
...........
wise, continue. parent 3 ZB
' 2
... 2;g.;
Step 3: (eligible edge set) Make the edge set E ( k ) ac-
cording to dynamic incidence matrix A ( k ) .
Step 4: (pendant node test) If E ( k ) = 0, let tk+' + n,
child 3
..........:.:
:.:.:........
I
2 6
.:+..:.:.::
kgl 5
v k + l c vpk U {n}. Go t o step 9; otherwise continue.
Fig. 4. The mutation operator
Step 5: (path extending) Select tk+' from Vt subject to
(tk,tk+') E E ( & )with the highest priority.
Step 6: (mesh matrix update) Make new mesh matrix of minimization problems, we have to convert the original
+
M ( k 1) t M ( k ) n V ( k 1). + objective value to a fitness value in order to ensure that
Step 7: (dynamic incident matrix update) Let A(k + the fitter individual has a larger fitness value.
1) + A ( k ) fl M ( k 1). + In our experiment, the roulette wheel approach was
Step 8: (iteration index update) k c k 1 and go to + adopted as the selection procedure which is one of the
step 2. fitness-proportional selection. The elitist way was com-
Step 9: (complete path) Return the complete path. bined with this approach in order to preserve the best chro-
The worst-case complexity of the path growth procedure mosome for the next generation and overcome the stochas-
is given by the following theorem [ll]. tic errors of sampling. With the elitist selection, if the
Theorem 4: (worst-case complexity) The path growth best individual in the current generation is not reproduced
procedure generates a path from a given chromosome in into the new generation, remove one individual randomly
O ( n 2 )time. from the new population and add the best one to the new
Proof. Step 1 takes 0(1)time. Step 2 takes at most population.
n-1 times if the path contains all nodes of the graph, which VI. NUMERICAL EXAMPLES
is the worst case. Within the main loop, step 3 requires n
times because that we just need to check the column t in Primary computational experiments were conducted on
matrix A ( k ) where t is the terminal node in the partial path three randomly generated test problems. The first prob-
P,",steps 6 and 7 require n times because that we simply lem contains 6 nodes and 10 edges, the second problem
set the column i as zero vector in matrix A ( k ) where i is contains 32 nodes and 66 edges and the third one contains
the new node appended into the path, and steps 4 and 5 70 nodes and 211 edges. The evolutionary environment
take 0(1) times. Therefore, the total time required at the is set as the follows: for the first one, population size 10,
worst case is O ( n 2 ) . maximum generation 50, crossover ratio 0.2 and mutation
ration 0.1,for the second one, population size 20, maximum
v. GENETICOPERATORS EVALUATION AND generation 100,crossover ratio 0.4 and mutation ration 0.1
The nature of the proposed encoding is a kind of permu- and for the third one, population size 40, maximum gener-
tation representation. A number of recombination opera- ation 200, crossover ratio 0.4 and mutation ration 0.2. For
tors have been investigated for permutation representation. each problem, 400 runs have done with different random
We used the position-based crossover operator proposed numberseed. The statistical results over 400 runs for each
by Syswerda [12]. It can be viewed as a kind of uniform problem are given in Table I. The optimal solutions are
crossover operator for integer permutation representation obtained by Floyd-Warshall algorithm [13].For the second
together with a repairing procedure as shown in Figure 3. problem, the proposed algorithm can obtain the optimal
Essentially, it takes some genes from one parent at random solution with a very high experimental probability. For
and fills the vacuum position with genes from the other the third problem, the experimental probability for getting
parent by a left-to-right scan. the optimal solution is about 64%. Note that we just use
the relative small parameter setting comparing with usual
............ ........................
1 3 gG:
... 2 6 $# $5 genetic algorithms practices. When the population size is
c c c increased, the frequency for obtaining the optimal solution
child will increase accordingly. We fixed the parameters max-
L L h imum generation as 200, crossover ratio as 0.4, mutation
ratio as 0.2, and varied population size from 10 to 100. The
results over 200 runs for each case are summarized in Ta-
Fig. 3. The position-basedcrossover operator ble 11. When population size is set as 10, the probability
is only 21%; when it is increased to 100, the probability is
The swap mutation operator was used here, which simply about 92%.
select two positions at random and swap their contents as We further fixed population size as 10 and varied max-
shown in Figure 4. imum generation from 100 to 3000. The results over 200
During each iteration, chromosomes are evaluated, using runs for each case are summarized in Table 111. When max-
some measure of fitness. Usually three main steps are in- imum generation is set as 2000, the probability for getting
cluded in evaluation: (1) convert chromosomes to a path, the optimal solution is about 92%. This result is very en-
(2) calculate the objective value, and (3) convert the objec- couraging, because the population size is a very small and
tive function's value to fitness. Since this problem is a kind the evolutionary process is not very long.
405
Authorized licensed use limited to: INDIAN INSTITUTE OF TECHNOLOGY KANPUR. Downloaded on September 02,2024 at 05:32:32 UTC from IEEE Xplore. Restrictions apply.
TABLE I
ON TBE RANMlM TEST PRoBLE?&
genetic algorithms
No. nodes edges optima .
best worst average
1 6 10 10 10 10 10 100%
2 32 66 205 205 220 205.15 98%
3 70 211 2708 2708 3040 2745.53 64%
TABLE II
FREQUEXCY DWFERENT POFWLAlTON S E FOR TBE PROHXM nodcs = 70 popsbe = 10
WlTB 70 NODES AND 211 EDGES edges = 211 maIceIl= 100
406
Authorized licensed use limited to: INDIAN INSTITUTE OF TECHNOLOGY KANPUR. Downloaded on September 02,2024 at 05:32:32 UTC from IEEE Xplore. Restrictions apply.