1 Introduction

Oil and gas pipelines have features of high pressure and flammability, sometimes accompanied by leakage, fire and explosion (Zhang et al. 2018a). Accidents could result in great loss of lives and high economic costs, so it is of great significance to inspect the pipeline regularly to minimize the risks. In recent years, unmanned aerial vehicles (UAV) have attracted much attention due to the low cost, high efficiency as well as safety. There has been extensive research regarding the civil UAV applications for pipeline inspection (Tu and Yang 2003; Patle et al. 2018; Reddy et al. 2011; Sedighi et al. 2004; Tsai et al. 2011; Hu and Yang 2004). UAVs can carry relevant detection equipment (Gómez and Green 2017) for different targets, including pipeline infrastructure, leak detection and pipeline environmental condition monitoring. UAV inspection paths of pipeline networks should be optimized to reduce manpower and to use material resources effectively. Previous research on optimization of inspection path focused on power grids, railway networks (Zhang et al. 2018b) and other networks. However, oil and gas pipeline network topology is more complicated (Wang et al. 2018a, b; Zhang et al. 2017b, d) and difficult to work out. Even though previous algorithms are applied, the optimal solution cannot be obtained in many cases.

Currently, there are three approaches to plan the inspection path for pipeline networks. The first one is the graph-based algorithm, such as the Voronoi diagram, the probabilistic roadmap and the Dijkstra’s algorithm. The Voronoi diagram has been widely used in robot path planning (Bhattacharya and Gavrilova 2007; Candeloro et al. 2017; Chen and Chen 2014; Garrido et al. 2006). The inspection area is divided into points and these points are used to generate the Voronoi diagram. Then the Voronoi diagram divides the inspection area into many convex polygons which contain only one inspection point. When the graph contains the initial position and destination position, the optimal inspection path can be obtained. A probabilistic roadmap (Akbaripour and Masehian 2017; Geraerts and Overmars 2006; Wang and Cai 2018) is to convert the continuous space into discrete space and adopts a search algorithm to find the path on the roadmap to improve search efficiency. The Dijkstra’s algorithm is one of the shortest path algorithms from one vertex to the rest of the vertices, solving the shortest path problem in the directed graph. The main feature of this algorithm is to extend the outer layer centering on the starting point until it reaches the end. Chen et al. (2015) proposed a multi-objective optimization model for a wireless sensor network mobile agent problem, and the improved Dijkstra’s algorithm was applied to solve the model. The optimal mobile agent path between any two nodes could be obtained according to the network environment. However, it is very difficult to combine the motion constraints of a UAV with the graph-based algorithm, and the number of sampling points also has a great effect on the path search results.

The second approach is the classical heuristic search algorithms (Gammell et al. 2015; Li et al. 2017; Yu and LaValle 2016), such as the A* algorithm and Sparse A* Search (SAS). The A* algorithm was first described by Hart et al. (1968) and determined the optimal path from an initial node to a target node which evaluated each search position in the state space. In order to reduce the search space and realize the real-time path planning for the UAV (Szczerba et al. 2000), the constraints of the drone flight process are taken into account. However, the A* algorithm and the SAS algorithm can only plan the path when all environmental information is known. What is worse, the search space will be larger with an increase in the number of inspection points, and the computation time of the classical heuristic search algorithm will increase exponentially.

The third approach is the modern heuristic search algorithm that mainly includes a genetic algorithm (GA) (Tu and Yang 2003; Nazarahari et al. 2019; Patle, et al. 2018; Sedighi et al. 2004; Tsai, et al. 2011; Hu and Yang 2004), particle swarm optimization (PSO) (Zhang et al. 2017c) and an ant colony optimization (ACO) (Zhang et al. 2017a). Shen et al. (2016) developed a novel method for the path planning for an electricity distribution network patrol. The vehicle routing problem (VRP) model was established, and the improved ACO was adopted to obtain the optimum patrol path. In this way, the patrol programs became more scientific, reasonable and efficient. Guo et al. (2017) established an optimization model of the logistics network to minimize the overall cost of the circulation-type distribution vehicle routing, and a genetic algorithm and a particle swarm optimization algorithm are implemented to solve the model. However, the proposed optimization issue is so complex that the computation can easily to fall into a local optimum in the evolutionary process, which will lead to premature convergence and miss the optimal solution.

