Method and system for predicting ammonia nitrogen concentration parameter of sewage treatment biological reaction tank
By screening the characteristics with mutual information and building the CNN-BiLSTM-Attention model, the accuracy and robustness of the prediction of ammonia nitrogen concentration in the wastewater treatment biological reaction tank are solved, and high-precision and low-complexity ammonia nitrogen concentration prediction is achieved, which is suitable for sewage treatment systems.
Patent Information
- Application Number
- CN202510678850.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-26
- Publication Date
- 2025-08-26
AI Technical Summary
When facing environmental changes and data noise, the prediction accuracy and robustness of the existing ammonia nitrogen concentration prediction model of biological reaction tanks in wastewater treatment is insufficient, making it difficult to accurately capture the complex nonlinear relationship between water quality parameters and ammonia nitrogen concentration, and the model structure is complex and the deployment is difficult.
The mutual information method is used to screen the feature set of water quality parameters, and a CNN-BiLSTM-Attention deep neural network model based on LSTM is constructed. The spatial features are extracted through the convolutional neural network, and the time features are extracted from the bidirectional long and short-term memory network, and dynamic weighting is performed through the self-attention mechanism to achieve high-precision prediction of ammonia nitrogen concentration.
It improves the accuracy and robustness of ammonia nitrogen concentration prediction, can maintain good prediction performance under high ambient noise, reduces model complexity, and is suitable for deployment in sewage plants or edge equipment.
Smart Images

