Outlet water ammonia nitrogen prediction method and system based on time sequence and multiple attention

By constructing an ammonia nitrogen prediction model based on BiGRU and multi-head attention, the problems of insufficient accuracy and poor real-time performance in effluent ammonia nitrogen prediction in existing technologies are solved, achieving high-precision, real-time prediction of nitrogen concentration in wastewater treatment effluent, and adapting to the high-frequency dynamic changes in municipal wastewater treatment plants.

CN121306304APending Publication Date: 2026-01-09HUAZHONG UNIV OF SCI & TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202511374818.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-25
Publication Date
2026-01-09

AI Technical Summary

Technical Problem

Existing wastewater treatment methods suffer from insufficient prediction accuracy and poor real-time performance in predicting effluent ammonia nitrogen, making it difficult to adapt to the high-frequency dynamic changes required by municipal wastewater treatment plants.

Method used

An effluent nitrogen prediction method based on time series and multi-head attention is adopted. By constructing an ammonia nitrogen prediction model that includes a BiGRU model and a multi-head attention layer, multivariate time series data is used for modeling, with particular attention to the influence of aeration rate, so as to achieve high-precision and real-time prediction of effluent nitrogen concentration.

Benefits of technology

It achieves high-precision, real-time prediction of nitrogen concentration in wastewater effluent, improves the model's adaptability and interpretability to dynamic operating conditions, and can effectively replace mechanistic models to adapt to the high-frequency dynamic changes in municipal wastewater treatment plants.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121306304A_ABST
    Figure CN121306304A_ABST
Patent Text Reader

Abstract

The invention provides an effluent ammonia nitrogen prediction method and system based on a time sequence and multiple attention, and relates to the technical field of sewage treatment.The method comprises the steps that historical operation data of sewage treatment is obtained, multiple key variables in the historical operation data are extracted, and a sample set containing multivariable time sequence data is constructed; constructing an effluent ammonia nitrogen prediction model comprising a time sequence model, a multi-head attention layer, a splicing layer and a full-connection output layer, and training, verifying and testing the constructed effluent ammonia nitrogen prediction model based on the sample set to obtain a final effluent ammonia nitrogen prediction model; and acquiring online operation data of sewage treatment, inputting the final effluent ammonia nitrogen prediction model, and outputting an ammonia nitrogen concentration prediction value at a future moment. According to the method, high-precision and real-time prediction of the ammonia nitrogen concentration in sewage treatment effluent can be realized, a mechanism-based model is effectively replaced, and high-frequency dynamic change working condition requirements of a municipal sewage treatment plant are met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of wastewater treatment technology, and in particular to a method and system for predicting effluent ammonia nitrogen based on time series and multi-head attention. Background Technology

[0002] With the acceleration of urbanization, the total amount of municipal sewage discharge is increasing year by year, and sewage treatment plants are facing stricter effluent standards and higher energy efficiency control requirements. To ensure effluent quality meets standards, especially the stable control of key indicators such as ammonia nitrogen, adjusting the aeration rate has become a core task in operation and management. In actual operation, aeration control often relies on the indirect regulation of effluent ammonia nitrogen concentration, and the ammonia nitrogen removal effect in the biological reaction tank is affected by multiple factors such as influent water quality, quantity, temperature, and microbial activity, exhibiting significant nonlinearity, time-varying characteristics, and lag. Traditional treatment methods typically rely on offline simulation or fixed-value prediction based on mechanistic models, but such models suffer from complex modeling, slow inference speed, and strong parameter dependence, making them difficult to adapt to the high-frequency dynamic changes in the operating conditions of municipal sewage treatment plants. Therefore, constructing a high-precision and high-efficiency effluent ammonia nitrogen prediction proxy model has become a key technological direction for improving system operating efficiency and intelligence.

[0003] Currently, most effluent water quality prediction methods employ single-structure modeling such as Long Short-Term Memory (LSTM) networks, using historical influent parameters and operational variables to predict water quality indicators like ammonia nitrogen. While this alleviates the slow computation and complex modeling issues of traditional mechanistic models to some extent, significant shortcomings remain. First, the LSTM structure relies on unidirectional time series modeling, making it difficult to fully capture the bidirectional causal relationships existing in the wastewater treatment process, thus affecting the model's adaptability to dynamically changing operating conditions. Second, although some methods introduce attention mechanisms to enhance the model's ability to identify the strength of time dependence of input variables, they typically treat all features as equivalent inputs, lacking explicit modeling and structured emphasis on key process variables (such as aeration intensity), resulting in insufficient model response to control variables and difficulty in achieving interpretable predictions. Furthermore, existing methods primarily rely on globally shared attention in their structural design, failing to construct dedicated channels guided by key variables, making it difficult to meet the needs of modeling control correlations and engineering-level optimization. Therefore, existing models still face a trade-off bottleneck between prediction accuracy, computational efficiency, and deployment availability, and cannot effectively replace mechanistic models for high-frequency rolling simulations in real-time control systems. Summary of the Invention