Given that oil and gas pipeline networks are more complex than electricity distribution networks, the self-adaptive genetic simulated annealing algorithm (AGASA) is introduced in this paper to improve the solution quality and efficiency of path planning. Moreover, based on the inspection demand of the pipeline network, taking the minimization of the total length of the inspection path as the objective, and through the establishment of constraints including the mission scenario and the safety performance of UAVs, a mixed-integer nonlinear programming (MINLP) model is proposed. By adopting the two-stage solution methodology, the optimal inspection path is obtained.

2 Methodology

2.1 Preliminaries

In our path planner, all of the candidate routes are evaluated in the workspace. The pipelines are usually distributed linearly, so the pipeline is divided into multiple nodes and the two-dimensional coordinates of these nodes are identified as deterministic parameters in the model. It should be noted that the flight path consists of straight-line segments, e.g., a sequence of segments connecting the way nodes from the starting node to the goal node, and the starting node and goal node are the same.

2.2 Objective function

Suppose that there are \(K\) UAVs implemented in the oil and gas pipeline network inspection mission. Taking the total inspection path length as the objective, which can be defined as follows:

$$\hbox{min} \,F = \sum\limits_{i} {\sum\limits_{h} {\sum\limits_{k} {\left( {L_{i,h} B_{i,h,k} } \right)} } } \quad i \in I;h \in H;k \in K$$
(1)
$$L_{i,h} = \sqrt {\left( {x_{i} - x_{h} } \right)^{2} + \left( {y_{i} - y_{h} } \right)^{2} }$$
(2)

where \(L_{i,h}\) defines the distance between the inspection node \(i\) and node \(h\). \(B_{i,h,k}\) is a binary variable, if the inspection mission from node \(i\) to node \(h\) is performed by UAV \(k\), it is 1. Otherwise it is 0, \(\left( {x_{i} ,y_{i} } \right)\) and \(\left( {x_{h} ,y_{h} } \right)\) are the coordinates of node \(i\) and node \(h.\)

2.3 Constraints

Each UAV starts from the base and returns to the base after completing the inspection mission. Also, it should be noted that the UAV is not allowed to return on the original path.

$$\sum\limits_{h}^{N} {B_{0,h,k} } = 1\quad h \in H;\quad k \in K$$
(3)
$$\sum\limits_{i}^{N} {B_{i,0,k} } = 1\quad i \in I;\quad k \in K;\quad i \ne h$$
(4)

Each node must be inspected by the UAV.

$$\sum\limits_{h}^{N} {B_{i,h,k} } = R_{i,k} \quad i \in I;\quad h \in H;\quad k \in K$$
(5)

The overall flight time of each UAV cannot exceed its endurance.

$$\sum\limits_{i} {\sum\limits_{h} {\alpha L_{i,h} R_{i,k} } } \le E_{k} \quad i \in I;\quad h \in H;\quad k \in K$$
(6)

Set \(a_{i} = \left( {x_{i} - x_{i - 1} ,y_{i} - y_{i - 1} } \right)\), the flight angle of the UAV cannot exceed the maximum turning angle.

$$\frac{{a_{i}^{{}} a_{i + 1}^{T} }}{{\left| {a_{i} } \right|\left| {a_{i + 1} } \right|}} \ge \cos \left( \theta \right)\quad i \in I$$
(7)

All of the UAVs perform the inspection mission according to the set path and the distance between UAVs cannot be less than the minimum safe distance \(d_{\text{s}}\).

$$d \ge d_{\text{s}}$$
(8)

3 Two-stage solution methodology

In this paper, the two-stage solution methodology is proposed to optimize the UAV inspection path. In the first stage, the pipeline is divided into some nodes according to the vision of UAV. In the second stage, the AGASA is adopted to solve the model and obtain the optimal patrol path for an oil and gas pipeline network.

3.1 First-stage solution

