Dissolved oxygen prediction method based on BP neural network
The BP neural network predicts dissolved oxygen concentration, which solves the problems of waste energy and unstable effluent water quality in sewage treatment plants, and realizes intelligent regulation of dissolved oxygen, reduces power consumption and improves the stability of effluent water quality.
Patent Information
- Application Number
- CN202411134446.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2024-06-14
- Filing Date
- 2024-08-19
- Publication Date
- 2024-12-17
AI Technical Summary
Sewage treatment plants have challenges in terms of electricity waste and effluent water quality stability. The aeration system has high energy consumption and cannot be adjusted dynamically, resulting in waste of electricity and environmentally friendly fines.
Using the dissolved oxygen prediction method based on BP neural network, data is collected by detection equipment, BP neural network model is constructed, input data is normalized and trained, intelligent regulation of dissolved oxygen concentration is realized, and aeration is dynamically adjusted to reduce electricity. Consume and ensure the quality of the effluent.
The accuracy of dissolved oxygen prediction is achieved to reach more than 88%, the data detection speed is improved, and the intelligent regulation of the inlet water quality and quantity is facilitated, electricity consumption is reduced, and the stability of the effluent water quality is improved.
Smart Images

Figure CN119150128A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of sewage treatment, and in particular relates to a dissolved oxygen prediction method based on BP neural network. Background Art
[0002] As the country's requirements for environmental protection become more and more stringent, there are more and more domestic sewage treatment plants. So many sewage treatment plants were built almost within 10 years. The relevant design technology and operation management technology are relatively backward, and the operation and management talents cannot keep up. The vast majority of sewage treatment plants are in an extensive management state (most of them fix the dissolved oxygen at about 3 every day, but the influent water volume and water quality will change, which causes a waste of electricity). The energy consumption of the aeration system accounts for about 60% of the overall energy consumption of the entire sewage treatment plant. Not only is a large amount of electricity wasted, but the aeration volume cannot be dynamically adjusted according to the influent water volume and water quality. It is not easy for the effluent to meet the standards stably, and often attracts environmental protection fines. Therefore, how to reduce power consumption efficiently and at a low cost while ensuring the effluent quality is a technical problem that needs to be solved urgently. Summary of the invention
[0003] Technical solution: In order to solve the above technical problems, the present invention will intelligently control the dissolved oxygen according to different influent water quality and water volume, reduce power consumption, and ensure the effluent water quality. Specifically, a dissolved oxygen prediction method based on BP neural network is provided, and the specific steps are as follows:
[0004] (1) Within a period of time, multiple groups of hourly data of the sewage treatment plant are collected and obtained through detection equipment. Each group of hourly data is regarded as a sample, and the data in each sample is divided into input data and output data;
[0005] (2) Divide the samples in step (1) into a training set and a test set, where the number of samples in the training set is greater than the number of samples in the test set;
[0006] (3) normalizing all data of all samples in step (2);
[0007] (4) Model construction and training: construct a BP neural network, generate a forward BP network using the newff function, set the transfer function of the hidden layer and the transfer function of the output layer; use the normalized data of the training set obtained in step (3) to train the neural network using the trainlm algorithm; calculate the prediction accuracy of the neural model, make multiple adjustments until the minimum threshold of the model prediction accuracy is met, and then end the training of the neural network;
[0008] (5) Using the trained neural network of step (4), based on the measured input data, obtain the predicted value of dissolved oxygen concentration data.
[0009] As an improvement, the monitoring data in step (1) include but are not limited to influent COD, ammonia nitrogen, pH value, water volume, external reflux flow, biochemical pool turbidity, and dissolved oxygen concentration.
[0010] As an improvement, the input data in step (2) include but are not limited to influent COD, ammonia nitrogen, pH, water volume, external reflow flow, and biochemical pool turbidity, and the output data is dissolved oxygen concentration.
[0011] As an improvement, the minimum threshold of the total number of samples for each method is 5500-6200, and the ratio of the number of training sets to the number of measurement sets is 25-35:1.
[0012] As an improvement, step (4) also includes: using the normalized data of the test set obtained in step (3), using the trained neural network in step (4) to output the predicted value of the dissolved oxygen concentration data, and comparing it with the output data of the test set obtained in step (3) to evaluate the accuracy of dissolved oxygen prediction.
[0013] As an improvement, in step (4), the normalization process is to perform a linear transformation on the data, mapping the data to the interval [0,1] without changing the distribution of the data. The specific formula is:
[0014]
[0015] Where x is the original data, min is the minimum value of the data, max is the maximum value of the data, and x′ is the transformed data.
[0016] As an improvement, the calculation formula for calculating the prediction accuracy of the model in step (4) is:
[0017]
[0018] Where n = 200, indicating the number of data, y represents the actual dissolved oxygen, and y′ represents the predicted dissolved oxygen.
[0019] Beneficial effect: The dissolved oxygen prediction method based on BP neural network proposed in the present invention is a method for calculating the input measured data based on a maturely trained neural network model to obtain the predicted value of dissolved oxygen, wherein the prediction accuracy of the model of the present invention is above 88%, with high accuracy and fast measurement speed, and can be used for extremely fast detection of data during sewage treatment to provide a basis for subsequent intelligent regulation of influent water quality and quantity. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 It is a schematic diagram of the BP neural network principle of the present invention.
[0021] Figure 2 Schematic diagram of two transfer functions in Embodiment 1 of the present invention.
[0022] Figure 3 This is the specific setting of the algorithm in Example 1 of the present invention.
[0023] Figure 4 Schematic diagram of parameters during training of the neural network model in Example 1 of the present invention.
[0024] Figure 5 This is a schematic diagram of measuring the degree of fit of the neural network corresponding to the data by drawing a regression line in Example 1 of the present invention.
[0025] Figure 6 This is a schematic diagram of the best verification performance measured by mean square error in Example 1 of the present invention.
[0026] Figure 7 This is a schematic diagram of tracking the model training data in Example 1 of the present invention.
[0027] Figure 8 This is a comparison chart of the predicted value and the measured value based on the BP neural network in Example 1 of the present invention.
[0028] Fig. 9 It is the prediction error based on the BP neural network prediction value in Example 1 of the present invention. DETAILED DESCRIPTION
[0029] The technical solutions in the embodiments of the present invention will be described clearly and completely below so that those skilled in the art can better understand the advantages and features of the present invention, thereby making a clearer definition of the protection scope of the present invention. The embodiments described in the present invention are only a part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present invention.
[0030] The dissolved oxygen prediction method based on BP neural network in the present invention is specifically as follows: through detection equipment, which can be a data sensor, etc., to collect and obtain monitoring data of a sewage treatment plant within a time period, such as within a year; perform parameter classification, define multiple input data and one output data, and divide the data into multiple samples, each sample includes a training set and a test set, the number of training sets is more than the number of test sets, and all data in the sample are normalized; construct a BP neural network, use the newff function to generate a forward BP network, set the transfer function of the hidden layer and the transfer function of the output layer, use the trainlm algorithm to train the neural network with the normalized data, calculate the model prediction accuracy, make multiple adjustments until the minimum threshold of the model prediction accuracy is met, and end the training of the neural network; through the trained neural network, based on the measured input data, obtain the predicted value of the output data.
[0031] In the present invention, the method of using in-sample data to train a neural network is: first training with input data and output data of a training set, then testing with input data of a test set, and comparing the correctness with the output data to train the neural network.
[0032] By calculating the model prediction accuracy, multiple adjustments are made until the minimum threshold of model prediction accuracy is met, and the training of the neural network is terminated.
[0033] Finally, based on the trained neural network, the measured input data is input to obtain the predicted value of the output data.
[0034] See Figure 1 As shown, it is a schematic diagram of the neural network model of the present invention. The neural network model includes an input layer, a hidden layer and an output layer, wherein the training and learning process of the neural network method has two steps of forward propagation and back propagation.
[0035] During forward propagation, sample data is transferred from the input layer to the output layer through the hidden layer. If the output does not meet the standard, the error signal is back-propagated, and the weights are updated using the mean square error and gradient descent method to reduce the output error. This process is repeated until the error meets the requirements or the maximum number of training times is reached.
[0036] In order to better describe the present invention, the following specific embodiments are used to introduce and illustrate it.
[0037] Example 1
[0038] The present invention calibrates a sewage treatment plant and predicts the dissolved oxygen in its sewage. The specific steps of the prediction method include:
[0039] Step 1: Data collection, hourly data from April 2023 to December 2023 were collected. The data values included influent COD, ammonia nitrogen, pH, water volume, external return flow, biochemical pool turbidity, and dissolved oxygen.
[0040] Step 2: Divide the input and output data: take the influent COD, ammonia nitrogen, pH, water volume, external reflow flow, and biochemical pool turbidity as input data, and dissolved oxygen as output data.
[0041] Step 3: Divide the data into multiple samples to improve the calculation speed. Each sample is divided into a training set and a test set. The total number of each sample is selected as 6081, of which 5881 are selected as training sets and 200 are selected as test sets. The calculation amount is expected to be about one week.
[0042] All data are normalized. The normalization in the present invention adopts a linear normalization method, which performs a linear transformation on the data and maps the data to the interval [0,1]. The Min-Max normalization in the present invention does not change the distribution of the data, and its formula is:
[0043]
[0044] Where x is the original data, min is the minimum value of the data, max is the maximum value of the data, and x′ is the transformed data.
[0045] Step 4: In the present invention, a BP neural network is generated, a forward BP network is generated using the newff function, the transfer function of the hidden layer and the transfer function of the output layer are set, the normalized data obtained in step 3 is used to train the neural network through the trainlm algorithm, the model prediction accuracy is calculated, and multiple adjustments are made until the model prediction accuracy threshold is met, and the training of the neural network is terminated.
[0046] As a specific implementation method, the number of neurons in the hidden layer is set to 11, and the transfer function of the hidden layer is selected as tan-sigmod, and the transfer function of the output layer is purelin. The two transfer functions are shown in Figure 2 shown.
[0047] In the present invention, the trainlm learning algorithm is used when training the neural network, and the sum of squared errors, mean absolute error, mean square error, and root mean square error are used for evaluation. The specific formula is as follows:
[0048] Error sum of squares:
[0049] Mean absolute error:
[0050] Mean Square Error:
[0051] Root Mean Square Error:
[0052] Where n=200, indicating 200 test data, y represents the actual dissolved oxygen, and y′ represents the predicted dissolved oxygen.
[0053] In the present invention, the accuracy is calculated by the following formula. When the accuracy is lower than the set minimum threshold, the training will continue until the condition is met and then stop.
[0054] Accuracy: Where n = 200, indicating the number of data, y represents the actual dissolved oxygen, and y′ represents the predicted dissolved oxygen.
[0055] In the present invention, the number of training times is 3000, the number of gradient descent steps is 0.01, the training target minimum error is 0.0001, and the results are generated: the sum of squared errors SSE is 28.2449; the mean absolute error MAE is 0.2928; the mean square error MSE is 0.1412, the root mean square error RMSE is 0.3757, and the model prediction accuracy is 88.3854%.
[0056] See Figure 3 As shown, the present invention selects the data partitioning algorithm as Random (dividerand), the training algorithm: Levenberg-Marquardt (trainlm), the performance: Mean Squared Error (mse: mean square error) compilation algorithm: MEX.
[0057] See Figure 4 As shown, in Example 1 of the present invention, the maximum number of iterations allowed by the network is 3000, the actual number of iterations is 47, and the calculation time is fast, less than 1s. The maximum error of the network is 0.227, the target error is 0.0001, and the actual error is 0.0131; the maximum gradient of the network is 3.15, the threshold gradient is 1.00e-7, and the actual gradient is 0.00376; the minimum damping factor in the Levenberg-Marquardt algorithm used by the network is 0.001, the threshold is 1.00e10, and the actual value is 1.00e-6; the generalization ability test standard of the network, the actual value of 0 indicates that the error is continuously reduced during the training process. If the error cannot be reduced after 6 consecutive trainings, the training task is terminated.
[0058] See Figure 5 As shown in Figure 1, the degree of fit of the neural network to the data is measured by drawing a regression line, which shows the output relative to the training target, the verification target, the test dataset target, and the output of all data targets. Figure 5 The black part (data) in the middle represents the training data, verification data, and test data set, the straight line represents the fitting segment, and the total coordinate represents the fitting function.
[0059] See Figure 6 As shown in the figure, the blue train curve, green validation curve, and red test curve represent the training data, verification data, and test data, respectively. The vertical axis refers to the performance of the network measured by the mean square error (mse). The lower the mean square error (mse), the better the performance. Furthermore, the more iterations, the better the performance. At the 41st iteration, the error is the smallest, and the error does not continue to decrease in the next six iterations.
[0060] See Figure 7As shown in the figure, this is the tracking of the training data. The first figure represents the gradient value, damping factor, and verification check during the 47 iterations. In the 47th iteration, the gradient is 0.0037638 and the damping factor is 1.00e-6. The third figure represents the default confirmation check value of 6 at the 47th iteration. It means that as the network is trained using the training samples, the error curve of the confirmation sample does not decrease for 6 consecutive iterations, and the training is terminated. If the error of the confirmation sample is basically no longer decreasing or even increasing as the network is trained, then there is no need to train the network anymore, because if the training continues, the error of the test sample will not improve when the network is tested using the test sample, and even overfitting may occur. This training terminates at epoch47.
[0061] Step 5: By measuring the influent COD, ammonia nitrogen, pH, water volume, external reflow flow, and biochemical pool turbidity, and inputting them into a mature and well-trained neural network, a predicted value of dissolved oxygen is obtained. The measurement accuracy in the present invention is relatively high.
[0062] Depend on Figure 8 It can be seen that the dissolved oxygen value has been stably controlled at about 2.5. The present invention provides a method for guiding the dynamic adjustment of dissolved oxygen to guide the sewage treatment plant staff to dynamically adjust the dissolved oxygen value according to the inlet water data, which can reduce the large fluctuations of dissolved oxygen and make the fan and valve operate smoothly. The present invention abandons the original extensive and unchanging extensive dissolved oxygen control management method, and provides a more feasible operation management method for the low-carbon operation of the sewage treatment plant.
[0063] The above-mentioned embodiments only express several implementation methods of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
Claims
1. A dissolved oxygen prediction method based on BP neural network, characterized in that: The specific steps are: (1) Within a period of time, multiple groups of hourly data of the sewage treatment plant are collected and obtained through detection equipment. Each group of hourly data is regarded as a sample, and the data in each sample is divided into input data and output data; (2) Divide the samples in step (1) into a training set and a test set, where the number of samples in the training set is greater than the number of samples in the test set; (3) normalizing all data of all samples in step (2); (4) Model construction and training: construct a BP neural network, generate a forward BP network using the newff function, set the transfer function of the hidden layer and the transfer function of the output layer; use the normalized data of the training set obtained in step (3) to train the neural network using the trainlm algorithm; calculate the prediction accuracy of the neural model, make multiple adjustments until the minimum threshold of the model prediction accuracy is met, and then end the training of the neural network; (5) Using the trained neural network of step (4), based on the measured input data, obtain the predicted value of dissolved oxygen concentration data.
2. The dissolved oxygen prediction method based on BP neural network according to claim 1, characterized in that: The monitoring data in step (1) include but are not limited to influent COD, ammonia nitrogen, pH value, water volume, external reflux flow, biochemical pool turbidity, and dissolved oxygen concentration.
3. The dissolved oxygen prediction method based on BP neural network according to claim 1, characterized in that: The input data in step (2) include but are not limited to influent COD, ammonia nitrogen, pH, water volume, external reflux flow, and biochemical pool turbidity, and the output data is dissolved oxygen concentration.
4. The dissolved oxygen prediction method based on BP neural network according to claim 1, characterized in that: The minimum threshold for the total number of samples in each set is 5500-6200, and the ratio of the number of training sets to the number of measurement sets is 25-35:
1.
5. The dissolved oxygen prediction method based on BP neural network according to claim 1, characterized in that: In step (4), the normalization process is to perform a linear transformation on the data, mapping the data to the interval [0,1] without changing the distribution of the data. The specific formula is: Where x is the original data, min is the minimum value of the data, max is the maximum value of the data, and x′ is the transformed data.
6. The dissolved oxygen prediction method based on BP neural network according to claim 1, characterized in that: The step (4) also includes: using the normalized data of the test set obtained in step (3), using the trained neural network in step (4) to output the predicted value of the dissolved oxygen concentration data, and comparing it with the output data of the test set obtained in step (3) to evaluate the accuracy of dissolved oxygen prediction.
7. The dissolved oxygen prediction method based on BP neural network according to claim 1, characterized in that: The calculation formula for calculating the prediction accuracy of the model in step (4) is: Where n = 200, indicating the number of data, y represents the actual dissolved oxygen, and y′ represents the predicted dissolved oxygen.
Citation Information
Cited By
Precise aeration method for optimizing BP neural network based on chicken flock algorithm
CN121063731A
