A water quality intelligent prediction method and wastewater treatment automatic control system
By adopting Transformer and LSTM models in the water treatment system, combining position coding and multi-head attention mechanism, the complexity problem of ammonia nitrogen content prediction in the sequence batch reactor is solved, and more efficient intelligent prediction and automatic control of water quality are achieved, improving Processing accuracy and stability.
Patent Information
- Application Number
- CN202411268470.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-11
- Publication Date
- 2024-12-24
- Estimated Expiration
- 2044-09-11
AI Technical Summary
The prior art is difficult to accurately predict the ammonia nitrogen content in the sequential batch reactor water treatment system in prediction and automatic control, resulting in low treatment efficiency and large environmental impact, and complex dynamic and discontinuous measurements hinder prediction accuracy and energy saving. Reduce consumption.
Using the ammonia nitrogen content prediction model based on Transformer and LSTM, the position encoding layer, Transformer encoder and LSTM decoder are designed by acquiring and pretreating wastewater monitoring data, and combining multi-head attention mechanism and long-term memory network to build intelligent water quality prediction methods and Automatic control system for wastewater treatment to realize real-time prediction and automatic execution of treatment processes.
It improves the accuracy and stability of ammonia nitrogen content prediction, reduces the risk of overfitting, enhances the generalization ability of the model, and can more accurately predict complex water quality indicators, ensuring the reliability and efficiency of automatic control.
Smart Images