Figure 1 shows the schematic diagram of the inspection area: The flight altitude is \(H\), the angle of view of UAV is \(a\), then the inspection radius can be calculated to be \(R = H\tan a\). In the first stage, the pipeline is divided into some nodes according to the inspection radius. When the UAV is located at the top of the node, the whole pipeline of length \(2R\) can be detected. Similarly, the UAV only needs to inspect the nodes, and the whole pipeline can be detected, which is shown in Fig. 2. In this way, the size of the model is greatly reduced, and the workload of the inspection task can be minimized, thereby improving the inspection efficiency.

Fig. 1
figure 1

Schematic diagram of the inspection area

Fig. 2
figure 2

Top view of UAV implements inspection mission

3.2 Second-stage solution

Genetic algorithm (GA) can search for the global optimal solution easily, but the local search optimization ability is poor and premature convergence could take place easily. As a stochastic optimization technique that simulates the annealing process of heating and melting metals proposed by Metropolis, the simulated annealing algorithm (SA) is able to get rid of the local optimal solution and inhibit the precocity of a genetic algorithm, but it evolves slowly. In this section, the global parallel search ability of GA and the strong local serial search ability of SA are combined. By introducing heuristic rules in the process of generating the initial population and crossover operation, the optimal solution is expected to be found.

3.2.1 Self-adaptive genetic algorithm

  1. (1)

    Generation of the initial population

The first step is to generate a set of flight routes for each UAV, and the starting node and terminal node of flight path are both the UAV base. To generate a large number of feasible solutions quickly, the pipeline is divided into segments, and the order of the nodes on the pipe segment remains unchanged. After that, the inspection path of each UAV is checked to see whether the constraints are satisfied. If the constraints are satisfied, the scheme would be feasible; otherwise, a new inspection path is generated, and the test is performed again. In this way, each inspection node is assigned to UAV, completing the layout of the initial solution. Better yet, the initial path has a lower fitness, which is beneficial to fundamentally improve the convergence speed of the algorithm and optimize the convergence result.

The encoding of the path can be expressed as follows:

$$\begin{aligned} L_{m} & = \left( {L_{1} ,L_{2} , \ldots ,L_{k} } \right) \\ & = \left( \begin{aligned} x_{0} ,y_{0} ,x_{11} ,y_{11} , \ldots ,x_{1s} ,y_{1s} ,x_{0} ,y_{0} ,x_{21} ,y_{21} , \ldots \hfill \\ \ldots ,x_{2t} ,y_{2t} ,x_{0} ,y_{0} ,x_{k1} ,y_{k1} , \ldots ,x_{kw} ,y_{kw} ,x_{0} ,y_{0} \hfill \\ \end{aligned} \right) \\ \end{aligned}$$
(9)

where \(L_{k}\) defines the inspection path of the UAV \(k\), \(x_{1s} ,y_{1s}\) is segment \(s\) of the pipeline inspected by the first UAV, \(x_{2t} ,y_{2t}\) is segment \(t\) of the pipeline inspected by the second UAV. Similarly, \(x_{kw} ,y_{kw}\) defines segment \(w\) of the pipeline inspected by UAV \(k\).

  1. (2)

    Fitness function

Fitness is a measure of the ability of an individual in a group to reach or come close to the optimal solution. The probability of individuals with higher fitness to evolve to the next generation is larger, while the probability of individuals with lower adaptation to reach the next generation is relatively small. From the analysis above, we can conclude that path planning is to find the minimum of the objective function under some constraints. If the inspection mission can be completed by one UAV, only four constraints are involved. If the inspection mission needs multiple UAVs, all five constraints should be included.

The objective function is chosen as a fitness function:

$$\hbox{min} \,f = L_{m} = \sum\limits_{i} {\sum\limits_{h} {\alpha L_{i,h} B_{i,h,k} } }$$
(10)
  1. (3)

    Selection of genetic operator

Selection operators are used to simulate the survival of the fittest in the process of biological and genetic evolution. Crossover operators are used to imitate the production of new biological individuals or species, and mutation operators are used to imitate the accidental errors resulting from cell division and replication. Also, the selection operator generates a next generation of the population by replicating individuals, and crossover and mutation operators are responsible for generating new individuals.

  1. (A)

    Selection operator

