Real-time Detection Method for Effluent Ammonia Nitrogen Concentration Based on Hierarchical Fusion Neural Network
By layered fusion neural network architecture and elite roulette selection strategy, the real-time and accuracy of effluent ammonia nitrogen concentration detection in the existing technology is solved, and efficient and low-cost ammonia nitrogen concentration detection is achieved under complex working conditions, improving detection accuracy and robustness.
Patent Information
- Application Number
- CN202510502633.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-22
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2045-04-22
AI Technical Summary
In the prior art, traditional detection methods have long detection cycles, high cost and complex operations, while the online ammonia nitrogen monitoring instrument has reduced reliability when facing load changes and pollutant fluctuations in the wastewater treatment process. The machine learning-based model does not pay enough attention to the higher-order nonlinearity and multivariate correlation of the ammonia nitrogen conversion process, making it difficult to achieve real-time and accurate detection of ammonia nitrogen concentration in the effluent.
A hierarchical fusion neural network architecture is adopted, combining fuzzy neural network (FNN), long and short-term memory network (LSTM) and polynomial neural network (PNN), and using elite roulette selection (ERWS) strategy, a real-time detection method of effluent ammonia nitrogen concentration is established, fuzzing and nonlinear mapping is performed through the Gaussian membership function, timing information is captured using a sliding window, and high-order fitting and residual correction are performed through the polynomial neural network.
It improves the accuracy and robustness of detection, maintains good prediction accuracy under complex operating conditions, reduces hardware expansion requirements and maintenance costs, enhances the robustness and noise resistance of the model, and realizes real-time accurate measurement of the ammonia nitrogen concentration in the effluent.
Smart Images

