Optimizing BPNN Algorithm by Improving Genetic Algorithm

GA–BPNN–PID uses the genetic algorithm to optimize the weight and threshold of BPNN so that the optimized BPNN can better realize the function output. Although the GA–BPNN–PID control method is larger than the traditional method, the optimized BPNN weight and threshold can provide better control effect for the liquid manure spraying control algorithm. Both simulation and platform tests have verified that the algorithm has small overshoot, good stability, short rise time, and can better achieve the effect of precise spraying.

In this study, optimizing the BPNN has three parts: determination of the BPNN composition, optimization via genetic algorithm, then prediction by BPNN. The corresponding processes are illustrated in Figure 7. The structure of BPNN was determined according to the input and output parameters. In this study, the input was vehicle speed and the outputs were Kp, Ki, Kd. According to the above input and output data, we set the BPNN structure as 1-6-3, that is, the input layer had 1 node, the hidden layer had 6 nodes, and the output layer had 3 nodes, with a total of 19 weights and 9 thresholds. Therefore, the individual coding length of the genetic algorithm was 28. The BPNN prediction used a genetic algorithm to obtain the initial weight and threshold assignment of the optimal individual to the network. Finally, the prediction function was output after training. The GA–BPNN–PID structure diagram is shown in Figure 8.

The essential factors of BPNN optimized using genetic algorithm t included the initial population, fitness function, select action, crossover operator, and revisited mutations.

The genetic algorithm majorization main theory of the BPNN–PID dominant algorithm involved optimizing the initial value as well as the threshold of BPNN using a genetic algorithm, such that BPNN optimization could better forecast function export. Simultaneously, genetic algorithm optimization of the BPNN input state was used to reduce the network output and was insensitive to the system import, which was likely lag. The corresponding stages were as below:

**Figure 7.** Flow chart of GA–BPNN.

**Figure 8.** GA–BPNN–PID structure diagram.


$$Y = k \left[ \sum\_{i=1}^{n} abs(O\_i - h\_i) \right] \tag{18}$$

where n is the quantity of network export panel points, *oi* is the BPNN's desired export of the ith panel point, *hi* is the forecast export of the ith panel point, and k is a ratio.

(3) The choice manipulation of a genetic algorithm is the choice policy according to the fitness proportion. The choice percentage *pi* of every personality i was such that (Equation (19)):

$$\mathcal{g}\_i = \frac{k}{G\_i}; p\_i = \frac{\mathcal{G}\_i}{\sum\_{j=1}^{N} G\_i} \tag{19}$$

where *Gi* is the fitness price of personality i. Before individual selection, the reciprocal of the fitness proportion was calculated. The factor is k, and N is the amount of the personality in the population.

(4) In the light of optimizing the population initialization process, real number coding was adopted according to the individual; therefore, a real number crossover valve was adopted for the crossover operation. The overlapping operation of the k-th chromosome *bk* as well as c-th chromosome *bc* at position j is as below (Equation (20)):

$$b\_{kj} = b\_{ij}d + b\_{kj}(1 - b); \\ b\_{cj} = b\_{kj}d + b\_{cj}(1 - d) \tag{20}$$

where *d* is a stochastic digit among (0–1).

(5) In the mutation operation, the j-th gene *bij* of i-th personality was chosen with mutation. The mutation operation method was as below (Equation (21)):

$$b\_{ij} = \begin{cases} (b\_{ij} - b\_{\max}) \cdot G(f) + b\_{ij} & r \ge 0.5\\ (b\_{\min} - b\_{ij}) \cdot G(f) + b\_{ij} & r < 0.5 \end{cases} \tag{21}$$

where *bmax* is the top margin of gene *bij*, *bmin* is the bottom margin of gene *bij*; *g*(*f*) = *r*2(1 − *f* / *fmax*), *r*<sup>2</sup> is the stochastic digit, and f is the present iteration digit. *Fmax* are the maximum evolution times, and r is stochastic digit among [0–1]. Its control principle is exhibited in Figure 9.

**Figure 9.** GA–BPNN–PID control schematic diagram.
