Water supply plant residual chlorine prediction method based on cascade time sequence neural network
Through the water supply plant residual chlorine prediction method based on cascade timing neural network, the problem of relying on manual operation of the control of chlorine links in the existing technology is solved, and the accurate prediction of residual chlorine concentration is achieved, which improves the water quality safety and the control accuracy of the automatic chlorine system.
Patent Information
- Application Number
- CN202510090328.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-21
- Publication Date
- 2025-05-16
AI Technical Summary
In the existing water treatment process, the control of the chlorination step relies on manual operation, resulting in low automation, difficult to ensure the safety of the effluent water quality, and difficult to achieve accurate residual chlorine prediction.
The residual chlorine prediction method of water supply plants based on cascade timing neural network is adopted. By collecting historical data, cleaning data, building a cascade timing neural network model and training, the accurate prediction of residual chlorine concentration is achieved.
This method can more accurately predict changes in residual chlorine concentration, improve the control accuracy of the automatic chlorination system, ensure the safety and stability of water quality, and reduce operating costs.
Smart Images

Figure CN120015156A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of water quality prediction, and in particular relates to a residual chlorine prediction method for a water supply plant based on a cascaded time series neural network. Background Art
[0002] Chlorine is the most widely used disinfectant in urban drinking water systems. It can effectively control the growth of bacteria in water. The residual chlorine in the water production and treatment process is an important indicator to ensure the safety of water quality leaving the factory. The low degree of automation of the dosing control means of the water plant will reduce the operating efficiency of the water plant, resulting in waste of chemicals and manpower, and it is difficult to ensure the quality of the effluent water. With the improvement of society's requirements for water supply quality and safety and reliability, it is particularly important to use advanced technology and equipment and dosing methods to realize the automation of production processes and improve the automation level of water plant production links.
[0003] At present, in the water treatment process, the control process of the chlorination link is basically done manually. The operator manually increases or decreases the dosage of the agent based on the production requirements and their own experience. With the increase in the scale of urban water use, the scale of the production system is also getting larger and larger. Through the automatic collection of on-site production data, the automation of the agent addition process is realized through the application of modern control technology. Among them, it is very important to establish a residual chlorine prediction model. Accurate residual chlorine prediction is very important for the subsequent control strategy. In this study, a residual chlorine prediction method for water supply plants based on cascaded time series neural networks is proposed. This deep learning model can effectively predict the residual chlorine in the effluent of the water treatment process. The accurate prediction of residual chlorine is the prerequisite for the implementation of subsequent automated control methods. Therefore, its accuracy has a vital impact on the effect and application of automatic dosing technology. Summary of the invention
[0004] The technical problem to be solved by the present invention is to overcome the deficiencies of the prior art and provide a method for predicting residual chlorine in a water supply plant based on a cascaded time series neural network, which can overcome the above problems or at least partially solve the above problems.
[0005] In order to solve the above technical problems, the basic concept of the technical solution adopted by the present invention is: a method for predicting residual chlorine in a water supply plant based on a cascaded time series neural network, comprising the following steps:
[0006] S1. Collect historical data, including but not limited to inlet flow, inlet residual chlorine, outlet flow, outlet turbidity, outlet residual chlorine, medicine tank level and weather temperature data;
[0007] S2. Cleaning the historical data to remove the original data and irrelevant data that interfere with the prediction results, and processing the abnormal data;
[0008] S3. Construct a residual chlorine prediction model for water supply plants based on a cascaded time series neural network. The front end of the model uses three fully connected layers to learn the basic regularity characteristics of the data, and the back end uses an LSTM network to capture the dynamic characteristics and trends in the time series data.
[0009] S4, training the model using the preprocessed data until the model converges;
[0010] S5. Use the test set data to comprehensively evaluate the prediction performance of the model;
[0011] Among them, the prediction performance is calculated as follows:
[0012]
[0013] Y i is the true value of the data, Represents the predicted value.
[0014] Preferably, the data cleaning step includes completing missing data and correcting abnormal data;
[0015] Among them, the missing data is supplemented by the translation and filling method;
[0016] For abnormal data, directly delete the abnormal value and then add a new data X new , new data X new The supplementary recording method is as follows:
[0017]
[0018] X prev is the data point before the outlier, X next is the data point after the outlier.
[0019] S202, calculate the average value of normal data Verify the average value With X new The error between
[0020] S203, set an error reference value μ=0.05,
[0021] S204, if μ′≤μ, X new ′ is the new data X new If μ′>μ, it will be manually corrected by the staff based on experience.
[0022] Preferably, in step S2, the sensor data needs to be uniformly adjusted to sampling data at fixed time intervals, the data of the liquid level of the medicine tank is calculated as the change in each time period, representing the amount of chlorine added in the time period, and the weather temperature data is collected through the network and adjusted to fixed time interval data that matches the sensor data.
[0023] Preferably, in the step of constructing a cascaded temporal neural network model, the three fully connected layers at the front end are used to preliminarily construct an initial feature profile of the input data and deeply explore the internal variation patterns of the data.
[0024] Preferably, the LSTM network includes an input gate, a forget gate and an output gate, which are used to control and update the flow and state information of the input data to further extract the deep-level characteristics of the residual chlorine change.
[0025] Preferably, before training the model, the cleaned data is divided into a training set, a validation set, and a test set according to a preset ratio.
[0026] Preferably, the preset ratio is 8:1:1, that is, 80% of the data is used for the training set, 10% of the data is used for the validation set, and 10% of the data is used for the test set.
[0027] Preferably, in the model training process, the model parameter design during training includes learning rate, batch size and maximum number of iterations, specifically, the learning rate is set to 0.001, the batch size is set to 8, and the maximum number of iterations is set to 50.
[0028] Preferably, during the model training process, a mean square error loss function is used to measure the difference between the model prediction value and the true value.
[0029] Preferably, the method further includes the following steps: after the model training is completed, the model parameters and loss curve graph are saved to facilitate subsequent model loading and reuse, and to evaluate whether the model has problems such as overfitting or underfitting.
[0030] After adopting the above technical scheme, the present invention has the following beneficial effects compared with the prior art: the present invention is based on the neural network structure, and constructs a water supply plant residual chlorine prediction model of a cascaded time series neural network. The model can process complex residual chlorine time series data, and can quickly extract features through a three-layer fully connected structure, analyze the periodicity of the data, and use the long-term and short-term memory capabilities of the LSTM unit to learn the long-term change trend of residual chlorine and obtain the change law of each time period; compared with other models, the overall error of the prediction result of the model is small, the stability is good, and the network training speed is faster. The model can more accurately predict the future changes in residual chlorine concentration. The mean square error of the model in the test set is 0.091. The accurate residual chlorine prediction of the model can provide theoretical guidance for the automatic chlorination system. By real-time monitoring and predicting the changes in residual chlorine, the amount of chlorine can be more accurately controlled through the PLC, thereby ensuring the safety and stability of water quality, which not only improves the efficiency of the treatment process, but also reduces operating costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In the attached picture:
[0032] Figure 1 A schematic diagram of a flow chart of a method for predicting residual chlorine in a water supply plant based on a cascaded time series neural network proposed by the present invention;
[0033] Figure 2 A loss curve diagram of the training process in a method for predicting residual chlorine in a water supply plant based on a cascaded time series neural network proposed by the present invention;
[0034] Figure 3 A comparison curve between the predicted value and the true value of residual chlorine in a water supply plant residual chlorine prediction method based on a cascaded time series neural network proposed by the present invention;
[0035] Figure 4 A network structure diagram of a prediction model of a water supply plant residual chlorine prediction method based on a cascaded time series neural network proposed by the present invention;
[0036] Figure 5 This is a LSTM neural network structure diagram of a water supply plant residual chlorine prediction method based on a cascaded time series neural network proposed in the present invention. DETAILED DESCRIPTION
[0037] The present invention is further described in detail below in conjunction with the accompanying drawings and embodiments so that those skilled in the art can implement the invention with reference to the description.
[0038] It should be understood that the terms such as “having”, “including” and “comprising” used herein do not exclude the existence or addition of one or more other elements or combinations thereof.
[0039] In the description of the present invention, the terms "lateral", "longitudinal", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside" and "outside" etc. to indicate directions or positional relationships are based on the directions or positional relationships shown in the accompanying drawings and are only for the convenience of describing the present invention and simplifying the description. They do not indicate or imply that the device or element referred to must have a specific direction, be constructed and operated in a specific direction, and therefore should not be understood as a limitation on the present invention.
[0040] Example 1: Reference Figure 1-Figure 5 , a method for predicting residual chlorine in a water supply plant based on a cascaded time series neural network, comprising the following steps:
[0041] S1. Collect historical data, including but not limited to inlet flow, inlet residual chlorine, outlet flow, outlet turbidity, outlet residual chlorine, tank level and weather temperature data;
[0042] S2. Clean the historical data, remove the original data and irrelevant data that interfere with the prediction results, and process the abnormal data;
[0043] S3. Construct a residual chlorine prediction model for water supply plants based on a cascaded time series neural network. The front end of the model uses three fully connected layers to learn the basic regularity characteristics of the data, and the back end uses an LSTM network to capture the dynamic characteristics and trends in the time series data.
[0044] S4. Use the preprocessed data to train the model until the model converges;
[0045] S5. Use the test set data to comprehensively evaluate the prediction performance of the model;
[0046] Among them, the prediction performance is calculated as follows:
[0047]
[0048] Y i is the true value of the data, Represents the predicted value.
[0049] In the present invention, the historical data of the water plant of Tianjin East Water Plant from May 2022 to November 2022 were first collected, including key data such as inlet flow, inlet residual chlorine, outlet flow, outlet turbidity, outlet residual chlorine, 1# medicine tank level and 2# medicine tank level; Pearson Correlation Coefficient analysis was performed on these historical data, and the calculation formula is as follows:
[0050]
[0051] xi and i are the values of the two variables of the i-th data point, and are the means of the two variables respectively;
[0052] The results of correlation coefficient calculation are shown in Table 1:
[0053] Table 1. Correlation coefficient matrix
[0054] Inlet flow Residual chlorine in influent Water flow Outlet turbidity Residual chlorine in effluent Tank level Inlet flow 1 0.088433 0.5859522 -0.219880 0.309140 -0.057141 Residual chlorine in influent 0.088433 1 0.016837 -0.332216 0.090914 -0.050611 Water flow 0.589522 0.016837 1 -0.117950 0.139868 -0.000497 Outlet turbidity -0.219880 -0.332216 -0.117950 1 -0.170545 0.228611 Residual chlorine in effluent 0.309140 0.090914 0.139868 -0.170545 1 0.228611 Tank level -0.057141 -0.050611 -0.000497 0.228611 -0.071174 1
[0055] As can be seen from Table 1, the residual chlorine in the effluent has a certain correlation with other data, all of which will affect the residual chlorine value in the effluent. Therefore, the instrument data used the inlet flow rate, inlet residual chlorine, outlet flow rate, outlet residual chlorine, and medicine tank level data. At the same time, because the reaction time of sodium hypochlorite is related to temperature, the weather temperature data was also obtained through network data collection.
[0056] Example 2: With reference to FIG. Figure 1-Figure 3 , which is basically the same as Example 1, furthermore: the data cleaning step includes completing missing data and correcting abnormal data;
[0057] Among them, the missing data is supplemented by the translation and filling method;
[0058] For abnormal data, directly delete the abnormal value and then add a new data X new , new data X new The supplementary recording method is as follows:
[0059]
[0060] X prev is the data point before the outlier, X next is the data point after the outlier.
[0061] S202, calculate the average value of normal data Verify the average value With X new The error between
[0062] S203, set an error reference value μ=0.05,
[0063] S204, if μ′≤μ, X new ′ is the new data X new, if μ′>μ, it is manually corrected by the staff based on experience; in step S2, the sensor data needs to be uniformly adjusted to sampling data at fixed time intervals, and the data of the liquid level in the medicine tank is calculated as the change in each time period, representing the amount of chlorine added in the time period. The weather temperature data is collected through the network and adjusted to fixed time interval data that matches the sensor data.
[0064] In the present invention, before inputting the data into the algorithm model, a series of preprocessing operations need to be performed on the data to ensure that it meets the input and output format requirements of the model; therefore, the sensor data needs to be uniformly adjusted to sampling data at fixed time intervals, and at the same time, the data of the liquid level of the medicine tank is calculated as the change in each time period, that is, representing the amount of chlorine added in the time period;
[0065] When uploading online instrument data, it is easily affected by the instrument equipment status, network and external environment, and even affects the subsequent prediction results; therefore, the translation and filling method is used to complete the missing data, and the abnormal data is updated according to the new data X. new The supplementary recording method is carried out;
[0066] Weather temperature data is collected through the Internet and is also adjusted to fixed time interval data that matches the sensor data to ensure data consistency and accuracy.
[0067] Embodiment 3: Referring to FIG. Figure 1-Figure 3 , which is basically the same as Example 2, and further: in the step of constructing a cascaded temporal neural network model, the three fully connected layers at the front end are used to preliminarily construct the initial feature profile of the input data and deeply explore the internal change rules of the data; the LSTM network includes an input gate, a forget gate and an output gate, which are used to control and update the flow and state information of the input data to further extract the deep-level characteristics of the residual chlorine change.
[0068] In the present invention, Figure 4 This is the network structure diagram of the residual chlorine prediction model of the water supply plant designed by the cascaded time series neural network. The front stage adopts a three-level fully connected layer, which aims to preliminarily construct the initial feature profile of the input data and deeply explore the internal change law of the data. A LSTM neural network structure diagram is cascaded later. The LSTM structure diagram is as follows Figure 5 As shown in the figure, each LSTM unit contains an input gate, a forget gate, and an output gate. These gates are used to control and update the flow and state information of the input data. LSTM further extracts the deep characteristics of the residual chlorine change and explores its fluctuation characteristics over time. This hierarchical cascade design helps to better understand the relationship between the residual chlorine change data and significantly improve the prediction accuracy.
[0069] In the step of building a cascaded time series neural network model, the three-layer fully connected layer at the front end is used to preliminarily build the initial feature profile of the input data and deeply explore the internal change rules of the data. These three layers of fully connected layers can quickly extract the basic features in the data and provide effective input for the subsequent LSTM network processing. By adopting the cascade design of the three-layer fully connected layer and the LSTM network, the internal rules and change trends of the data can be more deeply explored, which improves the prediction accuracy of the model;
[0070] The LSTM network includes an input gate, a forget gate, and an output gate, which are used to control and update the flow and state information of the input data to further extract the deep-level features of the residual chlorine changes. This structure enables the model to better capture the long-term dependencies in time series data, thereby improving the accuracy of prediction;
[0071] The introduction of the LSTM network enables the model to capture the long-term dependencies in time series data, thereby better predicting future changes in residual chlorine;
[0072] In summary, the model performs well in processing complex residual chlorine time series data, providing more accurate prediction results for the automatic chlorination system, which helps to ensure the safety and stability of water quality.
[0073] Embodiment 4: with reference to the figure Figure 1-Figure 3 , which is basically the same as Example 3, and further includes: before training the model, the cleaned data is divided into a training set, a validation set and a test set according to a preset ratio; the preset ratio is 8:1:1, that is, 80% of the data is used for the training set, 10% of the data is used for the validation set, and 10% of the data is used for the test set; during the model training process, the model parameter design during training includes the learning rate, the batch size and the maximum number of iterations, specifically, the learning rate is set to 0.001, the batch size is set to 8, and the maximum number of iterations is set to 50; during the model training process, the mean square error loss function is used to measure the difference between the model prediction value and the true value; and also includes the steps of: after the model training is completed, saving the model parameters and the loss curve graph for subsequent model loading and reuse, and evaluating whether the model has problems such as overfitting or underfitting.
[0074] In the present invention, before training, the input data are water inlet flow, water inlet residual chlorine, water outlet flow, medicine tank liquid level change and weather, and the output data is water outlet residual chlorine; the data set is divided into a training set, a validation set and a test set in a ratio of 8:1:1, and this step ensures that the model can be fully learned and verified during the training process; the model parameters during training are designed as a learning rate of 0.001, a batch size of 8, and a maximum number of iterations of 50, and the setting of these parameters helps the model to remain stable and converge quickly during the training process;
[0075] After the model training is completed, the loss change curve is saved to intuitively show the loss changes during the training process. Then the mean square error loss function is used to evaluate the prediction performance of the model. The calculation formula is as follows:
[0076]
[0077] Y i is the true value of the data, represents the predicted value; at the same time, in order to more intuitively compare the prediction effect, a curve chart showing the predicted value and the actual value of residual chlorine in the effluent over time is drawn, such as Figure 3 As shown;
[0078] During the model training process, the mean square error loss function is used to measure the difference between the model prediction value and the true value, which can intuitively reflect the prediction performance of the model and help optimize the model;
[0079] After the model training is completed, save the model parameters and loss curve graph. The loss curve graph can intuitively show the loss changes during the training process, which helps to evaluate whether the model has problems such as overfitting or underfitting.
[0080] The above embodiments only express several implementation methods of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several modifications and improvements can be made without departing from the concept of the present invention, which are equivalent modifications and improvements made to the above embodiments based on the essential technology of the present invention, and all of them belong to the protection scope of the present invention.
Claims
1. A method for predicting residual chlorine in a water supply plant based on a cascaded time series neural network, characterized in that: The following steps are involved: S1. Collect historical data, including but not limited to inlet flow, inlet residual chlorine, outlet flow, outlet turbidity, outlet residual chlorine, medicine tank level and weather temperature data; S2. Cleaning the historical data to remove the original data and irrelevant data that interfere with the prediction results, and processing the abnormal data; S3. Construct a residual chlorine prediction model for water supply plants based on a cascaded time series neural network. The front end of the model uses three fully connected layers to learn the basic regularity characteristics of the data, and the back end uses an LSTM network to capture the dynamic characteristics and trends in the time series data. S4, training the model using the preprocessed data until the model converges; S5. Use the test set data to comprehensively evaluate the prediction performance of the model; Among them, the prediction performance is calculated as follows: Y i is the true value of the data, Represents the predicted value.
2. A method for predicting residual chlorine in a water supply plant based on a cascaded time series neural network according to claim 1, characterized in that: The data cleaning step includes completing missing data and correcting abnormal data; Among them, the missing data is supplemented by the translation and filling method; For abnormal data, directly delete the abnormal value and then add a new data X new , new data X new The supplementary recording method is as follows: S201、 X prev is the data point before the outlier, X next is the data point after the outlier. S202, calculate the average value of normal data Verify the average value With X new The error between S203, set an error reference value μ=0.05, S204, if μ′≤μ, X new ′ is the new data X new If μ′>μ, it will be manually corrected by the staff based on experience.
3. A method for predicting residual chlorine in a water supply plant based on a cascaded time series neural network according to claim 2, characterized in that: In step S2, the sensor data needs to be uniformly adjusted to sampling data at fixed time intervals, and the data of the liquid level in the medicine tank is calculated as the change in each time period, representing the amount of chlorine added in the time period. The weather temperature data is collected through the network and adjusted to fixed time interval data that matches the sensor data.
4. The method for predicting residual chlorine in a water supply plant based on a cascaded time series neural network according to claim 1, characterized in that: In the step of constructing the cascaded temporal neural network model, the three fully connected layers at the front end are used to preliminarily construct the initial feature profile of the input data and deeply explore the internal change rules of the data.
5. The method for predicting residual chlorine in a water supply plant based on a cascaded time series neural network according to claim 1, characterized in that: The LSTM network includes an input gate, a forget gate and an output gate, which are used to control and update the flow and state information of the input data to further extract the deep-level characteristics of the residual chlorine change.
6. The method for predicting residual chlorine in a water supply plant based on a cascaded time series neural network according to claim 1, characterized in that: Before training the model, the cleaned data is divided into training set, validation set and test set according to the preset ratio.
7. A method for predicting residual chlorine in a water supply plant based on a cascaded time series neural network according to claim 6, characterized in that: The preset ratio is 8:1:1, that is, 80% of the data is used for the training set, 10% of the data is used for the validation set, and 10% of the data is used for the test set.
8. The method for predicting residual chlorine in a water supply plant based on a cascaded time series neural network according to claim 5, characterized in that: During the model training process, the model parameter design during training includes the learning rate, batch size and maximum number of iterations. Specifically, the learning rate is set to 0.001, the batch size is set to 8, and the maximum number of iterations is set to 50.
9. A method for predicting residual chlorine in a water supply plant based on a cascaded time series neural network according to claim 8, characterized in that: During model training, the mean squared error loss function is used to measure the difference between the model's predicted value and the true value.
10. A method for predicting residual chlorine in a water supply plant based on a cascaded time series neural network according to claim 9, characterized in that: It also includes the following steps: After the model training is completed, save the model parameters and loss curve graph to facilitate subsequent model loading and reuse, and evaluate whether the model has problems such as overfitting or underfitting.