{'fraction_non_alphanumeric': 0.034786474984649915, 'fraction_numerical': 0.007071626685863098, 'mean_word_length': 4.710554951033732, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 1, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Evolutionary Programmer: Autonomously Creating Path Planning Programs based on Evolutionary Algorithms

Evolutionary algorithms are wildly used in unmanned aerial vehicle path planning for their flexibility and effectiveness. Nevertheless, they are so sensitive to the change of environment that can't adapt to all scenarios. Due to this drawback, the previously successful planner frequently fail in a new scene. In this paper, a first-of-its-kind machine learning method named Evolutionary Programmer is proposed to solve this problem. Concretely, the most commonly used Evolutionary Algorithms are decomposed into a series of operators, which constitute the operator library of the system. The new method recompose the operators to a integrated planner, thus, the most suitable operators can be selected for adapting to the changing circumstances. Different from normal machine programmers, this method focuses on a specific task with high-level integrated instructions and thus alleviate the problem of huge search space caused by the briefness of instructions. On this basis, a 64-bit sequence is presented to represent path planner and then evolved with the modified Genetic Algorithm. Finally, the most suitable planner is created by utilizing the information of the previous planner and various randomly generated ones.


I. INTRODUCTION
U NMANNED Aerial Vehicles (UAVs) have shown great potential in several areas, e.g., military, logistics, agriculture, disaster rescue, etc. In recent years, autonomous path planning has drawn growing significance to the navigation process of UAVs, as the traditional human pilots, even have been highly trained, can't sustain control precision when the UAV is entrusted in complex missions [1].
The path planning problem is often formulated as a Constraint Satisfaction Problem (CSP), where the feasibility of a path lies on the constraints imposed by environments, missions and UAV itself. Meanwhile, the evaluation of a feasible path depends on the cost including length, risk, and fuel. Generally, a path is represented as a set of segments, i.e., line or curve, from the start point to the desired target. Therefore, the path planning problem is a CSP to find out a set of waypoints optimizing multiple objectives subject to various constraints. It has been verified this problem is NP-hard, which means the time complexity increases rapidly when the problem size grows, especially in a 3-dimensional environment with various obstacles.
Over the past few years, a bunch of UAV path planning methods have been proposed by scholars, for example, searchbased methods, such as voronoi diagram methods [2], A-star algorithm [3] and Gradient-based methods [4]; sampling-based methods, such as Rapidly-exploring Random Tree (RRT) [5], Probabilistic Road map (PRM) [6]; and nature-inspired methods,i.e.,Evolutionary Algorithms (EAs), including Genetic Algorithm (GA) [7]- [14], Particle Swarm Optimization (PSO) [14]- [17], Differential Evolution (DE) [18]- [21], Grey Wolf Optimization (GWO) [22], [23], etc. Among these methods, the EA-based planners are generally more effective and flexible to this problem, especially in cases where complex environments and numerous obstacles lead to the rapid shrink of the feasible solution area in the huge search space. However, in the problem of motion planning for robotics, which is quite similar to UAV path planning, the performance of traditional methods is remarkable because of the relatively small search space (i.e., 2-dimensional space) and constraints (e.g., it doesn't require considering the smoothness of the path). But as the problem gets more complicated, the more obvious EA's superiority is. This is because that EA needn't compute the configuration space, which is quite time-consuming, and more importantly, they normally have powerful global search capabilities due to their population-based nature, which partly prevents the algorithm from falling into local optima.
In EAs, when searching a feasible path, it generally consists of five phases, i.e., initialization, fitness computing, sorting and selection, exploitation and exploration. Although with different names for these phases in different algorithms, they are essentially similar, e.g., when using GA to solve this problem, it instantiate these phases as genome initialization, fitness computing, selection, crossover and mutation. Hence, these algorithms have the same framework. But there are quite differences among these algorithms, and even the same phase in same algorithm has various variants with numerous parameters to adapt to different environments. In other words, the EAs are very sensitive to the environment, so they still often fail or fall into local optima in practice.
Taking a closer look at this specific problem, the search space changes dramatically when the UAV fly in a completely different area. This implies that an algorithm that works effectively in one area does not always perform well in another region, and researchers are usually unable to determine arXiv:2204.02970v1 [cs.NE] 30 Mar 2022 which algorithm has a high performance before implementation. Therefore, the main idea adopted in this paper is to autonomously create EA-based path planning algorithm for UAV in a given flying environment.
There are always a dream for Artificial Intelligence (AI) to write programs. However, significant challenge still exist when the AI tries to create a generic program without human participation; that is, the AI can hardly learn to read codes written by humans and thus can't understand human logic. The existing auto programmers, such as DeepCoder [24], AI Programmer [25] and Robustfill [26], etc., all have their own internal limitations. First, the instructions used to construct a program should be Turing complete. However, this character makes the instructions are always not very complex and thus may easily lead to bugs that need human involvement to repair. Moreover, the simple instruction set also means the huge search space so that creating a program is very timeconsuming. Second, the auto programmers are generally unable to accept tasks directly, in other word, the communication between human programmers and machines is always difficult. It usually requires humans to abstract the mathematical model out of the problem, and it's not a piece of cake.
On this basis, we have proposed a first-of-its-kind auto programmer framework-Evolutionary Programmer (EP), which can automatically create suitable UAV path planning program based on EA in different flying environments. Distinct from the generic auto programmer discussed above, the instruction set in EP is high-level integrated and internal sequential because of the stationary five phases of EAs. This way, the EP can focus more on seeking a feasible solution with fewer bugs, and the performance of generated program depends a lot on the operator library. Therefore, we have chosen the most commonly used algorithms (i.e., GA, PSO, DE, GWO, Symbiotic Organisms Search (SOS) and their variants) with some other general strategies like Elitism, Rank system, Migration, etc., to build the operator library, which will be further introduced in Section III.
Finally, all operators are encoded as binaries, and every 64bit sequence represent a path planner. So we can focus on predicting an order on these operators and use it to guide the working of EP. Due to the outstanding performance of GA in automatic programming [27], we have chosen it to evolve the path planners (i.e., the original one as well as various randomly generated planners) when the UAV enters a new environment. After a few periods of iterations, the most suitable planner for this environment is created.
The rest of this paper is organized as follows: Section II proposes the mathematical model of the UAV path planning problem, including the representation and generation of scenarios and paths, the evaluation functions of the objectives and constraints. The framework of EAs to solve the problem is further introduced in Section III. In Section IV, the operator libraries is constructed and the EP is then proposed in detail. Finally, the conclusions are discussed in Section VI, and the source code is released for the reference: https://github.com/ loujiabin1994/Evolutionary Programmer.

II. PROBLEM DESCRIPTION
There are quite a few important factors (e.g., the description of environments, the representation of a path, the cost of missions, the constraints of the problem, etc.) that should be taken into consideration when planning a path for UAV. In this paper, the UAV path planning problem is treated as a multi-objective constrained optimization problem, and the mathematical model is described as follow.

A. Scenarios Representation
The scenarios for UAV path planning problem consist of the following components, terrain, obstacles, and the start point as well as the target point.
In this paper, we assume the terrain is open, implying that we can discretize the broad planning space into a surface. On this basis, the main physics obstacles in the space are the terrain, which is depicted as the point cloud and randomly generated using several layers of noises with diverse frequency and amplitude, see Fig.1(a). But such a discretized representation of terrain can't constrain all points in planning space, so we have used triangle interpolation among every three nearest points thus confirmed the minimum height of all points in the space, as shown in Fig.1(b).
Conventionally, other obstacles (i.e., radar detection, missile attacking, and entering no-fly zone) are treated as soft barriers [28], we call them threats in the latter. Finally, the starting and ending points are randomly generated within the safe area of the scenario, but in the simulation of this paper, we selected some scenarios with the same beginning and terminus as the display for easy comparison.

B. Path representation and heuristics
In EAs, the initial population is usually randomly generated without any constraints or heuristics for the sake of ignoring the characteristics of the specific problem. But in this problem, such a strategy will fail with large probability because of the strong constraints inside a path and the huge search space. It's wildly accepted that some heuristics can help the algorithm converge faster.
1) Rotated Coordinate System: In most studies, a path is usually represented as a set of waypoints within a global 3-D Cartesian coordinate system, which leads to a large search space since the direction of UAV is rarely consistent with the axes. To solve this problem, the rotated coordinate system O R -X R Y R Z, as shown in Fig.2, is established, where X R is the direction of the starting point to the target and Y R is perpendicular to X R on the horizontal plane. The transformation between the two coordinates can be obtained by the rotating matrix: where θ is the angle from X axis of the origin frame to X R axis of the rotated frame. 2) Control points: To ensure C 2 continuity of the generated curve, we use control points p = [p 1 , p 2 , . . . , p n ] to denote a path. In O R -X R Y R Z, we can assume that p is monotonically increasing along the X R axis which means that the UAV cannot move backwards. Actually, some other scholars [20], [21] have also utilized this benefit in the phase of path initialization to reduce the search space and they have proved that the solution set is almost never lost in this way. Furthermore, the x coordinate of each waypoint can roughly be locked in a fixed area since the velocity of the UAV should approximately remain constant or tiny change for the purpose of saving fuel. So We divide the ST by (n + 1) ∆l segments, and each equilateral point is the expected position of the control points. Considering that the distribution of each point is different and correlated, we can limit a point's x coordinate value between the expected value of the previous and the next.
Although we have effectively decreased the search space of the problem, the computational cost of the task remains huge. Considering that the y coordinate is unconstrained, there could be a lot of invalid points that away from the planned path. Therefore some external constraints can be added to the control points. As is shown in fig.2, two lines have limited the upper bound as well as lower bound, which are determined by extending outward a constant distance ∆d of the points from the nearest safe areas around the line ST . Under the boundary, the y coordinate is restricted in a certain scope [y min , y max ], which are calculated as (2) and (3), respectively: where R i is the radius of the ith threat, y * threat,i is the vertical coordinate of ith threat in the rotated coordinate frame O R .
Until now, every point in p is locked in a fixed area on the horizontal plane (e.g. w 2 is locked in blue and yellow areas, and w 3 is locked in yellow and green areas, and so forth). In addition, the velocity direction of UAV should not change aggressively for the reason of saving fuel. Based on this criterion, as seen in Fig.2, we define two boundaries parallel to the velocity to constrain the velocity direction variation trend with the metric ∆D equal to ∆l. So at the time of initialization, we can roughly determine the x and y range of p i+1 according the position of p i (e.g. p n−1 is locked in the gray area). This restrict is modeled as a Markov Chains, which require a considerable computational cost to be handled, so it is used only as an initial condition for increasing the feasibility of initial population.
So far we have defined the range of x and y of every points, but things are a little different for z coordinate. As a general rule, when flying at low altitude, the UAV can avoid radars on account of the terrain mask effect, and to a certain extent, fly at high altitude need more energy on takeoff and landing. Therefore, the minimum flight altitude is depicted as a constraint to the problem, and the flight altitude, which should be as lower as possible, is formulated as an objective function.
3) Generating approximate continuous path from control points: As discussed above, we used control points to represent a path. Nevertheless, the fuzzy situation between adjacent control points has hitherto caused some trouble for the computation of objective functions and constraint conditions. In other words, the ambiguity of the real behaviors between control points can hardly meet the requirements of kinematics and dynamics. There is a good deal of methods named smoother to address this issue. After this phase, the C 2 continuous waypoints w = [w 1 , w 2 , . . . , w m ] are generated. More details about the smoother will be introduced in section III-B.