The algorithm adopts the roulette wheel selection and the elitist model to select the individual.

  1. (1)

    Roulette wheel selection

The probability of an individual being selected is proportional to the fitness value. This can be expressed as follows:

$$P\left( {L_{m} } \right) = \frac{{f\left( {L_{m} } \right)}}{{\sum\nolimits_{m = 1}^{M} {f\left( {L_{m} } \right)} }}$$
(11)

The specific implementation of the algorithm is as follows:

  • Summing up the fitness function values of all individuals in the population and getting the \(f_{\text{total}} ;\)

  • A random number \(f_{\text{random}}\) is generated in the interval \(\left[ {0,f_{\text{total}} } \right];\)

  • The fitness function values are incremented one by one starting from the first individual. The chromosome \(L_{m}\) will be chosen if \(q_{m} \ge f_{\text{random}} ;\)

\(q_{m}\) is named as the accumulated probability of the chromosome \(L_{m}\), whose formula of calculation is expressed in Eq. (12)

$$q_{m} = \sum\limits_{k = 1}^{M} {P\left( {L_{m} } \right)}$$
(12)
  1. (2)

    Elitist model

The genetic algorithm continuously generates new individuals by performing crossover and mutation operations. Although more and more good individuals will be produced as the evolutionary process of the population increases, they may also destroy the individuals with the best fitness in the current population due to the randomness of genetic operations such as replication, crossover and mutation. Therefore, the elitist model is used to perform the survival of the fittest, the individuals with the highest fitness in the current population do not participate in the crossover and mutation operation. Instead, it is used to replace the individuals with the lowest fitness value after genetic manipulation in the current generation.

The specific operation steps of the elitist model are as follows:

  • Identify the individuals with the highest fitness value \(f_{\text{best}}^{m}\) and the lowest fitness value \(f_{\text{worst}}^{m}\) in the current population.

  • If \(f_{\text{best}}^{m} > f_{\text{best}}^{\text{all}}\), take the individual with the highest fitness value \(f_{\text{best}}^{m}\) as the best individuals in all populations, i.e., \(f_{\text{best}}^{\text{all}} = f_{\text{best}}^{m} .\)

  • Replace the individual with the lowest fitness value \(f_{\text{worst}}^{m}\) in the current population with the best individuals \(f_{\text{best}}^{m}\) in all populations, i.e., \(f_{\text{worst}}^{m} = f_{\text{best}}^{\text{all}} .\)

  1. (B)

    Crossover

The individuals generated by the parent generation will perform the multi-segment crossover operation, during which the nodes on the segment remain unchanged. In this way, the UAVs are restricted to fly along the pipeline, avoiding the redundant path in the process of crossover operation.

It can be described as follows:

  1. (1)

    Set the number of intersections to \(W\) and select the intersection range \(p \in [p,p + W]\) randomly. Meanwhile, set \(r = 1.\)

  2. (2)

    Search the position of the intersection in the individuals \(C_{1}\) and \(C_{2}\), and record it as \(x\) and \(y.\)

  3. (3)

    Switch the position of individuals \(C_{1} \left( {1,p} \right)\) and \(C_{2} \left( {1,p} \right).\)

  4. (4)

    Switch the position of individuals \(C_{1} \left( {1,x} \right)\) and \(C_{2} \left( {1,y} \right)\), \(r = r + 1.\)

  5. (5)

    If \(r < W\), go back to Step 2, otherwise, the crossover operation is finished.

