LSTM water quality prediction method based on multilayer reverse cell state
By adopting a multi-layer reverse cell state LSTM model in water quality prediction, using the series structure of the biological treatment layer and the three-level treatment layer, inputting and verifying data in stages, the problems of low water quality prediction accuracy and slow response speed in traditional methods are solved. , achieving more accurate and efficient water quality prediction.
Patent Information
- Application Number
- CN202411372312.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2024-12-27
AI Technical Summary
Traditional water quality prediction methods have problems with low prediction accuracy and slow response when capturing the complex dynamic interaction between water plant operating status and water quality changes, and have failed to effectively utilize the status data of biological processing unit.
Using the LSTM water quality prediction method based on multi-layer reverse cell state, a multi-layer reverse cell state long and short-term memory network model is designed. Through the tandem structure of the biological treatment layer and the tertiary treatment layer, data are input and verified in stages, and the cell state is combined with the cell state. With the operating status of the water plant, achieve more accurate water quality prediction.
It improves the accuracy and efficiency of water quality prediction, can more effectively capture the operating status of the water plant and the biochemical reaction process, and enhances the interpretability of the model and data utilization efficiency.
Smart Images

Figure CN119204333A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of sewage treatment, and in particular to an LSTM water quality prediction method based on multi-layer reverse cell states. Background Art
[0002] With the acceleration of urbanization and the development of industry, the protection and utilization of water resources have become the focus of global attention. Water quality monitoring and management are important links in ensuring the safety of water resources. Traditional water quality prediction methods rely on empirical models and statistical methods, which often have problems such as low prediction accuracy, slow response speed, and difficulty in adapting to complex environmental changes. With the development of artificial intelligence technology, especially the successful application of deep learning technology in various fields, new ideas and methods have been provided for water quality prediction.
[0003] In the field of sewage treatment, the operation status and water quality changes of water plants are affected by many factors, including influent water quality, effluent data of biological treatment units, total effluent water quality, biological treatment unit status data, and dosage of reagents. There are complex dynamic interactions between these factors, and traditional prediction models are difficult to accurately capture and simulate these relationships. In addition, biological treatment unit status data, such as mixed liquor suspended solids (MLSS), dissolved oxygen (DO), and temperature, are of great significance for predicting water quality changes, but existing technologies often ignore the rational use of these data, and usually input them simultaneously with the model input without distinction, resulting in low accuracy in water quality prediction. Summary of the invention
[0004] In order to solve the above problems, the present invention proposes a LSTM water quality prediction method based on a multi-layer inverse cell state, and designs a multi-layer inverse cell state long short-term memory network model suitable for water quality prediction in water plants. The model can reasonably utilize various state variables, so that the cell state components of the model can accurately capture the water plant operation process information, and correct the model parameter training process in real time, so as to more accurately and effectively complete the prediction of water quality of water plant effluent.
[0005] The present invention adopts the following technical solutions:
[0006] A LSTM water quality prediction method based on multi-layer reverse cell state includes the following steps:
[0007] Step 1: Data collection and preprocessing;
[0008] Step 1.1: Collect water quality data of the water plant to form training data. The water quality data includes inlet water quality data, biological treatment unit effluent water quality data, total effluent water quality data, biological treatment unit status data and reagent dosage data;
[0009] Step 1.2: Normalize the collected training data;
[0010] Step 1.3: Perform principal component analysis on the normalized influent water quality data to remove duplicate features;
[0011] Step 2: Construct a multi-layer inverse cell state long short-term memory network model suitable for water quality prediction in water plants, including:
[0012] Constructing and initializing a multi-layer reverse cell state long short-term memory network model, wherein the multi-layer reverse cell state long short-term memory network model is provided with a biological processing layer and a tertiary processing layer, and the biological processing layer and the tertiary processing layer are connected in series;
[0013] Step 3: Use the training data preprocessed in step 1 to train the multi-layer reverse cell state long short-term memory network model, including:
[0014] Step 3.1: After the biological processing layer processes the training data, the biological processing layer short-term memory output value and the biological processing layer long-term memory output value are obtained, and after the tertiary processing layer processes the training data, the tertiary processing layer output value is obtained;
[0015] The effluent quality data of the biological treatment unit is used to verify the short-term memory output value of the biological treatment layer, calculate the gradient and back-propagate, and the total effluent quality data is used to verify the output value of the tertiary treatment layer, calculate the gradient and back-propagate;
[0016] Step 3.2: Use the biological processing unit state data to verify the long-term memory output value of the biological processing layer, calculate the gradient and back-propagate;
[0017] Step 4: Prediction of effluent water quality; input the inlet water quality data and the reagent dosage data of the water plant to be tested into the multi-layer inverse cell state long short-term memory network model to obtain the output data, and denormalize the output data to obtain the predicted effluent water quality index data.
[0018] Preferably, in step 1.1:
[0019] The influent water quality data include influent chemical oxygen demand, influent ammonia nitrogen, influent total phosphorus, influent total nitrogen, influent flow rate and influent temperature, etc.;
[0020] The biological treatment unit status data includes the mixed liquor suspended solids concentration, temperature, dissolved oxygen content in the anoxic tank, etc.;
[0021] The effluent quality data of the biological treatment unit include the chemical oxygen demand of the biological treatment unit effluent, the ammonia nitrogen of the biological treatment unit effluent, the total phosphorus of the biological treatment unit effluent and the total nitrogen of the biological treatment unit effluent;
[0022] Total effluent water quality data include total effluent chemical oxygen demand, total effluent ammonia nitrogen, total effluent total phosphorus and total effluent total nitrogen;
[0023] The dosage data of reagents include the dosage of sodium hypochlorite for ultrafiltration membrane, the dosage of sodium hydroxide for ultrafiltration membrane, the dosage of PAC liquid for ultrafiltration membrane, the dosage of citric acid, the dosage of reducing agent, the dosage of phosphorus removal agent, the dosage of polyacrylamide, the dosage of carbon source and the dosage of sodium hypochlorite for disinfection, etc.
[0024] Preferably, in step 1.2:
[0025] The data normalization process uses the minimum-maximum normalization algorithm to scale all data to the interval [0,1], and the formula is as follows:
[0026]
[0027] Among them, X is the original data, each row is an observation, each column is a variable, X min and X max are the minimum and maximum values in the data set, respectively, and X norm is the normalized data matrix.
[0028] Preferably, in step 1.3:
[0029] The principal component analysis formula is as follows:
[0030]
[0031] ∑ω j =λ j ω j (3);
[0032] X'=X norm ×W (4);
[0033] Where n is the number of observations, W is a matrix consisting of the eigenvectors of the covariance matrix, which correspond to the largest variances in the data set, i.e., the principal components; X' is the transformed data matrix, with each column being a principal component;
[0034] λ j and ω j are the jth eigenvalue and the corresponding eigenvector, the eigenvector ω j The columns of the matrix W are formed according to λ j The sizes are sorted in descending order.
[0035] Preferably, if there are multiple biological treatment units, the number of biological treatment layers is consistent with the number of biological treatment units, and the biological treatment units correspond one to one with the effluent quality data of the biological treatment units, the status data of the biological treatment units and the biological treatment layers;
[0036] In the multi-layer inverse cell state long short-term memory network model, multiple biological processing layers are connected in parallel, and the multiple biological processing layers connected in parallel are connected in series with the tertiary processing layer.
[0037] Preferably, step 3.1 specifically includes the following steps:
[0038] Step 3.1.1: If there are multiple biological treatment layers, the input of each biological treatment layer includes the influent water quality data and the carbon source dosage. After the input data is processed by the biological treatment layer, the short-term memory output value and the long-term memory output value of the biological treatment layer are obtained;
[0039] Among them, the short-term memory output value of the biological treatment layer reflects the effluent water quality data of the corresponding biological treatment unit, and the long-term memory output value of the biological treatment layer reflects the status data of the corresponding biological treatment unit;
[0040] The short-term memory output value of the biological treatment layer is verified by the effluent water quality data of the biological treatment unit, the gradient is calculated and back-propagated, and the specific steps include:
[0041] ① After the influent water quality data and carbon source dosage are input into the biological treatment layer, the output value of this layer is calculated by forward propagation, and the formula is:
[0042] Forget gate: f t =σ(W f ·[h t-1 ,x t ]+b f ) (5);
[0043] Input gate: i t =σ(W i ·[h t-1 , x t ]+b i ) (6);
[0044]
[0045] Update cell status:
[0046] Output gate: o t =σ(W o ·[h t-1 ,x t ]+b o ) (9);
[0047] Final hidden state: h t =o t *tanh(C t ) (10);
[0048] Among them, σ is the activation function, tanh is the hyperbolic tangent activation function; f t represents the forget gate, i t is the input gate, is a candidate value; C t represents the cell state at time step t; o t is the activation value of the output gate; h t is the hidden state of the current time step; W f Represents the weight matrix of the forget gate, W i and W c represents the weight matrix of the input gate, W o represents the weight matrix of the output gate; b f represents the bias of the forget gate, b i and b c represents the bias of the input gate, b o represents the deviation of the output gate; [h t-1 , x t ] represents the concatenation of the hidden state and the current input;
[0049] ② Compare the short-term memory output value of the biological treatment layer with the corresponding actual biological treatment unit effluent water quality data to determine the deviation between the output value and the actual value; use the mean square error as the error calculation method, and the formula is:
[0050]
[0051] Among them, E is the calculated mean square error, N is the number of samples used in this calculation, is the predicted value of the model, y i The true value used for supervised training;
[0052] ③ Using the error value, calculate the gradient of the short-term memory output value of the biological processing layer according to the long short-term memory network back propagation algorithm;
[0053]
[0054] Forget Gate:
[0055]
[0056] Input Gate:
[0057]
[0058] Output Gate:
[0059]
[0060]
[0061] According to the calculated gradient, the network weights and biases associated with the short-term memory output value of the biological treatment layer are updated to more accurately predict the effluent water quality data of the biological treatment unit;
[0062] Step 3.1.2: If there are multiple biological treatment layers, the short-term memory output values of the multiple biological treatment layers are unified into a set of outputs after weighted average according to the flow of the corresponding biological treatment units, which are combined with the dosage data of the reagents except the dosage of the carbon source as the input of the tertiary treatment layer. After the input data is processed by the tertiary treatment layer, the short-term memory output value of the tertiary treatment layer is obtained. The short-term memory output value of the tertiary treatment layer reflects the total effluent quality of the water plant;
[0063] The short-term memory output value of the third-level processing layer is verified with the total effluent water quality data, and the back propagation algorithm is implemented. The specific steps include:
[0064] ④ Compare the short-term memory output value of the tertiary treatment layer with the actual total effluent water quality data and calculate the error;
[0065] ⑤ According to the long short-term memory network back propagation algorithm, calculate the gradient of the short-term memory output value of the three-level processing layer;
[0066] ⑥According to the calculated gradient, update the network weights and biases associated with the short-term memory output values of the tertiary processing layer to more accurately predict the total effluent water quality data.
[0067] Preferably, step 3.2 specifically includes:
[0068] ⑦ Compare the long-term memory output value of the biological treatment layer with the corresponding actual biological treatment unit state data, and calculate the error between the output value and the actual value;
[0069] ⑧ Using the error value, the gradient of each weight parameter and bias value related to the long-term memory output value of the biological processing layer is calculated according to the long short-term memory network back propagation algorithm. The specific formula is as follows:
[0070]
[0071] Forget Gate:
[0072]
[0073] Input Gate:
[0074]
[0075] ⑨According to the calculated gradient, update the weight parameters and bias values related to the long-term memory output value of the biological processing layer.
[0076] ⑩Complete the model training process by iteratively optimizing the network weights and biases until the predetermined number of training rounds is reached or the model prediction error drops below an acceptable threshold. In each iteration, update the network parameters according to the gradient calculated in the steps to gradually reduce the difference between the model prediction value and the actual value. During the training process, continuously monitor the performance on the validation set to ensure that the model does not overfit. End the training when any of the following conditions are met:
[0077] The performance of the model I on the validation set is no longer significantly improved, as shown by the error change being less than the preset small threshold in multiple consecutive cycles;
[0078] Ⅱ Reach the preset maximum number of training rounds to ensure that the model has enough time to learn data features while avoiding unnecessary waste of computing resources;
[0079] III The prediction error of the model drops below the acceptable threshold defined by the user, meeting the accuracy requirements in practical applications.
[0080] Preferably, step 4 is specifically:
[0081] The influent water quality data and the reagent dosage data of the water plant to be tested are normalized and principal component analyzed, and then the processed data are input into the multi-layer reverse cell state long short-term memory network model to obtain the output data;
[0082] The output data is denormalized using the following formula:
[0083]
[0084] Where X max and X min are the minimum and maximum values of the corresponding indicator in the original data set; is the output value of the model, is the final denormalized value.
[0085] Compared with the prior art, the advantages of the present invention are:
[0086] The present invention constructs an accurate network model for predicting water quality by comprehensively considering the dynamic interaction between the water plant's operating status and real-time data, thereby more accurately capturing the dynamic characteristics of water quality changes in each unit. The present invention adopts a method that combines cell status with water plant operating status data verification. This method does not input all data at once at the beginning of model training, but inputs and verifies data in stages and step by step, which more effectively captures the operating status of the water plant, fits the complex biochemical reaction process of the water plant, and enhances the interpretability of the model.
[0087] The present invention innovatively applies a multi-processing layer series structure based on the series structure of the water plant's operating units, connects the biological treatment layer and the tertiary treatment layer in series, realizes the phased input and phased training of data, and realizes the orderly flow of data and the deep integration of information. The biological treatment layer can simulate the biological treatment process of the sewage treatment plant, while the tertiary treatment layer simulates further refined treatment to predict the effluent water quality. This structural design not only corresponds to the actual treatment units and processes of the water plant, improving the interpretability of the model, but also through phased training, the model can use data more effectively and improve the efficiency of data utilization. Such a design enables the model to better fit the complex water treatment process, ensuring the prediction accuracy of each stage, thereby improving the accuracy and efficiency of water quality prediction as a whole. BRIEF DESCRIPTION OF THE DRAWINGS
[0088] Figure 1 This is the data preprocessing flow chart.
[0089] Figure 2 Schematic diagram of the multi-layer inverse cell state long short-term memory network model of Example 1.
[0090] Figure 3 This is a comparison chart of the actual concentration value of total nitrogen in the total effluent in Example 1 and the predicted concentration value of total nitrogen in the total effluent predicted by the multi-layer inverse cell state long short-term memory network model.
[0091] Figure 4 This is a comparison chart of the actual concentration value of total effluent ammonia nitrogen in Example 1 and the predicted concentration value of total effluent ammonia nitrogen predicted by using the multi-layer inverse cell state long short-term memory network model.
[0092] Figure 5 This is a comparison chart of the actual concentration value of total phosphorus in the total effluent in Example 1 and the predicted concentration value of total phosphorus in the total effluent predicted by using the multi-layer inverse cell state long short-term memory network model. DETAILED DESCRIPTION
[0093] The specific implementation of the present invention is further described below in conjunction with the accompanying drawings and specific embodiments:
[0094] Example 1
[0095] The experimental data comes from a sewage treatment plant in Gaobeidian, Baoding City. 5,000 sets of water quality data are obtained as training data, including influent water quality data, effluent water quality data of biological treatment units, total effluent water quality data, biological treatment unit status data and reagent dosage data.
[0096] Combination Figures 1 to 3 , a LSTM water quality prediction method based on multi-layer reverse cell state, including the following steps:
[0097] Step 1: Data collection and preprocessing.
[0098] Step 1.1: The biological treatment adopted by the sewage treatment plant is the A2O process. The water quality data of the water plant is collected to form training data. The water quality data includes influent water quality data, effluent water quality data of the biological treatment unit, total effluent water quality data, biological treatment unit status data and reagent dosage data.
[0099] The inlet water quality data include inlet chemical oxygen demand, inlet ammonia nitrogen, inlet total phosphorus, inlet total nitrogen, inlet flow rate and inlet temperature.
[0100] The biological treatment unit status data includes the mixed liquor suspended solids concentration, temperature, dissolved oxygen content in the anoxic tank, etc.
[0101] The water quality data of the effluent from the biological treatment unit include the chemical oxygen demand of the effluent from the biological treatment unit, the ammonia nitrogen of the effluent from the biological treatment unit, the total phosphorus of the effluent from the biological treatment unit and the total nitrogen of the effluent from the biological treatment unit.
[0102] The total effluent water quality data include total effluent chemical oxygen demand, total effluent ammonia nitrogen, total effluent total phosphorus and total effluent total nitrogen.
[0103] The dosage data of reagents include the dosage of sodium hypochlorite for ultrafiltration membrane, the dosage of sodium hydroxide for ultrafiltration membrane, the dosage of PAC liquid for ultrafiltration membrane, the dosage of citric acid, the dosage of reducing agent, the dosage of phosphorus removal agent, the dosage of polyacrylamide, the dosage of carbon source and the dosage of sodium hypochlorite for disinfection, etc.
[0104] Step 1.2: Normalize the collected training data.
[0105] Data normalization uses the minimum-maximum normalization algorithm to scale all data to the [0,1] interval. The formula is as follows:
[0106]
[0107] Among them, X is the original data, each row is an observation, each column is a variable, X min and X max are the minimum and maximum values in the data set, respectively, and X norm is the normalized data matrix.
[0108] Step 1.3: Perform principal component analysis on the normalized influent water quality data to remove duplicate features.
[0109] The principal component analysis formula is as follows:
[0110]
[0111] Σω j =λ jω j (3);
[0112] X'=X norm ×W (4);
[0113] Where n is the number of observations, W is a matrix consisting of the eigenvectors of the covariance matrix, which correspond to the largest variances in the data set, i.e., the principal components; X' is the transformed data matrix, with each column being a principal component;
[0114] λ j and ω j are the jth eigenvalue and the corresponding eigenvector, the eigenvector ω j The columns of the matrix W are formed according to λ j The sizes are sorted in descending order.
[0115] Step 2: Construct a multi-layer inverse cell state long short-term memory network model suitable for water quality prediction in water plants, including:
[0116] Construct and initialize a multi-layer inverse cell state long short-term memory network model. The plant has two biological treatment units, so the multi-layer inverse cell state long short-term memory network model has two biological treatment layers and one tertiary treatment layer. The two biological treatment layers correspond to the two biological treatment units one by one. The two biological treatment layers are connected in parallel and in series with the tertiary treatment layer.
[0117] Step 3: Use the training data preprocessed in step 1 to train the multi-layer reverse cell state long short-term memory network model, including:
[0118] Step 3.1: After the biological processing layer processes the training data, the biological processing layer short-term memory output value and the biological processing layer long-term memory output value are obtained. After the tertiary processing layer processes the training data, the tertiary processing layer output value is obtained.
[0119] The effluent water quality data of the biological treatment unit is used to verify the short-term memory output value of the biological treatment layer, calculate the gradient and back-propagate. The total effluent water quality data is used to verify the output value of the tertiary treatment layer, calculate the gradient and back-propagate.
[0120] The specific steps include:
[0121] Step 3.1.1: The input of each biological treatment layer includes the influent water quality data and the carbon source dosage. After the input data is processed by the biological treatment layer, the short-term memory output value and the long-term memory output value of the biological treatment layer are obtained.
[0122] Among them, the short-term memory output value of the biological treatment layer reflects the effluent water quality data of the corresponding biological treatment unit, and the long-term memory output value of the biological treatment layer reflects the status data of the corresponding biological treatment unit.
[0123] The short-term memory output value of the biological treatment layer is verified with the effluent water quality data of the biological treatment unit, the gradient is calculated and back-propagated. The specific steps include:
[0124] ① After the influent water quality data and carbon source dosage are input into the biological treatment layer, the output value of this layer is calculated by forward propagation, and the formula is:
[0125] Forget gate: f t =σ(W f ·[h t-1 , x t ]+b f ) (5);
[0126] Input gate: i t =σ(W i ·[h t-1 , x t ]+b i ) (6);
[0127]
[0128] Update cell status:
[0129] Output gate: o t =σ(W o ·[h t-1 , x t ]+b o ) (9);
[0130] Final hidden state: h t =o t *tanh(C t ) (10);
[0131] Among them, σ is the activation function, tanh is the hyperbolic tangent activation function; f t represents the forget gate, i t is the input gate, is a candidate value; C t represents the cell state at time step t; o t is the activation value of the output gate; h t is the hidden state of the current time step; W f Represents the weight matrix of the forget gate, W i and W c represents the weight matrix of the input gate, W o represents the weight matrix of the output gate; bf represents the bias of the forget gate, b i and b c represents the bias of the input gate, b o represents the deviation of the output gate; [h t-1 , x t ] represents the concatenation of the hidden state and the current input.
[0132] ② Compare the short-term memory output value of the biological treatment layer with the corresponding actual biological treatment unit effluent water quality data to determine the deviation between the output value and the actual value; use the mean square error as the error calculation method, and the formula is:
[0133]
[0134] Among them, E is the calculated mean square error, N is the number of samples used in this calculation, is the predicted value of the model, y i The true value used for supervised training.
[0135] ③ Using the error value, calculate the gradient of the short-term memory output value of the biological processing layer according to the long short-term memory network back propagation algorithm;
[0136]
[0137] Forget Gate:
[0138]
[0139] Input Gate:
[0140]
[0141] Output Gate:
[0142]
[0143] According to the calculated gradient, the network weights and biases associated with the short-term memory output values of the biological treatment layer are updated to more accurately predict the effluent water quality data of the biological treatment unit.
[0144] Step 3.1.2: The short-term memory output values of the two biological treatment layers are unified into a set of outputs after weighted averaging according to the flow rates of the corresponding biological treatment units. The output values are combined with the dosage data of the reagents except the dosage of the carbon source as the input of the tertiary treatment layer. After the input data is processed by the tertiary treatment layer, the short-term memory output values of the tertiary treatment layer are obtained. The short-term memory output values of the tertiary treatment layer reflect the total effluent quality of the water plant.
[0145] The short-term memory output value of the third-level processing layer is verified with the total effluent water quality data, and the back propagation algorithm is implemented. The specific steps include:
[0146] ④Compare the short-term memory output value of the tertiary treatment layer with the actual total effluent water quality data and calculate the error. The calculation formula is the same as ②.
[0147] ⑤ According to the long short-term memory network back propagation algorithm, calculate the gradient of the short-term memory output value of the three-level processing layer. The calculation formula is the same as ③.
[0148] ⑥According to the calculated gradient, update the network weights and biases associated with the short-term memory output values of the tertiary processing layer to more accurately predict the total effluent water quality data.
[0149] Step 3.2: Use the biological processing unit state data to verify the long-term memory output value of the biological processing layer, calculate the gradient and back-propagate.
[0150] Specifically include:
[0151] ⑦ Compare the long-term memory output value of the biological treatment layer with the corresponding actual biological treatment unit state data, and calculate the error between the output value and the actual value;
[0152] ⑧ Using the error value, the gradient of each weight parameter and bias value related to the long-term memory output value of the biological processing layer is calculated according to the long short-term memory network back propagation algorithm. The specific formula is as follows:
[0153]
[0154] Forget Gate:
[0155]
[0156] Input Gate:
[0157]
[0158] ⑨According to the calculated gradient, update the weight parameters and bias values related to the long-term memory output value of the biological processing layer.
[0159] ⑩Complete the model training process by iteratively optimizing the network weights and biases until the predetermined number of training rounds is reached or the model prediction error drops below an acceptable threshold. In each iteration, update the network parameters according to the gradient calculated in the steps to gradually reduce the difference between the model prediction value and the actual value. During the training process, continuously monitor the performance on the validation set to ensure that the model does not overfit. End the training when any of the following conditions are met:
[0160] The performance of the model I on the validation set is no longer significantly improved, as shown by the error change being less than the preset small threshold in multiple consecutive cycles;
[0161] Ⅱ Reach the preset maximum number of training rounds to ensure that the model has enough time to learn data features while avoiding unnecessary waste of computing resources;
[0162] III The prediction error of the model drops below the acceptable threshold defined by the user, meeting the accuracy requirements in practical applications.
[0163] Step 4: Prediction of effluent water quality; input the inlet water quality data and the reagent dosage data of the water plant to be tested into the multi-layer inverse cell state long short-term memory network model to obtain the output data, and denormalize the output data to obtain the predicted effluent water quality index data.
[0164] Specifically:
[0165] The influent water quality data and the reagent dosage data of the water plant to be tested are normalized and principal component analyzed, and then the processed data are input into the multi-layer reverse cell state long short-term memory network model to obtain the output data;
[0166] The output data is denormalized using the following formula:
[0167]
[0168] Where X max and X min are the minimum and maximum values of the corresponding indicator in the original data set; is the output value of the model, is the final denormalized value.
[0169] like Figure 3 As shown, Figure 3 The horizontal axis represents the amount of data, and the vertical axis represents the concentration of total nitrogen in the total effluent. The black line represents the actual concentration value of the total nitrogen in the total effluent, and the blue line represents the predicted concentration value of the total nitrogen in the total effluent predicted by the multi-layer inverse cell state long short-term memory network model of the present invention. It can be seen from the figure that the multi-layer inverse cell state long short-term memory network model proposed in the present invention is more accurate in predicting the total nitrogen in the total effluent.
[0170] like Figure 4 As shown, Figure 4 The horizontal axis represents the amount of data, and the vertical axis represents the concentration of total effluent ammonia nitrogen. The black line represents the actual concentration value of total effluent ammonia nitrogen, and the blue line represents the predicted concentration value of total effluent ammonia nitrogen predicted by the multi-layer reverse cell state long short-term memory network model of the present invention. It can be seen from the figure that the multi-layer reverse cell state long short-term memory network model proposed by the present invention is more accurate in predicting total effluent ammonia nitrogen. In the instrumental measurement of the water plant, the actual accuracy of ammonia nitrogen measurement is 0.01 mg / L, and the model prediction value error is below the measurement accuracy.
[0171] like Figure 5 As shown, Figure 5 The horizontal axis represents the amount of data, and the vertical axis represents the concentration of total phosphorus in the total effluent. The black line represents the actual concentration value of total phosphorus in the total effluent, and the blue line represents the predicted concentration value of total phosphorus in the total effluent predicted by the multi-layer reverse cell state long short-term memory network model of the present invention. It can be seen from the figure that the multi-layer reverse cell state long short-term memory network model proposed by the present invention is more accurate in predicting total phosphorus in the total effluent. In the instrumental measurement of the water plant, the actual accuracy of total phosphorus measurement is 0.01 mg / L, and the error of the model prediction value is below the measurement accuracy.
[0172] Of course, the above description is not a limitation of the present invention, and the present invention is not limited to the above examples. Changes, modifications, additions or substitutions made by technicians in this technical field within the essential scope of the present invention should also fall within the protection scope of the present invention.
Claims
1. A LSTM water quality prediction method based on multi-layer reverse cell state, characterized in that: The following steps are involved: Step 1: Data collection and preprocessing; Step 1.1: Collect water quality data of the water plant to form training data. The water quality data includes inlet water quality data, biological treatment unit effluent water quality data, total effluent water quality data, biological treatment unit status data and reagent dosage data; Step 1.2: Normalize the collected training data; Step 1.3: Perform principal component analysis on the normalized influent water quality data to remove duplicate features; Step 2: Construct a multi-layer inverse cell state long short-term memory network model suitable for water quality prediction in water plants, including: Constructing and initializing a multi-layer reverse cell state long short-term memory network model, wherein the multi-layer reverse cell state long short-term memory network model is provided with a biological processing layer and a tertiary processing layer, and the biological processing layer and the tertiary processing layer are connected in series; Step 3: Use the training data preprocessed in step 1 to train the multi-layer reverse cell state long short-term memory network model, including: Step 3.1: After the biological processing layer processes the training data, the biological processing layer short-term memory output value and the biological processing layer long-term memory output value are obtained, and after the tertiary processing layer processes the training data, the tertiary processing layer output value is obtained; The effluent quality data of the biological treatment unit is used to verify the short-term memory output value of the biological treatment layer, calculate the gradient and back-propagate, and the total effluent quality data is used to verify the output value of the tertiary treatment layer, calculate the gradient and back-propagate; Step 3.2: Use the biological processing unit state data to verify the long-term memory output value of the biological processing layer, calculate the gradient and back-propagate; Step 4: Prediction of effluent water quality; input the inlet water quality data and the reagent dosage data of the water plant to be tested into the multi-layer inverse cell state long short-term memory network model to obtain the output data, and denormalize the output data to obtain the predicted effluent water quality index data.
2. According to claim 1, a LSTM water quality prediction method based on multi-layer reverse cell state is characterized in that: In step 1.1: The influent water quality data include influent chemical oxygen demand, influent ammonia nitrogen, influent total phosphorus, influent total nitrogen, influent flow rate and influent temperature; The biological treatment unit status data include the mixed liquor suspended solids concentration, temperature, and dissolved oxygen content in the anoxic tank; The effluent quality data of the biological treatment unit include the chemical oxygen demand of the biological treatment unit effluent, the ammonia nitrogen of the biological treatment unit effluent, the total phosphorus of the biological treatment unit effluent and the total nitrogen of the biological treatment unit effluent; Total effluent water quality data include total effluent chemical oxygen demand, total effluent ammonia nitrogen, total effluent total phosphorus and total effluent total nitrogen; The dosage data of reagents include the dosage of sodium hypochlorite for ultrafiltration membrane, the dosage of sodium hydroxide for ultrafiltration membrane, the dosage of PAC liquid for ultrafiltration membrane, the dosage of citric acid, the dosage of reducing agent, the dosage of phosphorus removal agent, the dosage of polyacrylamide, the dosage of carbon source and the dosage of sodium hypochlorite for disinfection.
3. The LSTM water quality prediction method based on multi-layer reverse cell state according to claim 1 is characterized in that: In step 1.2: The data normalization process uses the minimum-maximum normalization algorithm to scale all data to the interval [0,1], and the formula is as follows: Among them, X is the original data, each row is an observation, each column is a variable, X min and X max are the minimum and maximum values in the data set, respectively, and X norm is the normalized data matrix.
4. The LSTM water quality prediction method based on multi-layer reverse cell state according to claim 1 is characterized in that: In step 1.3: The principal component analysis formula is as follows: Oh j =λ j oh j (3); X’=X norm ×W (4); Where n is the number of observations, W is a matrix consisting of the eigenvectors of the covariance matrix, which correspond to the largest variances in the data set, i.e., the principal components; X' is the transformed data matrix, with each column being a principal component; λ j and ω j are the jth eigenvalue and the corresponding eigenvector, the eigenvector ω j The columns of the matrix W are formed according to λ j The sizes are sorted in descending order.
5. The LSTM water quality prediction method based on multi-layer reverse cell state according to claim 2 is characterized in that: If there are multiple biological treatment units, the number of biological treatment layers shall be consistent with the number of biological treatment units, and the biological treatment units shall correspond one to one with the effluent quality data of the biological treatment units, the status data of the biological treatment units and the biological treatment layers; In the multi-layer inverse cell state long short-term memory network model, multiple biological processing layers are connected in parallel, and the multiple biological processing layers connected in parallel are connected in series with the tertiary processing layer.
6. The LSTM water quality prediction method based on multi-layer reverse cell state according to claim 5 is characterized in that: Step 3.1 specifically includes the following steps: Step 3.1.1: If there are multiple biological treatment layers, the input of each biological treatment layer includes the influent water quality data and the carbon source dosage. After the input data is processed by the biological treatment layer, the short-term memory output value and the long-term memory output value of the biological treatment layer are obtained; Among them, the short-term memory output value of the biological treatment layer reflects the effluent water quality data of the corresponding biological treatment unit, and the long-term memory output value of the biological treatment layer reflects the status data of the corresponding biological treatment unit; The short-term memory output value of the biological treatment layer is verified by the effluent water quality data of the biological treatment unit, the gradient is calculated and back-propagated, and the specific steps include: ① After the influent water quality data and carbon source dosage are input into the biological treatment layer, the output value of this layer is calculated by forward propagation, and the formula is: Forget gate: f t =σ(W f ·[h t-1 , x t ]+b f ) (5); Input gate: i t =σ(W i ·[h t-1 , x t ]+b i ) (6); Update cell status: Output gate: o t =σ(W o ·[h t-1 , x t ]+b o ) (9); Final hidden state: h t =o t *tanh(C t ) (10); Among them, σ is the activation function, tanh is the hyperbolic tangent activation function; ft represents the forget gate, i t is the input gate, is a candidate value; C t represents the cell state at time step t; o t is the activation value of the output gate; h t is the hidden state of the current time step; W f Represents the weight matrix of the forget gate, W i and W c represents the weight matrix of the input gate, W o represents the weight matrix of the output gate; b f represents the bias of the forget gate, b i and b c represents the bias of the input gate, b o represents the deviation of the output gate; [h t-1 , x t ] represents the concatenation of the hidden state and the current input; ② Compare the short-term memory output value of the biological treatment layer with the corresponding actual biological treatment unit effluent water quality data to determine the deviation between the output value and the actual value; use the mean square error as the error calculation method, and the formula is: Among them, E is the calculated mean square error, N is the number of samples used in this calculation, is the predicted value of the model, y i The true value used for supervised training; ③ Using the error value, calculate the gradient of the short-term memory output value of the biological processing layer according to the long short-term memory network back propagation algorithm; Forget Gate: Input Gate: Output Gate: According to the calculated gradient, the network weights and biases associated with the short-term memory output value of the biological treatment layer are updated to more accurately predict the effluent water quality data of the biological treatment unit; Step 3.1.2: If there are multiple biological treatment layers, the short-term memory output values of the multiple biological treatment layers are unified into a set of outputs after weighted average according to the flow of the corresponding biological treatment units, which are combined with the dosage data of the reagents except the dosage of the carbon source as the input of the tertiary treatment layer. After the input data is processed by the tertiary treatment layer, the short-term memory output value of the tertiary treatment layer is obtained. The short-term memory output value of the tertiary treatment layer reflects the total effluent quality of the water plant; The short-term memory output value of the third-level processing layer is verified with the total effluent water quality data, and the back propagation algorithm is implemented. The specific steps include: ④ Compare the short-term memory output value of the tertiary treatment layer with the actual total effluent water quality data and calculate the error; ⑤ According to the long short-term memory network back propagation algorithm, calculate the gradient of the short-term memory output value of the three-level processing layer; ⑥According to the calculated gradient, update the network weights and biases associated with the short-term memory output values of the tertiary processing layer to more accurately predict the total effluent water quality data.
7. The LSTM water quality prediction method based on multi-layer reverse cell state according to claim 6 is characterized in that: Step 3.2 specifically includes: ⑦ Compare the long-term memory output value of the biological treatment layer with the corresponding actual biological treatment unit state data, and calculate the error between the output value and the actual value; ⑧ Using the error value, the gradient of each weight parameter and bias value related to the long-term memory output value of the biological processing layer is calculated according to the long short-term memory network back propagation algorithm. The specific formula is as follows: Forget Gate: Input Gate: ⑨According to the calculated gradient, update the weight parameters and bias values related to the long-term memory output value of the biological processing layer. ⑩Complete the model training process by iteratively optimizing the network weights and biases until the predetermined number of training rounds is reached or the model prediction error drops below an acceptable threshold. In each iteration, update the network parameters according to the gradient calculated in the steps to gradually reduce the difference between the model prediction value and the actual value. During the training process, continuously monitor the performance on the validation set to ensure that the model does not overfit. End the training when any of the following conditions are met: The performance of the model I on the validation set is no longer significantly improved, as shown by the error change being less than the preset small threshold in multiple consecutive cycles; Ⅱ Reach the preset maximum number of training rounds to ensure that the model has enough time to learn data features while avoiding unnecessary waste of computing resources; III The prediction error of the model drops below the acceptable threshold defined by the user, meeting the accuracy requirements in practical applications.
8. The LSTM water quality prediction method based on multi-layer reverse cell state according to claim 1 is characterized in that: Step 4 is as follows: The influent water quality data and the reagent dosage data of the water plant to be tested are normalized and principal component analyzed, and then the processed data are input into the multi-layer reverse cell state long short-term memory network model to obtain the output data; The output data is denormalized using the following formula: Where X max and X min are the minimum and maximum values of the corresponding indicator in the original data set; is the output value of the model, is the final denormalized value.