C. Optimization Model
Mathematically, the UAV path planning problem can be modeled as a Multi-Objective Constraint Satisfaction Problem, whose objectives and the constraints are listed as follow.
1) Objective function: In this work, five objectives, i.e., length cost, flight altitude, radar detection, missile attacking and turning angle, will be considered to obtain a shortest, safest and smoothest path. These objectives are commonly in conflict, which means the improvements in one objective cannot be achieved without detriment to the others. In order to solve such a counterbalance problem, a weighted function (4) was proposed.
(1) Length cost Traditionally, the energy and time costs are highly related to the length of the UAV flight path. Under the same conditions of velocity and path smoothness, the longer the path, the huger the energy and time costs. The normalized approximate length of a path is described as follow: where x i denote the ith waypoint of w.
(2) Flight altitude According to II-B, a lower altitude is desired for the sake of avoiding radars and saving fuel, (6) denotes the mean flight altitude of the path.
Where M ap (x i , y i ) represent the ground height at the point (x i , y i ). (

3) Radar detection
The minimized probability of detection by hostile radars is going to guarantee the safety of flight. In this paper, we minimize the probability of drones being detected by radar to zero if it's possible, otherwise to the lowest risk. This probability can be calculated by (7) [29].
where ζ 1 and ζ 2 depend on the used radar, RCS denotes the radar cross section, which is calculated by (8), where α z = sinψ e , β z = cosψ e , α φ = sinφ e , β φ = cosφ e , and ψ e is the angle between the velocity vector of the UAV and the segment that joins the UAV and radar positions, φ e = φ − arctan(tanθ/sinψ) with φ, θ and ψ denote the roll, elevation and azimuth between the positions of the UAV and the radar. To sum up, the objective of radar detection can be represented as follow: where R is the number of radars.
(4) Missile attacking For the same reason, the probability of missile attacking should be as lower as possible. This probability, which depend on the distance between UAV and missile center d as well as the maximum hit radius of missile R M , can be calculated by (10), so the objective of this part is given by (11).
(5) Turning angle This objective is designed to calculate the degree of the path bending, the smaller the average turning angle, the more smooth the path, see (12).
2) Constraints: When planning a path, several constraints should be taken into account for safe flight. The mainstream way of constraint-handling consists of penalty function, feasibility keeping methods and hierarchy sort, etc. EP deals with these strategies as operators, seen in III-B with detailed discussion, and here we will introduce the concrete constraints as the following.
(1) Climbing/gliding Since the maneuverability of a UAV, the slope (i.e. the climbing and gliding angle), which describe the change of flying orientation in the vertical coordinate, should be restricted in the range given by (13)-(17).
For k in 2, . . . , m, where (2) Minimum flight altitude As discussed in II-B, the UAV should fly above a appropriate altitude for the sake of safety.
For k in 2, . . . , m, where H safe denotes the safe height above the ground.
(3) Forbidden flying area This constraint is introduced to avoid getting into the predefined no-fly zone (NFZ), which is high risky for the UAV. Therefore, in (19), the NFZs were established as hard constraints that the UAV must keep away from.
(4) Mission space As depicted in Fig.2, the rectangles have restricted the range of control points, hence: III. USING EA TO SOLVE PROBLEM EA is a cluster of Meta-heuristic algorithms inspired by natural intelligence, implying that they are population-based, derived from mimicking the behaviors of the organisms. The main phases of EAs to solve the UAV path planning problem are shown in Fig.3 and will be discussed in detail in the following subsection.