$$\begin{aligned} C_{1} & = L_{m}^{{C_{1} }} = \left[ {S_{1}^{{C_{1} }} ,S_{2}^{{C_{1} }} , \ldots ,S_{k}^{{C_{1} }} } \right] \\ & = \left[ \begin{array}{l} x_{0}^{{C_{1} }} ,y_{0}^{{C_{1} }} ,x_{11}^{{C_{1} }} ,y_{11}^{{C_{1} }} , \ldots ,x_{1s}^{{C_{1} }} ,y_{1s}^{{C_{1} }} ,x_{0}^{{C_{1} }} ,y_{0}^{{C_{1} }} ,x_{21}^{{C_{1} }} ,y_{21}^{{C_{1} }} , \ldots , \hfill \\ x_{2t}^{{C_{1} }} ,y_{2t}^{{C_{1} }} ,x_{0}^{{C_{1} }} ,y_{0}^{{C_{1} }} ,x_{k1}^{{C_{1} }} ,y_{k1}^{{C_{1} }} , \ldots ,x_{kw}^{{C_{1} }} ,y_{kw}^{{C_{1} }} ,x_{0}^{{C_{1} }} ,y_{0}^{{C_{1} }} \hfill \\ \end{array} \right] \\ \end{aligned}$$
(13)
$$\begin{aligned} C_{2} & = L_{m}^{{C_{2} }} = \left[ {S_{1}^{{C_{2} }} ,S_{2}^{{C_{2} }} , \ldots ,S_{k}^{{C_{2} }} } \right] \\ & = \left[ \begin{array}{l} x_{0}^{{C_{2} }} ,y_{0}^{{C_{2} }} ,x_{11}^{{C_{2} }} ,y_{11}^{{C_{2} }} , \ldots ,x_{1s}^{{C_{2} }} ,y_{1s}^{{C_{2} }} ,x_{0}^{{C_{2} }} ,y_{0}^{{C_{2} }} ,x_{21}^{{C_{2} }} ,y_{21}^{{C_{2} }} , \ldots , \hfill \\ x_{2t}^{{C_{2} }} ,y_{2t}^{{C_{2} }} ,x_{0}^{{C_{2} }} ,y_{0}^{{C_{2} }} ,x_{k1}^{{C_{2} }} ,y_{k1}^{{C_{2} }} , \ldots ,x_{kw}^{{C_{2} }} ,y_{kw}^{{C_{2} }} ,x_{0}^{{C_{2} }} ,y_{0}^{{C_{2} }} \hfill \\ \end{array} \right] \\ \end{aligned}$$
(14)

After performing the crossover operation, two new individuals \(D_{1}\) \(D_{2}\) can be obtained:

$$\begin{aligned} D_{1} & = L_{m}^{{D_{1} }} = \left[ {S_{1}^{{D_{1} }} ,S_{2}^{{D_{1} }} , \ldots ,S_{k}^{{D_{1} }} } \right] \\ & = \left[ \begin{array}{l} x_{0}^{{D_{1} }} ,y_{0}^{{D_{1} }} ,x_{11}^{{D_{1} }} ,y_{11}^{{D_{1} }} , \ldots ,x_{1s}^{{D_{1} }} ,y_{1s}^{{D_{1} }} ,x_{0}^{{D_{1} }} ,y_{0}^{{D_{1} }} ,x_{21}^{{D_{1} }} ,y_{21}^{{D_{1} }} , \ldots , \hfill \\ x_{2t}^{{D_{1} }} ,y_{2t}^{{D_{1} }} ,x_{0}^{{D_{1} }} ,y_{0}^{{D_{1} }} ,x_{k1}^{{D_{1} }} ,y_{k1}^{{D_{1} }} , \ldots ,x_{kw}^{{D_{1} }} ,y_{kw}^{{D_{1} }} ,x_{0}^{{D_{1} }} ,y_{0}^{{D_{1} }} \hfill \\ \end{array} \right] \\ \end{aligned}$$
(15)
$$\begin{aligned} D_{2}& = L_{m}^{{D_{2} }} = \left[ {S_{1}^{{D_{2} }} ,S_{2}^{{D_{2} }} , \cdots ,S_{k}^{{D_{2} }} } \right] \hfill \\& = \left[ \begin{array}{l} x_{0}^{{D_{2} }} ,y_{0}^{{D_{2} }} ,x_{11}^{{D_{2} }} ,y_{11}^{{D_{2} }} , \cdots ,x_{1s}^{{D_{2} }} ,y_{1s}^{{D_{2} }} ,x_{0}^{{D_{2} }} ,y_{0}^{{D_{2} }} ,x_{21}^{{D_{2} }} ,y_{21}^{{D_{2} }} , \cdots , \hfill \\ x_{2t}^{{D_{2} }} ,y_{2t}^{{D_{2} }} ,x_{0}^{{D_{2} }} ,y_{0}^{{D_{2} }} ,x_{k1}^{{D_{2} }} ,y_{k1}^{{D_{2} }} , \cdots ,x_{kw}^{{D_{2} }} ,y_{kw}^{{D_{2} }} ,x_{0}^{{D_{2} }} ,y_{0}^{{D_{2} }} \hfill \\ \end{array} \right] \hfill \\ \end{aligned}$$
(16)
  1. (C)

    Mutation