[0004] To address the issues of insufficient prediction accuracy and poor real-time performance in existing technologies, the present invention aims to provide a method and system for predicting effluent ammonia nitrogen based on time series and multi-head attention, thereby achieving high-precision, real-time prediction of ammonia nitrogen concentration in wastewater treatment effluent, effectively replacing mechanistic models, and adapting to the high-frequency dynamic changes required by municipal wastewater treatment plants.

[0005] To achieve the above objectives, the present invention provides the following technical solution:

[0006] In a first aspect, this invention provides a method for predicting effluent ammonia nitrogen based on time series and multi-head attention, comprising:

[0007] Historical operational data of wastewater treatment was acquired, and multiple key variables were extracted from the historical operational data to construct a sample set containing multivariate time series data. These key variables included influent water quality indicators, influent flow rate, aeration rate, and return sludge volume. An effluent ammonia nitrogen prediction model was constructed, comprising a time series model, a multi-head attention layer, a splicing layer, and a fully connected output layer. The time series model was used to process the multivariate time series data, and the multi-head attention layer was set at the output end of the time series model to independently model and calculate the attention of at least one key variable as an attention head. The results calculated by each attention head were spliced ​​through the splicing layer and then input into the fully connected output layer. The constructed effluent ammonia nitrogen prediction model was trained, validated, and tested based on the sample set to obtain the final effluent ammonia nitrogen prediction model. Online operational data of the wastewater treatment was acquired, input into the final effluent ammonia nitrogen prediction model, and the predicted ammonia nitrogen concentration for future times was output.

[0008] In a first aspect, the present invention provides a preferred embodiment in which, in the step of acquiring historical operation data of wastewater treatment, extracting multiple key variables from the historical operation data, and constructing a sample set of time series data containing multiple variables, an input-output sample set is constructed using a sliding time window method, the input is set to be a multivariate sequence that is not continuous for r hours, and the output is the effluent ammonia nitrogen concentration for the next k hours, thereby obtaining the sample set of the multivariate time series data.

[0009] In a first aspect, the present invention provides a preferred embodiment in which, after the steps of acquiring historical operation data of wastewater treatment, extracting multiple key variables from the historical operation data, and constructing a sample set containing multivariate time series data, the invention further includes: establishing a mechanistic model of the wastewater treatment process based on the AAO process flow, and using the output of the mechanistic model as a near-true value for use as a target reference during the training of the effluent ammonia nitrogen prediction model.

[0010] The present invention provides a preferred embodiment in the first aspect, wherein after the steps of obtaining historical operation data of wastewater treatment, extracting multiple key variables from the historical operation data, and constructing a sample set containing multivariate time series data, the method further includes: normalizing the sample set and time series interpolation alignment to obtain a sample set with consistency and completeness.

[0011] The present invention provides a preferred embodiment in the first aspect, wherein the time series model adopts a BiGRU model to extract bidirectional time series features of multivariate time series data; the BiGRU model consists of two GRU units in opposite directions: one for forward processing and the other for reverse processing, and the outputs of the two directions are concatenated to form a complete representation of the current time step; the input of the BiGRU model is multivariate time series data within a sliding time window, and the output of the BiGRU model is a bidirectional hidden state representation of each time step.

[0012] In a first aspect, the present invention provides a preferred embodiment in which one of the attention heads in the multi-head attention layer is specifically used to model the relationship between aeration rate and effluent ammonia nitrogen.

[0013] In a first aspect, the present invention provides a preferred embodiment in which, in the steps of training, validating and testing the constructed effluent ammonia nitrogen prediction model based on a sample set, the mean square error is used as the main loss function to guide the backpropagation and updating of the neural network parameters during the training process; and four performance indicators, namely mean absolute percentage error, mean absolute error, root mean square error and coefficient of determination, are introduced for model evaluation and comparison.

[0014] In a first aspect, the present invention provides a preferred embodiment in which the fully connected output layer adopts a linear activation function to maintain the predicted value as a continuous real number; and supports rolling prediction of effluent ammonia nitrogen for future single or multi-step time periods.

[0015] The present invention provides a preferred embodiment in a first aspect, wherein the water quality indicators include: COD, ammonia nitrogen, total nitrogen (TN), and total phosphorus (TP).