A. Encoding Approach and Initialization
As discussed in section II-B, the initialization of individuals could be guided with some heuristics. In this paper, three criterion are proposed: In the rotated coordinates system which we have built before, the x coordinate value of the control point is monotonically increasing. Moreover, we assume that x i obeying the normal distribution with mean (i∆l) and standard deviation (∆l/3) so that its value will fall in the expected range we defined in II-B with 99.7% probability according to the pauta criterion [30].
• y coordinate After the x-value of a control point is determined, the y-value of this point is assumed as obeying the uniform distribution with range of (−∆D+y t , ∆D+y t ), where y t is the y-value of the line P i−2 P i−1 at the point x i , or equal to 0 if this line doesn't exist.
• z coordinate We have hitherto initialized the x and y coordinates of the control points, hence we can obtain the ground constraints corresponding to the control points using M ap(x, y) function. Specifically, the z-value of P 0 is equal to M ap(x 0 , y 0 ), the ith point obeying the normal distribution with mean ) and standard deviation ∆h, where ∆h is set roughly equal to ∆l/3 in this paper according to the maneuverability of the UAV. Finally, the individual is generated, while the encoding approach is shown in Fig.4.

B. path smoother and fitness
Although we have obtained the control points of a path, the concrete situation between adjacent points is still vague. To keep the C 2 continuity, we picked four curves respectively, i.e., Bezier curve, B-spline curve, RST smoother and tangent circle curve, as seen in Fig.5. Each method may have its own inherent distinctive characteristics. Concretely, Bezier curve with three control points and four interpolating points could lie within the convex hull; cubic B-spline curve will pass through the midpoint of a line segment between two adjacent points; RST smoother has the lowest error of these four methods; and Tangent circle curve, owns the minimum computational cost of requirements. Anyhow, one thing is clear, the initial control points will be transformed into the way points w using one of these methods. Therefore, the fitness, which is the sole criterion for judging an individual, could be calculated according to (4). Although we have tried to increase the probability of valid solutions at the initial phase, the infeasible individuals still exist. To utilize the information of these individuals, the constraint-handling strategies named sorting operators in EP, are introduced. As shown in Fig.6, four different rules are utilized to handle constraints in this paper. In general, their parameters change with iteration to ensure that infeasible individuals suffer from more selection pressure at the later stage of evolution.