Figure CN120544733A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of sewage treatment, and in particular to a method and system for predicting ammonia nitrogen concentration parameters in a sewage treatment biological reaction tank. Background Art
[0002] With the rapid development of intelligent wastewater treatment technology, theoretical research on the prediction of ammonia nitrogen concentration in biological reactors has become increasingly important. Improving the prediction accuracy and robustness of the prediction model is of great significance for real-time monitoring of wastewater quality and optimization of wastewater treatment processes.
[0003] In recent years, the rapid development of artificial intelligence and machine learning has provided new research ideas for the prediction of ammonia nitrogen concentration. In the sewage treatment process, the water quality parameters of the biological reactor are affected by multiple factors. The number of parameters is large and the relationships between them are complex, with significant nonlinear characteristics. In addition, the biochemical reaction process is particularly sensitive to noise caused by environmental changes. At present, the mainstream sewage treatment process mostly adopts the combined sewer system, and changes in precipitation have become the main source of noise. Existing prediction sensors based on deep neural networks generally have problems such as high requirements for data volume and data quality, sensitivity to environmental changes, and poor model robustness. When the data noise is large or environmental changes cause data mutations, the prediction accuracy of the existing model will be affected to a certain extent.
[0004] A search revealed a Chinese invention patent application with publication number CN118645179A, which discloses a deep learning-based method for predicting biochemical pool indicators. This method constructs a knowledge base for selecting auxiliary variables based on process experience. Then, the optimal auxiliary variables are selected based on the correlation obtained by fusing four correlation coefficients with information entropy. A deep learning network based on the LSTM and Attention mechanisms is then constructed, with the Adam optimizer used to train the model using the second normal form error as the optimization objective. Finally, the auxiliary variable data and the trained model are used to output predictions for the target variable. The patent proposes selecting auxiliary variables based on the fusion of correlation coefficients and information entropy, and constructing an LSTM-Attention model to predict indicators such as ammonia nitrogen. While the overall solution is feasible, it still presents several challenges: Correlation coefficient methods have limited ability to identify nonlinear relationships. Most correlation coefficients (such as Pearson and Spearman) are primarily used to assess linear relationships and are unable to accurately capture the complex, nonlinear, and time-varying relationships between water quality parameters and ammonia nitrogen concentrations. This can lead to the omission of some key variables, impacting model performance. The model also has a relatively simple structure and insufficient ability to extract time series features. LSTM can only model time series in a unidirectional manner (from the past to the present), ignoring the potential contribution of future states to current predictions. It also fails to integrate convolutional features (such as local changes) with spatial relationships such as graph structures, limiting the model's comprehensive modeling capabilities.
[0005] Chinese invention patent application publication number CN117874708A discloses a temporal graph convolutional network prediction method using mutual information. This method uses mutual information to characterize the correlation between various parameters of industrial wastewater treatment plant influent. A deep learning architecture integrating convolutional neural networks (CNNs), graph convolutional neural networks (GCNs), gated recurrent units (GRUs), and attention mechanisms (AMs) serves as a prediction model to improve the accuracy of influent quality predictions for industrial wastewater treatment plants. The patent proposes using mutual information to construct a graph structure and integrating CNN, GCN, GRU, and attention for industrial wastewater influent quality prediction. This method demonstrates a certain level of complex modeling capabilities. However, in practical applications, it still suffers from the following shortcomings: a complex model structure, high interpretability, and deployment difficulties. The model integrates four complex submodules, resulting in a cumbersome structure and high computational overhead, making it unsuitable for online deployment. The feature selection process relies on graph construction, which frequently changes with variable fluctuations, increasing uncertainty in practical engineering applications. Furthermore, the prediction objective is influent quality, not focusing on key treatment process indicators (such as ammonia nitrogen). This patent does not specifically address the core process control objective of "predicting ammonia nitrogen concentration in the biological reactor." Summary of the Invention
[0006] In view of the defects in the prior art, the purpose of the present invention is to provide a method and system for predicting ammonia nitrogen concentration parameters in a sewage treatment biological reactor.
[0007] According to one aspect of the present invention, a method for predicting ammonia nitrogen concentration parameters in a sewage treatment biological reactor is provided, comprising:
[0008] Obtain sewage water quality parameter data under different climate and time conditions, and preprocess the data to obtain a data set;
[0009] The mutual information method is used to screen all water quality parameters that may affect the ammonia nitrogen concentration in the data set to obtain a feature set;
[0010] Construct a CNN-BiLSTM-Attention deep neural network prediction model based on LSTM, use the feature set as input, and perform network training;
[0011] The trained prediction model is used to predict the ammonia nitrogen concentration in the sewage treatment biological reactor.
[0012] Optionally, the preprocessing of the data includes normalizing all numerical data.
[0013] Optionally, the mutual information method is used to screen all water quality parameters in the data set that may affect the ammonia nitrogen concentration to obtain a feature set, including: calculating the mutual information between the water quality parameters and the ammonia nitrogen concentration, and screening key features that affect the ammonia nitrogen concentration based on the mutual information calculation results, wherein the water quality parameters include the concentration of inert dissolved organic matter, the concentration of inert non-dissolved organic matter, the concentration of easily degradable dissolved organic matter, the concentration of slowly degradable non-dissolved organic matter, the concentration of nitrate nitrogen, the concentration of dissolved organic nitrogen, the concentration of non-dissolved organic nitrogen, the concentration of heterotrophic microorganisms, the concentration of autotrophic microorganisms, the concentration of microbial metabolic residues, the dissolved oxygen concentration, the total alkalinity, the total suspended solids and the flow rate.
[0014] Optionally, the mutual information between the water quality parameter and the ammonia nitrogen concentration is calculated, and the key features affecting the ammonia nitrogen concentration are screened according to the mutual information calculation result, wherein the mutual information calculation formula is:
[0015]
[0016] Where I(X,Y) is the mutual information, n is the dataset size, i is the feature set time series index, x i is the characteristic index to be predicted, that is, the normalized data of ammonia nitrogen concentration, y i is other characteristic parameter data, which is used to calculate the correlation between this characteristic parameter and ammonia nitrogen concentration. p(·) is the probability density function, which is used for mutual information calculation and kernel density estimation is selected.
[0017] Parameters with mutual information values greater than the set threshold are selected as water quality parameters related to ammonia nitrogen concentration and added to the feature set.
[0018] Optionally, the method of using the mutual information method to screen all water quality parameters in the data set that may affect the ammonia nitrogen concentration to obtain a feature set also includes: taking the ammonia nitrogen concentration data of the previous reaction tank and the next reaction tank as feature parameters and adding them to the feature set.
[0019] Optionally, the constructing of the LSTM-based CNN-BiLSTM-Attention deep neural network prediction model, using the feature set as input, and performing network training includes:
[0020] Taking the feature set as input, extracting spatial feature information through a convolutional neural network;
[0021] Taking the spatial feature information as input, extracting temporal feature information through a bidirectional long short-term memory network and strengthening context information;
[0022] The temporal feature information is used as input and dynamically weighted through the self-attention mechanism to obtain the final prediction output.
[0023] Optionally, the spatial feature information is extracted by a convolutional neural network, wherein the calculation formula is:
[0024]
[0025] Where X(y+m) indicates that when calculating the output of step i, the input sequence information of m steps starting from step i needs to be considered, m ranges from 0 to K-1, X(·) is the input sequence, Y(i) is the output sequence, that is, the extracted spatial feature information, W(m) is the convolution kernel, that is, the weight matrix, K is the convolution kernel size, b is the bias term, and f(·) is the rectified linear unit ReLU activation function.
[0026] Optionally, the bidirectional long short-term memory network is used to extract temporal feature information and enhance context information, wherein the calculation formula is:
[0027]
[0028] Where t is the time step, h is t is hidden state, represents a forward time series, represents the reverse time series, is the output obtained by the forward LSTM network at the previous time step, is the output obtained by the reverse LSTM network at the next time step, H t This is the final output sequence of the BiLSTM layer, that is, the extracted spatial feature information.
[0029] Optionally, the dynamic weighting is performed through a self-attention mechanism, wherein the calculation formula is:
[0030] Q=XW Q ,K=XW k ,V=XW v
[0031]
[0032] In the formula, Q, K, and V represent query, key, and value respectively; K T is the transpose of the key matrix, W Q 、W k 、W v are their respective corresponding weight matrices, is the scaling factor, which is a constant related to the dimension of the K matrix. X is the input feature vector of the previous step, that is, the temporal feature information extracted by the BiLSTM layer. O is the output feature vector extracted by the Attention layer. Softmax(x) is the activation function.
[0033] According to another aspect of the present invention, a system for predicting ammonia nitrogen concentration parameters in a sewage treatment biological reactor is provided, comprising:
[0034] The data set acquisition module is used to obtain sewage water quality parameter data under different climate and time conditions, and pre-process the data to obtain a data set;
[0035] A feature set construction module is used to screen all water quality parameters that may affect the ammonia nitrogen concentration in the data set using a mutual information method to obtain a feature set;
[0036] A model training module is used to build a CNN-BiLSTM-Attention deep neural network prediction model based on LSTM, and perform network training using the feature set as input;
[0037] The prediction module is used to predict the ammonia nitrogen concentration in the sewage treatment biological reactor using the trained prediction model.
[0038] Compared with the prior art, the present invention has at least one of the following beneficial effects:
[0039] Based on historical water quality data that fully considers multiple influencing factors such as climate and time, the present invention performs correlation analysis through the mutual information method, considers the correlation between all features and ammonia nitrogen concentration, screens out a suitable feature set, and uses the CNN-BiLSTM-Attention method to build a network model. In this way, a method for predicting the water quality parameters of biological reactor wastewater that is highly robust to environmental change noise is constructed, thereby achieving high-precision prediction of ammonia nitrogen concentration and significantly improving the robustness and adaptability of the prediction model. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Other features, objects and advantages of the present invention will become more apparent upon reading the detailed description of non-limiting embodiments with reference to the following drawings:
[0041] Figure 1 1 is a flow chart of a method for predicting ammonia nitrogen concentration in one embodiment of the present invention;
[0042] Figure 2 1 is a schematic diagram of the structure of a CNN-BiLSTM-Attention network in one embodiment of the present invention;
[0043] Figure 3 1 is a comparison chart of the predicted results of ammonia nitrogen concentration in the No. 2 biological reactor under different climatic conditions in one embodiment of the present invention, wherein: (a) represents dry weather, (b) represents rainy weather, and (c) represents rainstorm weather. DETAILED DESCRIPTION
[0044] The present invention will be described in detail below with reference to specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but are not intended to limit the present invention in any form. It should be noted that, for those skilled in the art, several variations and improvements can be made without departing from the scope of the present invention. These all fall within the scope of protection of the present invention.
[0045] Long Short-Term Memory (LSTM) neural networks, as artificial neural networks based on time cycles, can effectively address long-term dependencies and prevent gradient vanishing and exploding. They have been widely used in time series nonlinear regression problems. Convolutional Neural Networks (CNNs) have advantages in extracting local features, especially in processing local spatial relationships. They can learn and enhance key features by reducing input dimensions, thereby improving the network's ability to capture long-term dependencies. The self-attention mechanism enhances the model's ability to learn global information, enabling it to dynamically focus on key time steps. This improves the model's expressiveness while enhancing its robustness to noise interference.
[0046] Aiming at the complex nonlinear relationship between various water quality parameters and ammonia nitrogen concentration in the sewage treatment process, and comprehensively considering the robustness of the prediction model in dealing with environmental noise, a method for predicting ammonia nitrogen concentration parameters in the biological reactor of the sewage treatment process based on deep neural network is proposed, which has important research value and engineering application significance.
[0047] Reference Figure 1 As shown, a method for predicting ammonia nitrogen concentration parameters in a sewage treatment biological reactor provided by one embodiment of the present invention includes:
[0048] S1. Obtain sewage water quality parameter data under different climate and time conditions, and preprocess the data to obtain a data set to be used as a feature set;
[0049] S2. Feature screening: The mutual information method is used to screen all water quality parameters in the data set that may affect the ammonia nitrogen concentration to obtain a feature set, which is used as the input feature of the prediction model;
[0050] S3. Deep neural network model construction and training: Build a CNN-BiLSTM-Attention deep neural network prediction model based on LSTM (Long Short-Term Memory Network), use the feature set as input, and perform network training;
[0051] S4. Use the trained prediction model to predict the ammonia nitrogen concentration in the sewage treatment biological reactor.
[0052] Specifically, simulation data is obtained using a public simulation platform, such as the open-source BSM1 simulation platform. The data provided by the simulation model serves as a feature set for training the predictive model. Different climate conditions include dry weather, rainy weather, and rainstorm weather. For example, simulation data for a 14-day sewage treatment process can be obtained, i.e., a feature set for three groups of sewage treatment system biological reactors operating over 14 days under different climate conditions: dry weather, rainy weather, and rainstorm weather.
[0053] In this embodiment of the present invention, a simulation model is first constructed to obtain data related to wastewater quality parameters of biological reactors under different climatic conditions, and data preprocessing is performed. Secondly, a mutual information method is used to perform correlation analysis and determine a feature set. Finally, a CNN-BiLSTM-Attention deep neural network prediction model based on LSTM is designed to predict ammonia nitrogen concentration parameters in the biological reactor during the treatment process. Based on historical water quality data information under various influencing factors such as climate and time, this embodiment of the present invention establishes a method for predicting wastewater quality parameters in biological reactors that is robust to environmental noise changes. This method fully utilizes historical ammonia nitrogen concentration information and related water quality parameter information to achieve accurate prediction of ammonia nitrogen concentration with good robustness.
[0054] To pre-process the data, in some embodiments, in step S1, all numerical data are normalized. The calculation formula for the normalization is as follows:
[0055]
[0056] In the formula, μ represents the mean of the eigenvalue, σ represents the standard deviation of the eigenvalue, x represents the original data, and x ′ Represents the normalized data.
[0057] In order to screen all water quality parameters in the data set that may affect the ammonia nitrogen concentration, in some embodiments, in step S2, the mutual information between the water quality parameters and the ammonia nitrogen concentration is calculated, and the key features affecting the ammonia nitrogen concentration are screened based on the mutual information calculation results, wherein the water quality parameters are the variables that need to be referenced for the derivation of the biochemical reaction formula considered in the BSM1 mechanism modeling, and the substrate concentration change rate is used as the biochemical reaction indicator. The concentration of inert dissolved organic matter, inert non-dissolved organic matter, easily degradable dissolved organic matter, slowly degradable non-dissolved organic matter, nitrate nitrogen concentration, dissolved organic nitrogen concentration, non-dissolved organic nitrogen concentration, heterotrophic microorganism concentration, autotrophic microorganism concentration, microbial metabolic residue concentration, dissolved oxygen concentration, total alkalinity, total suspended solids and flow rate are considered as feature set related parameters, so as to achieve accurate prediction of the ammonia nitrogen concentration, a key indicator of the nitrification rate of the biological reactor.
[0058] In some embodiments, the mutual information calculation formula is:
[0059]
[0060] Where I(X,Y) is the mutual information, n is the dataset size, i is the feature set time series index, x i is the characteristic index to be predicted, that is, the normalized data of ammonia nitrogen concentration, y i is the other characteristic parameter data, that is, the water quality parameter data mentioned above, which is used to calculate the correlation between this characteristic parameter and ammonia nitrogen concentration. p(·) is the probability density function used for mutual information calculation, and the kernel density estimation is selected:
[0061]
[0062] Among them, h is the window width, which is a hyperparameter, and φ(x) is the kernel function, which is selected as Gaussian normal distribution:
[0063]
[0064] Parameters with mutual information values greater than the set threshold are selected as water quality parameters related to ammonia nitrogen concentration, that is, water quality parameters that may affect ammonia nitrogen concentration (or key features that affect ammonia nitrogen concentration), and added to the feature set.
[0065] In order to improve the prediction accuracy, in some embodiments, the feature set construction process also includes: based on the series characteristics of the biological reaction tank, the ammonia nitrogen concentration data of the previous reaction tank and the next reaction tank are used as feature parameters and added to the feature set to enhance the model's ability to learn the spatiotemporal correlation characteristics of ammonia nitrogen concentration.
[0066] It should be noted that, for reaction pool No. 1, the previous reaction pool corresponds to the inlet water, and for reaction pool No. 5, the next reaction pool corresponds to the outlet water.
[0067] The above-mentioned embodiment of the present invention fully considers the various water quality parameter characteristics that affect the ammonia nitrogen concentration, and makes full use of historical water quality parameter information. Correlation analysis is performed through the mutual information method, and the correlation between all characteristics and ammonia nitrogen concentration is considered to screen out a suitable feature set. A prediction model based on this design can improve the prediction accuracy of ammonia nitrogen concentration and has good robustness.
[0068] Using a feature set selected through correlation analysis to establish a prediction model effectively reduces model complexity, thereby reducing the scale of model training and avoiding overfitting. Compared with empirical screening or linear feature screening methods, the embodiments of the present invention can better capture the complex nonlinear relationships between features, thereby improving prediction performance.
[0069] In some embodiments, the structural diagram of the LSTM-based CNN-BiLSTM-Attention deep neural network prediction model is as follows: Figure 2 As shown, step S3 specifically includes:
[0070] S31, using the normalized feature set as input, extracts spatial feature information through a convolutional neural network (CNN);
[0071] S32, using the spatial feature information in S31, i.e., the feature vector trained by the convolutional neural network, as input, extracting the temporal feature information through the bidirectional long short-term memory network BiLSTM, and strengthening the context information;
[0072] S33 uses the temporal feature information in S32, i.e., the feature vector trained by the bidirectional long short-term memory network BiLSTM, as input, and dynamically weights it through the self-attention mechanism to enhance the expression ability and obtain the final prediction output.
[0073] In some embodiments, spatial feature information is extracted by a convolutional neural network, where the calculation formula is:
[0074]
[0075] Where X(i+m) indicates that when calculating the output of step i, the input sequence information of step m starting from step i needs to be considered, m ranges from 0 to K-1, X(·) is the input sequence, Y(i) is the output sequence, that is, the extracted spatial feature information, W(m) is the convolution kernel, that is, the weight matrix, K is the convolution kernel size, b is the bias term, and f(·) is the rectified linear unit ReLU activation function.
[0076] Specifically, for any input x, f(x) = max(0, x).
[0077] In some embodiments, a bidirectional long short-term memory network is used to extract temporal feature information and enhance contextual information, wherein the calculation formula is:
[0078]
[0079] Where t is the time step, h is t is hidden state, represents a forward time series, represents the reverse time series, is the output obtained by the forward LSTM network at the previous time step, is the output obtained by the reverse LSTM network at the next time step, H t This is the final output sequence of the BiLSTM layer, that is, the extracted spatial feature information.
[0080] Specifically, the output obtained by the LSTM network is as follows:
[0081] f t =σ(W f [h t-1 ,X t ]+b f )
[0082] i t =σ(W i [h t-1 ,X t ]+b i )
[0083] o t =σ(W o [h t-1 ,X t ]+b o )
[0084]
[0085] h t =o t ⊙tanh(C t-1 )
[0086] Among them, f t Output feature vector for the forget gate, i t Output feature vector for the input gate, o t Output feature vector for the output gate, Output feature vector for candidate memory unit, C t is the cell state, that is, the memory unit state, W, b are the respective weight matrices and biases, W f ,b f is the weight matrix and bias vector of the forget gate, W i ,b i is the weight matrix and bias vector of the input gate, W o ,b o is the weight matrix and bias vector of the output gate, W c ,b c is the weight matrix and bias vector output by the candidate memory unit, h t is the hidden state at the current moment, σ(x) is the logistic function Sigmoid activation function:
[0087]
[0088] tanh(x) is the hyperbolic tangent activation function:
[0089]
[0090] ⊙ represents element-wise multiplication, that is, each element is multiplied one by one.
[0091] In some embodiments, dynamic weighting is performed through a self-attention mechanism, where the calculation formula is:
[0092] Q=XW Q ,K=XW k ,V=XW v
[0093]
[0094] In the formula, Q, K, and V represent query, key, and value respectively; K T is the transpose of the key matrix, W Q 、W k 、W v are their respective corresponding weight matrices, is the scaling factor, which is a constant related to the dimension of the K matrix. X is the input feature vector of the previous step, that is, the temporal feature information extracted by the BiLSTM layer. O is the output feature vector extracted by the Attention layer. Softmax(x) is the activation function.
[0095] Specifically,
[0096] The loss function is used to quantify the deviation between the final network predicted ammonia nitrogen concentration result curve and the expected simulation result.
[0097] The loss function is selected as MSE, and the formula is:
[0098]
[0099] Where N is the number of samples, y i is the true value, is the predicted value. The loss function is used to quantify the deviation between the final network predicted ammonia nitrogen concentration result curve and the expected simulation result.
[0100] The above-mentioned embodiment of the present invention uses the CNN-BiLSTM-Attention method to build a network model, which can better capture the spatial and temporal features between data. This method has excellent spatial and temporal feature capture capabilities, can focus on important time steps, enhance the ability to capture long-term dependencies, improve the ability to learn global information, and has strong robustness, which can effectively cope with high environmental noise.
[0101] In some embodiments, before using the trained prediction model to predict the ammonia nitrogen concentration in the sewage treatment biological reactor, the method includes: conducting comparative experiments on different network models under the same conditions to verify the robustness improvement effect of the prediction sensor model.
[0102] To conduct model comparison and validation, we conducted comparative experiments on the LSTM, BiLSTM, CNN-BiLSTM, and CNN-BiLSTM-Attention models under different climate conditions to evaluate and verify the robustness improvements achieved by the prediction models. Specifically, we selected the same historical data and feature set, and fixed the network hyperparameters to ensure consistent experimental conditions. We trained each of the four network models (LSTM, BiLSTM, CNN-BiLSTM, and CNN-BiLSTM-Attention) separately. We then compared the quantitative metrics of each network model on the test dataset under different climate conditions (dry weather, rainy weather, and torrential rain) using mean squared error (MSE) and coefficient of determination (R^2) to assess the model's predictive performance under different environments.
[0103] The above-described embodiments of the present invention are able to effectively fit the complex nonlinear regression relationships between multiple water quality parameters and ammonia nitrogen concentration, and perform well under conditions of high environmental noise. Comparisons with other methods for predicting ammonia nitrogen concentration show that this method achieves a lower mean square error (MSE) and a higher coefficient of determination (R²), and maintains good performance under noise interference, demonstrating high prediction accuracy and strong robustness.
[0104] Compared with the prior art in the background art, the above embodiments of the present invention have been improved in a targeted manner and have stronger practicality, accuracy and robustness. Specifically:
[0105] The feature selection method in the above embodiment of the present invention uses mutual information analysis instead of correlation coefficient to comprehensively capture nonlinear variable relationships and implicit dependencies between multiple variables, avoid missing key factors, and improve model training effects and generalization capabilities.
[0106] The model structure design in the above embodiment of the present invention introduces a CNN-BiLSTM-Attention composite model, which integrates multiple time feature extraction mechanisms. CNN extracts local time features, BiLSTM models temporal dependencies, and Attention selects key time points, significantly improving the accuracy of ammonia nitrogen prediction.
[0107] The time series processing in the above embodiment of the present invention uses BiLSTM to capture bidirectional dependencies and Attention to enhance the expression of key moment features.
[0108] The above-mentioned embodiments of the present invention have a strong target focus, focusing on ammonia nitrogen concentration as the prediction object, meeting the key control requirements of the process, and focusing on the core parameter of ammonia nitrogen concentration to provide key decision support for precise aeration control and energy saving and consumption reduction, which has greater engineering value.
[0109] The above embodiments of the present invention are highly deployment-friendly and have lower structural complexity than GCN. The model structure achieves a better balance between accuracy and efficiency, and is suitable for deployment in sewage treatment plants or edge devices.
[0110] Based on the same inventive concept, another embodiment of the present invention provides a system for predicting ammonia nitrogen concentration parameters in a sewage treatment biological reactor, comprising:
[0111] The data set acquisition module is used to obtain sewage water quality parameter data under different climate and time conditions, and pre-process the data to obtain a data set;
[0112] The feature set construction module is used to screen all water quality parameters in the data set that may affect the ammonia nitrogen concentration using the mutual information method to obtain a feature set, which is used as the input feature of the prediction model;
[0113] The model training module is used to build an LSTM-based CNN-BiLSTM-Attention deep neural network prediction model, using the feature set as input for network training;
[0114] The prediction module is used to predict the ammonia nitrogen concentration in the sewage treatment biological reactor using the trained prediction model.
[0115] The specific implementation techniques of each module / unit in the above example of the present invention can refer to the corresponding steps of the method for predicting ammonia nitrogen concentration parameters in a biological reactor for sewage treatment in the above embodiment, which will not be repeated here.
[0116] The following further illustrates the present application in conjunction with specific application examples / comparative examples to facilitate a better understanding of the above technical solutions of the present application. It should be understood that the following are merely partial examples and are not intended to limit the present application.
[0117] In a specific application example, the following is provided: Figure 1 The method for predicting ammonia nitrogen concentration parameters in a biological reactor of a sewage treatment process based on a deep neural network is shown in the figure. The specific operation steps are as follows:
[0118] (1) Obtain simulation data and preprocess it
[0119] Simulation data under different climate conditions, including drought, precipitation, and rainstorm, as well as water quality parameters of the five series-connected bioreactors, were obtained and preprocessed. The preprocessing step includes normalizing the data. The specific normalization formula is as follows:
[0120]
[0121] In the formula, μ and σ represent the mean and standard deviation of the eigenvalue respectively.
[0122] (2) Correlation analysis to determine the feature set
[0123] To predict the ammonia nitrogen concentration index at the next time step, it is necessary to consider the relationship between the concentration of inert dissolved organic matter (SI), inert non-dissolved organic matter (XI), easily degradable dissolved organic matter (SS), slowly degradable non-dissolved organic matter (XS), nitrate nitrogen concentration (SNO), dissolved organic nitrogen concentration (SND), non-dissolved organic nitrogen concentration (XND), heterotrophic microbial concentration (XBH), autotrophic microbial concentration (XAH), microbial metabolic residue concentration (XP), dissolved oxygen concentration (SO), total alkalinity (SALK), total suspended solids (TSS), flow rate (QI) and ammonia nitrogen concentration (SNH). The mutual information is calculated as follows:
[0124]
[0125] Where n is the size of the data set, p(x) is the probability density function, and the kernel density estimation is selected:
[0126]
[0127] Where h is the window width, which is a hyperparameter, and φ(x) is the kernel function, which is selected as a Gaussian normal distribution:
[0128]
[0129] The larger the mutual information I(X,Y), the stronger the correlation. Since the main biochemical reactions occurring in each biological reactor are different, the choice of mutual information threshold is also different. It is necessary to remove weakly correlated or irrelevant water quality parameter information as much as possible. Based on this, water quality parameters with mutual information greater than the set threshold are selected as parameters related to ammonia nitrogen concentration and added to the feature set. At the same time, considering the series characteristics of biological reactors, for biological reactor No. 2, the ammonia nitrogen concentration data of the previous reactor (for example, reactor No. 1 corresponds to the influent) and the next reactor (for example, reactor No. 3 corresponds to the effluent) are also used as feature parameters and added to the feature set. The specific data are shown in Table 1:
[0130] Table 1 Correlation analysis results
[0131]
[0132] (3) Network model construction
[0133] Build as Figure 2The CNN-BiLSTM-Attention network model shown in Figure 1 can better capture spatial and temporal features, as well as long-term dependencies, between data. This network has stronger global information capture capabilities and higher robustness, enabling it to effectively fit the complex nonlinear regression relationships between multiple water quality parameters and ammonia nitrogen concentrations even in conditions with high environmental noise.
[0134] The local spatial feature information is extracted through the convolutional neural network CNN. The formula is as follows:
[0135]
[0136] Where X(i) is the input sequence, Y(i) is the output sequence, W(m) is the convolution kernel, that is, the weight matrix, K is the convolution kernel size, b is the bias term, and f(x) is the rectified linear unit ReLU activation function:
[0137] f(x)=max(0,x)
[0138] The bidirectional long short-term memory network BiLSTM extracts temporal feature information and strengthens context information. The formula is as follows:
[0139]
[0140] Where t is the time step, h t is the hidden state, LSTM(X t ,h t ) is the output obtained by the LSTM network, and the formula is as follows
[0141] f t =σ(W f [h t-1 ,X t ]+b f )
[0142] i t =σ(W i [h t-1 ,X t ]+b i )
[0143] o t =σ(W o [h t-1 ,X t ]+b o )
[0144]
[0145]
[0146] h t =ot ⊙tanh(C t-1 )
[0147] Among them C t is the cell state, that is, the memory unit state, W, b are their respective weight matrices and bias σ(x) is the logistic function Sigmoid activation function:
[0148]
[0149] tanh(x) is the hyperbolic tangent activation function:
[0150]
[0151] ⊙ represents element-level multiplication, that is, each element is multiplied one by one;
[0152] The self-attention mechanism performs dynamic weighting to enhance the expressive power. The formula is as follows:
[0153] Q=XW Q ,K=XW k ,V=XW v
[0154]
[0155] Among them, Q, K, V represent query, key, value, and W are their respective weight matrices. is the scaling factor, a constant related to the dimension of the K matrix, and Softmax(x) is the activation function:
[0156]
[0157] The loss function is selected as MSE, and the formula is:
[0158]
[0159] Where N is the number of samples, y i is the true value, is the predicted value.
[0160] (4) Experimental examples and result analysis
[0161] In order to verify the accuracy of the ammonia nitrogen concentration prediction method and the robustness of the prediction model in the embodiment of the present invention, the BSM1 simulation model was used to train the water quality parameters of each bioreactor in five series-connected bioreactors during 14 days of operation under three climatic conditions: drought, precipitation, and rainstorm.
[0162] When evaluating the prediction performance of ammonia nitrogen concentration for each network, the mean square error (MSE) and the coefficient of determination (R^2) were selected as indicators. The smaller the MSE and the larger the R^2, the higher the prediction accuracy, the better the model fit, and the greater the credibility. The calculation formulas for MSE and R^2 are as follows:
[0163]
[0164]
[0165] Where N is the total number of prediction samples, y i is the true value, is the predicted value, is the true mean value.
[0166] Ammonia nitrogen concentrations were predicted using 1) LSTM, 2) BiLSTM, 3) CNN-BiLSTM, and 4) CNN-BiLSTM-Attention under three different climate conditions. The prediction results are shown in Table 2:
[0167] Table 2 Ammonia nitrogen concentration prediction results
[0168]
[0169] By comparing the prediction results obtained with different network structures, it can be seen that the CNN-BiLSTM-Attention network designed based on the above embodiment of the present invention has significantly improved the prediction accuracy compared with other models based on long short-term memory neural networks. The above embodiment of the present invention extracts spatial and temporal features at the same time and adds a self-attention mechanism to capture important information. The designed complex network structure shows stronger robustness in the face of environmental noise, especially in adverse weather conditions, with less drop in prediction accuracy. Figure 3 It can be seen that the ammonia nitrogen concentration fluctuates significantly in precipitation and rainstorm weather, and the CNN-BiLSTM-Attention network designed in the above embodiment of the present invention can better fit the inflection point of data fluctuations and show stronger robustness to environmental noise, thereby further improving the prediction accuracy of the model.
[0170] The above describes specific embodiments of the present invention. It should be understood that the present invention is not limited to the specific embodiments described above, and those skilled in the art may make various modifications or variations within the scope of the claims without affecting the essence of the present invention. The above preferred features may be used in any combination as long as they do not conflict with each other.
Claims
1. A method for predicting ammonia nitrogen concentration parameters in a sewage treatment biological reactor, characterized in that: include: Obtain sewage water quality parameter data under different climate and time conditions, and preprocess the data to obtain a data set; The mutual information method is used to screen all water quality parameters that may affect the ammonia nitrogen concentration in the data set to obtain a feature set; Construct a CNN-BiLSTM-Attention deep neural network prediction model based on LSTM, use the feature set as input, and perform network training; The trained prediction model is used to predict the ammonia nitrogen concentration in the sewage treatment biological reactor.
2. The method for predicting ammonia nitrogen concentration parameters in a sewage treatment biological reactor according to claim 1, characterized in that: The data preprocessing includes normalizing all numerical data.
3. The method for predicting ammonia nitrogen concentration parameters in a sewage treatment biological reactor according to claim 1, characterized in that: The mutual information method is used to screen all water quality parameters in the data set that may affect the ammonia nitrogen concentration to obtain a feature set, including: calculating the mutual information between the water quality parameters and the ammonia nitrogen concentration, and screening the key features that affect the ammonia nitrogen concentration based on the mutual information calculation results, wherein the water quality parameters include the concentration of inert dissolved organic matter, the concentration of inert non-dissolved organic matter, the concentration of easily degradable dissolved organic matter, the concentration of slowly degradable non-dissolved organic matter, the concentration of nitrate nitrogen, the concentration of dissolved organic nitrogen, the concentration of non-dissolved organic nitrogen, the concentration of heterotrophic microorganisms, the concentration of autotrophic microorganisms, the concentration of microbial metabolic residues, the concentration of dissolved oxygen, the total alkalinity, the total suspended solids and the flow rate.
4. The method for predicting ammonia nitrogen concentration parameters in a sewage treatment biological reactor according to claim 3, characterized in that: The mutual information between the water quality parameters and the ammonia nitrogen concentration is calculated, and the key features affecting the ammonia nitrogen concentration are screened according to the mutual information calculation results, wherein the mutual information calculation formula is: Where I(X,Y) is the mutual information, n is the dataset size, i is the feature set time series index, x i is the characteristic index to be predicted, that is, the normalized data of ammonia nitrogen concentration, y i is other characteristic parameter data, which is used to calculate the correlation between this characteristic parameter and ammonia nitrogen concentration. p(·) is the probability density function, which is used for mutual information calculation and kernel density estimation is selected. Parameters with mutual information values greater than the set threshold are selected as water quality parameters related to ammonia nitrogen concentration and added to the feature set.
5. The method for predicting ammonia nitrogen concentration parameters in a sewage treatment biological reactor according to claim 1, characterized in that: The method of using the mutual information method to screen all water quality parameters in the data set that may affect the ammonia nitrogen concentration to obtain a feature set also includes: taking the ammonia nitrogen concentration data of the previous reaction tank and the next reaction tank as feature parameters and adding them to the feature set.
6. The method for predicting ammonia nitrogen concentration parameters in a sewage treatment biological reactor according to claim 1, characterized in that: The LSTM-based CNN-BiLSTM-Attention deep neural network prediction model is constructed, and the feature set is used as input to perform network training, including: Taking the feature set as input, extracting spatial feature information through a convolutional neural network; Taking the spatial feature information as input, extracting temporal feature information through a bidirectional long short-term memory network and strengthening context information; The temporal feature information is used as input and dynamically weighted through the self-attention mechanism to obtain the final prediction output.
7. The method for predicting ammonia nitrogen concentration parameters in a sewage treatment biological reactor according to claim 6, characterized in that: The spatial feature information is extracted by the convolutional neural network, wherein the calculation formula is: Where X(i+m) indicates that when calculating the output of step i, the input sequence information of step m starting from step i needs to be considered, m ranges from 0 to K-1, X(·) is the input sequence, Y(i) is the output sequence, that is, the extracted spatial feature information, W(m) is the convolution kernel, that is, the weight matrix, K is the convolution kernel size, b is the bias term, and f(·) is the rectified linear unit ReLU activation function.
8. The method for predicting ammonia nitrogen concentration parameters in a sewage treatment biological reactor according to claim 7, characterized in that: The bidirectional long short-term memory network is used to extract temporal feature information and strengthen context information, wherein the calculation formula is: Where t is the time step, h is t is hidden state, represents a forward time series, represents the reverse time series, is the output obtained by the forward LSTM network at the previous time step, is the output obtained by the reverse LSTM network at the next time step, H t This is the final output sequence of the BiLSTM layer, that is, the extracted spatial feature information.
9. The method for predicting ammonia nitrogen concentration parameters in a sewage treatment biological reactor according to claim 8, characterized in that: The dynamic weighting is performed through the self-attention mechanism, where the calculation formula is: Q=XW Q ,K=XW k ,V=XW v In the formula, Q, K, and V represent query, key, and value respectively; K T is the transpose of the key matrix, W Q 、W k 、W v are their respective corresponding weight matrices, is the scaling factor, which is a constant related to the dimension of the K matrix. X is the input feature vector of the previous step, that is, the temporal feature information extracted by the BiLSTM layer. O is the output feature vector extracted by the Attention layer. Softmax(x) is the activation function.
10. A system for predicting ammonia nitrogen concentration parameters in a sewage treatment biological reactor, characterized in that: include: The data set acquisition module is used to obtain sewage water quality parameter data under different climate and time conditions, and pre-process the data to obtain a data set; A feature set construction module is used to screen all water quality parameters that may affect the ammonia nitrogen concentration in the data set using a mutual information method to obtain a feature set; A model training module is used to build a CNN-BiLSTM-Attention deep neural network prediction model based on LSTM, and perform network training using the feature set as input; The prediction module is used to predict the ammonia nitrogen concentration in the sewage treatment biological reactor using the trained prediction model.
Citation Information
Patent Citations
Time graph convolutional network prediction method applying mutual information
CN117874708A
Biochemical pool index soft measurement method based on deep learning
CN118645179A
Blast furnace thermal load abnormal state monitoring method based on attention mechanism
CN114015825A
Method for predicting effluent BOD concentration based on PSLSTM neural network
CN114565143A
Wetland effluent ammonia nitrogen concentration prediction method and system based on hybrid neural network
CN114707692A