[0016] In a second aspect, this invention provides an effluent ammonia nitrogen prediction system based on time series and multi-head attention, used to execute the above-mentioned method, comprising: a data acquisition and processing module, used to acquire historical operation data of wastewater treatment, extract multiple key variables from the historical operation data, and construct a sample set containing multivariate time series data; wherein, the multiple key variables include influent water quality indicators, influent flow rate, aeration rate, and return sludge volume; a model building module, used to construct an effluent ammonia nitrogen prediction model including a time series model, a multi-head attention layer, a splicing layer, and a fully connected output layer; wherein, the time series model is used to process multivariate time series data, the multi-head attention layer is set at the output end of the time series model, used to independently model and calculate the attention of at least one key variable as an attention head; the results calculated by each attention head are spliced ​​through the splicing layer and input into the fully connected output layer; a model training module, used to train, verify, and test the constructed effluent ammonia nitrogen prediction model based on the sample set to obtain the final effluent ammonia nitrogen prediction model; and an online prediction module, used to acquire online operation data of wastewater treatment, input it into the final effluent ammonia nitrogen prediction model, and output the predicted value of ammonia nitrogen concentration at future times.

[0017] Compared with the prior art, the present invention has the following advantages:

[0018] This invention presents a method and system for predicting effluent ammonia nitrogen concentration based on temporal series and multi-head attention. By constructing an effluent ammonia nitrogen prediction model combining temporal series and multi-head attention, it predicts the ammonia nitrogen concentration in treated wastewater. Temporal modeling enhances the model's ability to model dynamic wastewater treatment conditions, enabling real-time prediction. Simultaneously, key variables (such as aeration rate) are independently modeled and their attention calculated as attention heads, explicitly enhancing the model's ability to focus on and perceive key control variables, improving its responsiveness and interpretability, thereby achieving accurate prediction. Therefore, this invention can achieve high-precision, real-time prediction of ammonia nitrogen concentration in treated wastewater effluent, effectively replacing mechanistic-based models and adapting to the high-frequency, dynamic operating conditions of municipal wastewater treatment plants. Attached Figure Description

[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0020] Figure 1 A flowchart illustrating a method for predicting effluent ammonia nitrogen based on time series and multi-head attention, provided in a specific embodiment of the present invention;

[0021] Figure 2This is a block diagram of an effluent ammonia nitrogen prediction system based on time series and multi-head attention, provided in a specific embodiment of the present invention.

[0022] Figure 3 AAO processing flow chart;

[0023] Figure 4 This is a schematic diagram of the GRU structure;

[0024] Figure 5 This is a schematic diagram of the BiGRU structure;

[0025] Figure 6 This is a comparison chart showing the prediction results of effluent ammonia nitrogen concentration using the effluent ammonia nitrogen prediction model of this invention, various existing prediction models, and mechanistic models. Detailed Implementation

[0026] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0027] Please refer to Figure 1 In one optional embodiment, the technical solution adopted by the present invention is as follows: First, historical operating data is collected using the online monitoring system of a municipal wastewater treatment plant, key indicators are extracted, and a sample set is constructed. Then, a time-series model is used as the main time-series encoding module, followed by a multi-head attention mechanism. Finally, the model is trained to achieve the predicted output of effluent ammonia nitrogen. Specifically, an optional embodiment provides an effluent ammonia nitrogen prediction method based on time-series and multi-head attention, which is mainly implemented through the following steps:

[0028] S1. Obtain historical operation data of wastewater treatment, extract multiple key variables from the historical operation data, and construct a sample set containing multivariate time series data; among them, multiple key variables include influent water quality indicators, influent flow rate, aeration rate, and return sludge volume;

[0029] S2. Construct an effluent ammonia nitrogen prediction model that includes a time series model, a multi-head attention layer, a splicing layer, and a fully connected output layer. The time series model is used to process multivariate time series data. The multi-head attention layer is set at the output of the time series model to independently model and calculate the attention of at least one key variable as an attention head. The results calculated by each attention head are spliced ​​by the splicing layer and then input into the fully connected output layer.

[0030] S3. Based on the sample set, train, validate and test the constructed effluent ammonia nitrogen prediction model to obtain the final effluent ammonia nitrogen prediction model;

[0031] S4. Obtain online operation data of wastewater treatment, input the final effluent ammonia nitrogen prediction model, and output the predicted ammonia nitrogen concentration value at future times.