C. Selection
Under the EA framework, selection schemes will make a direct influence on the next generation. As shown in Fig.7, these four policies will be identified as operators and added to EP's operator library. There are also various parameters could be tweaked by EP such as the number of candidates in Tournament Selection, the method of assigning areas in Roulette Wheel Selection, the setting of a cutoff line in Truncation Selection, and the step size of every pointer in Stochastic Universal Sampling, etc.

D. exploitation and exploration
Meta-heuristic algorithms always have a trouble of making an appropriate balance between local searching exploitation and global searching exploration. In other words, these two phases are always in conflict since the computational cost in practice is limited. How to reconcile this balance is the essential problem of EA, where there is no particularly suitable solution at the moment. Although researchers have used abundant techniques (e.g. variation, hybridization, adaptation, etc.) to improve the performance of these algorithms, it's still almost impossible to propose a particular algorithm to fit any situation because this balance is vulnerable to the environment or parameters. This is what the EP is trying to solve. 1) Exploitation: In the term of exploitation, which focus on the local region, the search behavior should be conscientious. It indicates that the step size should be tiny and the searching information should ideally be provided by more than one individual. In this study, several operators are picked with such characteristics: • Crossover The Crossover, which contains numerous variants, is one of the most commonly used exploitation operators. According to the current literature of using this type of operator in the UAV path planning problem [8], [9], [18]- [20], the main variants consist of n-Point Crossover(nPX), Uniform Crossover(UX), Arithmetic Crossover(AX), which are shown in Fig.8. During this part, the key parameters of these three variants are the number of crossover points n, the Crossover Rate CR, and the coefficients (λ 1 , λ 2 ) ,respectively, which can be adjusted adaptively by EP.
• PSO The CIPSO [16] has proposed a modified parameter adjustment in PSO, which can also be modeled as an exploitation operator due to its features of small steps and directed searching. In this modified operator, the velocity and position of a particle is updating by (21).
where p(t) and v(t) denote the position and velocity of tth particle, w is the inertia weight, r 1 , r 2 are random value distributed in (0, 1), c 1 , c 2 are key parameters to balance the ability of searching and convergence, which are conformed by the function (22).
Where c max and c min are adjusted by EP.
• safari In the modified Wolf Pack Search algorithm (mWPS) [22], the safari process of wolves could also be encoded as an exploitation operator because of its strong following behavior and directed searching. This process can be illustrated as following: Firstly, select some of the higher ranking individuals as safari wolves.
Secondly, add some tiny perturbations to these safari wolves, select the best one, denoted as G best .
Finally, the whole wolf pack will approach the best individual: where step determines the convergence speed and premature level of the algorithm. This value and the distribution of disturbances are the key parameters in this part, which can be adjusted by EP.
• Commensalism As mentioned in Ref [23], the novel hybrid algorithm called HSGWO-MSOS is another efficient planner for solving UAV path planning problem. It has combined the exploration ability of the simplified Grey Wolf Optimizer (SGWO) with the exploitation ability of the modified symbiotic organisms search (MSOS), whose commensalism operator meets the requirement of this section and is described as follows: Where r −1,1 denotes a random value r ∈ (−1, 1), whose distribution is determined by EP.
• DE DE is another wildly used algorithms in the area of UAV path planning for its high convergence speed and efficient result, which has developed many variants [18], [20], [21], [31], [32]. We classified these variants into two categories: DE/rand and DE/best. Here we take the most commonly used scheme -DE/rand/1 as an example, which is described as (25)- (27).
otherwise (27) where v i (t) and u i (t) denotes the donor vector and trail vector of ith individual in tth generation respectively, the subscript j denotes the jth element in the vector, r 1 , r 2 , r 3 , r n ∈ [1, n], while r 1 = r 2 = r 3 , and F is a positive parameter called scale factor, which could be adjusted by EP.
2) Exploration: In exploration, which concentrates more on global scope, the search behavior shows significant randomness. In this paper, various algorithms are picked as exploration operators, they are: • Mutation The Mutation is a typical exploration operator. In recent years, it has aroused a lot of attention among researchers and thus many variants have been proposed [7]- [14]. In this paper, we select four most representative mutation operators from relevant research as alternate operators in EP, i.e., Uniform Mutation (UM), Non-Uniform Mutation (NUM), Gaussian Mutation (GM) and Cauchy Mutation (CM). They have some of the same operational processes: Firstly, they determine whether a genome performs the mutation operation according to the mutation probability P m .
Secondly, the trail variable determined by the concrete operator is generated based on a particular distribution.
Finally, replace the gene selected in the first step with the trail variable, the new vector is generated.
• PUS The population updating strategy (PUS) of hybrid PSO algorithm [16] is an efficient exploration operator, which leads the algorithm to high performance with a simple method (28).
Where P small and P large represent the half individuals with smaller and larger fitness respectively, r ∈ (0, 1) is a random variable, and a is the key parameter of this operator.
• SGWO The simplified gray wolf optimizer (SGWO) of HSGWO-MSOS algorithm [23] is another commonly used exploration operator, which can be described as follows: Firstly, the coefficient vectors A and C are generated randomly according to the rule of (29).
Secondly, calculate the value of D i with (30).
Finally, the new individual is produced by (31).
• CINF For solving the stagnation problem of DE, the collective information (CINF) was proposed in [33], and then was used in the UAV path planning problem [19]. It came up with the consecutive unsuccessful update CU U i , which is calculated by (32), to identify the stagnant individual.
When CU U i > T , where T stands for the threshold of stagnation, whose value can be adjusted by EP, the stagnation occurs and we use the following operation to deal with the stagnation. P i,j (t + 1) = P i,j (t) , r ≤ a or j = rn P ci mbest i ,j (t) otherwise (33) Where P ci mbest i ,j (t) is the jth element of collective vector P ci mbest i (t), which is defined as follows.
Where m i ∈ [1, i] is a random variable, w k is a weighting factor, which is calculated by (35).

