[Engine life prediction] Genetic algorithm optimizes BP neural network GA-BP aviation engine life prediction (multiple inputs and single output) (including comparison before optimization) [Including Matlab source code Issue 2349]

?Blogger profile: A Matlab simulation developer who loves scientific research. He cultivates his mind and improves his technology simultaneously. For cooperation on Matlab projects, please send a private message.
Personal homepage: Poseidon’s Light
How to obtain the code:
Poseidon’s Light Matlab King’s Learning Path-How to Obtain the Code
Motto: He who travels a hundred miles is half as good as ninety.

For more Matlab simulation content click
Matlab image processing (advanced version)
Path planning (Matlab)
Neural network prediction and classification (Matlab)
Optimization solution (Matlab)
Speech processing (Matlab)
Signal processing (Matlab)
Workshop Scheduling (Matlab)

?1. Genetic algorithm optimization of BP neural network

1 BP neural network (back propagation)
BP network is a nonlinear system, and its high degree of adaptability is its most significant feature. This algorithm takes n samples X=(x1,x2,…,xj,…,xn) of the research object as the input layer nodes of the neural network, and the expected result Y=(y1,y2,…,yj,…,yn) as The corresponding output node calculates the weight and threshold, and calculates the error value between the actual result and the predicted result, see equation (1). The fitness function is a standard that measures whether the error value meets the requirements. For calculation results that do not meet the requirements, the network will perform error backpropagation. Equation (2) is the correction amount of the hidden layer and the output layer. Through repeated iterations, if the error If the expectations are met, the model is successfully established.

In the formula: yi (n) is the expected result; y′i (n) is the predicted result; eta is the learning rate; E is the output value of the hidden layer; Wkj is the output value of the node in the output layer; ΔWkj is the correction amount.

2 Genetic algorithm (genetic algorithm)
The basic idea of the genetic algorithm is that a population that needs to be optimized evolves generation by generation based on the survival of the fittest, and the evolved population with better fitness is retained and passed on to the next generation. In this process Crossover and mutation operations are also needed to generate new populations with better fitness. The optimization process is shown in Figure 2.

Figure 2 Schematic flow chart of genetic algorithm optimization BP neural network algorithm

2.1 Chromosome coding
The encoding rules use floating-point encoding, which on the one hand can obtain higher-precision network weights and thresholds, and on the other hand can also obtain a wider search range than before [4]. Its length s is shown in Equation (3).

s=n1×n2 + n2×n3 + n2 + n3 (3)

In the formula: n1, n2, n3 are the number of neurons in the input layer, hidden layer and output layer.

2.2 Fitness function
In the process of training the BP neural network, the output of the network and the expected output yˉ(k) are selected as training samples, y(k) is used as the output generated after training, and the weights and thresholds after training are used as the selected weights and Threshold, the indicator of the genetic algorithm is used as the indicator of the optimized algorithm [5], and the sum of squared errors between the predicted value and the actual value is calculated, see equation (4).

Among them: k is the logarithm of the input and output sampling data, N is the number of network output nodes, yˉ(k) is the expected output value of the k-th node, and y(k) is the predicted output value of the k-th node. In order to avoid the division by zero phenomenon, a value ζ approaching zero is introduced here, and the fitness function is shown in equation (5).

2.3 Choice
Assume the population size is n, fi is the fitness, and this fitness is for individual i in the population, then the probability of i being selected is shown in Equation (6).

2.4 Crossover
The method of arithmetic crossover is commonly used in floating-point crossover individuals. Assume that arithmetic crossover is performed between individuals xtA and xtB. The new individual [6] generated after the operation is shown in equation (7).

In the formula: α is a random number uniformly distributed in the interval [0,1].

2.5 Mutation
In order to prevent the occurrence of premature phenomena, based on a small range of random numbers, genetic mutations occur in a small range of probability. The local search ability of the algorithm will also be strengthened in this step. At this time, assuming that the maximum and minimum values of the initial individuals of the population are xmax and xmin respectively, then the mutated gene [7] is shown in equation (8).

xk=xmin + β(xmin + xmax) (8)

In the formula: β is a random number uniformly distributed in the interval [0,1].

?2. Part of the source code

%% initialization
clear
close all
clc
warning off

%% read read
data=xlsread(data.xlsx’,Sheet1’,A2:E747’); %%Use the xlsread function to read the corresponding range of data in EXCEL

%Input and output data
input=data(:,1:end-1); The first column to the penultimate column of ?ta are the characteristic indicators
output=data(:,end); The last column of ?ta is the output indicator value

N=length(output); %number of all samples
testNum=100; %Set the number of test samples
trainNum=N-testNum; % calculate the number of training samples

