Secondary water supply residual chlorine prediction method based on deep learning model
By constructing a multi-layer nonlinear mapping model using deep learning, the problem of insufficient stability in residual chlorine prediction in existing technologies is solved, achieving high-precision and robust prediction in secondary water supply systems.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-17
- Publication Date
- 2026-03-24
AI Technical Summary
In existing technologies, residual chlorine prediction methods struggle to capture the multi-timescale dependence characteristics and complex nonlinear coupling processes in secondary water supply systems, resulting in large fluctuations and insufficient stability in prediction results under abrupt operating conditions or highly time-varying scenarios.
A deep learning-based approach is employed to construct a multi-layer nonlinear mapping model through data acquisition, feature sequence generation, nonlinear relationship extraction, and error evaluation. This model captures the temporal and nonlinear coupling information of residual chlorine characteristics to predict future residual chlorine levels. Furthermore, parameters are adjusted through error feedback to improve prediction accuracy.
It improves the accuracy and stability of residual chlorine prediction, enhances the robustness of prediction, and can more accurately reflect the dynamic trend of residual chlorine concentration, adapting to the complex and ever-changing secondary water supply environment.
Smart Images

Figure CN121725935A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of water quality management technology, specifically to a method for predicting residual chlorine in secondary water supply based on a deep learning model. Background Technology
[0002] Secondary water supply is a crucial link in urban water supply systems to ensure water quality safety for end users. Its operation is affected by various factors, including source water quality, pipe network flow velocity, pressure fluctuations, disinfectant dosage, and ambient temperature. Residual chlorine, as a key indicator for evaluating the safety and water quality stability of secondary water supply, exhibits significant spatiotemporal nonlinear characteristics in its concentration changes. In actual operation, the residual chlorine concentration in the pipe network shows a dynamic decay trend and is influenced by complex factors such as hydraulic conditions, pipe wall reactions, water storage time, and microbial activity. To ensure water quality safety, water supply management departments need to predict residual chlorine concentration in real time and accurately to achieve scientific regulation and early warning.
[0003] Existing technologies for residual chlorine prediction have shortcomings: most existing methods use time series modeling, but most models can only capture linear or short-term correlations, making it difficult to reflect the multi-timescale dependence characteristics and complex nonlinear coupling processes in water quality evolution. This results in large fluctuations and insufficient stability in prediction results when facing sudden changes or highly time-varying scenarios. Summary of the Invention
[0004] To address the shortcomings of existing technologies, this invention provides a method for predicting residual chlorine in secondary water supply based on a deep learning model, in order to solve the problems mentioned in the background.
[0005] To achieve the above objectives, the present invention provides the following technical solution: In a first aspect, the present invention provides a method for predicting residual chlorine in secondary water supply based on a deep learning model, comprising the following steps: S1. Collect historical hydraulic and water quality parameters to obtain raw characteristic data; S2. Generate a time-series feature sequence based on the original feature data; S3. Extract the residual chlorine features by performing nonlinear relationship extraction based on the time-series feature sequence; S4. Based on the characteristics of residual chlorine, predict the future residual chlorine and obtain the predicted residual chlorine value; S5. Based on the predicted residual chlorine value, conduct an error assessment to obtain the prediction accuracy index; S6. Optimize the prediction based on the prediction accuracy index to obtain the optimization result.
[0006] To further optimize this technical solution, the data acquisition in step S1 includes: Based on the structure of the secondary water supply facility, identify the data collection nodes, deploy data collection equipment, collect hydraulic and water quality parameter data, and obtain raw characteristic data.
[0007] To further optimize this technical solution, the feature sequence generation in step S2 includes: Based on the obtained original feature data, feature sequences are combined using a multi-scale sliding window and time delay weights to transform the static feature data into a time-series structure that reflects the time-varying patterns, thus obtaining a time-series feature sequence.
[0008] To further optimize this technical solution, the multi-scale sliding window and time delay weights include: Short-term and long-term feature sequences are constructed based on multi-scale time windows. Continuous time samples are generated through sliding windows. Time delay weights are introduced to characterize the hysteretic effect of features on residual chlorine changes. The feature sequences are then normalized and their structure is organized.
[0009] To further optimize this technical solution, the nonlinear relationship extraction in step S3 includes: Based on the obtained time-series feature sequence, the time information is fused with water conservancy and water quality characteristics through nonlinear fusion transformation to obtain composite features.
[0010] To further optimize this technical solution, the prediction of future residual chlorine in step S4 includes: Based on the obtained residual chlorine characteristics, the residual chlorine prediction value is obtained by capturing the time information and nonlinear coupling information in the characteristics through the residual chlorine prediction model and multi-layer nonlinear mapping.
[0011] To further optimize this technical solution, the residual chlorine prediction model includes:
[0012] in: :future Predicted residual chlorine value at any given time; Output layer weight matrix; : No. The feature output results of the layer; : Number of mapping layers; Output layer bias term.
[0013] To further optimize this technical solution, the multilayer nonlinear mapping includes:
[0014] in: : Non-linear activation function; : No. Layer weight matrix; : No. The feature output results of the layer; : No. Layer bias vector; By using nonlinear mapping, residual chlorine features are abstracted layer by layer into higher-order feature representations to achieve residual chlorine prediction.
[0015] To further optimize this technical solution, the error assessment in step S5 includes: Based on the obtained residual chlorine prediction value, error assessment is carried out by calculating multi-dimensional error indicators, the prediction performance is quantified, and the prediction accuracy index is obtained.
[0016] To further optimize this technical solution, the prediction optimization in step S6 includes: Based on the obtained prediction accuracy index, the adjustment parameters are determined, the parameters are iteratively corrected, targeted optimization is achieved, and the optimization result is obtained.
[0017] In a second aspect, the present invention provides a computer device, including a memory and a processor, wherein the memory stores a computer program, wherein: when the computer program instructions are executed by the processor, they implement the steps of a method for predicting residual chlorine in secondary water supply based on a deep learning model as described in the first aspect of the present invention.
[0018] Thirdly, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein: when the computer program instructions are executed by a processor, they implement the steps of a method for predicting residual chlorine in secondary water supply based on a deep learning model as described in the first aspect of the present invention.
[0019] Compared with existing technologies, this invention provides a method for predicting residual chlorine in secondary water supply based on a deep learning model, involving machine learning and deep learning technologies, which has the following beneficial effects: This deep learning-based method for predicting residual chlorine in secondary water supply uses multiple nonlinear mappings to explore the coupling relationship between time dependence and features, thereby more accurately reflecting the dynamic trend of residual chlorine concentration, improving prediction accuracy, and enhancing prediction robustness and stability. Attached Figure Description
[0020] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a flowchart illustrating a method for predicting residual chlorine in secondary water supply based on a deep learning model, as proposed in this invention. Figure 2 This is a flowchart illustrating the residual chlorine prediction model of a deep learning-based method for predicting residual chlorine in secondary water supply proposed in this invention. Detailed Implementation
[0022] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0023] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.
[0024] Secondly, the term "an embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in different places throughout this specification does not necessarily refer to the same embodiment, nor is it a single embodiment or an embodiment selectively excluded from other embodiments.
[0025] Example 1: Reference Figures 1-2 This is the first embodiment of the present invention, which provides a method for predicting residual chlorine in secondary water supply based on a deep learning model, including the following steps: S1. Collect historical hydraulic and water quality parameters to obtain raw characteristic data.
[0026] In this embodiment, the data acquisition includes: The dynamic changes in residual chlorine concentration are affected by a variety of factors, including influent water quality, hydraulic characteristics and external environmental conditions. In multi-stage water storage and multi-pipeline branch structures, there are significant differences in water age, flow rate and temperature between different nodes. Therefore, accurate and continuous historical data are required; otherwise, it is impossible to capture the physical and statistical laws of residual chlorine changes and form reliable characteristic patterns.
[0027] Based on the structure of the secondary water supply facility, the data collection nodes are identified, data collection equipment is deployed, and hydraulic and water quality parameter data are collected to obtain raw characteristic data. This results in comprehensive and accurate historical hydraulic and water quality parameter data, ensuring the reliability of predictions.
[0028] The implementation of data acquisition includes: Determine the collection scope and parameter set: Based on the structure of the secondary water supply facility, identify the collection nodes, including the water tank inlet, water tank outlet, main pipe and terminal water supply points, etc., and determine the parameter set to be collected, including influent residual chlorine concentration, effluent residual chlorine concentration, flow rate, water pressure, water tank level, temperature, pH value and turbidity, etc. Constructing equipment access and signal acquisition channels: Utilizing the data interface technology of an industrial SCADA system (a mature industrial data acquisition and monitoring platform), sensors and data acquisition units with communication modules are installed at each measurement point. The SCADA system uploads the sensor signals to the central server via the OPC protocol, forming a continuous and automated data stream. The acquisition frequency is usually set in the range of 1 to 5 minutes to balance real-time performance and data redundancy. Time synchronization and data alignment: Since the sampling periods and transmission delays of different sensors may be inconsistent, in order to prevent time misalignment from causing feature correlation distortion, it is necessary to perform unified timestamp synchronization. Time synchronization can be achieved through network time synchronization NTP, so that all data are stored in a unified time series. After synchronization is completed, it is also necessary to time-align signals with different sampling periods, and fill in missing time points through linear interpolation so that the data are aligned at the same time step. Anomaly identification and error removal: Statistical rules are used to detect outliers, such as distribution anomaly identification based on the 3σ criterion (used to remove abnormal data that deviates from the normal range) or sliding window extreme value detection (used to identify sudden peaks). When anomalies such as sudden changes in residual chlorine value or zero flow rate but residual chlorine still remains high are detected, they are marked and removed. For short-term anomalies, local mean interpolation can be used for repair. If the anomaly lasts for a long time, it is repaired through manual verification or backup sensor data. Perform data consistency checks and structured storage: After removing anomalies, unify the units of each parameter and store them in a structured manner to ensure that the data format and time granularity are consistent. A tabular database is usually used, with each record corresponding to a multi-dimensional parameter value at a certain point in time. Generate the original feature dataset: The cleaned and corrected data is indexed by time to form a continuous feature sequence containing multiple physical quantities, which is the original feature data. All the original feature data constitute the original feature dataset, which provides data support for subsequent steps.
[0029] S2. Generate a feature sequence based on the original feature data to obtain a time-series feature sequence.
[0030] In this embodiment, the feature sequence generation includes: In the secondary water supply process, the residual chlorine concentration is not only affected by instantaneous water quality or hydraulic conditions, but also by the continuous effect of historical conditions, exhibiting a lag characteristic. For example, flow fluctuations in the pipeline network may not be reflected in residual chlorine changes until tens of minutes later. Using data from a single point in time cannot capture this delay characteristic and time-series dependence.
[0031] Based on the obtained raw feature data, feature sequences are combined using multi-scale sliding windows and time delay weights to transform static feature data into a time-series structure that reflects the laws of time change, thereby obtaining a time-series feature sequence. This captures short-term fluctuations and long-term trends, quantifies the lag effect of features, and improves the time-series expressive ability of residual chlorine changes.
[0032] Furthermore, the multi-scale sliding window and time delay weights include: Short-term and long-term feature sequences are constructed based on multi-scale time windows. Continuous-time samples are generated through a sliding window, and time delay weights are introduced to characterize the hysteretic effect of features on residual chlorine changes. The feature sequences are then normalized and their structure is adjusted. Specific implementation methods include: Determine the time window scale: Different water quality parameters change at different rates. For example, flow rate and pressure respond quickly and change frequently, while parameters such as temperature and water level change slowly and change at low frequency. If all features are processed in the same window, short-term features will be smoothed out or long-term features will be fragmented. Therefore, it is necessary to comprehensively consider the sampling frequency and data change period and set short-term and long-term windows to ensure coverage of key time scales. For example, the short-term window is used to reflect the instantaneous fluctuations of flow rate and residual chlorine, with a time span of 30 minutes, while the long-term window is used to describe the effects of slow changes in temperature, water tank level, etc., with a time span of 12 hours, so as to fully depict the dynamic change process of residual chlorine and reflect both short-term disturbances and long-term decay. Constructing a sliding window sequence: A window slides along the time axis with a fixed step size. Each time the window slides, continuous feature data within the window is extracted to form a sample sequence. Each sequence contains time evolution information of multi-dimensional features, such as parameter values of residual chlorine, flow rate, water level, and temperature over multiple past time steps. The overlapping part of the sliding window is necessary. If the windows are completely independent, it will lead to a break in the time information. By controlling the window overlap ratio with a reasonable sliding step size (usually set to 50% to 75%), the continuity of data is ensured and the number of samples is increased to form a sample set, where each sample corresponds to a complete state sequence within a time period. Parallel generation of multi-scale features: For the same original dataset, a sliding extraction process is performed according to short-term and long-term windows respectively to form two sets of time-series features. The short-term feature sequence focuses more on local fluctuations and reflects rapid changes, such as the fluctuation of residual chlorine caused by flow rate, pressure, and pump start-up and shutdown. The long-term feature sequence focuses more on trend changes and reflects slow changes, such as chlorine consumption caused by temperature changes or water storage time. Then, the features are aligned by time index to ensure that the features of each time scale can correspond at the same time point, forming a parallel feature input structure with dual time scales, which provides a multi-scale learning foundation for subsequent steps. Time Delay Weight Encoding: In each generated time series, a delay weight is assigned to the features at different time steps. The weight setting can be determined based on experiments or physical experience, and the assignment is done in a segmented manner (e.g., reaching a peak at a specific delay time). For example, if the impact of flow rate changes on residual chlorine becomes apparent after about 10 minutes, the delay weight will reach its peak at that moment. Through this mechanism, the generated time series features not only reflect the time sequence but also carry physical delay response information, thus better reflecting the dynamic law of residual chlorine in the actual system, identifying the lag effect of past features on current residual chlorine, making it easier for the model to learn the lag relationship between features, reducing the interference of data from distant time points, and enhancing the dominant role of features from recent time points. Normalization and structural organization: Numerical normalization is performed on all time series samples along the feature dimensions to eliminate dimensional differences. Short-term and long-term features and delay weights are uniformly organized into a standardized input structure, so that each sample contains complete multi-time scale and weighted information, which can be directly read and nonlinear relationship extraction is performed, thereby transforming static and discrete data into a multi-level and dynamic time series set.
[0033] S3. Extract nonlinear relationships based on time-series feature sequences to obtain residual chlorine features.
[0034] In this embodiment, the nonlinear relationship extraction includes: In the secondary water supply process, the residual chlorine concentration is affected by multiple factors, such as water temperature, flow rate, water age, pH value, influent residual chlorine, and pipeline retention time. The relationship between these factors is not a linear superposition, but often exhibits nonlinear coupling characteristics. Traditional linear modeling (such as regression or ARIMA) is difficult to capture these complex relationships.
[0035] Based on the obtained time-series feature sequence, the time information is fused with water conservancy and water quality features through nonlinear fusion transformation to obtain a composite feature that contains both time dependence and physical correlation, namely residual chlorine feature. This improves the feature expression dimension, realizes joint modeling of time dependence and physical features, and reveals the nonlinear dynamic law of residual chlorine change.
[0036] Furthermore, the nonlinear fusion transformation includes: A multi-channel feature mapping structure is constructed to distinguish features at multiple time scales. Temporal variation patterns and feature coupling relationships are extracted through dual-channel embedding mapping. Nonlinear cross-fusion and multi-layer transformation are then performed to achieve layer-by-layer abstraction of local and global features. The implementation steps include: Construct a feature mapping layer structure: Based on the multi-scale time series feature sequence output by S2, set feature input channels, input features of different time scales in parallel, and process a set of time series independently. The short-term channel is responsible for capturing instantaneous fluctuations, and the long-term channel is responsible for describing the gradual trend, forming a multi-channel input structure to retain the difference between short-term fluctuations and long-term trends. Dual-channel embedding mapping of time and features: Dual-channel embedding is performed on each time series. One channel is used for extracting the time dimension of change features (inputting the sequence of each feature changing over time), and the other channel is used for modeling the joint relationship between physical parameters (inputting water quality and hydraulic features at the same time). The time dimension is mapped through a nonlinear transformation layer (e.g., using neural units with activation functions ReLU or Tanh) to identify dynamic patterns such as periodicity, abrupt change, or lag in residual chlorine changes. The complex interaction relationship between features is learned through nonlinear mapping, so that the model can learn coupling relationships in both the feature dimension and the time dimension simultaneously. Cross-channel correlation fusion: After the extraction of time channel and feature channel, the two types of embedding results are fused by nonlinear cross-mapping (such as product mapping or activation function coupling), for example, "cross-mapping of flow rate change in the past 5 minutes and current temperature fluctuation", to form a composite expression structure, so as to obtain the synergistic change law between time series features and physical features, capture the coupling response characteristics of different features at different times, and thus enhance the understanding of residual chlorine change law; Multi-layer nonlinear mapping: Based on the fusion results, a multi-layer mapping unit is constructed. Each layer performs a nonlinear transformation (such as using activation functions such as Sigmoid, ReLU, or Swish). The first layer mainly extracts local nonlinear relationships, such as the instantaneous coupling between flow rate and residual chlorine concentration. The middle layer extracts combined features across time periods, such as the indirect influence of temperature changes on the residual chlorine decay rate. The higher layers extract global features, such as long-term operating trends or residual chlorine evolution trajectories under typical operating conditions. This process abstracts features layer by layer, removes noise layer by layer, and highlights key relationships. After multi-layer mapping, a set of representative high-dimensional representations is obtained, which have strong discriminative and predictive capabilities. Output residual chlorine features: After multi-layer mapping extraction, the information output by each layer has different levels of abstraction and response features. The bottom layer outputs local features (such as instantaneous fluctuations), the middle layer outputs combined features (such as multi-factor synergistic changes), and the top layer outputs global features (such as trend patterns). The output results of all layers are integrated (including inter-layer splicing, weighted fusion, or hierarchical projection, etc.) to retain the complementary features of each layer and form a unified residual chlorine feature. This feature not only maintains temporal continuity and multi-scale features, but also contains complex nonlinear coupling information.
[0037] S4. Based on the characteristics of residual chlorine, predict the future residual chlorine value.
[0038] In this embodiment, the prediction of future residual chlorine includes: The changes in residual chlorine concentration during secondary water supply processes exhibit nonlinearity, multi-factor coupling, and time lag characteristics, necessitating the construction of a mapping mechanism to transform high-dimensional abstract features into concrete numerical prediction results. Traditional methods typically employ linear regression or single-step prediction models, which fail to fully utilize the complex nonlinear information within the latent features and struggle to capture the combined impact of short-term disturbances and long-term trends.
[0039] Based on the obtained residual chlorine characteristics, the time information and nonlinear coupling information in the characteristics are captured through the residual chlorine prediction model and multi-layer nonlinear mapping, so as to achieve high-precision prediction of future residual chlorine changes and obtain the residual chlorine prediction value. In this way, the potential laws are transformed into observable engineering indicators, providing real-time and accurate prediction basis for water supply management.
[0040] The specific implementation steps include: Constructing the prediction mapping input structure: Using the residual chlorine features output by S3 as the input of the prediction model, the time dependence and multidimensional coupling information of the features are maintained, and at the same time, they are organized into a unified input format. The input structure includes the latent feature vector and its time label, so that the model can identify the sequence evolution law. Establish a deep nonlinear mapping unit: Construct a multi-layer nonlinear mapping network, with each layer using a nonlinear activation function to process residual chlorine features, realizing the mapping from a high-dimensional abstract space to the output space. The mapping unit compresses information layer by layer, while highlighting the sensitive features to future residual chlorine changes, enabling the model to learn the complex relationship between residual chlorine features and actual residual chlorine values, making the prediction process more flexible and generalizable. Predictive output calculation: Through the linear mapping of the last layer, the processed features are transformed into the predicted residual chlorine values at future time points. The linear mapping is used at this stage to restore the actual physical quantity scale and ensure that the prediction results are interpretable and quantifiable. An error feedback adjustment mechanism is introduced: During the training phase, the error between the predicted result and the actual residual chlorine value is calculated using a loss function, and the error signal is fed back to the prediction mapping layer to adjust the parameters, improve the model's generalization ability under different operating conditions, prevent error accumulation from causing prediction distortion, and improve prediction accuracy and stability. Output the final residual chlorine prediction value: Output the residual chlorine prediction value at a specified future time point. This prediction value maintains the continuity of time and reflects the nonlinear coupling effect captured in the potential characteristics, providing a reliable reference for the management and control of secondary water supply.
[0041] Furthermore, the residual chlorine prediction model includes:
[0042] in: :future The predicted residual chlorine value at a given time indicates the magnitude of the predicted residual chlorine concentration. : Output layer weight matrix, used to map high-dimensional features to a single residual chlorine prediction value, is obtained by adjusting through error feedback during the model training phase; : No. The feature output of a layer, i.e., the higher-order feature representation obtained by layer-by-layer abstraction, is calculated by the output of the previous layer and the parameters of the current layer. The number of mapping layers, or the number of layers in a multi-layer nonlinear mapping network, determines the depth of feature abstraction. The more layers there are, the stronger the nonlinear expressive power of the model, but the computational complexity increases accordingly. The number of layers is set according to the task complexity during the model design stage, and is usually set to 3 to 6 layers. Output layer bias term, used to correct the overall offset of the predicted output, to ensure that the predicted value is consistent with the actual distribution. It is updated and adjusted together with the weights during the model training phase.
[0043] This model describes how to predict residual chlorine through multi-layer nonlinear mapping to obtain the predicted residual chlorine value.
[0044] Traditional residual chlorine prediction often employs conventional time series regression models, relying on univariate or limited statistical features for prediction. This neglects the nonlinear coupling relationships between multiple factors during residual chlorine changes. In contrast, this model uses a nonlinear mapping mechanism to learn the multi-layered dynamic laws of residual chlorine changes in a high-dimensional feature space. It discovers the coupling relationship between time dependence and features and establishes an error feedback adjustment mechanism to adjust parameters, thereby improving prediction accuracy, robustness, stability, and flexibility.
[0045] The steps for using this model include: Data acquisition: Through step S3, the residual chlorine characteristics are obtained as input data for the model; Multi-layer mapping: Based on the obtained residual chlorine features, the data is input into a multi-layer nonlinear mapping network to perform multi-layer nonlinear mapping, resulting in higher-order feature representations. ; Residual chlorine prediction: using higher-order feature representation Residual chlorine prediction is performed in the output layer to obtain the predicted residual chlorine value. .
[0046] Furthermore, the multilayer nonlinear mapping includes:
[0047] in: Non-linear activation functions are used to introduce non-linear feature mappings, enabling the model to fit complex relationships. They are selected and set during the model design phase, and commonly used functions are ReLU, Sigmoid, or Tanh. : No. The layer weight matrix is used to control the projection intensity of features from the previous layer onto the current layer, determining the direction and magnitude of feature abstraction. It is set through an initial random distribution (such as Xavier initialization) and adjusted through error feedback during the model training phase. : No. The feature output of the layer, when When the value is 1, it indicates that this is the first mapping, with no feature output result, and the residual chlorine feature obtained in step S3 is used as the input data, i.e. The residual chlorine characteristics output in step S3 are used as the initial input data for the entire model. : No. The bias vector of the layer is used to adjust the translation of the linear combination result, enhance the nonlinear expressive power of the model, and improve the convergence performance of the model. It is set by random initialization and updated and adjusted together with the weights during the model training phase. By using nonlinear mapping, residual chlorine features are abstracted layer by layer into higher-order feature representations to achieve residual chlorine prediction.
[0048] S5. Based on the predicted residual chlorine value, an error assessment is performed to obtain the prediction accuracy index.
[0049] In this embodiment, the error assessment includes: The residual chlorine levels in secondary water supply systems are affected by various factors, such as water temperature, residence time, flow rate, and the degree of aging of the pipe network, leading to a certain degree of uncertainty in the predicted values. In actual operation, if the predicted results output by the model deviate from the actual values, it will lead to misjudgment of the water quality status, potentially causing the risk of excessive chlorination or insufficient disinfection.
[0050] Based on the obtained residual chlorine prediction values, error assessment is carried out by calculating multi-dimensional error indicators (including mean absolute error, mean square error, relative error, etc.), the prediction performance is quantified, and the prediction accuracy index is obtained. This clarifies the difference in the model's prediction ability between the high residual chlorine fluctuation period and the steady-state period, determines the model's applicable range and credibility interval, judges whether the residual chlorine prediction model meets the technical standards for water supply safety monitoring, and realizes the connection between prediction and actual control.
[0051] The implementation of error evaluation includes: Actual residual chlorine data collection: Obtain the actual residual chlorine observation values corresponding to the prediction period, including the concentration and time label of each sampling point, to ensure strict time alignment with the residual chlorine prediction values obtained from S4. If there is a deviation between the sampling interval and the prediction step size, interpolation or time mapping is required to achieve time alignment for subsequent statistical calculations. Prediction error calculation: Compare the predicted value with the actual observed value point by point, subtract the actual value from the predicted value to obtain the prediction error at a single time point, thereby quantifying the prediction deviation at each time point and providing basic data for generating the overall accuracy index; Summarize and generate accuracy indicators: Statistically summarize the error series to generate overall accuracy indicators, such as root mean square error (RMSE), mean absolute error (MAE), and mean relative percentage error (MAPE), thereby intuitively reflecting the overall accuracy and bias distribution of the prediction model. Analyze the error distribution pattern: Analyze the time or characteristic dependence of the prediction deviation based on the error sequence, such as whether the error increases under high flow or high temperature conditions, or whether the error shows a systematic shift at night or under low load, to provide a reference for subsequent model adjustment or outlier handling; Output prediction accuracy indicators: The calculated accuracy indicators are organized into a dataset, and the output includes indicators such as RMSE, MAE, and MAPE, as well as error distribution analysis results. These serve as quantitative evaluation standards for model performance and provide decision-making basis for water supply management, scheduling optimization, and model iteration.
[0052] Furthermore, the prediction error calculation includes: Root Mean Square Error (RMSE) Calculation:
[0053] in: : The first moment Predicted residual chlorine value; : The first moment The actual value of residual chlorine; The number of data pairs in the error sequence; Used to quantify the overall prediction accuracy; the smaller the value, the higher the prediction accuracy. Mean Absolute Error (MAE) Calculation:
[0054] It reflects the absolute average level of the deviation between the predicted and actual values, providing an intuitive measure of the error magnitude, and is unaffected by the cancellation of positive and negative errors. Calculation of Mean Relative Percentage Error (MAPE):
[0055] It is used to measure the relative magnitude of prediction error; the smaller the value, the closer the prediction result is to the actual value.
[0056] S6. Optimize the prediction based on the prediction accuracy index to obtain the optimization result.
[0057] In this embodiment, the prediction optimization includes: In the prediction of residual chlorine in secondary water supply, the system operating environment is dynamically affected by factors such as temperature, flow rate, pressure and chlorine dosage, which causes the prediction model to exhibit performance fluctuations under different operating conditions. The model obtained from a single training cannot maintain optimal accuracy in the long term. Therefore, an optimization mechanism is needed to periodically correct the parameters of the residual chlorine prediction model so that the model can adapt to environmental changes, reduce error accumulation and maintain prediction stability.
[0058] Based on the obtained prediction accuracy index, adjustment parameters are determined, and the parameters are iteratively corrected to achieve targeted optimization, thereby improving prediction accuracy and stability, enhancing adaptability and generalization ability, and improving long-term operational reliability.
[0059] The steps involved in implementing prediction optimization include: Extract error information and establish feedback mapping relationship: Extract the main error indicators from the S5 output results, including RMSE, MAE, MAPE and error distribution analysis results, perform statistical and cluster analysis on the distribution pattern of prediction error in time and feature dimensions, establish the mapping relationship between error indicators and model prediction behavior, identify error sources, and use them to describe the performance differences of the model in different time periods and under different working conditions, such as higher error in a specific time period or insufficient contribution of a specific feature, thereby providing a basis for optimization objectives; Determine the set of parameters to be adjusted: After analyzing the sources of error, identify the specific model parameters that should be adjusted, such as weight matrix parameters (reflecting the mapping strength between features and prediction results, which need to be adjusted when the model is overly dependent on or ignores some features), learning rate (controlling the model update step size, which needs to be reset when the model converges too slowly or oscillates), feature weight coefficients (used to adjust the importance of different features, dynamically redistributing them when the error is concentrated on a certain feature) or time window length (determining the length of historical information that the model can utilize, which should be appropriately increased when the error mainly comes from insufficient lagged features), etc., so as to accurately identify the set of parameters that need to be optimized and avoid ineffective or excessive model adjustments. For example, if the error mainly comes from the influence of time lag, adjust the time window length; if the error mainly comes from feature bias, redistribute the feature weights. Iterative parameter correction: Using feedback error information, the internal parameters of the model are iteratively corrected. After each round of correction, prediction and error evaluation are re-executed until the prediction output converges to the expected value. The correction process can be carried out through a phased adjustment mechanism, such as adjusting global parameters in the initial stage and fine-tuning specific feature channels in the later stage. Update the model structure or learning strategy: When a persistent bias in the prediction error is found, structural optimization can be performed, such as increasing the depth of the feature fusion layer, adjusting the type of nonlinear mapping function, or modifying the temporal input window, to improve the prediction performance in a specific mode. If the error mainly comes from slow training convergence, the learning rate can be adjusted or a momentum acceleration mechanism can be introduced to improve convergence efficiency. Generate optimization results and update model output: After completing parameter or structure correction, output the optimized prediction model and its performance indicators to obtain the optimization results. Use the new prediction model to replace the old model and enter the next prediction cycle, so that the model has the ability to continuously learn and adapt to evolution.
[0060] Example 2: In practical applications, this method can be applied to the dynamic monitoring of water quality and prediction of residual chlorine concentration in the secondary water supply system of urban high-rise buildings. It can be used to predict and safely regulate the future changes of residual chlorine concentration in water storage tanks and water supply networks in real time, with a typical scenario of centralized water supply in large residential communities as an example.
[0061] In this scenario, online monitoring data of the community's secondary water supply network is first collected, including multi-source hydraulic and water quality parameters such as residual chlorine concentration, water temperature, flow velocity, pressure, and flow direction at the inlet, outlet, and intermediate pipe sections. Through analysis of historical operational data, a time-series sample set of water quality and hydraulic characteristics is established to reflect the dynamic changes in water quality within different time windows, transforming historical multi-dimensional data into a continuous time-series feature sequence.
[0062] In the feature extraction stage, the coupling relationship between water quality parameters is deeply analyzed through a nonlinear mapping structure to extract residual chlorine features, capture the impact of water quality fluctuations, temperature changes, and flow velocity disturbances on the residual chlorine decay rate, and make residual chlorine predictions for future periods based on the extracted potential features. Short-term and medium-to-long-term prediction results are obtained through multi-layer time series relationship modeling. The prediction results can be used to automatically update water quality control strategies, such as optimizing disinfectant dosage, adjusting the water discharge time of the storage tank, or dynamically adjusting the water supply pressure to keep the residual chlorine concentration at the end of the pipe network within a safe range.
[0063] After prediction is completed, an error assessment is performed. This involves comparing the predicted values with real-time monitoring values to calculate error indices and obtain the prediction accuracy under different time periods and operating conditions. If the prediction error is found to be too large, optimization is carried out based on the source of the error. The internal parameters of the prediction model are iteratively corrected to better adapt to new operating conditions, achieving continuous learning and performance evolution.
[0064] By implementing this method, high-precision prediction and dynamic control of residual chlorine concentration can be achieved in complex and ever-changing secondary water supply environments. This effectively reduces the water supply safety risks caused by water quality fluctuations, improves the intelligent operation level and water quality assurance capabilities of the water supply system, and ensures that end users have access to stable and safe drinking water in the long term.
[0065] Example 3: This embodiment also provides a computer device applicable to a method for predicting residual chlorine in secondary water supply based on a deep learning model, including a memory and a processor; the memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the method for predicting residual chlorine in secondary water supply based on a deep learning model as proposed in the above embodiment.
[0066] This embodiment also provides a storage medium storing a computer program that, when executed by a processor, implements a method for predicting residual chlorine in secondary water supply based on a deep learning model, as proposed in the above embodiment.
[0067] The computer device can be a terminal, comprising a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, carrier networks, NFC (Near Field Communication), or other technologies. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad on the computer device's casing, or an external keyboard, touchpad, or mouse.
[0068] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0069] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-including system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device.
[0070] More specific examples (a non-exhaustive list) of computer-readable media include: electrical connections (electronic devices) having one or more wires, portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which programs can be printed, because programs can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.
[0071] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0072] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. A method for predicting residual chlorine in secondary water supply based on a deep learning model, characterized in that, Includes the following steps: S1. Collect historical hydraulic and water quality parameters to obtain raw characteristic data; S2. Generate a time-series feature sequence based on the original feature data; S3. Extract the residual chlorine features by performing nonlinear relationship extraction based on the time-series feature sequence; S4. Based on the characteristics of residual chlorine, predict the future residual chlorine and obtain the predicted residual chlorine value; S5. Based on the predicted residual chlorine value, conduct an error assessment to obtain the prediction accuracy index; S6. Optimize the prediction based on the prediction accuracy index to obtain the optimization result.
2. The method for predicting residual chlorine in secondary water supply based on a deep learning model according to claim 1, characterized in that, The data acquisition in step S1 includes: Based on the structure of the secondary water supply facility, identify the data collection nodes, deploy data collection equipment, collect hydraulic and water quality parameter data, and obtain raw characteristic data.
3. The method for predicting residual chlorine in secondary water supply based on a deep learning model according to claim 1, characterized in that, The feature sequence generation in step S2 includes: Based on the obtained original feature data, feature sequences are combined using a multi-scale sliding window and time delay weights to transform the static feature data into a time-series structure that reflects the time-varying patterns, thus obtaining a time-series feature sequence.
4. The method for predicting residual chlorine in secondary water supply based on a deep learning model according to claim 3, characterized in that, The multi-scale sliding window and time delay weights include: Short-term and long-term feature sequences are constructed based on multi-scale time windows. Continuous time samples are generated through sliding windows. Time delay weights are introduced to characterize the hysteretic effect of features on residual chlorine changes. The feature sequences are then normalized and their structure is organized.
5. The method for predicting residual chlorine in secondary water supply based on a deep learning model according to claim 1, characterized in that, The nonlinear relationship extraction in step S3 includes: Based on the obtained time-series feature sequence, the time information is fused with water conservancy and water quality characteristics through nonlinear fusion transformation to obtain composite features.
6. The method for predicting residual chlorine in secondary water supply based on a deep learning model according to claim 1, characterized in that, The prediction of future residual chlorine in step S4 includes: Based on the obtained residual chlorine characteristics, the residual chlorine prediction value is obtained by capturing the time information and nonlinear coupling information in the characteristics through the residual chlorine prediction model and multi-layer nonlinear mapping.
7. The method for predicting residual chlorine in secondary water supply based on a deep learning model according to claim 6, characterized in that, The residual chlorine prediction model includes: ; in: :future Predicted residual chlorine value at any given time; Output layer weight matrix; : No. The layer's feature output results; : Number of mapping layers; Output layer bias term.
8. The method for predicting residual chlorine in secondary water supply based on a deep learning model according to claim 6, characterized in that, The multi-layer nonlinear mapping includes: ; in: : Non-linear activation function; : No. Layer weight matrix; : No. The layer's feature output results; : No. Layer bias vector; By using nonlinear mapping, residual chlorine features are abstracted layer by layer into higher-order feature representations to achieve residual chlorine prediction.
9. The method for predicting residual chlorine in secondary water supply based on a deep learning model according to claim 1, characterized in that, The error assessment in step S5 includes: Based on the obtained residual chlorine prediction value, error assessment is carried out by calculating multi-dimensional error indicators, the prediction performance is quantified, and the prediction accuracy index is obtained.
10. The method for predicting residual chlorine in secondary water supply based on a deep learning model according to claim 1, characterized in that, The prediction optimization in step S6 includes: Based on the obtained prediction accuracy index, the adjustment parameters are determined, the parameters are iteratively corrected, targeted optimization is achieved, and the optimization result is obtained.