E. Ending Criterion and others
According to the literature, the execution of an algorithm may end up with several conditions, e.g., the limited time running [34], the limit of generations [8] and the best individual has not changed for n-generations [20] as well as the n% individuals stay the same [35].
Besides, there are some other operators can be added to EP to avoid prematurity and they fall into two categories.
One is the multi-population technique, which divide the whole population to several subpopulations and exchange information around them, such as the island model [36], MAPS [37], CEGDA [38] and so on. Another is the diversity maintenance technique, such as Cellular [39], Injection [40], Decay Factor [12], etc. Detailed discussions of these methods are drawn in section IV.
Moreover, to speed up the convergence, several operators are proposed in literatures, such as Elitism to select the top n% individual as survival, Repair algorithm [41] to ensure all individuals remain feasible with greedy search after exploration and exploitation, and push-forward insertion heuristics (PFIH) [42] to optimize the solutions locally, etc.

IV. THE DESIGN OF EVOLUTIONARY PROGRAMMER
EP is a machine learning framework that can automatically create suitable UAV path planning program based on EA. Since the outstanding performance of GA in automatic programming, we choose it as the solver of EP. In this section, we will give a comprehensive overview of EP's software architecture.
As shown in Fig.9, when the UAV enters a new environment, the algorithm activates. First, it generates a series of binary arrays, which are mapped to path planners. These planners, together with the UAV on-board planner, formed the initial software cluster. Second, each planner is run based on the input scenario, then EP will record the cost and running time of each planner, and combine them into the fitness. Next, EP selects the planners with high fitness for cross-mutation of their genes and recombines them into a new software cluster. Finally, when the iteration satisfied the ending criterion, the UAV on-board planner is updated to be the individual with the highest fitness in the current software cluster. The detailed description of this process is discussed in the following subsections.