The individuals that will undergo a mutation operation can be expressed as follows:

$$\begin{aligned} E_{1} & = L_{m}^{{E_{1} }} = \left[ {S_{1}^{{E_{1} }} ,S_{2}^{{E_{1} }} , \ldots ,S_{k}^{{E_{1} }} } \right] \\ & = \left[ \begin{array}{l} x_{0}^{{E_{1} }} ,y_{0}^{{E_{1} }} ,x_{11}^{{E_{1} }} ,y_{11}^{{E_{1} }} , \ldots ,x_{1s}^{{E_{1} }} ,y_{1s}^{{E_{1} }} ,x_{0}^{{E_{1} }} ,y_{0}^{{E_{1} }} ,x_{21}^{{E_{1} }} ,y_{21}^{{E_{1} }} , \ldots , \hfill \\ x_{2t}^{{E_{1} }} ,y_{2t}^{{E_{1} }} ,x_{0}^{{E_{1} }} ,y_{0}^{{E_{1} }} ,x_{k1}^{{E_{1} }} ,y_{k1}^{{E_{1} }} , \ldots ,x_{kw}^{{E_{1} }} ,y_{kw}^{{E_{1} }} ,x_{0}^{{E_{1} }} ,y_{0}^{{E_{1} }} \hfill \\ \end{array} \right] \\ \end{aligned}$$
(17)
$$\begin{aligned} E_{2} &= L_{m}^{{E_{2} }} = \left[ {S_{1}^{{E_{2} }} ,S_{2}^{{E_{2} }} , \cdots ,S_{k}^{{E_{2} }} } \right] \hfill \\& = \left[ \begin{array}{l} x_{0}^{{E_{2} }} ,y_{0}^{{E_{2} }} ,x_{11}^{{E_{2} }} ,y_{11}^{{E_{2} }} , \cdots ,x_{1s}^{{E_{2} }} ,y_{1s}^{{E_{2} }} ,x_{0}^{{E_{2} }} ,y_{0}^{{E_{2} }} ,x_{21}^{{E_{2} }} ,y_{21}^{{E_{2} }} , \cdots , \hfill \\ x_{2t}^{{E_{2} }} ,y_{2t}^{{E_{2} }} ,x_{0}^{{E_{2} }} ,y_{0}^{{E_{2} }} ,x_{k1}^{{E_{2} }} ,y_{k1}^{{E_{2} }} , \cdots ,x_{kw}^{{E_{2} }} ,y_{kw}^{{E_{2} }} ,x_{0}^{{E_{2} }} ,y_{0}^{{E_{2} }} \hfill \\ \end{array} \right] \hfill \\ \end{aligned}$$
(18)

The specific mutation operation is described as follows:

  1. (1)

    A random mutation probability \(p_{m}\) is generated in the interval \(\left[ {0,1} \right].\)

  2. (2)

    A random two elements on the chromosome \(L_{m}\) will switch position if \(0 \le p_{m} \le 0.5\), otherwise, a random three elements on the chromosome \(L_{m}\) will switch position if \(0.5 < p_{m} \le 1.\)

  3. (3)

    The new individuals \(F_{1}\) and \(F_{2}\) are generated after a mutation operation.

$$F_{1} = L_{m}^{{F_{1} }} = \left[ {S_{1}^{{F_{1} }} ,S_{2}^{{F_{1} }} , \ldots ,S_{k}^{{F_{1} }} } \right]$$
(19)
$$F_{2} = L_{m}^{{F_{2} }} = \left[ {S_{1}^{{F_{2} }} ,S_{2}^{{F_{2} }} , \ldots ,S_{k}^{{F_{2} }} } \right]$$
(20)

3.2.2 Simulated annealing algorithm

  1. (1)

    Initial temperature