Figure CN118800352B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of prediction analysis and automatic control in water treatment engineering, and in particular to a water quality intelligent prediction method and a wastewater treatment automatic control system. Background Art
[0002] SBR reactor (Sequencing Batch Reactor) water treatment technology is a typical process for wastewater treatment, which is popular for its adaptability, operational flexibility and resource utilization efficiency. Accurately predicting the concentration of ammonia nitrogen in a sequencing batch reactor system is crucial to optimize the treatment plan and ensure compliance with strict regulatory standards.
[0003] The advent of advanced computational methods, particularly machine learning and deep learning, has revolutionized the field of predictive analytics in water treatment engineering, providing unprecedented insights into the dynamics of complex systems.
[0004] In recent years, the integration of complex neural network architectures including LSTM (Long Short-Term Memory) and Transformer (Transformer Model) has attracted great attention in predictive modeling tasks in the field of water treatment. The fusion of these architectures provides a powerful framework for time series analysis that can capture the complex spatiotemporal dependencies inherent in sequencing batch reactor processes.
[0005] In order to improve the automation and sustainability of wastewater treatment, it is necessary to accurately predict water quality indicators such as ammonia nitrogen content in sequencing batch reactor water treatment systems. Ammonia nitrogen content is an important indicator of treatment efficiency and environmental impact. However, complex dynamics and the complexity and discontinuity of ammonia nitrogen measurement hinder the prediction accuracy and automated control of energy saving and consumption reduction. Summary of the invention
[0006] In view of the above-mentioned deficiencies in the prior art, the present invention provides a water quality intelligent prediction method and a wastewater treatment automatic control system.
[0007] In order to achieve the above-mentioned object of the invention, the technical solution adopted by the present invention is:
[0008] A water quality intelligent prediction method comprises the following steps:
[0009] S1. Acquire wastewater monitoring data, preprocess the wastewater monitoring data to obtain preprocessed data, and establish a variable data set according to the wastewater monitoring data and the preprocessed data set;
[0010] S2. Design a prediction model for the ammonia nitrogen content of wastewater based on Transformer and LSTM, divide the variable data set into a training data set and a test data set, and use the training data set and the test data set to train and test the prediction model for the ammonia nitrogen content of wastewater to obtain the prediction model for the ammonia nitrogen content of wastewater after the test;
[0011] S3. Obtain real-time monitoring data of wastewater and preprocess it, establish a real-time variable data set, and obtain the predicted value of ammonia nitrogen content in wastewater based on the ammonia nitrogen content prediction model of the tested wastewater to make an intelligent prediction of water quality.
[0012] Further, in step S1, the monitoring data of the wastewater includes the conductivity, dissolved oxygen and oxidation-reduction potential of the wastewater; and the pretreatment data includes the change rate and cumulative value of the monitoring data of the wastewater.
[0013] Furthermore, the prediction model of ammonia nitrogen content in wastewater includes a position encoding layer, a Transformer encoder, and an LSTM decoder connected in sequence;
[0014] The position encoding layer is used to receive an input variable set, perform position encoding on the input variable set, and output an input variable set with position information;
[0015] The Transformer encoder is used to perform a dot product operation on the input variable set with position information to output a feature enhanced variable set;
[0016] The LSTM decoder is used to serially process the output feature enhancement variable set, the output of the previous time step, and the unit state of the previous time step to obtain the predicted value of the ammonia nitrogen content of the wastewater.
[0017] Furthermore, in the position encoding layer, position encoding is performed on the input variable set to output the input variable set with position information, including the following steps:
[0018] A1. Calculate the odd position encoding data of the input variable set, expressed as:
[0019]
[0020] in: For the The odd-numbered positions of the input variable set at time steps are encoded, is the time step, For the dimension, is a sine function, Encode the data corresponding to the position;
[0021] A2, calculate the even position encoding data of the input variable set;
[0022]
[0023] in: For the The even-numbered position encoding values of the input variable set at time steps, is the cosine function;
[0024] A3. Output the input variable set with position information according to the input variable set, the odd position encoding data of the input variable set and the even position encoding data of the input variable set, expressed as:
[0025]
[0026] in: For the A set of input variables with location information for time steps, For the The set of input variables with time steps, For the The position-encoded values of the set of input variables at time steps.
[0027] Furthermore, the Transformer encoder includes a multi-head attention mechanism, a first normalization layer, a first linear addition layer, a feedforward layer, a second normalization layer and a second linear addition layer connected in sequence; the first linear addition layer is connected to the input of the Transformer encoder; and the feedforward layer is connected to the second linear addition layer.
[0028] Furthermore, in the multi-head attention mechanism, a dot product operation is performed on the input variable set with position information, and the feature enhanced variable set output by the multi-head attention mechanism includes the following steps:
[0029] B1. Calculate the keyword vector, value vector, and query vector of the input variable set with position information, expressed as:
[0030] ,
[0031] ,
[0032]
[0033] in: For the input variable set with position information in The keyword vector of the attention head, is the number of the attention head, is a set of input variables with position information, For the The trainable projection matrix of the keyword vectors of the attention heads, For the input variable set with position information in The value vector of the attention head, For the The trainable projection matrix of the value vectors of the attention heads, For the input variable set with position information in The query vector of the attention head, For the The trainable projection matrix of the query vector for each attention head;
[0034] B2. Perform dot product operations on the keyword vector, value vector, and query vector of the input variable set with position information to obtain the feature enhancement variable set of a single attention head, expressed as:
[0035]
[0036] in: For the The feature enhancement variable set of the attention head, is the symbol of the softmax function, is the dimension of the keyword vector, For keyword vector The transpose of
[0037] B3. Parallel calculation is performed on the feature enhancement variable set of a single attention head to obtain the feature enhancement variable set output by the multi-head attention mechanism, which is expressed as:
[0038]
[0039] in: It is the feature enhancement variable set output by the multi-head attention mechanism. To parallelize the symbolic computation, , is the total number of attention heads in the multi-head attention mechanism, is the trainable projection matrix for the multi-head attention mechanism.
[0040] Furthermore, the feed-forward layer includes two linear transformation layers connected by ReLU activation functions. The calculation process of the linear transformation layer is:
[0041]
[0042] in: To output the ammonia nitrogen value, For the matrix The transpose of is the input variable, is the bias term of the function.
[0043] Furthermore, the LSTM decoder includes a first linear rectification layer, a long short-term memory network operation layer, a second linear rectification layer, a first fully connected layer and a second fully connected layer which are connected in sequence.
[0044] Furthermore, the long short-term memory network operation layer includes an input gate, a forget gate, an output gate and a unit state gate.
[0045] An automatic wastewater treatment control system using the above method comprises an SBR reactor, a data collection unit, a water quality intelligent prediction unit and an automatic wastewater treatment unit connected in sequence;
[0046] The SBR reactor is used to treat wastewater and produce wastewater treatment samples;
[0047] The data collection unit is used to obtain wastewater monitoring data, pre-process the wastewater monitoring data to obtain pre-processed data, and establish a variable data set based on the wastewater monitoring data and the pre-processed data set; divide the variable data set into a training data set and a test data set; perform data monitoring on wastewater treatment samples, obtain real-time monitoring data of wastewater and pre-process it, and establish a real-time variable data set;
[0048] The water quality intelligent prediction unit is used to design a wastewater ammonia nitrogen content prediction model based on Transformer and LSTM, train and test the wastewater ammonia nitrogen content prediction model using training data sets and test data sets, and obtain the wastewater ammonia nitrogen content prediction model after the test; and obtain the predicted value of the wastewater ammonia nitrogen content based on the real-time variable data set and the wastewater ammonia nitrogen content prediction model after the test;
[0049] The automatic wastewater treatment unit is used to automatically execute the wastewater treatment process according to the predicted value of the ammonia nitrogen content of the wastewater.
[0050] The present invention has the following beneficial effects:
[0051] (1) The present invention designs a prediction model for ammonia nitrogen content in wastewater based on Transformer and LSTM, which can not only enable the model to focus on parallel data processing, through encoders and decoders, pay attention to specific data parts to ensure that both time series characteristics and water quality index data characteristics are well preserved, thereby improving prediction accuracy, but also process sequential data and capture overall data trends to ensure sufficient feature coverage and further improve prediction accuracy;
[0052] (2) The present invention uses model integration to mitigate the risk of overfitting by utilizing different information sources such as wastewater conductivity, dissolved oxygen, redox potential, and the change rate and cumulative value of corresponding data, as well as their complementarity, thereby enhancing the generalization ability of the prediction model. It is able to make more accurate predictions for water quality index data that are complex to measure and difficult to measure continuously and accurately, and further, by integrating global and time series information, more stable and accurate prediction results can be obtained;
[0053] (3) The wastewater treatment automatic control system provided by the present invention comprises an SBR reactor, a data collection unit, a water quality intelligent prediction unit and an automatic wastewater treatment unit connected in sequence; the SBR reactor can treat wastewater and generate wastewater treatment samples; the data collection unit can obtain monitoring data of wastewater, pre-process the monitoring data of wastewater to obtain pre-processed data, and establish a variable data set according to the monitoring data of wastewater and the pre-processed data set, divide the variable data set into a training data set and a test data set, perform data monitoring on wastewater treatment samples, obtain real-time monitoring data of wastewater and pre-process it, and establish a real-time variable data set; the water quality intelligent prediction unit can design a wastewater ammonia nitrogen content prediction model according to Transformer and LSTM, train and test the wastewater ammonia nitrogen content prediction model using the training data set and the test data set, obtain the wastewater ammonia nitrogen content prediction model after the test, and obtain the wastewater ammonia nitrogen content prediction value based on the real-time variable data set and the wastewater ammonia nitrogen content prediction model after the test; the automatic wastewater treatment unit can automatically execute the wastewater treatment process according to the predicted value of the wastewater ammonia nitrogen content. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 It is a schematic diagram of a process of intelligent water quality prediction method;
[0055] Figure 2 This is a schematic diagram of the structure of the prediction model for ammonia nitrogen content in wastewater;
[0056] Figure 3 This is a schematic diagram of the operation layer structure of the long short-term memory network;
[0057] Figure 4 This is a schematic diagram of the structure of an automatic control system for wastewater treatment. DETAILED DESCRIPTION
[0058] The specific implementation modes of the present invention are described below so that those skilled in the art can understand the present invention. However, it should be clear that the present invention is not limited to the scope of the specific implementation modes. For those of ordinary skill in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the attached claims, these changes are obvious, and all inventions and creations utilizing the concept of the present invention are protected.
[0059] like Figure 1 As shown, a water quality intelligent prediction method includes steps S1-S3, which are as follows:
[0060] S1. Acquire wastewater monitoring data, preprocess the wastewater monitoring data to obtain preprocessed data, and establish a variable data set based on the wastewater monitoring data and the preprocessed data set.
[0061] In an optional embodiment of the present invention, the monitoring data of the wastewater includes the conductivity, dissolved oxygen and oxidation-reduction potential of the wastewater; and the pretreatment data includes the change rate and cumulative value of the monitoring data of the wastewater.
[0062] Specifically, in the present invention, the wastewater sample is taken from a collection container in the SBR reactor (sequencing batch reactor) pool, and the collection container allows filtered water to pass through to eliminate the interference of activated sludge. The present invention uses EC sensor Lu Heng 665 to monitor the conductivity of the wastewater, uses DO sensor Lu Heng 229 to monitor the dissolved oxygen of the wastewater, and uses ORP sensor Lu Heng 402 to monitor the oxidation-reduction potential of the wastewater. The present invention processes the monitoring data of the wastewater to obtain the monitoring and processing data of the wastewater, specifically subtracting the monitoring data of the wastewater in the previous time step from the monitoring data of the wastewater in the current time step to obtain the change rate of the monitoring data of the wastewater, and specifically adding the monitoring data of the wastewater in all time steps to obtain the cumulative value of the monitoring data of the wastewater.
[0063] S2. Design a prediction model for the ammonia nitrogen content in wastewater based on Transformer and LSTM, divide the variable data set into a training data set and a test data set, and use the training data set and the test data set to train and test the prediction model for the ammonia nitrogen content in wastewater to obtain the prediction model for the ammonia nitrogen content in wastewater after the test.
[0064] In an optional embodiment of the present invention, the present invention designs a prediction model for ammonia nitrogen content in wastewater based on Transformer and LSTM. Figure 2 As shown, the ammonia nitrogen content prediction model of wastewater includes a position encoding layer, a Transformer encoder and an LSTM decoder connected in sequence.
[0065] The position encoding layer is used to receive an input variable set, perform position encoding on the input variable set, and output an input variable set with position information.
[0066] The input variable set is represented as:
[0067]
[0068] in: is the input variable set, is the electrical conductivity of the wastewater, is the rate of change of the conductivity of the wastewater, is the cumulative value of the electrical conductivity of the wastewater, is the dissolved oxygen in wastewater, is the rate of change of dissolved oxygen in wastewater, is the cumulative value of dissolved oxygen in wastewater, is the redox potential of the wastewater, is the rate of change of the redox potential of the wastewater, It is the cumulative value of the redox potential of the wastewater.
[0069] The present invention performs position encoding on an input variable set in a position encoding layer to output an input variable set with position information, including the following steps:
[0070] A1. Calculate the odd position encoding data of the input variable set, expressed as:
[0071]
[0072] in: For the The odd-numbered positions of the input variable set at time steps are encoded, is the time step, For the dimension, is a sine function, Encodes the data corresponding to the position.
[0073] A2, calculate the even position encoding data of the input variable set;
[0074]
[0075] in: For the The even-numbered position encoding values of the input variable set at time steps, is the cosine function.
[0076] A3. Output the input variable set with position information according to the input variable set, the odd position encoding data of the input variable set and the even position encoding data of the input variable set, expressed as:
[0077]
[0078] in: For the A set of input variables with location information for time steps, For the The set of input variables with time steps, For the The position-encoded values of the set of input variables at time steps.
[0079] The Transformer encoder is used to perform a dot product operation on the input variable set with position information to output a feature enhanced variable set.
[0080] The Transformer encoder includes a multi-head attention mechanism, a first normalization layer, a first linear addition layer, a feedforward layer, a second normalization layer, and a second linear addition layer connected in sequence; the first linear addition layer is connected to the input of the Transformer encoder; and the feedforward layer is connected to the second linear addition layer.
[0081] In the present invention, in a multi-head attention mechanism, a dot product operation is performed on an input variable set with position information, and a feature enhancement variable set output by the multi-head attention mechanism includes the following steps:
[0082] B1. Calculate the keyword vector, value vector, and query vector of the input variable set with position information, expressed as:
[0083] ,
[0084] ,
[0085]
[0086] in: For the input variable set with position information in The keyword vector of the attention head, is the number of the attention head, is a set of input variables with position information, For the The trainable projection matrix of the keyword vectors of the attention heads, For the input variable set with position information in The value vector of the attention head, For the The trainable projection matrix of the value vectors of the attention heads, For the input variable set with position information in The query vector of the attention head, For the The trainable projection matrix of the query vector for each attention head.
[0087] B2. Perform dot product operations on the keyword vector, value vector, and query vector of the input variable set with position information to obtain the feature enhancement variable set of a single attention head, expressed as:
[0088]
[0089] in: For the The feature enhancement variable set of the attention head, is the symbol of the softmax function, is the dimension of the keyword vector, which is used to adjust the similarity calculation between the query vector and the keyword vector. For keyword vector The transpose of .
[0090] B3. Parallel calculation is performed on the feature enhancement variable set of a single attention head to obtain the feature enhancement variable set output by the multi-head attention mechanism, which is expressed as:
[0091]
[0092] in: It is the feature enhancement variable set output by the multi-head attention mechanism. To parallelize the symbolic computation, , is the total number of attention heads in the multi-head attention mechanism, is the trainable projection matrix for the multi-head attention mechanism.
[0093] The feed-forward layer includes two linear transformation layers connected by ReLU activation functions. The calculation process of the linear transformation layer is:
[0094]
[0095] in: To output the ammonia nitrogen value, For the matrix The transpose of is the input variable, is the bias term of the function.
[0096] like Figure 2 As shown, the LSTM decoder is used to enhance the output feature variable set and the output O of the previous time step. t-1 and the cell state C at the previous time step t-1 Serial processing is performed to obtain the predicted value of ammonia nitrogen content in wastewater.
[0097] The LSTM decoder includes a first linear rectification layer, a long short-term memory network operation layer, a second linear rectification layer, a first fully connected layer and a second fully connected layer which are connected in sequence.
[0098] like Figure 3 As shown, the long short-term memory network operation layer includes input gate, forget gate, output gate and unit state gate.
[0099] The calculation formula of data in the input gate is expressed as:
[0100] i t =σ(W i [h t-1 ,x t ]+b i )
[0101] t =tanh(W C [h t-1 ,x t ]+b C )
[0102] Where: i t is the activation value of the input gate at the current time step, which determines how much information of the candidate value at the current time step will be updated to the cell state C t In the above equation, σ is the sigmoid activation function, which compresses any real value into the interval (0, 1) and is used to control the amount of information passing through. i is the weight matrix corresponding to the input gate, used to obtain the hidden state h from the previous time step t-1 and the input x at the current time step t Learn how to control the influx of information, i is the bias term corresponding to the input gate, [h t-1 , x t ] is the hidden state h of the previous time step t-1 and the input x at the current time step t The concatenation calculation is to merge the two vectors into a longer vector as the input gate, forget gate, unit candidate value and output gate input. t is the candidate value of the cell state at the current time step. The candidate value of the cell state is calculated at each time step and is used to update the new information of the cell state. Tanh is the hyperbolic tangent activation function, which is used to compress any real value into the interval (-1, 1) to generate a new candidate cell state value. W C is the weight matrix of candidate values for the cell state, used to obtain the hidden state h from the previous time step t-1 and the input x at the current time step t Learn how to control the influx of information, C is the bias term for the candidate value of the meta-state.
[0103] The calculation formula of data in the forget gate is expressed as:
[0104] f t =σ(W f [h t-1 ,x t ]+b f ),
[0105] Where: f t is the activation value of the forget gate at the current time step, which determines the cell state C at the previous time step t-1How much information will be retained to the cell state C at the current time step? t In, W f is the weight matrix corresponding to the forget gate, b f is the bias term corresponding to the forget gate.
[0106] The calculation formula of data in the output gate is expressed as:
[0107] o t =σ(W o [h t-1 ,x t ]+b o )
[0108] Among them: t is the activation value of the output gate at the current time step, which determines the cell state C t How much information will be output to the hidden state h t In, W o is the weight matrix corresponding to the output gate, b o is the bias term corresponding to the output gate.
[0109] The data processed by the three gates will be passed down to two memory modules. In different memory modules, the long-term and short-term dependencies of the data are selected and processed. The specific processing methods are as follows. The calculation formula of long memory is expressed as:
[0110] C t =f t ×C t-1 +i t × t
[0111] Where: C t is the cell state of the current time step, which is the core part of the LSTM network and is used to store information for a long time. t-1 is the cell state at the previous time step.
[0112] The calculation formula of short memory is expressed as:
[0113] O t =o t ×tanh(C t )
[0114] Among them: t is the output value of the current time step, also regarded as short memory, based on the unit state C of the current time step t and the activation value o of the output gate t To generate, tanh(C t ) is to change the unit state C tThe value of is scaled by the tanh function to produce the same value as the output gate o t Candidate output values to multiply.
[0115] Before the reconstructed LSTM decoding layer outputs the results, this model introduces two fully connected layers to improve the robustness of the model and the reliability of the predicted data results.
[0116] The present invention utilizes wastewater monitoring data and wastewater monitoring treatment data to construct a training data set and a test data set, specifically: the wastewater monitoring data and wastewater monitoring treatment data are utilized to construct an input variable set, and then in each cycle of 720 minutes, the data collected from 0 to 30 minutes and from 661 to 720 minutes are excluded to eliminate the influence of the filling period and the sedimentation period, and data from 40 treatment cycles are collected, 12 of which are randomly separated and used as test data sets, and the rest are used as training data sets.
[0117] The present invention uses a training data set and a test data set to train and test a prediction model for the ammonia nitrogen content of wastewater, and obtains the prediction model for the ammonia nitrogen content of wastewater after the test.
[0118] The present invention adopts a simulation method to conduct a result comparison experiment on the prediction model of ammonia nitrogen content in wastewater, long short-term memory network model (LSTM), gated recurrent neural network model (GRU), Transformer neural network model and recurrent neural network model (RNN), and specifically uses key evaluation indicators (determination coefficient, root mean square error and mean absolute error) to compare the performance, as shown in Table 1.
[0119]
[0120] The present invention shows through the above comparison:
[0121] The prediction model of ammonia nitrogen content in wastewater achieved better performance on the test set, showing R 2 The coefficient of determination is 0.9255, the root mean square error is 2.6306 mg / L, and the MAE is 2.0430 mg / L. The results of the three key evaluation indicators are better than those of other models. This shows that the present invention can utilize the complementary advantages of different models to significantly improve the prediction performance of ammonia nitrogen content in wastewater.
[0122] S3. Obtain real-time monitoring data of wastewater and preprocess it, establish a real-time variable data set, and obtain the predicted value of ammonia nitrogen content in wastewater based on the ammonia nitrogen content prediction model of the tested wastewater to make an intelligent prediction of water quality.
[0123] In an optional embodiment of the present invention, the present invention obtains real-time monitoring data of wastewater, processes the monitoring data of wastewater to obtain real-time monitoring and processing data of wastewater, and constructs the real-time monitoring data of wastewater and the real-time monitoring and processing data of wastewater into an input variable set and inputs them into a prediction model of ammonia nitrogen content of wastewater after test to obtain the predicted value of ammonia nitrogen content of wastewater.
[0124] like Figure 4 As shown, an automatic wastewater treatment control system using the above method includes an SBR reactor, a data collection unit, a water quality intelligent prediction unit and an automatic wastewater treatment unit connected in sequence.
[0125] In an optional embodiment of the present invention, an SBR reactor is used to treat wastewater to generate a wastewater treatment sample.
[0126] In an optional embodiment of the present invention, the data collection unit is used to obtain monitoring data of wastewater, preprocess the monitoring data of wastewater to obtain preprocessed data, and establish a variable data set based on the monitoring data of wastewater and the preprocessed data set; divide the variable data set into a training data set and a test data set; perform data monitoring on wastewater treatment samples, obtain real-time monitoring data of wastewater and preprocess it, and establish a real-time variable data set.
[0127] In an optional embodiment of the present invention, the water quality intelligent prediction unit is used to design a prediction model for the ammonia nitrogen content of wastewater based on Transformer and LSTM, train and test the prediction model for the ammonia nitrogen content of wastewater using a training data set and a test data set, and obtain the prediction model for the ammonia nitrogen content of wastewater after the test; and based on the real-time variable data set and the prediction model for the ammonia nitrogen content of wastewater after the test, obtain the predicted value of the ammonia nitrogen content of the wastewater.
[0128] In an optional embodiment of the present invention, the automatic wastewater treatment unit is used to automatically execute the wastewater treatment process according to the predicted value of the ammonia nitrogen content of the wastewater.
[0129] The automatic wastewater treatment unit includes a stirrer and an aeration pump; the stirrer is used to perform a stirring operation according to the predicted value of the ammonia nitrogen content of the wastewater to perform an anaerobic biochemical reaction on the wastewater; the aeration pump is used to perform an aeration operation according to the predicted value of the ammonia nitrogen content of the wastewater to perform an aerobic biochemical reaction on the wastewater.
[0130] The present invention performs a wastewater treatment process according to a predicted value of ammonia nitrogen content of the wastewater, specifically: judging whether the predicted value of ammonia nitrogen content of the wastewater is lower than 5 mg / L; if so, stopping the biochemical reaction and entering the sedimentation and drainage stage to achieve wastewater treatment; otherwise, using an aeration pump to perform an aeration operation, continuing aeration for aerobic biochemical reaction, and using a stirrer to perform a stirring operation, continuing stirring for anaerobic biochemical reaction, until the data is monitored again for prediction and judgment and the standard is met.
[0131] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0132] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0133] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0134] The present invention uses specific embodiments to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
[0135] Those skilled in the art will appreciate that the embodiments described herein are intended to help readers understand the principles of the present invention, and should be understood that the protection scope of the present invention is not limited to such specific statements and embodiments. Those skilled in the art can make various other specific variations and combinations that do not deviate from the essence of the present invention based on the technical revelations disclosed by the present invention, and these variations and combinations are still within the protection scope of the present invention.
Claims
1. A water quality intelligent prediction method, characterized in that: The following steps are involved: S1. Obtaining wastewater monitoring data, where wastewater samples are taken from a collection container in an SBR reactor pool, preprocessing the wastewater monitoring data to obtain preprocessed data, and establishing a variable data set based on the wastewater monitoring data and the preprocessed data set; Wastewater monitoring data include wastewater conductivity, dissolved oxygen and redox potential; The pre-treatment data include the change rate and cumulative value of the wastewater monitoring data; S2. Design a prediction model for the ammonia nitrogen content of wastewater based on Transformer and LSTM, divide the variable data set into a training data set and a test data set, and use the training data set and the test data set to train and test the prediction model for the ammonia nitrogen content of wastewater to obtain the prediction model for the ammonia nitrogen content of wastewater after the test; The prediction model of ammonia nitrogen content in wastewater includes a position encoding layer, a Transformer encoder and an LSTM decoder connected in sequence; The position encoding layer is used to receive an input variable set, perform position encoding on the input variable set, and output an input variable set with position information; The Transformer encoder is used to perform a dot product operation on an input variable set with position information to output a feature enhanced variable set; the Transformer encoder includes a multi-head attention mechanism, a first normalization layer, a first linear addition layer, a feedforward layer, a second normalization layer, and a second linear addition layer connected in sequence; the first linear addition layer is connected to the input of the Transformer encoder; the feedforward layer is connected to the second linear addition layer; The feed-forward layer includes two linear transformation layers connected by ReLU activation functions. The calculation process of the linear transformation layer is: in: To output the ammonia nitrogen value, For the matrix The transpose of is the input variable, is the bias term of the function; The LSTM decoder is used to serially process the output feature enhancement variable set, the output of the previous time step, and the unit state of the previous time step to obtain the predicted value of the ammonia nitrogen content of the wastewater; the LSTM decoder includes a first linear rectification layer, a long short-term memory network operation layer, a second linear rectification layer, a first fully connected layer, and a second fully connected layer connected in sequence; S3. Obtain real-time monitoring data of wastewater and preprocess it, establish a real-time variable data set, and obtain the predicted value of ammonia nitrogen content in wastewater based on the ammonia nitrogen content prediction model of the tested wastewater to make an intelligent prediction of water quality, and execute the wastewater treatment process according to the predicted value of ammonia nitrogen content in wastewater, specifically: determine whether the predicted value of ammonia nitrogen content in wastewater is lower than 5 mg / L; if so, stop the biochemical reaction and enter the sedimentation and drainage stage to achieve the treatment of wastewater, otherwise use the aeration pump to perform aeration operation to continue aerobic biochemical reaction, and use the agitator to perform stirring operation to continue anaerobic biochemical reaction, until the predicted value of ammonia nitrogen content in wastewater reaches the standard.
2. The water quality intelligent prediction method according to claim 1, characterized in that: In the position encoding layer, the input variable set is positionally encoded to output the input variable set with position information, including the following steps: A1. Calculate the odd position encoding data of the input variable set, expressed as: in: For the The odd-numbered positions of the input variable set at time steps are encoded, is the time step, For the dimension, is a sine function, Encode the data corresponding to the position; A2, calculate the even position encoding data of the input variable set; in: For the The even-numbered position encoding values of the input variable set at time steps, is the cosine function; A3. Output the input variable set with position information according to the input variable set, the odd position encoding data of the input variable set and the even position encoding data of the input variable set, expressed as: in: For the A set of input variables with location information for time steps, For the The set of input variables with time steps, For the The position-encoded values of the set of input variables at time steps.
3. The water quality intelligent prediction method according to claim 1 is characterized in that: In the multi-head attention mechanism, a dot product operation is performed on the input variable set with position information, and the feature enhancement variable set output by the multi-head attention mechanism includes the following steps: B1. Calculate the keyword vector, value vector, and query vector of the input variable set with position information, expressed as: , , in: For the input variable set with position information in The keyword vector of the attention head, is the number of the attention head, is a set of input variables with position information, For the The trainable projection matrix of the keyword vectors of the attention heads, For the input variable set with position information in The value vector of the attention head, For the The trainable projection matrix of the value vectors of the attention heads, For the input variable set with position information in The query vector of the attention head, For the The trainable projection matrix of the query vector for each attention head; B2. Perform dot product operations on the keyword vector, value vector, and query vector of the input variable set with position information to obtain the feature enhancement variable set of a single attention head, expressed as: in: For the The feature enhancement variable set of the attention head, is the symbol of the softmax function, is the dimension of the keyword vector, For keyword vector The transpose of B3. Parallel calculation is performed on the feature enhancement variable set of a single attention head to obtain the feature enhancement variable set output by the multi-head attention mechanism, which is expressed as: in: It is the feature enhancement variable set output by the multi-head attention mechanism. To parallelize the symbolic computation, , is the total number of attention heads in the multi-head attention mechanism, is the trainable projection matrix for the multi-head attention mechanism.
4. The water quality intelligent prediction method according to claim 1, characterized in that: The LSTM network operation layer includes input gate, forget gate, output gate and unit state gate.
5. An automatic wastewater treatment control system using the method according to any one of claims 1 to 4, characterized in that: It includes an SBR reactor, a data collection unit, a water quality intelligent prediction unit and an automatic wastewater treatment unit connected in sequence; The SBR reactor is used to treat wastewater and produce wastewater treatment samples; The data collection unit is used to obtain wastewater monitoring data, preprocess the wastewater monitoring data to obtain preprocessed data, and establish a variable data set according to the wastewater monitoring data and the preprocessed data set; Divide the variable data set into a training data set and a test data set; Conduct data monitoring on wastewater treatment samples, obtain real-time monitoring data of wastewater and pre-process it to establish a real-time variable data set; The water quality intelligent prediction unit is used to design a wastewater ammonia nitrogen content prediction model based on Transformer and LSTM, train and test the wastewater ammonia nitrogen content prediction model using training data sets and test data sets, and obtain the wastewater ammonia nitrogen content prediction model after the test; and obtain the predicted value of the wastewater ammonia nitrogen content based on the real-time variable data set and the wastewater ammonia nitrogen content prediction model after the test; The automatic wastewater treatment unit is used to automatically execute the wastewater treatment process according to the predicted value of the ammonia nitrogen content of the wastewater.