[0032] Please refer to Figure 2 Correspondingly, to implement the effluent ammonia nitrogen prediction method based on time series and multi-head attention presented in this embodiment, an effluent ammonia nitrogen prediction system based on time series and multi-head attention is provided to execute the above method. This system mainly includes the following components: a data acquisition and processing module 1, used to acquire historical operating data of wastewater treatment, extract multiple key variables from the historical operating data, and construct a sample set containing multivariate time series data; wherein, the multiple key variables include influent water quality indicators, influent flow rate, aeration rate, and return sludge volume; and a model building module 2, used to construct an effluent ammonia nitrogen prediction system containing a time series model, a multi-head attention layer, a splicing layer, and a fully connected output layer. The system comprises a water ammonia nitrogen prediction model, a time series model for processing multivariate time series data, a multi-head attention layer at the output of the time series model for independently modeling and calculating the attention of at least one key variable as an attention head, and the results calculated by each attention head concatenated by a splicing layer and input into a fully connected output layer. A model training module 3 is used to train, validate, and test the constructed effluent ammonia nitrogen prediction model based on a sample set to obtain the final effluent ammonia nitrogen prediction model. A prediction module 4 is used to acquire online operational data from wastewater treatment, input it into the final effluent ammonia nitrogen prediction model, and output the predicted ammonia nitrogen concentration for future times.

[0033] The present invention provides a method and system for predicting effluent ammonia nitrogen based on time-series and multi-head attention. By constructing an effluent ammonia nitrogen prediction model combining time-series and multi-head attention, the ammonia nitrogen concentration in treated wastewater is predicted. Time-series modeling enhances the model's ability to model dynamic operating conditions of wastewater treatment, enabling real-time prediction. Simultaneously, key variables (such as aeration rate) are independently modeled and their attention calculated as attention heads, explicitly enhancing the model's ability to focus on and perceive key control variables, improving its responsiveness and interpretability, thereby achieving accurate prediction. Therefore, the present invention can achieve high-precision, real-time prediction of ammonia nitrogen concentration in treated wastewater effluent, effectively replacing mechanistic models and adapting to the high-frequency, dynamic operating conditions of municipal wastewater treatment plants.

[0034] Based on the above implementation methods and steps, a more preferred and specific implementation method for predicting effluent ammonia nitrogen based on time series and multi-head attention is given as follows:

[0035] S1. Obtain historical operational data of the wastewater treatment plant, extract multiple key variables from the historical operational data, and construct a sample set containing multivariate time series data; wherein, the multiple key variables include influent water quality indicators, influent flow rate, aeration rate, and return sludge volume. This step is essentially processing the historical operational data collected by the wastewater treatment plant's online monitoring system. In a more preferred embodiment, this data processing step mainly includes the following sub-steps:

[0036] S11. First, a mechanistic model of the wastewater treatment process is established based on the AAO process flow. The simulation results of the mechanistic model are used as the target output for training the effluent ammonia nitrogen prediction model of this invention. That is, as a reference for model fitting the quasi-realistic system output, the AAO treatment process flow... Figure 3 As shown.

[0037] S12. Then, extract the key variables required for modeling from the monitoring data, including influent water quality indicators (such as COD, ammonia nitrogen, total nitrogen TN, total phosphorus TP), influent flow rate, aeration rate, and return sludge volume.

[0038] S13. Next, an input-output sample set is constructed using a sliding time window method. The input is set as a multivariate sequence of r consecutive hours, and the output is the effluent ammonia nitrogen concentration in the next k hours, thereby obtaining the sample set of the multivariate time series data.

[0039] S14. Finally, the sample set is divided into training set, validation set and test set, and normalization and time series interpolation alignment are performed uniformly to ensure the consistency and integrity of sample input and output.

[0040] S2. Construct an effluent ammonia nitrogen prediction model comprising a time series model, a multi-head attention layer, a splicing layer, and a fully connected output layer; wherein, the time series model is used to process multivariate time series data, the multi-head attention layer is set at the output of the time series model, and is used to independently model and calculate the attention of at least one key variable as an attention head; the results calculated by each attention head are spliced ​​by the splicing layer and then input into the fully connected output layer. This step is, in fact, a prediction model construction process. In a more preferred embodiment, this prediction model construction step mainly includes the following sub-steps:

[0041] S21. Constructing a time series model. In a preferred embodiment, the time series model employs a BiGRU model to extract bidirectional time series features from multivariate time series data. The BiGRU model consists of two GRU units operating in opposite directions: one for forward processing and the other for reverse processing. The outputs from both directions are then concatenated to form the complete representation of the current time step. The input to the BiGRU model is the multivariate time series data within a sliding time window, and the output of the BiGRU model is the bidirectional hidden state representation for each time step.

[0042] GRU is a recurrent neural network architecture used to process time-series data. It improves the model's ability to model long-term time-dependent features by introducing a gating mechanism to control the retention and forgetting of historical information. Compared with traditional RNNs, GRU has a simpler structure, higher computational efficiency, and is suitable for modeling dynamic systems with nonlinear and time-delay characteristics, such as wastewater treatment processes.