The initial temperature needs to be high enough to ensure that the algorithm has strong ergodicity from the beginning to avoid falling into the local optimal solution. \(T_{0}\) is selected as the initial temperature which can be denoted as:

$$T_{0} = 10 \times N$$
(21)
  1. (2)

    Temperature update function

The temperature update function is used to modify the temperature value in the external cycle. It is generally required that the temperature drops to nearly zero and then converges to the global optimal solution. Equal proportion temperature is chosen as the temperature update function since it is effective and easy to implement:

$$T_{n + 1} = wT_{n} ,n \ge 0,0 \le w \le 1$$
(22)
  1. (3)

    Acceptance function

Generally, the Metropolis criterion is selected as the acceptance function for generating a solution to a combinatorial optimization problem. At the same time, it is used to discriminate against the probability \(P_{t}\) that the new solution \(q_{\text{new}}\) will replace the old solution \(q_{\text{old}}\). \(t\) is the temperature of the isothermal process. The formula for calculating the probability is as follows:

$$P_{t} = \left\{ \begin{array}{l} 1 \hfill \\ \exp \left( {\frac{{\left( {f\left( {q_{\text{old}} } \right) - f\left( {q_{\text{new}} } \right)} \right)}}{t}} \right) \hfill \\ \end{array} \right.\begin{array}{*{20}c} {} \\ {} \\ \end{array} \begin{array}{*{20}c} {f\left( {q_{\text{old}} } \right) \ge f\left( {q_{\text{new}} } \right)} \\ {f\left( {q_{\text{old}} } \right) < f\left( {q_{\text{new}} } \right)} \\ \end{array}$$
(23)

3.2.3 Path planning steps

The steps to plan the patrol path of UAVs by AGASA are shown in Fig. 3 and described as follows:

Fig. 3
figure 3

Flowchart of the second-stage solution

  1. (1)

    Initialize a group of paths with the size of \(M\) and set the parameters of the initial temperature \(T_{0}\), maximum evolution generations \(G_{\hbox{max} }\), and termination temperature \(T_{\text{end}} .\)

  2. (2)

    Initialize the genetic algebra counter \(g = 0\) and evaluate the fitness of each path.

  3. (3)

    According to the crossover probability and mutation probability, the individuals selected from each subpopulation to undergo the operations of selection, crossover as well as mutation are decided, then the fitness value of each new individual is calculated.

  4. (4)

    Decide whether to replace the old individual with the new individual according to the Metropolis criterion.

  5. (5)

    If \(g < G_{\text{max}}\), \(g = g + 1\), go back to Step 3, Otherwise, go to Step 6.

  6. (6)

    If \(T < T_{\text{end}}\), update the temperature and go back to Step 2, otherwise, the optimal or near-optimal routes are found.

4 Computational studies

UAVs are equipped with high-resolution cameras and sensors that transmit information in real time, through which they can detect changes in the environment around the pipeline and identify any pipeline leaks. Table 1 presents the parameters and configuration of UAV.

Table 1 The parameters and configuration of UAV

4.1 Example 1

A 5 × 5 km virtual pipeline network is set as a research example. In this paper, we propose a two-stage solution method for the inspection path optimization as shown in Fig. 4. The proposed method shows a relatively universal frame and realizing methodology for the comprehensive solution of optimization. The coordinates of production wells and valves are known. The base was chosen to be built at the valve to facilitate the operation of UAVs. The method is decomposed into two parts: One is the pipeline segmentation according to the vision capability of the UAV, which can select an effective inspection range and greatly reduce the scale of the model. In the second part, the self-adaptive genetic simulated annealing algorithm is introduced to deal with the inspection path optimization problem for the oil and gas pipeline network. Finally, the optimal solution shows that only one UAV is required for the inspection task, and the total length of the inspection path is 16,250 m.

Fig. 4
figure 4

The frame of the two-stage solution method

In this paper, three algorithms (AGASA, GA and SA) are applied to solve the model. During initialization, the population size is set to 500, the maximum evolution generations are 2000, the temperature update coefficient is 0.97, and the termination temperature is set to 0.001. To test the stability of each algorithm, the calculation was repeated 10 times, and the results are shown in Fig. 5. It can be noted that the calculation stability of GA and SA is unsatisfactory. As for GA, the solution is not tending to be stable after 2000 iterations. SA has a better performance than GA; it tends to be stable after 150 iterations. However, the calculation results are not consistent each time, which means that there is a serious risk that the algorithm missed the optimal solution and fell into a local optimum in the calculation process. On the contrary, the calculation results of AGASA are consistent each time after 900 iterations, which can be attributed to the treatment of the initial solution and introduction of heuristic rules in the algorithm. This further verified that the AGASA proposed in this paper has a great advantage in solving the problem of UAV inspection path optimization for oil and gas pipeline networks.

Fig. 5
figure 5

Calculation results of different algorithms

Also, the influence of algorithm parameters on the optimal solution is tested in this paper. Generally, two main parameters affecting the performance of the algorithm include population size and temperature update coefficient. According to that, the experiments are conducted, respectively, with the specified w value of 0.95 and then continued with the specified M value of 500. Tables 2 and 3 show the calculation results under different population and temperature update coefficients. From Table 2, it can be noted that the performance of genetic optimization is not very good if the population size is too small. Conversely, selecting a larger number of initial populations can process more solutions at the same time, thereby finding the global optimal solution easily. In detail, the optimal solution can be found when the population size reaches 350. Meanwhile, there is a similar phenomenon in the temperature update coefficient. When the value of the temperature update coefficient is closer to 1, the chance of finding the global optimal solution is greater.

Table 2 Influence of population size on calculation results
Table 3 Influence of temperature update coefficient on calculation results

4.2 Example 2

A real case in North China is studied as a research example, including a central processing facility (CPF), four valves and twenty-nine production wells. Figure 6 shows the topology of the gathering and transportation network. The base was chosen to be built at the CPF.

Fig. 6
figure 6

The topology of the gathering and transportation network

During the generation of the initial solution and crossover operation, the nodes on the pipeline segment remain unchanged, which means that the size of the model is largely related to the number of segments divided. For the sake of simplification, pipelines of less than 1.5 km in length will not be divided and considered as segments directly. In contrast, pipelines with a length greater than 1.5 km will be divided into segments at a distance of 1.5 km. This can greatly reduce the model scale and accelerate the convergence speed, thereby finding the optimal solution quickly.

Similarly, the population size is set to be 500, the maximum evolution generation is 3000, the temperature update coefficient is 0.97, and the termination temperature is set to be 0.001. Meanwhile, the calculation is repeated 10 times by adopting SA and AGASA, and the results are shown in Fig. 7. As seen from the table, the stability and convergence of SA are unsatisfactory as the model scale increases. Differently from that, AGASA showed great stability and good convergence owing to the reduction in model scale and the introduction of heuristic rules. This shows that the AGASA proposed in this paper has a great advantage in solving the problem of UAV inspection for oil and gas pipeline networks. Figure 8 shows the inspection paths obtained by AGASA, and the total length of the inspection path is 82,389 km.

Fig. 7
figure 7

Calculation results of SA and AGASA

Fig. 8
figure 8

Inspection path of UAVs for the oil and gas pipeline network (**brown and blue in the paths represent the first and second UAV)

5 Conclusions

In this paper, a new inspection path optimization method for oil and gas pipeline networks is proposed. A mixed-integer nonlinear programming model is established by setting the minimum length of the inspection path as the objective function, which also takes the mission scenario and the safety performance of UAVs into account. In model solving part, a two-stage solution methodology is proposed. In the first stage, the pipeline is divided into some nodes according to the vision capability of the UAV. In the second stage, the AGASA that introduces heuristic rules is adopted to solve the model. Finally, three algorithms (GA, SA and AGASA) are employed for calculation, and the results show that the AGASA proposed in this paper has great stability and convergence. What is more, it can be applied to the inspection path planning optimization problem of most oil and gas pipeline networks. This paper considered the importance of each inspection node is the same, ignoring the difference in the inspection of high-leakage danger zones, densely populated areas and no-man’s land. Therefore, further research can add the requirement for the number of inspection times in each area and solve the optimization problem of inspection path planning.