%% Divide training set and test set
input_train = input(1:trainNum,:);
output_train =output(1:trainNum)’;
input_test =input(trainNum + 1:trainNum + testNum,:);
output_test =output(trainNum + 1:trainNum + testNum)’;

%% Data normalization
[inputn,inputps]=mapminmax(input_train,0,1);
[outputn,outputps]=mapminmax(output_train);
inputn_test=mapminmax(apply’,input_test,inputps);

%% Get the number of input layer nodes and output layer nodes
inputnum=size(input,2);
outputnum=size(output,2);
disp(/’)
disp(‘Neural network structure…’)
disp([The number of nodes in the input layer is:’,num2str(inputnum)])
disp([The number of nodes in the output layer is:’,num2str(outputnum)])
disp(‘ ‘)
disp(‘The process of determining hidden layer nodes…’)

%Determine the number of hidden layer nodes
% Use the empirical formula hiddennum=sqrt(m + n) + a, m is the number of input layer nodes, n is the number of output layer nodes, a is generally an integer between 1-10
MSE=1e + 5; % initialization minimum error
for hiddennum=fix(sqrt(inputnum + outputnum)) + 1:fix(sqrt(inputnum + outputnum)) + 10

%Build network
net=newff(inputn,outputn,hiddennum);
% Network parameters
net.trainParam.epochs=1000; % training times
net.trainParam.lr=0.01; % learning rate
net.trainParam.goal=0.000001; % training target minimum error
% network training
net=train(net,inputn,outputn);
an0=sim(net,inputn); %Simulation results
mse0=mse(outputn,an0); %mean square error of simulation
disp(['When the number of hidden layer nodes is',num2str(hiddennum),', the mean square error of the training set is:',num2str(mse0)])

%Update the best hidden layer node
if mse0<MSE
    MSE=mse0;
    hiddennum_best=hiddennum;
end

end

?3. Operation results



?4. Matlab version and references

1 matlab version
2014a

2 References
[1] Guo Lijin, Qiao Zhizhong. Research on grain temperature prediction based on genetic algorithm optimization of BP neural network [J]. Grain and Oil. 2023,36(01)

3 Remarks
Introduction This part is taken from the Internet for reference only. If there is any infringement, please contact us to delete it.

Simulation consulting
1 Improvement and application of various intelligent optimization algorithms

Production scheduling, economic scheduling, assembly line scheduling, charging optimization, workshop scheduling, departure optimization, reservoir scheduling, three-dimensional packing, logistics location selection, cargo space optimization, bus scheduling optimization, charging pile layout optimization, workshop layout optimization, container ship dispatching Load optimization, water pump combination optimization, medical resource allocation optimization, facility layout optimization, visible area base station and drone site selection optimization

2 Machine learning and deep learning
Convolutional neural network (CNN), LSTM, support vector machine (SVM), least squares support vector machine (LSSVM), extreme learning machine (ELM), kernel extreme learning machine (KELM), BP, RBF, width learning, DBN , RF, RBF, DELM, XGBOOST, TCN realize wind power prediction, photovoltaic prediction, battery life prediction, radiation source identification, traffic flow prediction, load prediction, stock price prediction, PM2.5 concentration prediction, battery health prediction, water optical parameter reflection performance, NLOS signal recognition, accurate subway parking prediction, transformer fault diagnosis

3 Image processing
Image recognition, image segmentation, image detection, image hiding, image registration, image splicing, image fusion, image enhancement, image compressed sensing

4 Path planning
Traveling salesman problem (TSP), vehicle routing problem (VRP, MVRP, CVRP, VRPTW, etc.), UAV three-dimensional path planning, UAV collaboration, UAV formation, robot path planning, raster map path planning, multi-mode Intermodal transportation problems, vehicle collaborative UAV path planning, antenna linear array distribution optimization, workshop layout optimization

5 UAV applications
UAV path planning, UAV control, UAV formation, UAV collaboration, UAV task allocation

6 Wireless sensor positioning and layout
Sensor deployment optimization, communication protocol optimization, routing optimization, target positioning optimization, Dv-Hop positioning optimization, Leach protocol optimization, WSN coverage optimization, multicast optimization, RSSI positioning optimization

7 Signal processing
Signal recognition, signal encryption, signal denoising, signal enhancement, radar signal processing, signal watermark embedding and extraction, EMG signal, EEG signal, signal timing optimization

8 Power system aspects
Microgrid optimization, reactive power optimization, distribution network reconstruction, energy storage configuration

9 Cellular Automata
Traffic flow Crowd evacuation Virus spread Crystal growth

10 Radar aspects
Kalman filter tracking, track correlation, track fusion