Method for predicting hydrological flow based on MLP neural network model of PSO algorithm
By using the MLP neural network model based on PSO algorithm in hydrological flow prediction, the model parameters are optimized, and the limitations of traditional methods in hydrological flow dynamic prediction are solved, and the accuracy and efficiency of prediction are improved.
Patent Information
- Application Number
- CN202510269394.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-07
- Publication Date
- 2025-07-01
- Estimated Expiration
- 2045-03-07
AI Technical Summary
Traditional statistical methods have limitations in hydrological flow prediction, and it is difficult to accurately predict dynamic changes in hydrological flows, especially when climate change complexity increases.
The MLP neural network model based on PSO algorithm is adopted to improve its performance in hydrological flow dynamic prediction by optimizing the weight and deviation parameters of the MLP model.
Optimizing the MLP model through the PSO algorithm solves the problem of slow convergence speed and easy to fall into local optimization, and improves the accuracy and efficiency of hydrological flow prediction, especially in the case of hydropower stations in the river area.
Smart Images

Figure CN120234558A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of hydrological prediction, and particularly to a method for predicting hydrological flow based on an MLP neural network model with the PSO algorithm. Background Art
[0002] The prediction of the dynamic changes of hydrological flow has always been an important issue in water resources management, flood control, and disaster reduction, and it is also a research hotspot in the field of water resources. With the increasing complexity of climate change, the changes in hydrological flow have become increasingly unstable. Accurately predicting the dynamic changes of hydrological flow plays an important guiding role in decision-making and engineering design. Traditional statistical methods have certain limitations in hydrological flow prediction. Summary of the Invention
[0003] Object of the Invention: In order to overcome the deficiencies in the prior art, the present invention provides a method for predicting hydrological flow based on an MLP neural network model with the PSO algorithm, which optimizes the MLP model based on the PSO optimization algorithm and applies it to the field of hydrological dynamic prediction.
[0004] Technical Solution: To achieve the above object, the method for predicting hydrological flow based on an MLP neural network model with the PSO algorithm of the present invention includes the following steps: Step S1: Collect hydrological flow data and preprocess the hydrological flow data; Step S2: Construct an MLP neural network model, and input the hydrological flow data into the MLP neural network model for iterative training; Step S3: Use the PSO algorithm to optimize the weight and bias parameters of the MLP neural network model.
[0005] Further, in Step S1, the quartile method is used to detect and process outliers in the hydrological flow data, the linear interpolation or mean filling method is used to fill in the missing values in the hydrological flow data, and the moving average method is used to smooth the hydrological flow data.
[0006] Further, in Step S2, it specifically includes the following steps: Step S2.1: Determine the grid structure of the MLP neural network model; for the input layer, determine the number of nodes in the input layer according to the number of input features; for the hidden layer, select an appropriate number of hidden layer neurons and activation function; for the output layer, determine the number of nodes in the output layer according to the prediction target; Step S2.2: Perform forward propagation; input the preprocessed hydrological data into the MLP model, calculate the weighted input, convert the weighted input into an output through the activation function, and the output value of the final output layer is the predicted hydrological flow value; Step S2.3: Adjust the network weights by minimizing the loss function; Step S2.4: Backpropagation; calculate the error of the output layer, calculate the error of each layer layer by layer according to the magnitude of the error, and finally update the weights according to the error and the learning rate.
[0007] Further, in step S2.1, the features input by the input layer include one or more of water level, flow velocity, flow rate, precipitation, and evaporation.
[0008] Further, in step S2.1, for the river area with a hydropower station upstream, the features input by the input layer include water level, flow velocity, flow rate, precipitation, evaporation, the electricity consumption of the corresponding power consumption area of the hydropower station, and the water level difference between the upstream and downstream of the hydropower station, and the output of the output layer is the flow rate of this river area.
[0009] Further, in step S2.2, the activation function selects the Sigmoid function.
[0010] Further, in step S2.3, the mean square error is used as the loss function.
[0011] Further, in step S3, it specifically includes the following steps: Step S3.1: Initialize the particle swarm; use the position of the particle to represent the weights and biases of the MLP network, and initialize the velocity and position of the particle; Step S3.2: Update the velocity and position of the particle, and update the weights and biases of the MLP network according to the new particle position; Step S3.3: Fitness evaluation; define a fitness function to evaluate the prediction accuracy of the neural network, and update the individual best position and global best position of each particle according to the fitness value; Step S3.4: Repeat the execution of velocity update, position update, and fitness evaluation until the stop condition is met.
[0012] Further, in step S3.2, the formula for calculating the updated velocity of the particle is:
[0013]
[0014] where, v i t+1 represents the velocity of the i-th particle at the (t + 1)-th moment, v i t represents the velocity of the i-th particle at the (t + 1)-th moment, w is the inertia weight, c1 and c2 are learning factors, r1 and r2 are random numbers, pi is the historical best position of the i-th particle, p g is the global best position, x i t represents the position of the i-th particle at the t-th moment; the formula for calculating the updated position of the particle is: where, x i t+1 represents the position of the i-th particle at the (t + 1)-th moment; during the iteration process, the value of the inertia weight w decays with the increase of the iteration times, and the decay rate of the inertia weight w is negatively correlated with the change rate of the recent river flow rate.
[0015] Furthermore, the value formula of the inertia weight w is as follows:
[0016] w(t) = w min +(w max - w min )·e -λ(ΔQ)·t ;
[0017]
[0018] where wmin is the lower limit of the inertia weight, wmax is the upper limit of the inertia weight, ΔQ(t) is the flow rate change rate, λ(ΔQ) is the decay rate coefficient, λbase is the base decay rate, ΔQmax is the historical maximum flow rate change rate, N is the sliding window length, is the average flow rate within the window.
[0019] Beneficial effects: The method for predicting hydrological flow using the MLP neural network model based on the PSO algorithm of the present invention has the following beneficial effects:
[0020] 1) Using the PSO algorithm to optimize the MLP neural network model can solve the problems of slow convergence speed and easy entrapment in local optimization of the MLP neural network model;
[0021] 2) For river regions with hydropower stations upstream, the input features also include the electricity consumption of the corresponding power consumption areas of the hydropower stations and the water level differences upstream and downstream of the hydropower stations, which can improve the prediction effect of hydrological flow;
[0022] 3) When the flow rate of the river region is output by the output layer, the value of the inertia weight w decays with the increase of the number of iterations, and the decay rate of the inertia weight w is negatively correlated with the change rate of the recent river flow rate; during the high flow rate change period, the decay rate of the inertia weight w can be delayed to maintain the exploration ability to cope with mutations and more accurately predict the flood peak; during the low flow rate change period, convergence can be accelerated and the number of iterations can be shortened. Description of the Drawings
[0023] Att Figure 1 is a line graph of hydrological data for a certain region;
[0024] Att Figure 2 is a chart of hydrological data for a certain region;
[0025] Att Figure 3 is a chart of the eigenvalue data of the MLP after converting the hydrological data;
[0026] Att Figure 4 is a chart of the parameter settings of the PSO algorithm;
[0027] Att Figure 5 is a schematic diagram of the change of fitness;
[0028] Appendix Figure 6 It is a comparison graph of the MLP model optimized by the PSO algorithm and the unoptimized MLP model;
[0029] Appendix Figure 7 It is a comparison graph of the MLP model optimized by the PSO algorithm and the BP model;
[0030] Appendix Figure 8 It is a schematic diagram of the performance of the MLP model optimized by the PSO algorithm in predicting the flow error value;
[0031] Appendix Figure 9 It is a schematic diagram of the performance of the unoptimized MLP model in predicting the flow error value;
[0032] Appendix Figure 10 It is a schematic diagram of the performance of the BP model in predicting the flow error value;
[0033] Appendix Figure 11 It is a comparison graph of the MAE values of the three algorithm models;
[0034] Appendix Figure 12 It is a comparison graph of the MAPE values of the three algorithm models;
[0035] Appendix Figure 13 It is a comparison graph of the RMSE values of the three algorithm models;
[0036] Appendix Figure 14 It is a comparison graph of the algorithm iteration times of the three algorithm models. Specific implementation manner
[0037] The present invention will be further described below with reference to the accompanying drawings.
[0038] As in the appendix Figures 1 to 14 The method for predicting hydrological flow using the MLP neural network model based on the PSO algorithm includes the following steps:
[0039] Step S1: Collect hydrological flow data and preprocess the hydrological flow data;
[0040] Step S2: Construct an MLP neural network model and input the hydrological flow data into the MLP neural network model for iterative training;
[0041] Step S3: Use the PSO algorithm to optimize the weight and bias parameters of the MLP neural network model.
[0042] Aiming at the problems of slow convergence speed and easy to fall into local optimization when the MLP algorithm solves the weights and offsets in the neural network model, this paper optimizes the MLP model based on the PSO optimization algorithm, applies it to the field of hydrological flow dynamic prediction, and comprehensively applies the PSO algorithm and the MLP algorithm.
[0043] Hydrological flow data is crucial data for studying hydrological processes and water resource management, and has important application values for flood prediction, water resource assessment, hydraulic engineering design, etc. Accurately and precisely collecting and preprocessing data related to hydrological flow is of great significance for hydrological research. The main sources of data related to hydrological flow include hydrological stations, remote sensing data, simulation models, etc. Hydrological stations are the most common data sources, and data such as water levels and flow velocities can be collected through devices such as water level gauges and current meters. Remote sensing data can be obtained through satellite remote sensing technology, and large-scale hydrological data such as rainfall and evaporation can be obtained.
[0044] Commonly used hydrological flow data collection devices include water level gauges, current meters, rain gauges, etc. Water level gauges can obtain water level data by measuring the water level difference. Current meters can obtain flow velocity data by measuring the flow velocity, and rain gauges can obtain rainfall data by measuring rainfall. In addition, there are some advanced devices such as remote sensing satellites and radars that can obtain more extensive hydrological data. To improve the objectivity of prediction results, satellite observations can be used to improve data collection, relevant hydrological flow data from hydrological stations can be used as research data, and the corresponding uncertainty information can be further analyzed. Its main data includes water level, flow velocity, flow rate, water quality parameters, etc.
[0045] To improve the quality of hydrological flow data and facilitate subsequent analysis, it is necessary to preprocess the data. Common data preprocessing methods include outlier processing, missing value filling, data smoothing, etc. Outlier processing refers to excluding or correcting outliers in the data; missing value filling refers to interpolating or estimating missing values in the data; data smoothing refers to reducing data fluctuations and extracting trends and periodicities from the data.
[0046] Specifically, in step S1, the quartile method is used to detect and process outliers in hydrological flow data, the linear interpolation or mean filling method is used to fill missing values in hydrological flow data, and the moving average method is used to smooth hydrological flow data.
[0047] The quartile method is usually used to process outliers in hydrological flow data. The formula for the quartile method is as follows:
[0048] Q1 - 1.5 * IQR;
[0049] Q3 + 1.5 * IQR;
[0050] In the above formula, Q1 and Q3 represent the first quartile and the third quartile of the data respectively, and IQR represents the interquartile range (Q3 - Q1). According to this formula, values less than Q1 - 1.5 * IQR or greater than Q3 + 1.5 * IQR are considered outliers.
[0051] Common methods for handling missing values in hydrological flow data include linear interpolation and mean filling. The applicable method for linear interpolation is that when the data points before and after the missing data point are known, the linear interpolation method can be used to fill the missing value. Suppose the missing value is x, the previous data point is x1, and the next data point is x2, corresponding to times t1 and t2 respectively. The formula for the interpolation result of x is as follows:
[0052]
[0053] If there are no known data points before or after the missing data point, the mean filling method can be used. Use the average of other known data to completely fill the missing value. In data processing, based on ensuring the continuity of the data sequence, select the corresponding missing value filling method according to the actual application requirements.
[0054] Smooth the hydrological flow data by the moving average method. In the specific implementation, first calculate the average value of the data within the window, and based on this, reduce the data fluctuation and extract the long-term trend of the time series data. The formula for the moving average method is:
[0055]
[0056] In the above formula, n is the size of the moving average window, p1, p2... p n represent the hydrological flow observations within the sliding window, and δ is the average value of the observations within the window. The appropriate window size can be selected according to actual needs. Collecting and preprocessing data related to hydrological flow is an important part of hydrological research, which can improve the quality and accuracy of the data and provide reliable data support for establishing hydrological models and water resource management.
[0057] Figure 1 Shows the preprocessed hydrological flow data in a certain area, and these data have been converted into a visual chart format.
[0058] In step S2, it specifically includes the following steps:
[0059] Step S2.1: Determine the grid structure of the MLP neural network model. The MLP neural network is a neural network composed of three-layer network structures, namely the input layer, the hidden layer, and the output layer; for the input layer, determine the number of nodes in the input layer according to the number of input features; for the hidden layer, select the appropriate number of hidden layer neurons and activation function; for the output layer, determine the number of nodes in the output layer according to the prediction target;
[0060] Step S2.2: Perform forward propagation; input the preprocessed hydrological data into the MLP model, calculate the weighted input, convert the weighted input into an output through the activation function, and the output value of the final output layer is the predicted hydrological flow value;
[0061] Step S2.3: Adjust the network weights by minimizing the loss function;
[0062] Step S2.4: Backpropagation; Calculate the error of the output layer, and based on the magnitude of the error, calculate the error of each layer layer by layer. Finally, update the weights according to the error and the learning rate.
[0063] For the input layer, the input layer of the MLP neural network receives the original data as input. The number of nodes in the input layer is the same as the number of features in the data, and each node corresponds to a feature in the data. The data can be represented as a vector, where each element corresponds to the value of a feature. The input layer receives the preprocessed hydrological feature data as input.
[0064] For the hidden layer, the hidden layer is the middle layer of the neural network, where the neurons perform a non-linear transformation on the data of the input layer. Each neuron receives the output of the upper-layer neurons and activates it through an activation function to obtain the output of that neuron.
[0065] The expression formula for the hidden layer is:
[0066]
[0067] In the above formula, hj represents the output value of the j-th neuron in the hidden layer. g represents the activation function. xi represents the value of the i-th input neuron in the input layer. wij represents the connection weight between the i-th neuron in the input layer and the j-th neuron in the hidden layer. bj represents the bias value of the j-th neuron in the hidden layer. n represents the number of input neurons.
[0068] For the output layer, in the MLP neural network, the function of the output layer is to map the result of the hidden layer to the final output result. For the hydrological flow prediction model, the design of the output layer needs to consider how to convert the features of the hidden layer into the predicted value of the hydrological flow. The input of the output layer is the output of the hidden layer, which can be expressed as:
[0069]
[0070] In the above formula, Ok represents the output value of the k-th neuron in the output layer. Vkj represents the weight between the j-th neuron in the hidden layer and the k-th neuron in the output layer. ck represents the bias value of the k-th neuron in the output layer. m represents the number of neurons in the hidden layer.
[0071] In one embodiment, in step S2.1, the features input by the input layer include one or more of water level, flow velocity, flow rate, precipitation, and evaporation, and the features output by the output layer can also be one or more of water level, flow velocity, flow rate, precipitation, and evaporation.
[0072] In another embodiment, in step S2.1, for a river area with a hydropower station upstream, the features input into the input layer include water level, flow velocity, flow rate, precipitation, evaporation, the electricity consumption of the power consumption area corresponding to the hydropower station, and the water level difference between the upstream and downstream of the hydropower station. What the output layer outputs is the flow rate of this river area.
[0073] Generally speaking, the flow rate of a river area is mainly affected by natural factors. However, for a river area with a hydropower station upstream, the working conditions of the hydropower station will also affect the flow rate of the river area. Therefore, there will be human factors interfering with the flow rate prediction of the river area. Therefore, the features input into the input layer cannot only consider natural factors. So, in the present invention, when predicting the flow rate of a river, relevant features of the hydropower station are additionally input into the MLP neural network model, so that the MLP neural network model can comprehensively consider the influences of natural factors and human factors.
[0074] Specifically, during the power generation process of a hydropower station, the power generation amount is positively correlated with the water flow rate passing through the hydropower station, and the power generation amount of the hydropower station is also positively correlated with the electricity consumption of the power consumption area corresponding to the hydropower station. Therefore, the water flow rate passing through the hydropower station can be judged by collecting relevant data on the electricity consumption of the power consumption area corresponding to the hydropower station. In addition, some special situations need to be considered. For example, different drought and flood conditions in the upstream area of the hydropower station will cause the hydropower station to adopt different water storage and release strategies, which will also affect the flow rate downstream of the hydropower station. Considering this factor, the water level difference between the upstream and downstream of the hydropower station can be used as one of the features input into the input layer.
[0075] Therefore, the two additional input features, namely the electricity consumption of the power consumption area corresponding to the hydropower station and the water level difference between the upstream and downstream of the hydropower station, one considers the influence generated during the operation of the hydropower station, and the other considers the influence generated by the water storage and release strategy of the hydropower station. Under the combined action of these two additional features, the prediction result of the MLP neural network model for the flow rate of the river can be made more accurate.
[0076] In step S2.2, forward propagation refers to the process of signals being transmitted from the input layer to the output layer. In each layer, each neuron multiplies the output of the previous layer by its corresponding weight, adds and activates through the activation function to obtain the output of this neuron. In the present invention, the Sigmoid function is selected as the activation function. This output can be used as the input of the neurons in the next layer. In the present invention, the mean squared error can be selected as the loss function in model training, and its formula is:
[0077]
[0078] In the above formula, yi represents the actual observed value, represents the model prediction value. E represents the value of the loss function. N represents the number of samples.
[0079] In step S2.3, the goal of model training is to adjust the network parameters by minimizing the value of the loss function. During the forward propagation process, the neural network sequentially propagates the input sample data along the network layers until the output layer generates the prediction result. The specific steps are as follows: The input value of the input layer is initialized as the sample data. Then, for each neuron in the hidden layer and the output layer, the weighted input is calculated and transformed into the output value through the activation function. The output value is used as the input value of the next layer, and the above steps are repeated until the output layer is reached. The output value of the output layer is the prediction result. For the l-th layer (l = 1 is the input layer), the weighted input of the i-th neuron is:
[0080]
[0081] In the above formula, Z(l, i) represents the weighted input value of the i-th neuron in the l-th layer. W(l, i, j) represents the weight connecting the j-th neuron in the previous layer and the i-th neuron in the current layer in the l-th layer. A(l - 1, j) represents the output value of the j-th neuron in the (l - 1)-th layer. B(l, i) represents the bias value of the i-th neuron in the l-th layer.
[0082] Through the sigmoid activation function, the weighted input is transformed into the output value, and the formula is as follows:
[0083] A(l - 1) = g(Z(l, i)).
[0084] In step S2.4, backpropagation refers to adjusting the connection weights of each neuron in the network based on the error between the prediction result and the true label, and propagating the updated weights layer by layer from the output layer to the input layer. This can be achieved through the gradient descent algorithm. The weight of each neuron is updated according to the gradient of the loss function. During the backpropagation process, it is necessary to calculate the gradient of the loss function to update the weights.
[0085] First, calculate the error of the output layer:
[0086]
[0087] In the above formula, delta(L) is the error of the L-th layer; then, according to the magnitude of the error, calculate the error of each layer layer by layer:
[0088]
[0089] The above steps need to be iteratively trained multiple times and continuously adjust the weights until the predetermined stop conditions are reached, including reaching the maximum number of iterations or the convergence of the loss function. On this basis, use the optimal algorithm to dynamically adjust the weights of each neuron in the neural network to reduce the error and improve the prediction accuracy.
[0090] According to the characteristics of hydrological data and the basic theory of the MLP neural network, determine the scale of the input layer. If we use the hydrological data of the past n days to predict the flow of the next day, then the input dimension is n. Use the sigmoid activation function to enhance the nonlinear fitting ability of the model. The determination of the final output layer is based on the expected purpose of the task. If predicting the flow of the next day, the dimension of the output layer is 1. In the training stage and the learning stage, it is necessary to select an appropriate optimization algorithm and update the relevant parameters.
[0091] In the present invention, the PSO algorithm is selected to optimize the MLP neural network model. The PSO algorithm, also known as the particle swarm optimization algorithm, is a swarm intelligence optimization algorithm that simulates the search behaviors of birds and fish. The particles are used as the objects to solve the MLP neural network, and the weights and biases are represented by their positions. On this basis, a fitness function is defined to evaluate the prediction accuracy of the neural network. In step S3, it specifically includes the following steps:
[0092] Step S3.1: Initialize the particle swarm; use the positions of the particles to represent the weights and biases of the MLP network, and initialize the velocities and positions of the particles; usually, the initial positions of the particles can be randomly generated, and the initial velocities of the particles can be set according to experience;
[0093] Step S3.2: Update the velocities and positions of the particles, and update the weights and biases of the MLP network according to the new particle positions; specifically, the formula for calculating the updated velocity of the particle is:
[0094]
[0095] where, v i t+1 represents the velocity of the i-th particle at the (t + 1)-th moment, v i t represents the velocity of the i-th particle at the (t + 1)-th moment, w is the inertia weight, c1 and c2 are learning factors, r1 and r2 are random numbers, pi is the historical best position of the i-th particle, p g is the global best position, and x i t represents the position of the i-th particle at the t-th moment;
[0096] The formula for calculating the updated position of the particle is:
[0097]
[0098] where, x i t+1 represents the position of the i-th particle at the (t + 1)-th moment;
[0099] Step S3.3: Fitness evaluation; Define a fitness function to evaluate the prediction accuracy of the neural network, and update the individual best position and the global best position of each particle according to the fitness value; Select the minimum mean square error as the optimal fitness function;
[0100] Step S3.4: Repeat the execution of velocity update, position update, and fitness evaluation until the stop condition is met, including reaching the maximum number of iterations or the fitness reaching a certain threshold.
[0101] The PSO algorithm can gradually optimize the weight and bias parameters of the MLP neural network, thereby continuously improving the fitness of the MLP neural network on the training set and achieving better model performance.
[0102] In the PSO algorithm, the value of the inertia weight w is related to the convergence speed of the PSO algorithm. If the value of the inertia weight w is larger, the global search ability of the PSO algorithm is stronger, but the convergence speed of the algorithm is slower. If the value of the inertia weight w is smaller, the convergence accuracy of the PSO algorithm is higher, but it is easy to fall into the local optimum.
[0103] Therefore, in order to make the PSO algorithm have both strong global search ability and high convergence accuracy at the end, generally in the iterative process, the inertia weight w will adopt a dynamic value strategy, that is, make the value of the inertia weight w higher in the initial stage, so that there is strong global search ability in the initial stage, and then as the number of iterations increases, the inertia weight w gradually decays, so that a higher convergence accuracy can be achieved in the later stage.
[0104] Since in the present invention, the MLP model optimized by PSO is used to predict hydrological flow data. For river regions, there are significant differences in the flow change rate of rivers in the rainy season and the dry season. In the rainy season, the river flow is more likely to mutate, while in the dry season, the change rate of the river flow is smaller.
[0105] Therefore, the present invention optimizes the value strategy of the inertia weight w. In the iterative process, the value of the inertia weight w decays as the number of iterations increases, and the decay rate of the inertia weight w is negatively correlated with the change rate of the recent river flow. In this way, in the rainy season, when the river is in a high flow change period, the decay rate of the inertia weight w can be delayed to maintain the exploration ability to cope with mutations; in the dry season, when the river is in a low flow change period, the convergence can be accelerated, the number of iterations can be shortened, and the local convergence accuracy can be improved.
[0106] In one embodiment, the value formula of the inertia weight w is as follows:
[0107] w(t) = w min +(w max - w min )·e -λ(ΔQ)·t ;
[0108]
[0109] Among them, wmin is the lower limit of the inertia weight, such as 0.4; wmax is the upper limit of the inertia weight, such as 0.9; ΔQ(t) is the flow rate change rate; λ(ΔQ) is the decay rate coefficient; λbase is the base decay rate; ΔQmax is the historical maximum flow rate change rate; N is the sliding window length; is the average flow rate within the window.
[0110] For seasonal rivers, the flow rate fluctuates violently during the rainy season, and ΔQ(t) is relatively high. Therefore, the decay rate of the inertia weight w decreases, w can be maintained at a relatively high level, the global search ability is stronger, and it is easier to capture the flood peak. During the dry season, the flow rate is stable, ΔQ(t) is relatively low, w decays rapidly, the convergence speed is faster, and the local convergence accuracy of the model is higher. Through the above method, the present invention can dynamically adjust the value-taking strategy of the inertia weight w according to the differences between the rainy season and the dry season of the river, with stronger ability to predict the flood peak during the rainy season and shorter convergence iteration times during the dry season.
[0111] To evaluate the optimization effect of the PSO algorithm on the MLP neural network model, the present invention compares the MLP model optimized by PSO, the unoptimized MLP model, and the BP model.
[0112] Appendix Figure 2 The charts in it show the water level, flow velocity, flow rate, precipitation, and evaporation data of a certain inland river area during different periods from January 1, 2021, to December 30, 2021. The data collection range is the hydrological flow data from January 1, 2021, to December 30, 2021. The collection period is once per hour, and Table 1 only shows part of the hydrological data. These data are used as samples for the prediction of the MLP neural network model, and a part of the dataset is classified into a training set, a validation set, and a test set. Hydrological flow prediction relies on the use of the MLP neural network to obtain the eigenvalue data of the data, and these eigenvalue data are analyzed to obtain certain patterns for predicting the hydrological flow. Appendix Figure 3 The charts in it show the eigenvalue data of the MLP after the hydrological data is transformed. From the data in Appendix Figure 3 it can be learned that after the model processes the hydrological flow eigenvalue data, the data features are relatively unified. Feature extraction and transformation of the input hydrological data can improve the performance and generalization ability of the model.
[0113] After obtaining and preprocessing the hydrological data, the PSO model is used to optimize the parameters of the MLP neural network model, initializing the position and velocity of each particle in the particle swarm, as well as the individual best solution and global best solution of each particle. A part of the training set is selected to train the MLP neural network, and the model parameters are updated by adjusting the position and velocity of each particle in the particle swarm until the stopping condition is reached. Attached Figure 4 The charts in it show some parameters of the evaluation experiment settings.
[0114] According to the experimental structure, during the training process, after using the PSO algorithm to optimize the neural network model, the fitness of the model also changes with the number of iterations. Attached Figure 5 shows the change of fitness during the experiment. From attached Figure 5 it can be learned that the fitness of the MLP model optimized by PSO continuously changes with the increase of the number of iterations. When the number of iterations is greater than 10, the fitness value gradually stabilizes and is relatively stable between 40 - 50 iterations. Therefore, it is reasonable to choose 50 iterations when conducting the experiment. After using PSO to optimize the MLP neural network model, the prediction results of the hydrological flow changes in this area are obtained, as Figure 6 and Figure 7 shown.
[0115] Figure 6 and Figure 7 respectively test the hydrological flow prediction performance between different algorithms. Figure 6 shows the comparison of the prediction results between the MLP model optimized by the PSO algorithm and the unoptimized MLP model, while Figure 7 shows the comparison of the prediction results between the MLP model optimized by the PSO algorithm and the BP model, and shows the actual hydrological flow data of this area for 12 months in 2021.
[0116] Since there is no significant comparison of the predicted hydrological flow for 12 months in the figure, the hydrological flow in July and December is selected for comparison with the predicted values. Figure 6 and Figure 7The overall data shows that the hydrological flow predicted by the MLP after the PSO optimization algorithm is closer to the actual hydrological flow value. From the prediction data for July and December, it can be seen that the hydrological flow in this area in July is 2,238 cubic meters per second. The predicted value by the MLP model optimized by PSO is 2,238.48 cubic meters per second, while the predicted value by the unoptimized MLP model is 2,229.87 cubic meters per second. The predicted value by the BP neural network is 2,237 cubic meters per second. The hydrological flow in this area in December is 978 cubic meters per second. The predicted value by the MLP model optimized by PSO is 977.24 cubic meters per second, while the predicted value by the unoptimized MLP model is 950.49 cubic meters per second. The predicted value by the BP neural network is 979 cubic meters per second. It can be concluded that the MLP model optimized by PSO has more accurate predicted values and smaller prediction errors, followed by the BP neural network.
[0117] Appendix Figure 8 、 9 And 10 tested the performance of the three algorithms in predicting the flow error values in 30 hydrological flow data samples. After comparison, it can be found that the MLP model optimized by PSO has the best hydrological flow prediction effect, with relatively small fluctuations in the flow prediction error values and a relatively small overall error range. In addition, compared with the BP model, the MLP model has larger errors.
[0118] In addition, in the algorithm performance evaluation, MAE (Mean Absolute Error), MAPE (Mean Absolute Percentage Error), RMSE (Root Mean Square Error) and the algorithm iteration time are used as indicators to measure and compare the actual application effects of the algorithms.
[0119] MAE aims to measure the accuracy of model predictions. Compared with other indicators, MAE is not affected by outliers because it only focuses on the absolute value of the gap between the predicted value and the true value. When comparing the performance of different models, MAE can be used as an evaluation indicator to select the best model.
[0120] MAPE is an indicator used to evaluate the accuracy of prediction models. MAPE can evaluate the relative error between the predicted value and the true value, making it more suitable for prediction tasks involving percentages or ratios. The calculation formula of MAPE is as follows:
[0121]
[0122] In the above formula, MAPE represents the mean absolute percentage error, n represents the total number of data points, pv represents the actual value, and tv represents the predicted value.
[0123] RMSE is an average error metric used to measure the difference between the predicted values and the actual values of a regression model. It is a commonly used metric for evaluating the accuracy of a regression model, and a lower RMSE value indicates better model performance. Based on the predicted hydrological flow values for 12 months in 2021 in this region, their MAE, MAPE, RMSE, and algorithm iteration times were calculated. Statistical analysis was performed on the obtained 12 sets of data, and their mean-variance graphs were presented.
[0124] The comparison of the MAE values of the three algorithm models is shown in the appendix Figure 11 as shown, in the appendix Figure 11 The results in the appendix show that the average MAE error of the MLP model optimized by PSO is approximately 0.245; the average MAE error of the unoptimized MLP model is approximately 0.398; and the average MAE error of the BP model is approximately 0.349.
[0125] The comparison of the MAPE values of the three algorithm models is shown in the appendix Figure 12 as shown, in the appendix Figure 12 The results in the appendix show that the average MAPE error of the MLP model optimized by PSO is approximately 0.015; the average MAPE error of the unoptimized MLP model is approximately 0.032; and the average MAPE error of the BP model is approximately 0.022.
[0126] The comparison of the RMSE values of the three algorithm models is shown in the appendix Figure 13 as shown, in the appendix Figure 13 The results in the appendix show that the RMSE error value of the MLP model optimized by PSO is smaller, with an average of approximately 0.128. The unoptimized MLP model has the highest RMSE error value, with an average of 0.184, while the average RMSE error value of the BP model is approximately 0.180.
[0127] The comparison of the algorithm iteration times of the three algorithm models is shown in the appendix Figure 14 as shown, in the appendix Figure 14 The results in the appendix show that the MLP model optimized by PSO requires less iteration time to predict hydrological flow, with an average iteration time of 149 milliseconds. The average iteration time of the unoptimized MLP is approximately 185 milliseconds, while the average iteration time of the BP model is 167 milliseconds.
[0128] Based on the above specific comparison results, compared with the unoptimized MLP model and the BP model, the MLP model based on PSO optimization has more ideal results.
[0129] The above are only the preferred embodiments of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present invention.
Claims
1. A method for predicting hydrological flow using an MLP neural network model based on a PSO algorithm, characterized in that: The following steps are involved: Step S1: collecting hydrological flow data and preprocessing the hydrological flow data; Step S2: constructing an MLP neural network model, and inputting hydrological flow data into the MLP neural network model for iterative training; Step S3: Use the PSO algorithm to optimize the weight and bias parameters of the MLP neural network model.
2. The method for predicting hydrological flow using the MLP neural network model based on the PSO algorithm according to claim 1 is characterized by: In step S1, the quartile method is used to detect and process outliers in the hydrological flow data, the linear interpolation or mean filling method is used to fill in the missing values in the hydrological flow data, and the sliding average method is used to smooth the hydrological flow data.
3. The method for predicting hydrological flow using the MLP neural network model based on the PSO algorithm according to claim 1 is characterized in that: In step S2, the following steps are specifically included: Step S2.1: Determine the grid structure of the MLP neural network model; for the input layer, determine the number of nodes in the input layer according to the number of input features; for the hidden layer, select the appropriate number of hidden layer neurons and activation function; for the output layer, determine the number of output layer nodes according to the prediction target; Step S2.2: Perform forward propagation; input the preprocessed hydrological data into the MLP model, calculate the weighted input, convert the weighted input into output through the activation function, and the output value of the final output layer is the predicted hydrological flow value; Step S2.3: Adjust the network weights by minimizing the loss function; Step S2.4: Back propagation; calculate the error of the output layer, calculate the error of each layer layer by layer according to the error size, and finally update the weight according to the error and learning rate.
4. The method for predicting hydrological flow using the MLP neural network model based on the PSO algorithm according to claim 3 is characterized by: In step S2.1, the features inputted by the input layer include one or more of water level, flow velocity, flow, precipitation and evaporation.
5. The method for predicting hydrological flow using the MLP neural network model based on the PSO algorithm according to claim 3 is characterized by: In step S2.1, for the river area with a hydropower station upstream, the features input by the input layer include water level, flow velocity, flow, precipitation, evaporation, power consumption of the hydropower station in the power application area, and the water level difference between the upstream and downstream of the hydropower station, and the output layer outputs the flow of the river area.
6. The method for predicting hydrological flow using the MLP neural network model based on the PSO algorithm according to claim 3 is characterized by: In step S2.2, the Sigmoid function is selected as the activation function.
7. The method for predicting hydrological flow using the MLP neural network model based on the PSO algorithm according to claim 3 is characterized by: In step S2.3, the mean square error is used as the loss function.
8. The method for predicting hydrological flow using the MLP neural network model based on the PSO algorithm according to claim 1, characterized in that: In step S3, the following steps are specifically included: Step S3.1: Initialize the particle swarm; use the particle positions to represent the weights and biases of the MLP network, and initialize the particle velocities and positions; Step S3.2: Update the velocity and position of the particle, and update the weight and bias of the MLP network according to the new particle position; Step S3.3: Fitness evaluation; define a fitness function to evaluate the prediction accuracy of the neural network, and update the individual optimal position and global optimal position of each particle according to the fitness value; Step S3.4: Repeat the speed update, position update and fitness evaluation until the stop condition is met.
9. The method for predicting hydrological flow using the MLP neural network model based on the PSO algorithm according to claim 8, characterized in that: In step S3.2, the formula for calculating the particle update speed is: Among them, v i t+1 represents the velocity of the ith particle at time t+1, v i t represents the velocity of the ith particle at time t+1, w is the inertia weight, c1 and c2 are learning factors, r1 and r2 are random numbers, pi is the best historical position of the ith particle, p g is the global optimal position, x i t represents the position of the i-th particle at time t; The formula for calculating the particle update position is: Among them, x i t+1 represents the position of the i-th particle at time t+1; During the iteration process, the value of the inertia weight w decays with the increase of the number of iterations, and the decay rate of the inertia weight w is negatively correlated with the rate of change of recent river flow.
10. The method for predicting hydrological flow using the MLP neural network model based on the PSO algorithm according to claim 9, characterized in that: The formula for determining the inertia weight w is as follows: w(t)=w min +(w max -w min )·e -λ(ΔQ)·t ; Among them, w min is the lower limit of inertia weight, w max is the upper limit of inertia weight, ΔQ(t) is the flow rate change rate, λ(ΔQ) is the attenuation rate coefficient, λ base is the base decay rate, ΔQ max is the historical maximum flow rate change rate, N is the sliding window length, is the mean flow rate in the window.
Citation Information
Patent Citations
Neural network-based abnormal-traffic detection method and system
CN109617888A
Multi-heat-source annular heat supply network hydraulic optimization scheduling method based on PSO algorithm
CN109636037A
Scenic spot passenger flow prediction method and system based on particle swarm algorithm and BP network
CN109784579A
Hydrological time series prediction method based on GA-PSO optimization XGBoost
CN112733996A
Sewage treatment effluent quality early warning method based on dynamic weight PSO optimization BP neural network
CN114037163A