3.1. Back Propagation Neural Network Parameter Settings
The neural network reflects the structure and function of the human brain neural network, which abstracts the basic characteristics of the real brain according to theory and simplifies it into an information processing system. The back propagation neural network (BPNN) is a kind of multilayer feedforward neural network trained according to the error back propagation algorithm, and is one of the most widely used neural networks. Such neural networks typically consist of one input layer, one or more hidden layers, and one output layer, and its basic structure is shown in
Figure 2. The gradient search technique of the BP neural network is the gradient descent method, which takes the minimum mean square error (MSE) as the training basis [
16].
The input layer and output layer formulas of the BP neural network are expressed in Equations (1)–(4) [
17]:
where
is the input value of the
node of the hidden layer,
is the input value of BP neural network;
is the weight of the input layer to the hidden layer;
is the output value of the
node in the hidden layer;
is the hidden layer threshold;
is the input value of the
node in the output layer;
is the input value of the
node in the output layer;
is the weight of the hidden layer to the output layer;
is the output layer threshold;
is the transfer function of BP neural network. Error function
and threshold correction coefficient are shown in Equations (5)–(9):
where
is the total number of samples;
is the measured value;
is the actual output value;
is the coefficient of the learning rate;
is the weight correction coefficient of the hidden layer to the output layer;
is the weight correction coefficient from the input layer to the hidden layer;
is the threshold correction coefficient of the output layer; and
is the threshold correction coefficient of the hidden layer.
In the BP neural network model of pipeline failure, the risk subitems of each pipeline are taken as the input of the model, and leakage is taken as the output of the network model. The number of hidden layer nodes
is the core part of the neural network structure, which can be calculated by Equation (10) [
18]:
where
are the number of nodes of the input layer, hidden layer and output layer of the neural network, respectively [
19];
is the regulating constant,
; There are seven risk subitems in the model, and thus the number of input nodes
, and the output is leakage, represented by logical values
and
, then
. In the data selected in this paper, the error is minimum when
, that is,
. The number of nodes in the hidden layer has a great influence on the prediction results of the model [
20]. If the number of nodes is too small, the network will not obtain sufficient information for the training, which will lead to a poor training effect and thus greater errors in the prediction results. When the number of nodes of the hidden layer is increased, the training ability can be improved, and so does the prediction ability. However, when the number of nodes is excessive, the prediction ability will decline.
3.2. Back Propagation Neural Network Optimized by Particle Swarm Optimization
Particle swarm optimization (PSO) is a random global search algorithm based on swarm intelligence theory [
21,
22], which is characterized by information sharing and coevolution among individuals in a colony by simulating the migration and aggregation behavior of birds in the process of foraging and abstract modeling the rule of colony activity. It is widely used in various fields because of its simple concept, fast convergence speed and easy implementation. Each particle in the algorithm is a solution to the problem. Through calculation and comparison of fitness function values, the position and velocity of particles are constantly updated, and the whole space is searched to find the global optimal solution.
This study proposes a PSO-BP model to address the issues of traditional BP neural networks, such as their tendency to become trapped in local minima, slow convergence, and weak generalization ability. Compared with BP neural networks, the PSO algorithm can search in a larger space and prevent BP neural network from falling into the limitation of local optimal solution. The traditional PSO algorithm optimized BP neural network method is to take the weight and bias of the network as the position of the particle and update the weight and bias of the network, so as to realize the optimization of the BP neural network. However, due to the problem of premature convergence of particle swarm optimization, the algorithm falls into the local minimum value and does not take into account the error back propagation characteristic of the BP neural network itself. Therefore, this paper introduces the PSO algorithm into the BP neural network, and uses the way of error back propagation to constantly update the position and velocity of each particle in the particle swarm based on the optimal of each particle in the particle swarm and its global optimal. By calculating the fitness value of the whole space search, and keeping the back propagation (BP) neural network to search the global optimum with the PSO algorithm, the above problems can be avoided.
In the particle population, each particle should have a position vector, a velocity vector and an adaptive value determined by the established objective function [
23]. The position vector of particle
i in n-dimensional space is expressed as
, and the flight velocity vector is expressed as
, each dimension has a maximum speed limit
. If the speed of one dimension exceeds
, the speed of this dimension is limited to
. The velocity and position of the particle are updated by:
where,
is the velocity of the
-dimension of particle
in the
th iteration;
is the position of the
-dimension of particle
in the
th iteration;
is inertial weight;
and
are learning factors; and
and
are random numbers.
According to the objective function, the particle can calculate the adaptive value of the optimal solution at the current position, and know the best position discovered so far () and the current position Xi, that is, the particle’s own flight experience. In addition, each particle also knows the () position (the flight experience of the swarm) that is found for all particles in the entire swarm. The particle uses its own experience and the best experience of the group to determine how to adjust the direction and speed of its flight for the next iteration. In this way, the whole population of particles will gradually approach the optimal solution.
3.3. PSO-BP Pipeline Failure Model
The PSO-BP Pipeline failure model flow chart is shown in
Figure 3.
The main steps of the PSO-based parameter optimization process are summarized below:
(1) Determine the structure of the neural network, select the number of nodes in the input and output layers of the network according to the sample data, and determine the number of nodes in the hidden layer.
(2) According to the established BP neural network initialization parameters of the PSO algorithm, build a single particle network and particle swarm network, set the particle swarm size, set the number of iterations, inertia weight , and , etc.
(3) Input training data and testing data sets.
(4) Iterative optimization, traverse all particles in the particle swarm, and calculate the fitness value of each particle.
(5) In the iteration process, compare fitness values with the corresponding terms in three parts.
In part 1, the current fitness value of particles is compared with the optimal position of individual particles in the past dynasties. If the current fitness value is better than that of the individual particles in the past dynasties, is set as the current particle position; otherwise, the single particle network is updated according to the original historical optimal back propagation.
In part 2, the current fitness value of the particles is compared with the global optimal position of all particles in the population. If the current fitness value is better than the global optimal position of all particles in the population, the current particle position is assigned to ; otherwise, the PSO network is updated by the propagation according to the global historical optimal inverse position.
In part 3, the current and of particles is compared. If is better than G_best, assign the current of particles to , otherwise update the particle swarm network according to the original back propagation.
(6) Update and , and update the positions and velocities of all particles in the particle swarm by using the characteristics of adjusting weights and thresholds by BP neural network back propagation.
(7) Judge whether the overall error reaches the target convergence precision range or the number of iterations reaches the maximum number of iterations. If the conditions are met, the calculation is terminated; otherwise, the number of iterations +1 returns to step (4) to continue the iterative calculation of the fitness value of each particle.
(8) Verify the trained neural network with the test set.