A. Operator Library and the Genomes
A genome is a sequence of genes used to represent instructions. To translate genomes into programs, the first thing is building an operator library and mapping its components onto the genes. As a result, each genome in EP consists of 64-bit sequence with a value of 0 or 1. The decoder will covert a genome into the related program according to the criterion established at the time of encoding. This section will describe the criterion in detail.
• Initialization In the term of initialization, 10-bits genes are encoded to represent some specific operators, as seen in Table I  • Sorting and Selection As shown in Table II, So implies sorting operators, which consist of Penalty Function, Non-dominated Sorting, α-level comparison and the Number of unfulfilled constraints; Se, which denotes selection operators, consists of Tournament selection, Truncation selection, Roulette Wheel Selection and Stochastic Universal Sampling; Rank assigns scores as selection criterion to the sorted individuals, these scores could be linear, logarithmic, exponential, etc. See Section.III-B and III-C for a detailed explanation of these operators. • exploitation and exloration As illustrated in III-D, the genes of this part are depicted as Table III, where Twins and Infer operate on the offspring produced by exploitation and exploration, respectively.

• Ending Criterion
The Ending Criterion is a crucial option to avoid additional calculation. Generally, we end up a EA with fixed generation or running time, which is encoded in the token End and End param . But there exist some cases denoting that even we keep executing the algorithm, the progress we make will be quite limited. For example, when the prematurity happens, which means that the algorithm is trapped into local minimum, we could stop this population to avoid wasting computational resources. The definition of prematurity and related parameters are encoded in Case1 and Case1 param , consisting of default setting (do nothing in this term), evolutionary stagnation, population homogenization and goal achievement. Similarly, in Case2 which is designed for multi-population situations, when the current population is too similar to a solved population, the options are default, reset, killing, and adjustment. • other operators Besides the previously proposed operations, there are other non-standard operators to improving the performance of algorithm and speed up the convergence. An presented in Table V, the Cell, Injc, Anti, F bcl and Decy, which have been explained in the section III-E, are used to maintain the diversity of the population. And the rest of operators are used mainly for improving the rate of convergence.

B. Fitness
The fitness of EP, which is different from the description in section III-B and used to evaluate how well a created program performs, should be well designed from the user-defined target. In this paper, the efficiency and performance are what we are concerning about. For the former, we use a time variable F t to represent it. And for the latter, we pick F which is calculated in (4) to denote it. So the fitness function of EP could be formulated as (36).
Where E t is the expectation of the running time that can be adjusted by user, W 1 and W 2 are weights that sum to 1.