Figure CN120028508B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of urban sewage treatment detection, and specifically relates to a real-time detection method for the ammonia nitrogen concentration in the effluent based on a hierarchical fusion neural network. Background Art
[0002] The stability of the urban sewage treatment system is closely related to the monitoring of the effluent water quality. Among them, the ammonia nitrogen concentration in the effluent, as one of the key indicators, directly reflects the sewage treatment effect and the ecological environment safety. The currently commonly used detection methods for the ammonia nitrogen concentration in the effluent mainly include two methods: traditional detection methods and instrument detection methods.
[0003] The traditional detection methods mainly include the Nessler reagent spectrophotometry or other detection methods based on chemical analysis. Although the detection accuracy is high, there are problems such as long detection cycle, high cost, and complex operation process, which are difficult to meet the real-time monitoring requirements of the sewage treatment process.
[0004] In contrast, although the on-line ammonia nitrogen monitoring instrument can achieve real-time detection, it generally has problems such as high maintenance cost and unstable measurement. Especially in the working conditions where the influent load changes significantly or the pollutant composition fluctuates greatly, the reliability of the instrument decreases.
[0005] At present, measurement models based on machine learning or deep learning have attracted much attention, such as a single fuzzy neural network (FNN) or long short-term memory network (LSTM). Although they can effectively capture the non-linear or time series characteristics of input variables, they often pay insufficient attention to the high-order non-linearity and multi-variable correlation in the ammonia nitrogen conversion process, and it is difficult to comprehensively describe the complex biochemical reaction process in the sewage treatment process, resulting in the detection accuracy still to be improved. To address the above problems, there is an urgent need to establish a real-time, accurate, and robust measurement method to achieve accurate and rapid detection of the ammonia nitrogen concentration in the effluent, so as to ensure the stability of the sewage treatment process and the continuous compliance of the effluent water quality. Summary of the Invention
[0006] Aiming at the problems of insufficient model representation ability and weak generalization performance when facing non-linear, non-stationary and time-series dependence problems in the prior art, the purpose of the present invention is to provide a hierarchical neural network architecture that integrates a fuzzy neural network (FNN), a long short-term memory network (LSTM), and a polynomial neural network (PNN), and combines an elite roulette wheel selection (ERWS) strategy to achieve a real-time detection method for the ammonia nitrogen concentration in the sewage effluent with accurate prediction.
[0007] To achieve the above purpose, the technical solution adopted by the present invention is: a real-time detection method for the ammonia nitrogen concentration in the effluent based on a hierarchical fusion neural network, including the following steps:
[0008] Step 1: Collect the index parameters that affect the ammonia nitrogen concentration in the effluent during the sewage treatment process, define the input matrix X, mark the collected ammonia nitrogen concentration in the effluent as the target data Y, normalize the input matrix X and the target data Y, and divide the normalized data into a training set, a validation set, and a test set as the input and output of the subsequent model;
[0009] Step 2: Establish an FNN structure with Gaussian membership functions, perform fuzzification and non-linear mapping processing on the input matrix X, and extract the non-linear features in the original multi-dimensional input matrix X;
[0010] Step 3: Construct a time series sample from the output of the retained FNN structure and the target data Y, set a sliding window, intercept segments from the time series to predict the ammonia nitrogen concentration in the effluent, capture the time series information in the LSTM layer, iteratively update the LSTM parameters through backpropagation, and calculate the prediction error of each LSTM on the validation set;
[0011] Step 4: Introduce a polynomial neural network PNN to perform high-order fitting and residual correction on the non-linear features extracted in Step 2 and the time series dependencies captured in Step 3, and obtain a hierarchical fusion neural network model of "FNN→LSTM→PNN";
[0012] Step 5: Input the index parameters that affect the ammonia nitrogen concentration in the effluent into the hierarchical fusion neural network model of "FNN→LSTM→PNN" to output the prediction result of the ammonia nitrogen concentration in the effluent.
[0013] In the above real-time detection method of ammonia nitrogen concentration in the effluent based on a hierarchical fusion neural network, in Step 1, the index parameters include the effluent oxidation-reduction potential, dissolved oxygen at the aerobic end, total solid suspended matter, nitrate nitrogen in the effluent, and effluent pH value.
[0014] In the above real-time detection method of ammonia nitrogen concentration in the effluent based on a hierarchical fusion neural network, in Step 1, the input matrix X is obtained by arranging the collected N samples in chronological order, , where, represents the feature vector of the i-th sample, M represents the input dimension, and T is the matrix transpose symbol;
[0015] The target data , where, represents the ammonia nitrogen concentration value corresponding to the i-th sample. After normalization, the data is mapped to the interval [0, 1].
[0016] In the above real-time detection method of ammonia nitrogen concentration in the effluent based on a hierarchical fusion neural network, in Step 2, the fuzzification and non-linear mapping processing is to fuzzify the input using r fuzzy rules and weight the response of each rule, and finally output a preliminary predicted value of ammonia nitrogen concentration.
[0017] The above real-time detection method for effluent ammonia nitrogen concentration based on a hierarchical fusion neural network, where step 2 includes:
[0018] Step 2-1: Establish an FNN structure: Design r fuzzy rules, each rule corresponding to an RBF node, including a center vector and a width , as well as the output layer weights ;
[0019] Step 2-2: Calculate the Gaussian membership degree. Calculate the distance between the incoming input vector and each center , and use the Gaussian function to obtain the response . Then, normalize the output of each RBF node to obtain the membership degree ;
[0020] Step 2-3: After obtaining all , multiply them by the output layer weights and sum them up to obtain the FNN output : ;
[0021] Step 2-4: Parallelly train randomly initialized FNNs. Use elite roulette wheel selection (ERWS) to screen, and select k FNNs with small retained errors on the validation set. Make predictions on the retained FNNs on the training set, validation set, and test set respectively, and splice them into a new feature matrix to provide input for the subsequent steps. Among them, represents the number of training set samples, k represents the number of FNN models retained after ERWS screening, represents the output value of the j-th retained FNN model for the i-th sample, R represents the set of real numbers, represents a real matrix space with m rows and k columns.
[0022] For the above real-time detection method for effluent ammonia nitrogen concentration based on a hierarchical fusion neural network, in step 2-2, the response , where represents the input vector of the -th sample, represents the number of features, is the value of this sample in the d-th dimension, represents the center of the j-th fuzzy rule in the d-th dimension, represents the width of the j-th fuzzy rule in the d-th dimension, is the exponential function, such that the activation degree Finally, in the range of (0,1], the activation values of all nodes are added together to obtain: ,like , then let , otherwise normalization yields , where r represents the number of fuzzy rules.
[0023] In the above-mentioned method for real-time detection of effluent ammonia nitrogen concentration based on hierarchical fusion neural network, step 3 comprises:
[0024] Step 3-1: Construct a time series sliding window of length w. The retained FNN layer output has k columns of features, and a size of The matrix Z1 of the sliding window processing is expressed as: , where s represents the starting subscript, Indicates the end of subscript;
[0025] Step 3-2: In a single-layer LSTM network, the hidden unit dimension is h. Inside the LSTM, these w inputs are regarded as a small batch with a sequence length of w. Let the internal time step t=1,2,…,w. The core formula of LSTM at time step t is:
[0026] ,
[0027] ,
[0028] ,
[0029] ,
[0030] ,
[0031] ,in, To receive the input vector, is the hidden state at time step t, is the hidden state of the previous time step, is the new candidate value, , , are the outputs of the forget gate, input gate, and output gate at time step t, respectively. is the cell state at time step t, , , , Respectively represent the connection input at time step t To the weight matrices of different gates, , , , is the bias term, is the sigmoid function, and ⊙ represents element-wise multiplication;
[0032] Step 3-3: When the LSTM processes the last step \(t = w\), its hidden state passes through the fully connected layer to obtain the output prediction ;
[0033] Step 3-4: Train LSTMs in parallel, calculate the error on the validation set, and retain LSTM outputs through ERWS screening.
[0034] The above real-time detection method for effluent ammonia nitrogen concentration based on a hierarchical fusion neural network, the said Step 4 includes:
[0035] Step 4-1: Denote the retained LSTM outputs as , representing the retained output variables;
[0036] Step 4-2: Construct quadratic polynomial features: , by traversing different column combinations, candidate polynomial neurons PN can be generated;
[0037] Step 4-3: Use least squares with regularization in PN to solve the regression coefficient vector β:
[0038] where, represents the polynomial expansion matrix in the training set, y represents the target value vector, λ represents the regularization coefficient, I represents the identity matrix, the regression coefficient vector , and e is the polynomial coefficient;
[0039] Step 4-4: Calculate the prediction error of each PN on the validation set, calculate the fitness, retain the optimal PN, and select its prediction result as the final output .
[0040] The above real-time detection method for effluent ammonia nitrogen concentration based on a hierarchical fusion neural network, the said calculation of fitness includes:
[0041] Step a: Let the true target be , the prediction be , the common loss function be the mean square error E, and the loss can be written as:
[0042] ;
[0043] Step b: During the training process, by performing gradient descent on , , to minimize the loss, the gradient of is approximated as: , where represents taking the partial derivative;
[0044] Step c: According to the chain rule, obtain the update direction. The gradient of is approximated as:
[0045] ,
[0046] The gradient of
[0047] is approximated as: represents the center of the j-th fuzzy rule in the d-th dimension, is the width of this rule in the d-th dimension, is the feature value of the i-th sample in the d-th dimension;
[0048] Step d: Calculate the mean square error of each FNN on the validation set. Let the error of the -th model be , and define the fitness: .
[0049] The beneficial effects of a real-time detection method for effluent ammonia nitrogen concentration based on a hierarchical fusion neural network of the present invention are as follows:
[0050] The technical solution of the present invention has strong generalization ability. FNN, LSTM, and PNN make full use of fuzzy membership, gated sequential learning, and high-order polynomial fitting in their respective dimensions, and can cover data distributions under various complex working conditions. Even if the data features change greatly with the process conditions, good prediction accuracy can be maintained through layer-by-layer correction and elite selection.
[0051] It has strong anti-noise ability. The fuzzy neural network first performs a smoothing mapping on the original data that is more sensitive to noise. LSTM can filter out high-frequency noise while capturing key sequential information, and polynomial regression refines and fits the remaining errors in the front. The combination of the three significantly improves the suppression effect of the overall model on noise interference.
[0052] The robustness is improved. By training multiple models in parallel at each layer and using ERWS for elite retention, it can ensure that the optimal model is not randomly eliminated, and gives sub-optimal models a certain "survival" chance, thereby reducing the sharp decline in performance caused by poor individual initialization or improper hyperparameter settings, and enhancing the overall robustness of the model.
[0053] Through the flexible combination of hierarchical series connection (FNN→LSTM→PNN) and elite roulette wheel selection (ERWS), it is possible to achieve real-time and accurate measurement of the ammonia nitrogen concentration in the effluent of sewage in a relatively low-cost computing environment, reduce the need for blindly expanding hardware equipment, and thus significantly reduce the overall system deployment and maintenance costs. Description of the Drawings
[0054] Figure 1 Schematic diagram of the detection model architecture in the embodiment of the present invention;
[0055] Figure 2 Schematic diagram of the FNN unit structure in the embodiment of the present invention;
[0056] Figure 3 Schematic diagram of the LSTM layer structure in the embodiment of the present invention;
[0057] Figure 4 Schematic diagram of the LSTM unit structure in the embodiment of the present invention;
[0058] Figure 5 Schematic diagram of the PN neuron structure in the embodiment of the present invention;
[0059] Figure 6 Schematic diagram of the real-time measurement effect of the ammonia nitrogen concentration in the effluent in the embodiment of the present invention. Detailed Embodiments
[0060] To enable those skilled in the art to better understand the technical solutions of the present invention, the technical solutions of the present invention will be described below in conjunction with the detailed embodiments and the drawings.
[0061] Embodiment 1
[0062] As Figure 1 shown, a real-time detection method for the ammonia nitrogen concentration in the effluent based on a hierarchical fusion neural network includes the following steps.
[0063] Step 1: Obtain sewage data. First, collect various indicators related to the ammonia nitrogen concentration in the effluent during the sewage treatment process, including but not limited to the effluent oxidation-reduction potential ORP (mV), dissolved oxygen DO (mg / l) at the end of aerobic treatment, total suspended solids TSS (mg / l), nitrate nitrogen NO3-N (mg / l) in the effluent, effluent pH, etc. Arrange the N collected samples in chronological order and define the input matrix:
[0064] , where is the feature vector of the i-th sample, and M represents the input dimension. At the same time, the collected ammonia nitrogen concentration in the effluent is recorded as:
[0065] ,
[0066] Among them, represents the effluent ammonia nitrogen concentration value (mg / L) corresponding to the i-th sample.
[0067] In order to make the features with different dimensions comparable when entering the model, the present invention normalizes the input data X and the target data Y, maps the data to the interval [0, 1], so as to reduce the training instability and the difficulty of model convergence caused by the too large numerical range. Then, the normalization results are respectively used as the input and output of the subsequent models (FNN, LSTM, PNN) to enter the next training and verification process.
[0068] Step 2: After collecting the above X and Y, first perform a "fuzzification" and non-linear mapping process on X.
[0069] The present invention uses an FNN with a Gaussian membership function (RBF) as the first-layer model. The core idea is: using r fuzzy rules to fuzzify the input and weighting the responses of each rule, and finally outputting a preliminary ammonia nitrogen concentration prediction value.
[0070] The implementation method is as follows:
[0071] First, establish the FNN structure: design r fuzzy rules, each rule corresponds to an RBF node, including the center vector and width , as well as the output layer weight .
[0072] Secondly, calculate the Gaussian membership: calculate the distance between the incoming input vector and each center , and obtain the response using the Gaussian function. After that, normalize the output of each RBF node to obtain the membership degree .
[0073] After obtaining all , multiply them by the output layer weight and sum them up to obtain the FNN output :
[0074] .
[0075] Finally, train FNNs in parallel: To improve the robustness, train randomly initialized FNNs at the same time, and then select the k best-performing FNNs on the validation set for the subsequent stage. Here, the elite roulette wheel selection (ERWS) is used. The FNNs with small validation set errors are directly retained as "elites", and then the other FNNs are screened by roulette according to the fitness ratio.
[0076] Through this step, the non-linear features in the original multi-dimensional input data X can be better extracted, enabling the subsequent model to work in a more "fuzzy and smooth" feature space, which helps reduce noise interference.
[0077] Step 3: Capture temporal information in the LSTM layer. First, set the sliding window: construct the retained FNN output and the true label target data Y into temporal samples, that is, use a sliding window of length w to intercept segments [s, s + 1,..., s + w - 1] from the time series as input to predict the ammonia nitrogen concentration in the effluent at time s + w.
[0078] Next, initialize LSTM models, each model includes an input layer with an input dimension of k, the number of FNN models after ERWS screening, that is, the number of features output by the previous layer, LSTM hidden layer units with a gating mechanism, and a fully connected output layer, and iteratively update the parameters of the LSTM layer through backpropagation.
[0079] Finally, calculate the prediction error of each LSTM on the validation set, and continue to use the ERWS screening method to retain the optimal LSTM outputs. This can take into account both fixing and retaining the optimal model, and randomly retaining some sub-optimal models to prevent overfitting.
[0080] Step 4: Use PNN (Polynomial Network) for high-order fitting and residual correction. Although the first two layers (FNN and LSTM) have initially captured the non-linearity and temporal dependence of the input data, under the complex and changeable conditions of urban sewage treatment, there is a non-linear coupling effect between multiple variables, which requires polynomial high-order terms and cross terms to describe. Therefore, the present invention introduces a polynomial neural network (PNN) in the third layer to further correct the outputs of the first two layers.
[0081] First, obtain the outputs of the parallel LSTMs. After training LSTMs in parallel in the second layer, use the validation set error and ERWS elite roulette selection to retain optimal models, and list their outputs on the training / validation / test sets as a new feature matrix.
[0082] Secondly, perform polynomial feature expansion. If the retained LSTM outputs contain 2 to 3 columns (or more), various column combinations can be enumerated, and polynomial features can be constructed respectively. For a given input combination, select a quadratic polynomial (including cross terms).
[0083] Next, on the generated feature matrix, PNN uses the following regularized least squares to solve the regression coefficients :
[0084] ,
[0085] Among them, represents the weight of each input feature in the model output, which is used to map the expanded feature matrix to the target variable . λ is the regularization coefficient. When λ>0, overfitting can be suppressed. When λ = 0, it degenerates to ordinary least squares. Subsequently, the error of each combination is calculated on the validation set, and the optimal PN (polynomial neuron) is screened again using ERWS.
[0086] Finally, a hierarchical fusion neural network model of "FNN→LSTM→PNN" is obtained, which can more accurately fit the potential high-order nonlinear and time-series features in the ammonia nitrogen concentration of the sewage effluent, thereby further reducing the residual error. Through this step, the present invention can introduce polynomial regression to describe complex high-order relationships while retaining the advantages of LSTM time-series features, thus significantly improving the measurement accuracy and generalization ability of the ammonia nitrogen concentration of the effluent.
[0087] Step 5: Input the parameters obtained that affect the ammonia nitrogen concentration of the effluent into the detection model determined in Steps 1 - 4, and the real-time accurate detection of the ammonia nitrogen concentration of the effluent can be realized, that is, the measured value is obtained .
[0088] Example 2
[0089] A real-time detection method for the ammonia nitrogen concentration of the effluent based on a hierarchical fusion neural network, combined with Figures 1-5 the schematic diagram of the detection model architecture in
[0090] Step 1: Obtain relevant characteristic variables from the sewage treatment system, including but not limited to the effluent oxidation-reduction potential ORP (mV), dissolved oxygen DO (mg / l) at the aerobic end, total suspended solids TSS (mg / l), effluent nitrate nitrogen NO3-N (mg / l), effluent pH, etc. Assume there are N samples in total, and construct the input matrix:
[0091] ,
[0092] Among them is the feature vector of the i-th sample, and M represents the input dimension.
[0093] Collect the ammonia nitrogen concentration of the effluent as the target data Y, denoted as:
[0094] ,
[0095] Among them represents the ammonia nitrogen value of the -th sample (which can be mg / L).
[0096] After normalization, the sorted data is divided into a training set of 60%, a validation set of 20%, and a test set of 20%, which are used for model training, hyperparameter validation, and final evaluation respectively.
[0097] Step 2: The processed data is processed through an FNN (Fuzzy Neural Network) layer. In the first layer of the present invention, a fuzzy neural network (FNN) in the RBF style is used to perform non - linear mapping and fuzzification on the input features. The main principle is as follows:
[0098] Suppose the FNN has r fuzzy rules (or RBF nodes). Each rule contains a "center" (with the same dimension as the input dimension M), a "width" and an "output layer weight" . For any input vector x, the activation value (Gaussian membership degree) of the j - th RBF node can be expressed as:
[0099] (1).
[0100] Sum the activation values of all nodes:
[0101] (2),
[0102] where r represents the number of fuzzy rules. If (to prevent division by zero), then let ; otherwise, normalize to get:
[0103] (3).
[0104] The final output of the FNN is:
[0105] (4).
[0106] Error and gradient update.
[0107] Let the true target be , the prediction be , and the common loss function be the mean squared error (MSE). Taking a single sample as an example, the loss can be written as:
[0108] (5).
[0109] During training, the loss is minimized by performing gradient descent on the FNN parameters (center , width and weight ).
[0110] Taking the weight as an example, its gradient approximation:
[0111] (6).
[0112] The central gradient and the width term gradient are approximately expressed as:
[0113] (7).
[0114] (8).
[0115] The above is the update direction obtained according to the chain rule. denotes taking the partial derivative.
[0116] Then, train FNNs in parallel. To reduce the unstable factors brought by random initialization, the present invention can train FNNs at one time. Then, perform ERWS screening: calculate the MSE of each FNN on the validation set. Let the error of the th model be , and define the fitness:
[0117] (9).
[0118] After sorting, retain the top NE FNNs as elites, and then perform roulette wheel selection on the remaining models according to the fitness ratio. Finally, retain optimal FNNs. For the retained FNNs, make predictions on the training set, validation set, and test set respectively, and splice them into a new feature matrix Z1 to provide input for the subsequent steps.
[0119] Step 3: Then, pass the spliced feature matrix to the next LSTM (Long Short-Term Memory Network) layer. Since the effluent ammonia nitrogen concentration has an obvious dependence in the time dimension, in order to further capture the dynamic features, the present invention introduces an LSTM model on the features output by the FNN.
[0120] The main idea is as follows:
[0121] First, construct a time series sliding window: If the final retained output of the FNN layer has k columns, then form a matrix of size for the training set. To enable the LSTM to learn the time correlation, the present invention uses a window length w to intercept w consecutive inputs from the sequence as a time series sample to predict the target value of the (w + 1)th item. Specifically, it can be denoted as:
[0122] (10).
[0123] where s represents the starting subscript, represents the ending subscript.
[0124] Taking a single-layer LSTM as an example, let the dimension of the hidden unit be h. The core formula of the LSTM at time step t is:
[0125] (11),
[0126] (12),
[0127] (13),
[0128] (14),
[0129] (15),
[0130] (16),
[0131] Among them, is sigmoid, ⊙ represents element-wise multiplication, is the received input vector, is the hidden state vector at time step t, and finally the hidden state at the last time step When, The output prediction is obtained through the fully connected layer , is the hidden state of the previous time step, is the new candidate value, , , are the outputs of the forget gate, input gate, and output gate at time step t respectively, is the cell state vector at time step t, , , , respectively represent the weights connecting the input to different gates at time step t, , , , is the bias term.
[0132] At the same time, similar to the FNN, the present invention will train LSTMs in parallel, calculate the error on the validation set, and retain the LSTM outputs through ERWS screening for use in subsequent polynomial networks.
[0133] Step 4: The output of the filtered LSTM layer is corrected at a high order through the PNN (Polynomial Network) layer. Under complex working conditions, there may be multivariable high-order interaction relationships among water quality indicators. In order to further reduce the residual error in addition to the non-linear and time-series information extracted by the first two layers, the present invention introduces a Polynomial Network (PNN) for fitting and correction.
[0134] First, if the second layer retains LSTM output columns, denoted as:
[0135] , these outputs are used to construct polynomial features. Each represents an output variable of a retained LSTM model.
[0136] Construct quadratic polynomial features:
[0137] (17).
[0138] By traversing different column combinations, candidate PNs (Polynomial Neurons) can be generated.
[0139] Let the polynomial expansion matrix in the training set be , with dimension . If the target value vector is y, then the regression coefficient vector β is solved using regularized least squares in the PN:
[0140] (18),
[0141] where, represents the polynomial expansion matrix in the training set, y represents the target value vector, λ represents the regularization coefficient, I represents the identity matrix, the regression coefficient vector , e is the polynomial coefficient, λ is the regularization coefficient, λ>0 can suppress overfitting; λ = 0 degenerates to ordinary least squares. In this embodiment, the function type of the PN neuron is a simplified quadratic polynomial , and represent the output variables of the i-th and j-th LSTM models retained after being screened by the Elite Roulette Wheel Selection Strategy (ERWS).
[0142] Then, calculate the prediction error of each PN on the validation set and calculate the fitness according to formula (9). Retain the optimal PN through "elitist retention + roulette wheel selection" and select its prediction result as the final output .
[0143] Step 5: As Figure 1As shown in the figure, the present invention constructs an effluent ammonia nitrogen detection model based on a "FNN-LSTM-PNN" hierarchical fusion neural network. In the initial stage, first, the fuzzy neural network (FNN) is used to preprocess the input data and extract deep non-linear features in the data: the original multi-dimensional variables are mapped into the fuzzy rule space through the Gaussian membership function, so as to capture the key features under different operating conditions and weaken the noise interference. Subsequently, after screening and splicing, the output of the FNN is transmitted to the long short-term memory network (LSTM) layer; this layer uses the gating mechanism (forget gate, input gate, output gate) to dynamically capture the long-term dependence relationship of time series data and effectively reveal the law of change of effluent ammonia nitrogen over time. Finally, in the third layer, the polynomial network (PNN) is used for high-order feature interaction combination and fitting correction to further explore potential non-linear coupling and cross relationships between variables.
[0144] In the above multi-layer model, the elite roulette wheel selection (ERWS) strategy is also integrated to perform multiple rounds of screening and retention on the FNN and LSTM models trained in parallel, so as to strengthen the attention to key features and excellent models and suppress the output of sub-models with poor performance under complex working conditions. Through this mechanism, the feature channels are dynamically adjusted and optimized, and finally more robust and generalized prediction results are obtained.
[0145] Step 6: Input the variables obtained that affect the effluent ammonia nitrogen concentration into the detection model determined in Steps 1-Step 5, and the effluent ammonia nitrogen concentration can be obtained. 。
[0146] To evaluate the performance of the model of the present invention, the root mean square error (RMSE) and the correlation coefficient (R 2 ) are used as evaluation indicators here, and the calculation formulas are respectively:
[0147] (19),
[0148] (20),
[0149] Among them, is the true measured value of the i th sample in the test set, is the detected value of the test set sample, is the mean value of the detected samples, and N is the number of samples.
[0150] Table 1 is a comparison result table of different algorithms. When comparing the performance of multiple models, including the FNN, LSTM, and PNN models, by deeply analyzing these two key statistical indicators of RMSE and R 2 , the present invention shows significant advantages, and the specific prediction results are as Figure 6As shown. Specifically, the present invention is far lower than other models in terms of RMSE, indicating that the difference between the detection results and the real data is small, and the detection accuracy is high. At the same time, the proposed hierarchical model R 2 is the highest, which can accurately mine the non-linear relationship between data and has a high fitting degree. At the same time, it only takes 1 second to process sewage data. These indicators show that the present invention can effectively improve the measurement accuracy and reduce the running time. The present invention is of great significance for improving the accuracy and real-time performance of the detection of the effluent ammonia nitrogen concentration.
[0151] Table 1: Comparison results of different algorithms
[0152] 。
[0153] The above embodiments are only for explaining the inventive concept and features of the present invention, and the purpose is to enable those of ordinary skill in the art to understand the content of the present invention and implement it accordingly. It should not be used to limit the protection scope of the present invention. Any equivalent changes or modifications made according to the essence of the content of the present invention should be covered within the protection scope of the present invention.
Claims
1. A real-time detection method for the ammonia nitrogen concentration in the effluent based on a hierarchical fusion neural network, characterized in that, It includes the following steps: Step 1: Collect the index parameters affecting the ammonia nitrogen concentration in the effluent during the sewage treatment process, define the input matrix X, mark the collected ammonia nitrogen concentration in the effluent as the target data Y, normalize the input matrix X and the target data Y, and divide the normalized data into a training set, a validation set, and a test set as the input and output of the subsequent model. The input matrix X is obtained by arranging the N collected samples in chronological order. , where represents the feature vector of the i-th sample, M represents the input dimension, and T is the matrix transpose symbol; The target data , where represents the effluent ammonia nitrogen concentration value corresponding to the i-th sample. After normalization, the data is mapped to the interval [0, 1]; Step 2: Establish an FNN structure with Gaussian membership functions, perform fuzzification and non-linear mapping on the input matrix X, and extract non-linear features from the original multi-dimensional input matrix X; Step 3: Construct the output of the retained FNN structure and the target data Y into time-series samples, set a sliding window, intercept segments from the time series to predict the concentration of ammonia nitrogen in water, capture time-series information in the LSTM layer, iteratively update the LSTM parameters through backpropagation, and calculate the prediction error of each LSTM on the validation set; Step 4: Introduce a polynomial neural network PNN to perform high-order fitting and residual correction on the non-linear features extracted in Step 2 and the time-series dependencies captured in Step 3, to obtain a hierarchical fusion neural network model of "FNN→LSTM→PNN"; Step 5: Input the index parameters affecting the concentration of ammonia nitrogen in the effluent into the hierarchical fusion neural network model of "FNN→LSTM→PNN", and output the prediction result of the concentration of ammonia nitrogen in the effluent.
2. The real-time detection method for the ammonia nitrogen concentration in the effluent based on the hierarchical fusion neural network according to claim 1, wherein, In Step 1, the index parameters include the oxidation-reduction potential of the effluent, dissolved oxygen at the aerobic end, total suspended solids, nitrate nitrogen in the effluent, and pH value of the effluent.
3. The real-time detection method for effluent ammonia nitrogen concentration based on a hierarchical fusion neural network according to claim 1, characterized in that In Step 2, the fuzzification and non-linear mapping process fuzzifies the input using r fuzzy rules, weights the responses of each rule, and finally outputs a preliminary predicted value of ammonia nitrogen concentration.
4. The real-time detection method for the ammonia nitrogen concentration in the effluent based on the hierarchical fusion neural network according to claim 3, characterized in that Step 2 includes: Step 2-1: Establish the FNN structure: Design r fuzzy rules, each rule corresponding to an RBF node, including the center vector and the width , as well as the output layer weights ; Step 2-2: Calculate the Gaussian membership degree. For the incoming input vector calculate the distance to each center and obtain the response using the Gaussian function . Then, normalize the outputs of each node in the RBF to obtain the membership degree ; Step 2-3: After obtaining all of them, multiply them with the output layer weights and sum them up to obtain the FNN output : ; Step 2-4: Parallel Training Randomly initialize FNNs, and use elite roulette selection ERWS to screen. Select k FNNs with small retained errors on the validation set. Make predictions for the retained FNNs on the training set, validation set, and test set respectively, and splice them into a new feature matrix , which provides input for subsequent steps. Among them, represents the number of training set samples, k represents the number of FNN models retained after ERWS screening, represents the output value of the j-th retained FNN model for the i-th sample, R represents the set of real numbers, represents a real matrix space with m rows and k columns.
5. The real-time detection method for the ammonia nitrogen concentration in the effluent based on the hierarchical fusion neural network according to claim 4, characterized in that, In the said step 2-2, in response to , where represents the input vector of the th sample, represents the number of features, is the value of this sample in the d-th dimension, represents the center of the j-th fuzzy rule in the d-th dimension, represents the width of the j-th fuzzy rule in the d-th dimension, is an exponential function such that the activation degree finally falls within the range (0, 1]. The activation values of all nodes are added together to obtain: , if , then let , otherwise normalize to obtain , where r represents the number of fuzzy rules.
6. The real-time detection method for the ammonia nitrogen concentration in the effluent based on the hierarchical fusion neural network according to claim 4, wherein, Step 3 includes: Step 3-1: Construct a time series sliding window of length w. The retained FNN layer output has k columns of features, and a size of The matrix Z1 of the sliding window processing is expressed as: , where s represents the starting subscript, Indicates the end of subscript; Step 3-2: In a single-layer LSTM network, the dimension of the hidden unit is h. Inside the LSTM, regard these w inputs as a mini-batch with a sequence length of w, and let the internal time step t = 1, 2, …, w. The core formula of the LSTM at time step t is: , , , , , , where is the received input vector, is the hidden state at time step t, is the hidden state of the previous time step, is the new candidate value, , , are the outputs of the forget gate, input gate, and output gate at time step t, respectively, is the cell state at time step t, , , , respectively represent the weight matrices connecting the input to different gates at time step t, , , , is the bias term, is the sigmoid function, and ⊙ represents element-wise multiplication; Step 3-3: When the LSTM processes the last step \(t = w\), its hidden state obtains the output prediction through the fully connected layer ; Step 3-4: Parallel training LSTMs, calculate the error on the validation set, and retain the LSTM outputs through ERWS screening.
7. The real-time detection method for effluent ammonia nitrogen concentration based on a hierarchical fusion neural network according to claim 6, characterized in that Step 4 includes: Step 4-1: Denote the remaining LSTM output columns as , which represents the remaining output variables; Step 4-2: Construct quadratic polynomial features: , by traversing different column combinations, candidate polynomial neurons PN can be generated; Step 4-3: Use least squares with regularization in the PN to solve the regression coefficient vector β: Among them, represents the polynomial expansion matrix in the training set, y represents the target value vector, λ represents the regularization coefficient, I represents the identity matrix, and the regression coefficient vector , and e is the polynomial coefficient; Step 4-4: Calculate the prediction error of each PN on the validation set, calculate the fitness, retain the optimal PN, and select its prediction result as the final output .
8. The real-time detection method for the ammonia nitrogen concentration in the effluent based on the hierarchical fusion neural network according to claim 7, wherein The calculation of fitness includes: Step a: Let the true target be , the prediction be , the common loss function be the mean squared error E, and the loss can be written as: ; Step b: During the training process, by performing , , gradient descent to minimize the loss, the gradient of is approximated as: , where denotes taking the partial derivative; Step c: Obtain the update direction according to the chain rule, The gradient of , The gradient approximation is: , where represents the center of the j-th fuzzy rule in the d-th dimension, is the width of this rule in the d-th dimension, is the eigenvalue of the i-th sample in the d-th dimension; Step d: Calculate the mean square error of each FNN on the validation set. Let the error of the -th model be , and define the fitness: .
Citation Information
Patent Citations
Knowledge-based robust effluent ammonia nitrogen soft measurement method
CN110542748A