[0043] The GRU cell mainly consists of two gating structures: the update gate and the reset gate. The update gate controls the extent to which the current cell state retains historical information, while the reset gate controls the degree to which new inputs are integrated with historical states, thereby enabling dynamic modeling of time dependencies. Its structure diagram is shown below. Figure 4 As shown, the state update formula is as follows:

[0044] r t =σ(W r ·[h t-1 ,x t (1)

[0045]

[0046] z t =σ(W z ·[h t-1 ,x t (3)

[0047]

[0048] Among them, h t-1 and h t x represents the state of the wastewater treatment system at time steps t-1 and t, respectively. t At time step t, the input is the sigmoid activation function σ, and W... r W and W z These represent different sets of parameter weights. Reset gate r t Defined by equations (1)-(2), it determines the value of h t-1 How much information is retained, and how much is updated in gate z? t Defined by equations (3)-(4), the previous state h is controlled. t-1 With candidate hidden state The trade-off between these factors affects the final hidden state h. t .

[0049] BiGRU is an extension of GRU, designed to utilize both forward and backward information from time series data to enhance the model's ability to express contextual information. BiGRU consists of two GRU units operating in opposite directions: one for forward processing (from time step 1 to T), and the other for backward processing (from T to 1). The outputs from both directions are then concatenated to provide a complete representation of the current time step. This structure can better capture complex causal relationships and feedback paths between variables. Its structure is illustrated below. Figure 5 As shown. Among them, Figure 5 The meanings of each parameter are as follows:

[0050] x t This represents the water inflow input vector from time t-9 to time t. and Let b and h represent the hidden states of the forward and backward GRUs at time t, respectively, where b represents the bias term corresponding to the hidden layer, and h represents the hidden state. t This represents the final hidden state at time t.

[0051] In this embodiment, the BiGRU model serves as the master time encoder for the effluent ammonia nitrogen prediction model. Its input consists of multivariate sequence data within a sliding time window (including influent water quality indicators, operating load parameters, etc.), and its output is a bidirectional hidden state representation for each time step. This structure can simultaneously model the evolution trend of historical operating conditions and the lag response mechanism of future prediction indicators, significantly improving the model's fitting accuracy and prediction robustness for non-stationary dynamic processes.

[0052] The output features of the BiGRU model will be used as input to the next layer of multi-head attention mechanism to further identify the influence weights of different variables in the prediction task, thereby enhancing the model's interpretability and ability to perceive key variables.

[0053] In some alternative implementations, the timing model can be replaced by the following structural models:

[0054] (1) Unidirectional GRU or LSTM structure is used to extract unidirectional time-dependent features;

[0055] (2) The Transformer Encoder structure has global modeling capabilities and is suitable for long sequence prediction tasks;

[0056] (3) TCN (Temporal Convolutional Network) structure, which extracts features through one-dimensional dilated convolution.

[0057] S22. Construct a multi-attention layer, a splicing layer, and a fully connected output layer to obtain an effluent ammonia nitrogen prediction model.

[0058] Attention mechanisms are important structures used for weighting input features. Originally applied in natural language processing tasks, they can be used to automatically learn the importance of each time step or dimension of a variable in an input sequence for the current prediction task. In time series modeling tasks, attention mechanisms can effectively address the problem of "different input features having different degrees of influence on the output," thereby improving the model's ability to identify key variables and its prediction accuracy.

[0059] Multi-head attention mechanisms are an extension of single-head attention mechanisms. By setting up multiple independent attention subspaces, they can focus on and model input features in parallel from different perspectives. Each attention head can perform adaptive weighted calculations using its own query vector, key vector, and value vector. Finally, the outputs of multiple subspaces are concatenated and fused to form the final context vector for subsequent prediction.

[0060] In a preferred embodiment of the present invention, considering that aeration rate is one of the most important control variables in the wastewater treatment process and has a direct impact on the change of effluent ammonia nitrogen concentration, a dedicated attention head for aeration characteristics (aeration rate) is specifically introduced into the multi-head attention mechanism to independently model the correlation path between aeration variables and effluent ammonia nitrogen. This attention head generates a query, key, and value based on the aeration variable, performs feature weighting through a self-attention mechanism, and is subsequently concatenated with the outputs of other attention heads before being input into the fully connected output layer. The other attention heads are ordinary heads, and their input includes all influent data.

[0061] The core technical advantages of this structural design are: on the one hand, it enhances the model's feature separation capability under multivariate input conditions, avoiding the averaging of key variable features; on the other hand, it improves the model's response capability and interpretability to control variables, enabling the model to structurally identify the causal chain between "control variables → water output indicators"; at the same time, it keeps the overall model structure parameters controllable, making it suitable for engineering deployment scenarios.

[0062] Finally, the output features of all attention heads are concatenated and fed into the fully connected output layer as input to the next effluent ammonia nitrogen prediction module, thus completing the feature aggregation and modeling information fusion.

[0063] The effluent ammonia nitrogen prediction model proposed in the above embodiments of the present invention consists of a BiGRU model (also known as a BiGRU encoding module), a multi-head attention mechanism layer, a splicing layer, and a fully connected output layer. Its final prediction output is the effluent ammonia nitrogen concentration at a future time.

[0064] After completing BiGRU encoding and multi-head attention weighting, the context feature vector generated by the model contains the temporal evolution characteristics of each input variable and its influence on the target variable (effluent ammonia nitrogen concentration). To achieve specific concentration prediction, this embodiment concatenates the outputs of multiple attention heads and inputs them into a fully connected layer for regression prediction, generating predicted effluent ammonia nitrogen concentration values ​​for future time steps.

[0065] The fully connected output layer employs a linear activation function to maintain continuous real values ​​in the predicted values, making it suitable for predicting physical quantities in wastewater treatment processes. The model can flexibly configure the output dimensions according to the deployment scenario, such as outputting the ammonia nitrogen concentration at a single time step, or outputting the ammonia nitrogen concentration trend for multiple consecutive time steps in the future, achieving single-step prediction or multi-step rolling prediction.

[0066] The fully connected output layer supports interface integration with existing process control systems in wastewater treatment plants. Predicted values ​​can be used as input for subsequent functional modules such as aeration rate control, setpoint adjustment, or process status assessment. Simultaneously, the predicted results can be compared with real-time monitoring values ​​to construct a prediction error closed loop, providing a basis for dynamic model fine-tuning.

[0067] S3. Based on the sample set, train, validate, and test the constructed effluent ammonia nitrogen prediction model to obtain the final effluent ammonia nitrogen prediction model. The dataset (sample set) used for model training is divided into training set, validation set, and test set in chronological order. The validation set is used to monitor the generalization ability of the model during training, and the test set is used to evaluate the final performance of the model. The model training process uses online sampling data from real wastewater treatment plants, with a time span of no less than 24 months, a sampling interval of no more than 2 hours, and a training sample size of no less than 5000 sets.

[0068] To achieve high-precision modeling and generalization capabilities, the model needs to be trained in a supervised manner. The training samples are a sample set constructed through a sliding window, that is, a sample set containing multivariate time series data. The target output is the simulation results of the mechanism model.

[0069] During training, mean squared error (MSE) is used as the primary loss function to guide the backpropagation and update of neural network parameters. In addition, four other performance metrics are introduced for model evaluation and comparison: mean absolute percentage error (MAPE), mean absolute error (MAE), root mean square error (RMSE), and coefficient of determination (R²). 2 Its expression is as follows:

[0070]

[0071] in, For the predicted value, y i This represents the actual value (i.e., the simulation result of the mechanism model). is the mean of the actual values, and N is the total number of samples.

[0072] To verify the effectiveness of the effluent ammonia nitrogen prediction model proposed in this invention, online monitoring data from a real-world municipal wastewater treatment plant was selected, with a sampling period of 2 hours. The model was trained and validated using this real dataset, and the simulation results of the SUMO mechanistic model (a type of AAO mechanistic model) were used as the target output to evaluate whether the effluent ammonia nitrogen prediction model can effectively replace the mechanistic model and achieve accurate modeling of the wastewater treatment process.

[0073] In the experimental section, to verify the effectiveness of the effluent ammonia nitrogen prediction model of this invention, its prediction performance was compared with that of the mechanistic model, and it was also compared with existing mainstream data-driven models such as GRU-Attention, BiGRU, and standard GRU. The comparison figures are shown below. Figure 6 As shown. All comparison models used the same network structure and hyperparameter configuration, and were trained for 10 epochs respectively. The epoch with the best performance was selected as the evaluation result.

[0074] Experimental data show that the effluent ammonia nitrogen prediction model (BGMA) of this invention exhibits significantly superior prediction accuracy. The results demonstrate that the surrogate model proposed in this invention, based on the fusion of BiGRU and multi-head attention mechanism, achieves better prediction accuracy in RMSE, MAE, MAPE, and R... 2 It outperforms existing mainstream models in many evaluation indicators, has higher prediction accuracy and stronger generalization ability, and can effectively replace traditional mechanistic models to meet the accuracy and real-time requirements of municipal sewage treatment systems for predicting effluent ammonia nitrogen concentration.

[0075] S4. Acquire online operational data from the wastewater treatment plant, input it into the final effluent ammonia nitrogen prediction model, and output the predicted ammonia nitrogen concentration for future times. The effluent ammonia nitrogen prediction model, after training, validation, and testing, can be used in practical applications. By inputting the online monitoring data from the corresponding wastewater treatment plant into the model, the predicted ammonia nitrogen concentration for future times can be obtained, thus achieving prediction. The prediction model supports rolling predictions of effluent ammonia nitrogen for single or multiple time periods in the future. The output results can be used for process control, setpoint adjustment, or early warning decisions in the wastewater treatment system.

[0076] Based on the above embodiments, the present invention can achieve the following beneficial technical effects:

[0077] (1) This invention constructs a proxy model for predicting effluent ammonia nitrogen concentration in municipal wastewater treatment processes based on the fusion of a bidirectional gated cyclic unit (BiGRU) and a multi-head attention mechanism. The aim is to improve the modeling accuracy and inference efficiency of key water quality indicators, especially the prediction accuracy of key water quality indicators such as effluent ammonia nitrogen and the efficiency of model deployment in engineering, thus overcoming the shortcomings of existing models in structural expression and engineering application. By simultaneously extracting forward and backward dependency information of the time series through the BiGRU structure, the model's ability to model dynamic conditions of wastewater treatment is improved. Simultaneously, a multi-head attention mechanism is introduced, setting up a dedicated aeration feature attention head in the model structure to handle aeration variables, explicitly enhancing the model's attention to and perception of key control variables, and achieving interpretable modeling. Experiments show that, under the condition of using the SUMO mechanism model as the quasi-real system output, this proxy model exhibits higher accuracy and faster inference speed in the effluent ammonia nitrogen prediction task compared to GRU, BiGRU, and GRU-Attention models, improving computational efficiency by approximately 60 times compared to the SUMO mechanism model. It possesses strong real-time prediction capabilities and can serve as an effective replacement for the mechanism model. This invention is applicable to typical municipal wastewater treatment process scenarios, especially for activated sludge systems using biological processes such as AAO. Its modeling inputs include multi-dimensional time-series variables such as historical influent water quality parameters, aeration intensity, and operating load, and the output is the predicted effluent ammonia nitrogen concentration.

[0078] (3) This invention first extracts forward and backward features of the input sequence simultaneously based on a bidirectional GRU structure, effectively capturing the long-term dependencies and dynamic trends between variables in the wastewater treatment process. Subsequently, a multi-head attention mechanism is introduced into the model structure, using multiple parallel subspaces to weighted model the input features and extract key semantics from different perspectives. A dedicated attention head for aeration features is specifically set up, enabling the model to explicitly focus on the impact of aeration, a key control variable, on effluent quality, thereby enhancing the interpretability and accuracy of the prediction. Furthermore, the prediction model of this invention uses a rolling time window for training and prediction, exhibiting good temporal adaptability. Therefore, this invention can serve as an efficient alternative to mechanistic models such as SUMO, for rapid prediction and engineering modeling of effluent quality in wastewater treatment systems. Specifically, it integrates a bidirectional GRU structure and a multi-head attention mechanism to enhance sequence modeling capabilities. A dedicated attention channel for aeration features is set up to improve the modeling effect of key variables. The rolling sequence method improves prediction stability and dynamic response capabilities. Alignment with the output of the mechanistic model achieves a high-precision replacement of the surrogate model. Experimental results show that the present invention exhibits high prediction accuracy under multiple typical wastewater treatment conditions, and the model structure is stable, making it suitable for deployment in intelligent control systems of wastewater treatment plants. It provides an efficient and practical technical solution for digital modeling and operational optimization of municipal wastewater treatment processes. Therefore, this method can be widely applied to scenarios such as digital operation, predictive control, and process optimization in municipal wastewater treatment plants, demonstrating strong engineering adaptability and promotional value.

[0079] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.

[0080] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification. Furthermore, the above embodiments only illustrate several implementation methods of the present invention, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the present invention. For those skilled in the art, several modifications and improvements can be made without departing from the concept of the present invention, and these all fall within the protection scope of the present invention.

Claims

1. A method for predicting effluent ammonia nitrogen based on time series and multi-head attention, characterized in that, include: Historical operation data of wastewater treatment was obtained, and multiple key variables were extracted from the historical operation data to construct a sample set containing multivariate time series data. Among them, multiple key variables include influent water quality indicators, influent flow rate, aeration rate and return sludge volume. A predictive model for effluent ammonia nitrogen was constructed, comprising a time series model, a multi-head attention layer, a splicing layer, and a fully connected output layer. The time series model was used to process multivariate time series data. The multi-head attention layer was set at the output of the time series model to independently model and calculate the attention of at least one key variable as an attention head. The results calculated by each attention head were spliced ​​by the splicing layer and then input into the fully connected output layer. The effluent ammonia nitrogen prediction model was trained, validated, and tested based on the sample set to obtain the final effluent ammonia nitrogen prediction model. The system acquires online operational data from wastewater treatment, inputs it into the final effluent ammonia nitrogen prediction model, and outputs predicted ammonia nitrogen concentration values ​​for future times.

2. The method for predicting effluent ammonia nitrogen based on time series and multi-head attention as described in claim 1, characterized in that, In the step of acquiring historical operation data of wastewater treatment, extracting multiple key variables from the historical operation data, and constructing a sample set of time series data containing multiple variables, a sliding time window method is used to construct the input and output sample sets. The input is set to be a multivariate sequence that is not continuous for r hours, and the output is the effluent ammonia nitrogen concentration for the next k hours, thereby obtaining the sample set of the multivariate time series data.

3. The method for predicting effluent ammonia nitrogen based on time series and multi-head attention as described in claim 1, characterized in that, After the steps of acquiring historical operation data of wastewater treatment, extracting multiple key variables from the historical operation data, and constructing a sample set containing multivariate time series data, the method further includes: establishing a mechanism model of the wastewater treatment process based on the AAO process flow, and using the simulation results of the mechanism model as the target output when training the effluent ammonia nitrogen prediction model of this invention.

4. The method for predicting effluent ammonia nitrogen based on time series and multi-head attention as described in claim 1, characterized in that, After the steps of obtaining historical operation data of wastewater treatment, extracting multiple key variables from the historical operation data, and constructing a sample set of time series data containing multiple variables, the method further includes: normalizing the sample set and time series interpolation alignment to obtain a sample set with consistency and completeness.

5. The method for predicting effluent ammonia nitrogen based on time series and multi-head attention as described in claim 2, characterized in that, The time series model employs a BiGRU model to extract bidirectional time series features from multivariate time series data. The BiGRU model consists of two GRU units operating in opposite directions: one for forward processing and the other for reverse processing. The outputs from both directions are then concatenated to form the complete representation of the current time step. The input to the BiGRU model is the multivariate time series data within a sliding time window, and the output of the BiGRU model is the bidirectional hidden state representation for each time step.

6. The method for predicting effluent ammonia nitrogen based on time series and multi-head attention as described in claim 1, characterized in that, One of the attention heads in the multi-head attention layer is specifically used to model the relationship between aeration rate and effluent ammonia nitrogen.

7. The method for predicting effluent ammonia nitrogen based on time series and multi-head attention as described in claim 1, characterized in that, In the steps of training, validating, and testing the constructed effluent ammonia nitrogen prediction model based on the sample set, the mean square error is used as the main loss function to guide the backpropagation and updating of the neural network parameters during the training process; and four performance indicators, namely mean absolute percentage error, mean absolute error, root mean square error, and coefficient of determination, are introduced for model evaluation and comparison.

8. The method for predicting effluent ammonia nitrogen based on time series and multi-head attention as described in claim 1, characterized in that, The fully connected output layer uses a linear activation function to keep the predicted values ​​continuous real numbers; and supports rolling prediction of effluent ammonia nitrogen for future single or multi-step time periods.

9. The method for predicting effluent ammonia nitrogen based on time series and multi-head attention as described in claim 1, characterized in that, The water quality indicators include: COD, ammonia nitrogen, total nitrogen (TN), and total phosphorus (TP).

10. A time-series and multi-head attention-based effluent ammonia nitrogen prediction system, used to perform the method as described in any one of claims 1 to 9, characterized in that, include: The data acquisition and processing module is used to acquire historical operation data of wastewater treatment, extract multiple key variables from the historical operation data, and construct a sample set containing multivariate time series data; among which, multiple key variables include influent water quality indicators, influent flow rate, aeration rate, and return sludge volume; The model building module is used to construct an effluent ammonia nitrogen prediction model that includes a time series model, a multi-head attention layer, a splicing layer, and a fully connected output layer. The time series model is used to process multivariate time series data. The multi-head attention layer is set at the output of the time series model to independently model and calculate the attention of at least one key variable as an attention head. The results calculated by each attention head are spliced ​​by the splicing layer and then input into the fully connected output layer. The model training module is used to train, validate, and test the constructed effluent ammonia nitrogen prediction model based on the sample set, so as to obtain the final effluent ammonia nitrogen prediction model. The online prediction module is used to acquire online operation data of wastewater treatment, input the final effluent ammonia nitrogen prediction model, and output the predicted value of ammonia nitrogen concentration at future times.

Citation Information

Cited By

  • Water quality multi-step prediction method, device and equipment and storage medium

    CN121765287A