C. Generations
A generation in GA consists of several operators. The better and faster the generated program produces the result, the higher its fitness is, and thus the more likely it is to be selected and maintain to the next generation at each epoch. The process in a generation is carried out as follows.
• Selection In every epoch, there are a fixed number of genomes as the pool of selection. For the sake of rapid convergence, here we choose the RWS (section III-C) as the selection operator..
• Crossover and Mutation In each epoch, a bunch of offspring are generated via crossover and mutation. To be specific, a process called crossover implies that parents contribute a part of genome to the child, and the mutation is that adding the stochastic disturbance under some controlled rules to specific genes of the child.
• Survival of the Fittest After the above process, a ranking system is introduced for the purpose of sorting all the genomes relying on their fitness at the earlier searching stage and removing the infeasible genomes whose running time exceeded the E t at the later stage. Concretely, the worst planner got the lowest score (about 0.8 in this paper), the best one got a score of 1.2 and all others were rank in between. This ranking system prevents better planners from being disproportionately favored in the phase of selection.

D. Terminate Conditions and Output
The entire evolutionary process has to end with some limited elapsed time. In this paper, we assume that the UAV goes through a phase of calibrating and burning the planner before entering a new scene, that is, EP is given enough time to work. Due to the fast convergence of GA, we limit the running time of EP to a maximum of 20 minutes. And as the process of evolution stopped, the planner with the highest fitness is output and burn onto the UAV's onboard computer.

V. SIMULATION RESULTS
In theory, by evolving the operators of EA, EP will get better performance than the origin algorithms under certain circumstances, and, in different environments, EP should have evolved to show better adaptability. To verify these features that do exist, 1) we designed different scenarios for proving the adaptive ability of EP, and 2) in some representative scenarios, we compared EP with the state-of-the-art evolutionary methods, which were decomposed and formed the operator library in this paper, for testifying the performance of EP.

A. adaptive verification
In this section, plenty of scenarios were generated to test the adaptive ability of EP to the changes of topographic relief, obstacle density and starting&ending points. In each of the experimental groups, an identical terrain, as shown in Fig.10, was used as the base terrain, so that we can compare which factor changes EP is more sensitive to. Moreover, we set up an initial planner (genetic algorithm) as input to the EP, labeled Origin Planner. Uniformly we set the mission space as performance. For the purpose of testifying adaptive capacity to the environment of EP, four scenarios with different obstacle density in 2D view 1 are shown in Fig.11(a)-(d), whose Obstacle density could be characterized as sparse, not too much, a bit more and dense, respectively. According to the constraints, the UAV should be forbidden from entering rectangular areas, and it is better to keep away from circular areas to reduce the probability of detection and attack. In each scenario, the evolved planner can always find the smooth path to avoid all the obstacles. In contrast, the original planner can only avoid obstacles in simple scenarios, but cannot adapt to the requirements of complex scenarios. Besides, the numerical results are list in Table VI. We can clear see that evolved planner have been shown superior to the origin one. On the one hand, the former have meet all the constraints in a relatively small amount of time. However, there is an exception in the dense condition, the evolved planner took 1 In order to display performance effects intuitively, this paper only presents 2D views of scenarios, and all data and 3D views can be accessed in https: //github.com/loujiabin1994/Evolutionary Programmer/tree/numpy/script/data. more time than the original one, which is worth since the result of avoiding breaking into no-fly zones. On the other hand, the evolved planner has got the solution with better fitness in all scenes, which means the trajectory has a smaller length cost, lower flight altitude, smoother turning, lower probability of radar detection and missile attack. 2) Topographic relief In this kind of scenarios, we have removed all artificial restrictions and just simulate different natural wild scenes, e.g. base scenario, high mountain, canyon and hills. The results are shown in Fig.12 and the numerical results are list in Table VII. From these materials, the performances of evolved planners perform well in all terrains and are all better than the original planners. In addition, we observed that the original planners haven't met the constraint of safe flight height in three scenarios. This may be because in the case of severe terrain fluctuations, the UAV cannot break through the limitation of climbing angle and thus cannot reach a safe height under the expectation of smaller distance cost and lower altitude. But evolved planners do a good job of reconciling these contradictions.

3) Starting&ending points
We have now demonstrated that EP is adaptive to new scenarios, but we don't know whether such an adaptation is scenario-specific or mission-specific. In theory, the planner EP created should be scenario-specific since only scenarios are input when EP works. To verify this hypothesis, we assign different starting&ending points to each scenario shown in Fig.11 to represent diverse missions, and the previous evolved and original planners are ordered to perform these missions. As shown in Fig.13, the evolved planners exactly outperform the original ones in the horizontal, vertical and oblique missions of all scenarios. Concretely, the evolved planners always accurately avoid the no-fly zones and try to choose a low-lying place to reach the target. For example, as shown in Fig.13(d), three planned paths accurately pass through the small gap where the no-fly zones intersect, while the last mission is blocked by the no-fly zone in the middle, so the evolved planner chooses to reach the target from the mountain side at the edge. In order to further illustrate the adaptability of EP is scenario-specific, we conducted path planning in these scenarios for 100 times respectively with randomly generated mission points, and the statistical result were sampled in Table.VIII. Different from before, we added the values of constrains together, recorded the average measures in each scenario. It's similar to what we saw before, the evolved planners have a absolute advantage in terms of fitness and constraints, but its running time is relatively sensitive to the complexity of the environment. However, it's worth for the results of excellent performance and the running time is also within the limits permitted by practice.

