A Genetic Algorithm for Shortest Path Motion Problem in Three Dimensions Marzio Pennisi1 , Francesco Pappalardo1,2, Alfredo Motta3 , and Alessandro Cincotti4 1
Department of Mathematics and Computer Science, University of Catania 2 Faculty of Pharmacy, University of Catania
[email protected],
[email protected] 3 Politecnico di Milano Milano, Italy
[email protected] 4 School of Information Science Japan Advanced Institute of Science and Technology, Japan
[email protected]
Abstract. We present an evolutionary approach to search for nearoptimal solutions for the shortest path motion problem in three dimensions (between a starting and an ending point) in the presence of obstacles. The proposed genetic algorithm makes use of newly defined concepts of crossover and mutation and effective, problem optimized, methods for candidate solution generation. We test the performances of the algorithm on several test cases.
1
Introduction
The application of genetic algorithms (GA) [10] to problems where the search space is particularly wide and complex can produce good results [11],[4]. One of the problems we can adapt to GA search is the shortest path motion problem in three dimensions (between a starting and an ending point) in the presence of obstacles. It has been proved that if the obstacles are constituted by polyhedrons, the problem is NP hard [2],[9]. In particular, the problem is exponential in the number of vertices.Various approximating algorithms have been proposed in literature. The interested reader can find additional informations in [1],[8],[3]. The complexity of this kind of problem in its general form is not strictly and directly connected to the complexity of the obstacles. It has been proved [15] that the Euclidean shortest path motion problem in three dimensions remains NP hard if the obstacles are disjoint parallelepipeds parallel to the axes. This is the case that we are going to analyze in this paper. This problem can be found in many practical applications and has investigated in many different environments. “Path planning research” is a common problem
F.P. and M.P. acknowledge partial support from IMMUNOGRID project, under EC contract FP6-2004-IST-4, No. 028069.
D.-S. Huang, L. Heutte, and M. Loog (Eds.): ICIC 2007, LNAI 4682, pp. 534–542, 2007. c Springer-Verlag Berlin Heidelberg 2007
A Genetic Algorithm for Shortest Path Motion Problem
535
in robot automation: in order to move a robot arm, all the obstacles have to be avoided and obtaining shortest path is preferable. This problem has been explored for example in [6],[7]. Another topic that founds application can be represented by routing in communication networks. In this case shortest path can represent best route and obstacles can be link failure or congestion. A Neural Network for this particular case has been presented in [5], while some AntNet algorithms have been shown in [13],[14]. Automated driving systems in presence of obstacles can also represent another practical application of the problem. The paper is organized as follows. In section 2, we describe in depth our algorithm. Section 3 provides computational results, while Section 4 is devoted to conclusions and final remarks.
2
The Genetic Algorithm
We start our description with the formal definition of the problem we intend to study. – Instance: two points s and t and Np parallelepipeds pairwise-disjoint in an Euclidean three-dimensional space; – solution: the shortest path between s and t that avoids the interior of the given obstacles; – measure: the total length of the path in Euclidean metric. With term world we intend a subset of the Euclidean space R3 , while we consider an obstacle as parallelepiped parallel to the Cartesian axes. A gene is defined as a tern of real values < x, y, z >. It describes the position of a point in the Euclidean space. Genes are subject to particular constraints: – Every gene is positioned on one of the 12 edges of the Np parallelepipeds, limiting considerably the search space. – Two consecutive genes in a chromosome cannot be connected by a segment intersecting an obstacle. A chromosome is a sequence of genes representing the vertices of the broken line. s and t are identified as terns of real values < x, y, z > representing the starting and the ending points. They are respectively connected to the first and the last gene of every chromosome by a segment that does not intersect any parallelepiped. Therefore every chromosome represents a candidate solution to the problem. The number of chromosomes and the maximum dimension of a chromosome are fixed and we call these values respectively Nc and Dc . The algorithm resembles classical GAs and can be briefly described by the pseudo-code showed on Procedure 1. During the generation of chromosomes, we proceed in the following way: let f be the segment connecting s to t. If there is not a direct connection from s
536
M. Pennisi et al.
Procedure 1. GeneticAlgorithm for SPMP3D Generate the initial population Compute the fitness of each individual while no. of desired iterations is not reached do Select best-ranked individuals from population Execute crossover and mutation operators to obtain new offsprings Compute the fitness of the offsprings Replace worst-ranked individuals with offsprings end while return best-ranked individual
to t, it will intersect at least an obstacle. If this is the case, we proceed with a corrective approach eliminating all the “errors”, i.e. all intersections between s and t. To gain individuals diversity, for other chromosomes, we choose parallel segments [s , t ] to f . After the initial corrections, we substitute s , t with s, t. After that we make corrections only on the final parts. For choosing s , t we use the following method to find acceptable points: let < x1 , y1 , z1 > and < x2 , y2 , z2 > be respectively the coordinates of s and t. Let < Xm , Ym , Zm > be the tern indicating the max dimensions of the world, we define a “validity range” r as follows: r = min(x1 , y1 , z1 , x2 , y2 , z2 , Xm −x1 , Ym −y1 , Zm −z1 , Xm −x2 , Ym −y2 , Zm −z2 ). Three random values vx , vy , vz ∈ (0, r) are chosen. s and t will be defined respectively as < x1 + vx , y1 + vy , z1 + vz > and < x2 + vx , y2 + vy , z2 + vz >. Figure 1 shows the method. For correcting the “errors” we act in two different ways, according with the position of the ingoing and the outgoing points on the obstacle. If the ingoing and outgoing points are on adjacent faces, the gene will be positioned on a random point of the edge shared by the two faces. If they are on parallel faces, we need two genes. First we choose a face that can minimize the path between the two points. Then we choose randomly: 1. one point on the edge shared by this face and the face containing the ingoing point, 2. one point on the edge shared by this face and the face containing the outgoing point. The process is shown on Figure 2. Fitness function F is defined as follows. Let c be a chromosome; let gi be the i-th gene of the chromosome c; let g0 = s and gDc = t. We have: F (c) =
Dc
p(gi , gi−1 ),
i=1
where p(gi , gi−1 ) represents the Euclidean metric distance between gi and gi−1 .
A Genetic Algorithm for Shortest Path Motion Problem
537
Fig. 1. Example of validity range in an Euclidean space XY Z
A “roulette wheel” selection method is used to select the chromosomes which will take part to the crossover process: the chance of a chromosome of getting selected is proportional to its fitness. Elitism on the best chromosome is implemented: the chromosome with the best fitness will be preserved and it will be a member of the next population. We proceed with a modified single-point crossover: every gene in a chromosome is placed on an edge of parallelepiped. Given gp a randomly chosen crossover point, the first part from beginning of chromosome to gp is copied from the first parent, the rest is copied from the second parent. If gp = gp+1 or the segment (gp , gp+1 ) intersects no obstacles the chromosome is accepted and no more work has to be done. We else allow, to permit chromosome acceptance, the reconstruction of a subpart of the chromosome in a such way that no obstacles are intersected. To avoid total chromosome reconstruction we introduced a fixed threshold Cx indicating the maximum number of genes that can be replaced (Figure 3). Starting from gp and proceeding towards the ends we compute the sub-part of ends (gi1 , gik ) whose exclusion avoids the repeating of parallelepipeds in the
538
M. Pennisi et al.
Fig. 2. Two ways for correcting “errors”
sequence. We proceed for reconstruction only if the following conditions are satisfied: 1. ik − i1 + 1 ≤ Cx 2. i1 > 1 3. ik < Dc . For rebuilding the remaining sub-part of the chromosome under the compatible threshold, we have to recalculate the missing genes of the new offspring from gi1 to gik . We proceed in the following way: let f be the straight line connecting s to t. Consider Dc equidistant points in f so that the number of these points is equal to the number of genes in a chromosome. We assimilate the i-th gene of a chromosome to the i-th point of f supposing that in most cases a good chromosome contains genes whose position is not too far from the indicated points. We therefore proceed during the initialization of the algorithm building a [Dc × Np ] matrix so that the (i, j) cell contains the j-th obstacle closer to the i-th point. Let r be the index of gene we need to recalculate, we choose an integer value y between 0 and Np − 1 using the following law: y = (((k1x − 1)/k2 ) · Np ) where k1 = 10, k2 = 9 are two constants and x ∈ [0, 1[⊂ R is a randomly chosen value. We finally choose to position the r-th gene on a random edge of the obstacle contained in the (r, y) cell. From experimental results we observed that the presented law tends toward closest obstacles without excluding the distant ones. Mutation process can happen in different ways. Due to particular chromosome structure and constraints, a canonical mutation process was unusable. It
A Genetic Algorithm for Shortest Path Motion Problem
539
Fig. 3. An example of crossover: inside the first offspring, c2 represents a parallelepiped out of the threshold Cx . The first offspring will be rejected. The second offspring will pass the test and will be accepted.
was instead necessary to take into account particular chromosome meaning. We therefore decided to allow specific mutation in four different ways, each way with 4 a specific probability pi , pi = 1. i=1
When a gene gi of a chromosome is selected for mutation, a random real number p ∈ (0, 1) is generated. Let gi be the mutated gene, gi is obtained from gi using one of the following mutation processes: 1. 2. 3. 4.
shift gi on the same edge (0 ≤ p < p1 ); move gi on different edge of the same parallelepiped (p1 ≤ p < p1 + p2 ); move gi on a parallelepiped in the neighborhood (p1 + p2 ≤ p < p1 + p2 + p3 ); collapse gi on the previous or subsequent gene (p1 + p2 + p3 ≤ p < 1).
We chose p1 ≥ p2 ≥ p3 ≥ p4 to favor mutations which alter less the chromosome. It’s clear that only one mutation process is chosen at a time (mutually exclusive events). Two mutations cannot occur to the same gene in the same time step. If the mutated chromosome does not respect the constraints, p is regenerated and the entire process will be repeated for no more than Nt times (where Nt is a positive integer value). If the number of tries exceeds the threshold Nt , the mutation process will fail and the chromosome will not be modified. For the case (1), the best results have been obtained limiting the length of the range where a new position has to be chosen: gi is obtained choosing a random position on the same edge where gi is placed in a such way that the distance between gi and the segment [s, t] will be not greater to than the distance between gi and the same segment. If we are in case (2), gi is obtained first choosing a random edge e of the parallelepiped where gi is located, and then choosing a random position on e.
540
M. Pennisi et al.
In case (3) a new parallelepiped p in the neighborhood is firstly chosen using the same method seen during crossover process for rebuilding of sub-parts. A new position on p is therefore obtained using the same process seen in case (2). Case (4) has been introduced to make the real number of different genes smaller and thus to reduce the number of segments of a candidate solution. In this case gi is overwritten by gi−1 or gi+1 . This process can be useful if the dimension of the chromosomes results overestimated in respect of the complexity of the problem. After mutation on cases (1), (2) and (3), if g was already part of a set of collapsed genes, an “anti-star” procedure that provides to move the entire set to the new position is called to avoid a star effect. Figure 4 shows us a star effect due to cases (1), (2) and (3) and the resolved situation after calling “anti-star” procedure.
Fig. 4. An example without (left side) and with (right side) “anti-star” procedure
We also use some auxiliary and optimization procedures for obtaining best results. The first one is called after the crossover process. This procedure selects a chromosome with a given probability Pv from those have not taken part to the crossover process and overwrites it with a new generated one. In this way diversity of the population is maintained and local minimums should be avoided. The second procedure looks into the chromosomes for two non consecutive genes [gi1 , gik ] placed on the same obstacle p and will collapse, if necessary, the entire sequence in a such way that all the constraints are respected. It is used to avoid that a candidate solution passes from a point gi1 on an obstacle p and, after a loop, it returns to p (Figure 5).
3
Computational Results
To our best knowledge there are no test suites available for the problem. For that reason we tested the algorithm in two different ways. On the first 6 cases we used worlds with a well-known solution, created “adhoc” for testing purposes. On the other ones we used random bigger worlds
A Genetic Algorithm for Shortest Path Motion Problem
541
Fig. 5. An example of loop
without knowing the best solution. The algorithm has been repeated 20 times for every case. We have set Nc and Dc to a congruous value for every case. We use “2decimal” precision for the results except for the standard deviation that uses a “5-decimal” precision. Table 1. Path lengths for different test cases Obstacles Best Best result % 2 137.33 100% 3 194.47 100% 4 109.44 100% 5 168.65 100% 14 190.85 100% 28 368.47 100% Obstacles Best Found Best Found % 20 342.68 60% 20 288.08 70% 20 147.05 100% 40 240.05 5% 40 295.56 45% 40 221.80 85% 60 363.41 10% 60 533.03 10% 60 371.37 5% 80 349.98 70% 80 399.70 5% 80 549.32 5%
Mean Standard deviation 137.33 0 194.47 0 109.44 0 168.65 0 190.85 0 368.47 0 Mean Standard deviation 342.70 0.03996 288.08 0.00113 147.05 0 240.07 0.00570 295.80 0.49896 221.80 0.00185 363.99 0.26146 534.79 2.38956 373.78 1.34352 350.87 2.73466 403.74 2.94401 551.23 0.45042
542
M. Pennisi et al.
From Table 1 we can see that the given algorithm is able to find always the best solution for less-populated words where the optimal solution is known. Further analysis and comparison of the remaining cases with approximated algorithms will be examined in future work.
4
Conclusion and Future Work
We have presented an evolutionary algorithm to find effective near-optimal solution for the shortest path motion problem in three dimensions. One of the major novelties of our algorithm, is the usage of particularly adapted optimization procedures, like new defined crossover and mutation. Future work will see our GA compared to approximate algorithms and to be adapted in worlds where the position of obstacles changes with the passing of the time.
References 1. Papadimitriou, C.H.: An Algorithm for Shortest-Path Motion in Three Dimensions.Inform Process. Lett20.(1985)259-263 2. Canny, J.,Reif,J.H.: Lower Bound for Shortest Paths and Related Problems. In Proceedings of 28th Annual Symposium on Foundations of Computer Science (1987)4960 3. Clarkson, K.L.: Approximation algorithms for shortest path motion planning. Proceedings of 19th Annual ACM Symposium on Theory of Computing (1987)56-65 4. Goldberg,D.E.: Genetic Algorithms in Search. Optimization and Machine Learning, Addison-Wesley(1989)1-88 5. Zhang, L., Thomopoulos, S.C.A: Neural Network Implementation of the Shortest Path Algorithm for Traffic Routing in Communication Networks. International Joint Conference on Neural Networks.Vol2. 591(1989) 6. Fujimura,K., Samet,H.: Planning A Time-Minimal Motion among Moving Obstacles. Algorithmica, Vol.10.(1993)41-63 7. Fujimura, K.: Motion Planning Amid Transient Obstacles. International Journal of Robotics Research, Vol.13.No.5.(1994)395-407 8. Choi,J., Sellen,J., Chee,K.Y.: Approximate Euclidean Shortest Path in 3-space. Annual Symposium on Computational Geometry Archive. Proceedings of the Tenth Annual Symposium on Computational Geometry. (1994)41-48 9. Reif,J.H., Storer,J.A.: A Single-Exponential Upper Bound for Finding Shortest Paths in Three Dimensions. J. ACM (1994)1013-1019 10. Whitley, D.: A Genetic Algorithm Tutorial. Statistics and Computing (1994)65-85 11. Chambers, L.: Practical Handbook of Genetic Algorithms,Applications Vol.1. CRC Press (1995)143-172 12. Mitchell, M.: An Introduction to Genetic Algorithms. The Mit Press (1996) 13. Baran, B., Sosa,R.: A new approach for AntNet routing. Proceedings. Ninth International Conference on Computer Communications and Networks (2000)303-308 14. Baran,B.: Improved AntNet routing. ACM SIGCOMM Computer Communication Review, Vol.31.Issue 2 Supplement(2001)42-48 15. Mitchell, J.S.B., Sharir, M.: New Results on Shortest Paths in Three Dimensions. Annual Symposium on Computational Geometry Archive Proceedings of the Twentieth Annual Symposium on Computational Geometry (2004)124-133