B. Performance Comparison
Although we have verified that EP is self-adaptive, it has not been testified that whether the evolved planner produced by EP is superior to other planners. Furthermore, we will explore whether the superiority of evolve planner is unique to the current environment. Therefore, we select six recently proposed EA-based planners, i.e., GA [14], CIPSO [16], JADE [43], CIPDE [19], mWPS [22] and HSGWO [23], and one planner generated by EP through hundreds of scenarios named Heuristic Hybrid Partical Swarm Optimization(HHPSO) with uniform evolution generations and population size, as compared algorithms. Here,we have selected four representative scenarios Case 1-4 to test the capabilities of algorithms. As shown in 14, although the evolved planners cannot achieve a remarkable superiority in fitness, they can satisfy the constraints well in all scenarios, which is the most important requirement in practice. In particular, we have selected two extreme cases, i.e., case 2 and case 3, to explore EP's adaptability to soft and hard constraints. In Case 2, the UAV is banned from NFZs, which mean the trajectory planned by algorithm must not cross with the rectangle areas, and we can see that only the result of evolved planner meets this constraint. And in Case 3, the UAV need to avoid radar detection and missile attacks, which doesn't require the trajectory to be completely isolated from the display area since the terrain mask effect and altitude factor, so the path planned by evolved planner is partially within the circle areas but still satisfy constraints. To compare the performance of different algorithms, we ran all algorithms 100 times in each scenario and adopted several metrics to measure the final output, which are Successful Rate(SR), Average Fitness(AF) and Average Time(AT). Here we define a successfully planned path where no more than one constraint is violated and the constraint value does not exceed 0.1, which means the UAV can be allowed up to 0.1m bellow the safe height or slightly exceed the climbing/gliding angle. The results are recorded in Table IX, of all the algorithms, EP achieve 96.5% SR in about 0.3 seconds of AT in these complex environment, which is superior to the rest of the algorithms. JADE can achieve the optimal AF with a relatively long At but only 25.75 SR, which is not practical for this particular problem. The same as mWPS, CIPSO and HSGWO. In contrast, other algorithms focus on the satisfaction of constraints and achieve a relatively higher SR compared with the aforementioned algorithms, but thus have lost part of fitness. Essentially, the HHPSO is created by EP with training from a large number of scenarios. Although it has a higher SR than other algorithms, there is still a big gap with EP. From the above discussions, the planners programed by EP is more effective and efficient than the compared algorithms. On the one hand, the former can achieve the highest SR with relative less AT in particular scenario. On the other hand, the planners generated by EP with different scenes does not adapt well to the new environment. This illustrates that the superiority of evolve planner is unique to the current environment, and the effect of EP is to constitute such a planner.

VI. CONCLUSION AND DISCUSSIONS
It's very sensitive for EA-based path planner to the changes of environment. To solve this problem, this paper presents a machine learning system named EP that can autonomously create adaptive path planner. This system is inspired by the obstacles to automatic program generation, i.e., the bugs caused by simplified instruction sets and the communication difficulties between humans and machines. Based on the inspiration, the mathematical model of the problem and a specific operator library are established. In order to further speed up the convergence rate, some heuristics are involved to guarantee the feasibility of initial paths. Comparative simulation shows that the evolved planners produced by EP outperform the original ones and other state-of-the-art EA-based planners, particularly in the complex scenarios with severe terrain relief and dense obstacles around.
In theory, creating a program from a few basic instructions is possible but remains a practical gap. So we cut the state-of-theart EAs of path planning problem to some operators and then recombined them into new algorithms using genetic algorithm. This approach avoids building algorithms from screws and thus can generate effective programs after a few minutes of training. Moreover, such an idea is not only applicable to path planning but also any problems sensitive to environments.
Although the performance of EP is remarkable in simulation, it has not been tested in the real world. Part of the reason is that there is no such a large site to place terrain and obstacles. On the other hand, the transformation between simulation and reality has been a long-standing difficulty in robotics. We may further work on these two issues. For the former, we've set up an indoor test environment, including the drones(Crazyflie 2.1) [44], the position system(Mocap) and the ground control system. We plan to place obstacles in a simulation environment and then utilize the mixed reality technology to fly the drones in the real world. For the latter, we will adopt Reinforce Learning to generate residual control signal for adapting the real world. Finally, we hope that some studies motivated by our work will be proposed to solve realworld problems, and this work could facilitate the applications of evolutionary algorithms in robotics.