A Water Pollution Source Reverse Tracking Method Based on LSTM Model and Pollution Scenario Database

By combining the LSTM model with a pollution scenario database and using the SP model to simulate pollutant diffusion, a pollution scenario database is generated. This solves the problem of low efficiency in pollution source identification when data is limited in traditional methods, and enables fast and accurate pollution source tracking and type identification.

CN119167034BActive Publication Date: 2026-03-10DALIAN UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-23
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

Traditional pollution tracing methods struggle to quickly and accurately identify pollution sources and types when data is limited, and are particularly inefficient and costly in complex pollution scenarios.

Method used

An LSTM model is used in conjunction with a pollution scenario database. The SP model is used to simulate pollutant diffusion to generate a pollution scenario database. A machine learning model is used for data matching to identify pollution source characteristic parameters. Combined with measured data, reverse tracking is performed.

Benefits of technology

It improves the efficiency and accuracy of pollution source tracing, reduces reliance on large-scale monitoring data, is highly adaptable, can quickly identify pollution sources and types, is applicable to different watersheds and pollution types, and enhances emergency response speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119167034B_ABST
    Figure CN119167034B_ABST
Patent Text Reader

Abstract

This water pollution source reverse tracing method, based on an LSTM model and a pollution scenario database, belongs to the field of water quality monitoring and pollution source tracing technology. It addresses the challenge of accurately identifying pollution sources and types under limited data conditions. The key technical points are: constructing a model based on pollutant diffusion equations to describe the migration and diffusion of pollutants within a watershed; mapping the input pollution source characteristic parameters, output pollutant concentration change curves, residual values, and corresponding pollution scenarios to a database; training a machine learning model using data from the database; and matching the pollution source characteristic parameters predicted by the machine learning model against the database to obtain the corresponding pollution scenarios. The method effectively improves the accuracy and efficiency of pollution source tracing and can be used for watershed pollution control and environmental monitoring and early warning, providing crucial technical support for watershed water environment management.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of water quality monitoring and pollution tracing, and relates to a river pollution source reverse tracking and identification method based on an LSTM model and a pollution scenario database, which is used for quickly judging pollution types and sources. BACKGROUND

[0002] Water quality monitoring and management of rivers and lakes are crucial for protecting water environment and ensuring ecological health. In water quality management, timely and accurate identification of pollution sources and their pollution types (such as point or non-point source pollution) is the basis for developing and implementing effective pollution control measures. However, traditional pollution tracing methods usually rely on a large amount of field monitoring data and complex numerical simulation. These methods are not only time-consuming and costly, but also often difficult to provide fast and accurate tracing results in the case of limited data.

[0003] In the water quality management at the basin level, the occurrence of water pollution incidents is often accompanied by complex pollution scenarios, including multiple pollution sources and different pollution diffusion pathways. In this case, how to quickly identify the type and source of pollutants under limited monitoring data conditions becomes a core problem faced by water quality management. The solution to this problem not only directly affects the efficiency of emergency handling of pollution incidents, but also relates to the long-term protection of the entire basin and the sustainability of the ecological system.

[0004] In recent years, with the development of artificial intelligence technology, deep learning-based models have gradually been applied in water quality analysis and pollution tracing. Among them, the Long Short-Term Memory (LSTM) model shows broad application prospects due to its unique advantages in processing time series data. LSTM model can effectively capture the temporal variation of water quality factors, and combined with measured data, it can simulate the trend of pollutant concentration. However, relying solely on the LSTM model for prediction is still insufficient to solve the problems in practical applications, especially in the case of complex pollution scenarios and limited monitoring data. SUMMARY

[0005] In view of the problem that the prior art is difficult to accurately identify pollution sources and pollution types under limited data conditions, according to the water quality pollution source reverse tracking method in some embodiments of the application, the method comprises:

[0006] Obtaining pollution source characteristic parameters in water quality monitoring data; the pollution source characteristic parameters include the concentration, time and location of pollution factors;

[0007] Constructing a model for describing the migration and diffusion of pollution factors in the basin according to the pollutant diffusion equation;

[0008] According to different pollution scenarios, the pollution source characteristic parameters of water quality monitoring data are input into the model, and according to the model, the pollution factor concentration change curves in response to the input pollution scenarios are obtained.

[0009] Calculate the residual between the observed pollutant concentrations in each scenario and the predicted pollutant concentrations in the model's response to the input and output.

[0010] The pollution source characteristic parameters input into the model, the pollution factor concentration change curve output by the model, the residual value, and the corresponding pollution scenario are mapped and stored in the database;

[0011] The machine learning model is trained using data from the database. The input format is time series data, and the input data is time series data of water quality factor concentrations. The output target is pollution source characteristic parameters.

[0012] The time series data of measured pollutant concentrations are input into the trained machine learning model, and the machine learning model predicts and outputs pollution source characteristic parameters in response to the input.

[0013] The pollution source feature parameters predicted by the machine learning model are matched with the database to obtain the pollution scene corresponding to the pollution source feature parameters matched in the database.

[0014] The location information of the pollution source is obtained based on the pollution source feature parameters predicted and output by the machine learning model, and the pollution scene information is obtained based on the pollution scene corresponding to the pollution source feature parameters matched in the database.

[0015] According to the water pollution source reverse tracing method in some embodiments of this application, the pollution scenarios include point source pollution scenarios and non-point source pollution scenarios.

[0016] According to the water pollution source reverse tracing method in some embodiments of this application, the pollution factor includes any one or a combination of COD or ammonia nitrogen.

[0017] The water pollution source reverse tracing method according to some embodiments of this application further includes preprocessing of the pollution source characteristic parameters, the preprocessing including:

[0018] Standardize the pollution source characteristic parameters;

[0019] Complete the missing data points in the water quality monitoring data.

[0020] According to the water pollution source reverse tracing method in some embodiments of this application, the model used to describe the migration and diffusion of pollutants within the watershed includes the SP model, which is expressed by the following formula:

[0021]

[0022] In the formula, C(x,t) represents the concentration of the pollutant at a distance x from the pollution source and at time t, indicating the concentration change curve of the pollutant. x is the distance from the pollution source and is used to indicate the location. c0 is the initial concentration of the pollutant. t is the time. D is the diffusion coefficient of the pollutant. v is the water flow velocity.

[0023] The water pollution source reverse tracing method according to some embodiments of this application further includes evaluating the fitting accuracy of the model used to describe the migration and diffusion of pollutants within the watershed, including: evaluating the fitting accuracy of the model using the Nash efficiency coefficient (NSE) and mean squared error (MSE) statistical indicators; wherein the Nash efficiency coefficient (NSE) is used to assess the relative error of the model's predicted values ​​relative to the observed values; and the mean squared error (MSE) is used to quantify the error between the predicted values ​​and the observed values.

[0024]

[0025] In the formula, c obs,i It is the observation value at the i-th time point or location, c sim,i It is the predicted value at the i-th time point or location. is the average of the observations, and n is the number of data points.

[0026] According to the water pollution source reverse tracing method in some embodiments of this application, the machine learning model is the hidden layer and output layer of an LSTM model, represented by the following formula:

[0027] h t =σ(W x ·X t +W h ·h t-1 +b)

[0028] c pred =W0·h t +b0

[0029] In the formula, h t Let X represent the hidden layer state, σ represent the activation function, and X represent the hidden layer state. t For input data, W x Indicates input X t The weight matrix, h t-1 W represents the hidden state at the previous time step t-1. h Indicates the hidden state h in the previous moment. t-1 The weight matrix, b represents the bias vector, used to add a constant adjustment value to the hidden state, and c pred For the predicted pollution source features, W0 represents the weight matrix from the hidden state to the output, which will weight the hidden state ht Convert to the output space, where b0 represents the output bias term.

[0030] According to the water pollution source reverse tracing method in some embodiments of this application, the LSTM model includes an input layer, an LSTM layer, and an output layer, wherein:

[0031] The input layer accepts multidimensional time series data, with each time step containing several input features, mainly including the concentration changes of water quality factors monitored in the river;

[0032] LSTM layers process time-series data, storing long-term dependency information through memory cells, and using gate mechanisms to control the flow of information. Each LSTM layer includes at least two LSTM units, which include an input gate, a forget gate, and an output gate, and have functions for candidate memory cell states, memory cell updates, and hidden state updates.

[0033] The output layer is a fully connected layer that outputs the predicted value. The activation function for the output layer is a linear activation function.

[0034] According to the water pollution source reverse tracing method in some embodiments of this application, the LSTM unit input gate is used to control the inflow of new information, as expressed by the following formula:

[0035] i t =σ(W i ·[h t-1 ,x t ]+b i )

[0036] Where: i t σ is the activation value of the input gate, a value between 0 and 1, controlling the extent to which new input information flows into the memory unit; σ is the activation function, which compresses the input value to between 0 and 1; W i The weight matrix for the input gate is used to weight the previous hidden state h. t-1 and the current input x t Mapped to the input gate; h t-1 The hidden state of the previous time step; x t b is the input data for the current time step; i This is the bias term for the input gate;

[0037] The forget gate in the LSTM unit is used to control the information in the forgetting memory unit, and is represented by the following formula:

[0038] f t =σ(W f ·[h t-1 ,x t ]+b f )

[0039] Among them, f t The activation value for the forget gate, a value between 0 and 1, controls the extent to which information in the memory unit from the previous moment is retained or forgotten; W f Here is the weight matrix for the forget gate, used to store the previous hidden state h. t-1 and the current input x t Mapped to the forget gate; b f For the bias term of the forget gate;

[0040] The output gates of the LSTM unit are used to control the output information, as expressed by the following formula:

[0041] o t =σ(W o ·[h t-1 ,x t ]+b o )

[0042] Among them, o t The activation value of the output gate is a value between 0 and 1, controlling the degree to which information in the memory unit is output to the hidden state; W o The weight matrix for the output gate is used to weight the previous hidden state h. t-1 and the current input x t Mapped to the output gate; b o This is the bias term for the output gate;

[0043] The candidate memory cell states of the LSTM unit are represented by the following formula:

[0044]

[0045] in, The candidate memory cell state represents the latent memory state updated based on the current input and the hidden state of the previous time step; tanh is the hyperbolic tangent activation function, which compresses the value to between -1 and 1; W C b is the weight matrix for the candidate memory cell states; C The bias term for the state of candidate memory cells;

[0046] The update of the memory cells in the LSTM unit is represented by the following formula:

[0047]

[0048] Among them, C t The memory unit state at the current time step, combined with the results of the forget gate and the input gate, represents the complete memory at the current moment; C t-1 This represents the state of the memory cell at the previous time step; * indicates element-wise multiplication;

[0049] The hidden state update of the LSTM unit is represented by the following formula:

[0050] h t =o t *tanh(C t )

[0051] Among them, h t The hidden state at the current time step is calculated based on the output gate and memory cell states; tanh(C t () is a non-linear transformation of the state of the memory cell, used to adjust the output amplitude.

[0052] According to the water pollution source reverse tracing method in some embodiments of this application, the step of training a machine learning model using data from the database includes the following steps:

[0053] The data used for training will be processed into time series format;

[0054] The dataset is divided into a training set, a validation set, and a test set;

[0055] After constructing the LSTM model, the model is trained. The mean squared error (MSE) is selected as the loss function to measure the error between the model's predicted value and the actual value, as expressed by the following formula:

[0056]

[0057] Among them, y true,i This is the actual value, y pred,i is the predicted value, and n is the number of samples.

[0058] The model parameters are updated using the backpropagation algorithm and the gradient descent optimizer. The gradient descent optimizer is represented by the following formula:

[0059] m t =β1m t-1 +(1-β1)g t

[0060] v t =β2v t-1 +(1-β2)g t 2

[0061]

[0062] Where, θ t The values ​​of the model parameters at time step t; g t m is the current gradient calculated at time step t; t For first-order moment estimation; v t It is a second-order moment estimate; This is the bias correction value for the first-order moment estimation; α is the bias correction value for the second moment estimation; β1 is the learning rate; β2 is the exponential weighted decay rate controlling the first moment estimation; ∈ is a small constant added to prevent division by zero.

[0063] Beneficial effects:

[0064] In the first aspect, this invention proposes a reverse source tracing method for water pollution by combining an LSTM model with a pollution scenario database. Using the SP model, a comprehensive pollution scenario database is established by simulating pollutant concentration changes under different pollution scenarios. This database covers various possible pollution types and sources, enabling rapid identification of pollutant types and sources by matching limited monitoring data with scenarios in the database. This method not only improves the efficiency and accuracy of pollution source tracing but also provides strong technical support for watershed water quality management. The application of this method is of great significance for watershed environmental protection. On the one hand, it helps managers take timely measures when pollution incidents occur, reducing the impact of pollution on the ecological environment; on the other hand, it also provides new ideas and tools for the long-term protection and scientific management of watersheds, contributing to the sustainable development of the watershed's ecological environment.

[0065] Secondly, this invention employs an SP model combined with simulation techniques under limited data conditions. By simulating the pollution diffusion process, it can rapidly generate various pollution scenarios even when monitoring data is incomplete. Through the combination of an LSTM model and a database, reliable source tracing results can be provided using historical data and a pollution scenario database when real-time monitoring data is lacking, thereby reducing reliance on large-scale data.

[0066] In the first direction of the second aspect, the present invention has strong adaptability: because the SP model is based on the pollutant diffusion equation, it can flexibly adjust parameters such as diffusion coefficient and flow velocity. This makes the technology not only applicable to specific watersheds, but also extend to other watersheds or regions, exhibiting strong universality. The parameter adjustments in the model adapt to the geographical and hydrological characteristics of different watersheds, thus enabling relatively accurate pollution source identification under different environmental conditions.

[0067] In the second aspect, and in the second direction, this invention possesses scalability: scalability is reflected in the parameterization characteristics of the model and the expansion of the database. The pollution scenario database can be continuously updated to cover more pollution sources and pollution types. Furthermore, the model's structure and computational methods can be adjusted to adapt to watershed systems of different sizes, and new data sources and pollutant types can be added as needed, expanding the application scope.

[0068] In terms of third-party aspects, compared to using machine learning models alone for reverse tracking of water pollution sources, this invention improves model accuracy and reliability, reduces data requirements, enhances the ability to handle complex pollution scenarios, strengthens adaptability and scalability, and accelerates the response speed of pollution source tracking by using a pre-built SP model, establishing a pollution scenario database, and then training the machine learning model.

[0069] In the first direction of the third aspect, this invention improves model accuracy and reliability: the SP model, based on pollutant diffusion equations, can simulate the concentration changes of pollutants in different times and spaces, and generate multiple pollution scenarios. These simulation results can provide more training data for machine learning models, enabling them to handle complex pollution situations in practical applications and improve prediction accuracy. Compared to training solely based on historical data, this approach combining simulation and learning can capture more potential pollution patterns, thereby enhancing the model's generalization ability and prediction reliability.

[0070] In the second direction of the third aspect, this invention reduces data requirements: traditional machine learning models typically rely on large amounts of monitoring data for training, while this invention generates simulated data through the SP model, compensating for the lack of actual monitoring data. This allows the model to work effectively even with limited data, reducing reliance on long-term, large-scale monitoring data and thus improving the method's practicality, especially in watersheds or environments with limited data resources. In the third direction of the third aspect, this invention enhances the ability to handle complex pollution scenarios: standalone machine learning models may struggle to cope with complex, multi-source pollution scenarios, but by introducing the SP model and a pollution scenario database, this invention can simulate pollution events of different types and sources. This allows the system to quickly match current monitoring data with pollution scenarios in the database, thereby accurately identifying pollution sources and types, with significant advantages, especially in sudden or atypical pollution events.

[0071] In the fourth direction of the third aspect, this invention enhances adaptability and scalability: through pre-simulation using the SP model and the establishment of a database, this invention is not limited to specific watersheds or pollution types, exhibiting strong adaptability and scalability. The database can be continuously expanded according to actual needs, adding different pollution scenarios, thereby improving the system's adaptability to different environments and pollution events. This scalability allows the method to be applied not only to the current target watershed but also to water quality management and pollution source tracing in other regions.

[0072] In the fifth direction of the third aspect, this invention can accelerate the response speed of pollution source tracing: since a pollution scenario database has been pre-established, when a pollution event occurs, the model can quickly match the current data with the scenarios in the database and rapidly identify the pollution source. Compared with traditional machine learning models that rely on a step-by-step training and optimization process, this method significantly accelerates the emergency response speed and can provide source tracing results as soon as a pollution event occurs. Attached Figure Description

[0073] Figure 1 This is a flowchart of the reverse tracing of watershed water pollution types according to the present invention.

[0074] Figure 2 This is a graph showing the changes in pollutant concentrations simulated by the water quality model established in this invention.

[0075] Figure 3 This is a graph showing the change in pollutant concentrations for a specific pollution scenario in the database established by this invention.

[0076] Figure 4 This is a graph showing the change in pollutant concentration predicted by the LSTM model established in this invention. Detailed Implementation

[0077] This invention relates to a method for reverse tracing of water pollution types based on an LSTM model and database. This method is suitable for accurately identifying and tracing pollution sources within a watershed using limited measured data. It provides strong support for watershed water quality management and rapid response to pollution incidents.

[0078] like Figure 1 As shown, a method for reverse tracing of water pollution types using an LSTM model and a database includes the following steps:

[0079] Step 1, Data Collection and Preprocessing.

[0080] 1.1) Collect water quality monitoring data of tributaries and sources within the basin, including the concentrations of key pollutants such as COD and ammonia nitrogen, as well as the corresponding time and location information;

[0081] 1.2) Use normalization or standardization methods to preprocess the data, such as standardizing the concentration of pollutants, as shown in the following formula:

[0082]

[0083] Where X represents the original data, μ is the mean, and σ is the standard deviation. This processed data facilitates subsequent model input and training.

[0084] 1.3) For missing data points, use interpolation or KNN methods to complete them, ensuring the integrity and continuity of the dataset.

[0085] Step 2: Construction of the SP model and simulation of pollution scenarios.

[0086] 2.1) Set the input concentration c0(t) and input time t0 of the pollutant, and record the geographical location of the pollution source (distance x from the source);

[0087] 2.2) Based on the pollutant diffusion equation, an SP model is constructed to describe the migration and diffusion process of pollutants within the watershed. The formula is as follows:

[0088]

[0089] Where C(x,t) is the concentration of the pollutant at a distance x and a time t, D is the diffusion coefficient, and v is the flow velocity;

[0090] 2.3) Statistical indicators such as the Nash efficiency coefficient (NSE) and mean squared error (MSE) are used to evaluate the model's fitting accuracy, ensuring that the simulation results have high accuracy. NSE is used to assess the relative error between the model's predicted values ​​and the observed values, with a value ranging from (-∞, 1]. The closer the value is to 1, the better the model's fit. MSE is used to quantify the magnitude of the error between the simulated values ​​and the observed values; the smaller the MSE value, the smaller the model's error.

[0091]

[0092] Among them, c obs,i It is the observation value at the i-th time point or location, c sim,i It is the simulated value at the i-th time point or location. is the average of the observations, and n is the number of data points.

[0093] 2.4) Based on different pollution scenarios, change the values ​​of c0, t0 and x, input them into the SP model, and simulate the concentration change curves c(x,t) of various pollutants.

[0094] 2.5) Calculate the residual values ​​under each simulation scenario, and store the simulation results, residual values, and their corresponding input data in the pollution scenario database.

[0095] Step 3: Training and optimization of the LSTM model.

[0096] 3.1) Split the data in the pollution scenario database from step 2 into a training set and a validation set. The input format is time series data, in the form [c t-n ,c t-n+1 ,…,c t-1 ,ct ], c represents the water quality factor concentration and related characteristics at each time step, and the corresponding label is the time series data of water quality factor concentration;

[0097] 3.2) Construct an LSTM model, defining the structure of the hidden and output layers. The model form is as follows:

[0098] h t =σ(W x ·X t +W h ·h t-1 +b)

[0099] c pred =W0·h t +b0

[0100] Among them, h t For the hidden layer state, X t For input data, c pred For predicted pollution source characteristics;

[0101] 3.3) The Adam optimizer is used for model training to minimize the loss function (such as MSE) between the predicted value and the true label. The model parameters are tuned through cross-validation to ensure the generalization ability of the model.

[0102] Step 4: Reverse tracing of pollution sources based on the LSTM model.

[0103] 4.1) The real-time monitored water quality data [c t-n ,c t-n+1 ,…,c t-1 ,c t The input is fed into a pre-trained LSTM model, which will predict the possible pollution source parameters c0, t0, and x.

[0104] 4.2) Match the pollution source features output by the LSTM model with the pollution scenario database to find the closest pollution scenario and determine the type (point source or area source) and specific location of the pollution source.

[0105] 4.3) Based on the matching results of the model and the database, a pollution source identification report is generated and fed back to the watershed management department for pollution emergency response and long-term management.

[0106] The beneficial effects of this invention are as follows: by combining the SP model and the LSTM model, accurate reverse tracking of water pollution types is achieved under limited monitoring data conditions, which significantly improves the accuracy and efficiency of pollution source identification.

[0107] This method reduces data requirements and has strong adaptability and scalability, providing effective technical support for watershed water environment management.

[0108] Low data requirement: This technology uses SP models combined with simulation methods under limited data conditions to simulate the pollution diffusion process, enabling the rapid generation of various pollution scenarios even with incomplete monitoring data. By combining LSTM models with databases, reliable source tracing results can be provided using historical data and pollution scenario libraries when real-time monitoring data is lacking, thereby reducing reliance on large-scale data.

[0109] Strong adaptability: Because the SP model is based on the pollutant diffusion equation, it can flexibly adjust parameters such as diffusion coefficient and flow velocity. This makes the technology not only applicable to specific watersheds but also extend to other watersheds or regions, exhibiting strong universality. The parameter adjustments in the model adapt to the geographical and hydrological characteristics of different watersheds, thus enabling relatively accurate pollution source identification under various environmental conditions.

[0110] Scalability: Scalability is reflected in the model's parameterization features and the database's expandability. The pollution scenario database can be continuously updated to cover more pollution sources and types. Furthermore, the model's structure and computational methods can be adjusted to adapt to watershed systems of different sizes, and new data sources and pollutant types can be added as needed, expanding the application scope.

[0111] Compared to using machine learning models alone for reverse tracking of water pollution sources, this invention improves model accuracy and reliability, reduces data requirements, enhances the ability to handle complex pollution scenarios, strengthens adaptability and scalability, and accelerates the response speed of pollution source tracking by first establishing a SP model and a pollution scenario database, and then training the machine learning model.

[0112] Improving Model Accuracy and Reliability: The P-model, based on pollutant diffusion equations, can simulate the concentration changes of pollutants in different times and spaces, generating multiple pollution scenarios. These simulation results can provide more training data for machine learning models, enabling them to handle complex pollution situations in real-world applications and improve prediction accuracy. Compared to training solely based on historical data, this approach combining simulation and learning can capture more potential pollution patterns, thereby enhancing the model's generalization ability and prediction reliability.

[0113] Reduced Data Requirements: Traditional machine learning models typically rely on large amounts of monitoring data for training, while this invention uses the SP model to generate simulated data, compensating for the lack of actual monitoring data. This allows the model to work effectively even with limited data, reducing reliance on long-term, large-scale monitoring data and thus improving the method's practicality, especially in watersheds or environments with limited data resources.

[0114] Enhancing the ability to handle complex pollution scenarios: Standalone machine learning models may struggle to cope with complex, multi-source pollution scenarios. However, by introducing the SP model and a pollution scenario database, this invention can simulate pollution events of different types and sources. This allows the system to quickly match current monitoring data with pollution scenarios in the database, thereby accurately identifying pollution sources and types, with significant advantages, especially in sudden or atypical pollution events.

[0115] Enhanced Adaptability and Scalability: Through pre-simulation using the SP model and the establishment of a database, this invention is not limited to specific watersheds or pollution types, exhibiting strong adaptability and scalability. The database can be continuously expanded according to actual needs, adding different pollution scenarios, thereby improving the system's adaptability to different environments and pollution events. This scalability allows the method to be applied not only to the current target watershed but also to water quality management and pollution source tracing in other regions.

[0116] Accelerating the response speed of pollution source tracing: Because a pollution scenario database is pre-established, when a pollution event occurs, the model can quickly match the current data with the scenarios in the database to rapidly identify the pollution source. Compared to traditional machine learning models that rely on a gradual training and optimization process, this method significantly speeds up emergency response and can provide source tracing results immediately after a pollution event occurs.

[0117] The present invention will be further described in detail below with reference to specific embodiments.

[0118] The following is a reverse tracing process of water pollution types in the Fudu River Basin of Dalian City, Liaoning Province, China.

[0119] Step 1: Data collection and preprocessing;

[0120] Historical water quality data from recent years can be obtained from various monitoring points in the Fudu River basin through the Dalian Environmental Monitoring Center, or the latest monitoring data can be obtained from the annual environmental quality reports of the Dalian Municipal Environmental Protection Bureau. If historical data is insufficient, current water quality data can be obtained through on-site sampling. At least 6-8 monitoring points should be selected in the Fudu River basin, focusing on monitoring the concentrations of COD (Chemical Oxygen Demand) and ammonia nitrogen, with sampling conducted 2-3 times per month. The data collection period should cover at least one year to capture seasonal changes in the Fudu River basin.

[0121] The data collected from each monitoring point underwent initial screening to remove obviously unreasonable outliers (such as data points with suddenly extremely high or low COD concentrations exceeding 3 standard deviations). Box plots or the 3σ rule were used for data visualization analysis to ensure that the removed data conformed to statistical regularities. For a small number of missing values, linear interpolation was used to impute them.

[0122] The COD and ammonia nitrogen concentration data at each monitoring point are normalized or standardized to make the data more suitable for input to the LSTM model and avoid error amplification due to different data units.

[0123] Step 2: Construction of the SP model and simulation of pollution scenarios;

[0124] Based on the geographical and hydrological characteristics of the Fudu River, the river channel was divided into three sub-segments, each serving as an independent simulation unit. Within the SP model framework, each sub-segment includes the pollution source input, the pollutant migration and diffusion pathway in the water body, and its environmental effect. Calibration was performed based on typical diffusion coefficient values ​​for similar rivers from the literature, combined with measured data. The diffusion coefficient was assumed to be D = 0.01m. 2 / s, the degradation coefficient of COD is Kd_COD=0.005s -1 The degradation coefficient of ammonia nitrogen is A fixed pollutant concentration is set at the upstream inlet, and free outflow is assumed at the downstream outlet. Based on the above parameters and measured data, the following one-dimensional transport-diffusion equation is used to simulate the pollutant concentration:

[0125]

[0126] Where c is the pollutant concentration (COD or ammonia nitrogen), t is time, x is the spatial location in the river, v is the flow velocity, D is the diffusion coefficient, and Kd is the degradation coefficient.

[0127] The model equations were discretized using the finite element method, and numerical solutions were obtained by writing code in Python to simulate the changes in pollutant concentration in the river over time.

[0128] The pollutant concentration change curves generated by the simulation results illustrate the migration and diffusion of pollutants in the river.

[0129] like Figure 2 As shown, the simulation results are compared with the measured data. The Nash efficiency coefficient (NSE) and mean square error (MSE) are used to calibrate the model parameters to ensure the accuracy and reliability of the model. In this example, the NSE of ammonia nitrogen is 0.9646 and the MSE is 0.0001, and the NSE of COD is 0.8903 and the MSE is 0.3333.

[0130] Based on the established water quality model, the trends of COD and ammonia nitrogen concentrations over time and space under various scenarios are analyzed to identify areas with high pollutant concentrations and potential environmental risk points.

[0131] Scenario 1: Point source pollution emergency:

[0132] A sudden industrial discharge event was simulated in three sub-sections of the Fudu River. It was assumed that an improper discharge by a certain enterprise caused the COD concentration in the area to increase instantaneously to [10,15] mg / L. Based on the water quality model, the diffusion and degradation of pollutants after the pollution event were simulated.

[0133] Scenario 2: Agricultural non-point source pollution incidents:

[0134] In three sub-sections of the Fudu River, a large amount of agricultural non-point source pollution was simulated to enter the river channel, causing the ammonia nitrogen concentration in the area to rise rapidly to [0.5,2] mg / L in a short period of time. Based on the water quality model, the diffusion and degradation of pollutants after the pollution event were simulated, with particular attention paid to the impact of rainfall on pollutant concentration.

[0135] Calculate and statistically analyze the residual data of the monitoring points. The residual calculation formula is as follows:

[0136] e i =|c obs,i -c sim,i |

[0137] Among them, c obs,i c is the measured value at the i-th monitoring point or time point. sim,i It is the simulated value of the i-th monitoring point or time point, e i It is the residual at the i-th monitoring point or time point.

[0138] Create a relational database using MySQL, containing the following main tables:

[0139] Pollution Scenario Table: Records the parameter settings for each simulation scenario (such as input concentration, input time, etc.);

[0140] Simulation Results Table: Records the simulated concentration values ​​at monitoring points under each scenario;

[0141] Actual Measurement Data Table: Stores the actual water quality monitoring data collected;

[0142] Residual table: Stores the residual values ​​of each monitoring point and time node under each scenario;

[0143] Model parameter table: Records the model parameter settings for each simulation (such as flow rate, diffusion coefficient, degradation coefficient, etc.).

[0144] The following table illustrates a scenario extracted from the database used in this example. Figure 3 This is a simulation diagram of pollutant concentrations under this scenario.

[0145] Table 1. Parameter settings for a certain pollution scenario in the database.

[0146]

[0147] Table 2 shows the simulated, measured, and residual data of pollutants under this scenario (partial).

[0148]

[0149] Step 3: Training and optimization of the LSTM model;

[0150] From the previously established database, the input data, namely the time series data of water quality factor concentrations, and the output targets, namely the pollution source characteristic parameters (initial pollutant concentration, pollutant input time, and pollution source distance, etc.), are extracted. The data is then organized into a format suitable for the LSTM model, namely time series format, with each input feature and target arranged by time index.

[0151] The dataset is divided into training, validation, and test sets. In this example, the split ratio is 70% for training, 15% for validation, and 15% for testing.

[0152] The LSTM model structure consists of an input layer, hidden layers (LSTM layers), and an output layer.

[0153] The input layer accepts multidimensional time series data, with each time step containing several input features, mainly including the concentration changes of key water quality factors monitored in the river, which are usually time-series data.

[0154] The LSTM layer is responsible for processing time-series data. It uses memory cells to store long-term dependency information and gate mechanisms (input gate, forget gate, output gate) to control the flow of information. This example includes one LSTM layer and several LSTM units. The calculation formula for a single LSTM unit is as follows:

[0155] Input gate: controls the inflow of new information.

[0156] i t =σ(W i ·[h t-1 ,x t ]+b i )

[0157] Among them, i t σ is the activation value of the input gate (between 0 and 1), controlling the extent to which new input information flows into the memory unit; σ is the activation function (usually the sigmoid function), which compresses the input value to between 0 and 1; W i The weight matrix for the input gate is used to weight the previous hidden state h. t-1 and the current input x t Mapped to the input gate; h t-1The hidden state of the previous time step (the output of the previous LSTM unit); x t b is the input data for the current time step; i This is the bias term for the input gate.

[0158] Forgetting gates: control the information in forgotten memory units.

[0159] f t =σ(W f ·[h t-1 ,x t ]+b f )

[0160] Among them, f t The activation value of the forget gate (between 0 and 1) controls the extent to which information in the memory cell from the previous moment is retained or forgotten; W f Here is the weight matrix for the forget gate, used to store the previous hidden state h. t-1 and the current input x t Mapped to the forget gate; b f This is the bias term for the forget gate.

[0161] Output gate: controls the output information

[0162] o t =σ(W o ·[h t-1 ,x t ]+b o )

[0163] Among them, o t The activation value of the output gate (between 0 and 1) controls the degree to which information in the memory unit is output to the hidden state; W o The weight matrix for the output gate is used to weight the previous hidden state h. t-1 and the current input x t Mapped to the output gate; b o This is the bias term for the output gate.

[0164] Candidate memory cell state

[0165]

[0166] in, The candidate memory cell state represents the latent memory state updated based on the current input and the hidden state of the previous time step; tanh is the hyperbolic tangent activation function, which compresses the value to between -1 and 1; W C b is the weight matrix for the candidate memory cell states; C The bias term for the state of candidate memory cells.

[0167] Memory unit update

[0168]

[0169] Among them, C t The current memory unit state at the current time step combines the results of the forget gate and the input gate, representing the complete memory at the current moment; C t-1 This represents the state of the memory cell at the previous time step; * indicates element-wise multiplication (Hadamard product), meaning multiplying element by element.

[0170] Hidden status update

[0171] h t =o t *tanh(C t )

[0172] Among them, h t The hidden state at the current time step (also the output of the current LSTM unit) is calculated based on the output gate and memory unit states; tanh(C t () is a non-linear transformation of the state of the memory cell, used to adjust the output amplitude.

[0173] The output layer is a fully connected layer that outputs predicted values ​​(initial pollutant concentration, pollutant input time, and distance to the pollution source, etc.). The activation function of the output layer is chosen to be a linear activation function because the output predicted value can be any real number.

[0174] After constructing the LSTM model, the model is trained, and the mean squared error (MSE) is selected as the loss function to measure the error between the model's predicted value and the actual value.

[0175]

[0176] Among them, y true,i This is the actual value, y pred,i is the predicted value, and n is the number of samples.

[0177] The reason for choosing mean squared error (MSE) as the loss function is as follows:

[0178] Measuring the error between predicted and actual values: In water pollution source tracing, LSTM models need to predict characteristic parameters related to the pollution source (such as initial concentration, pollution time, distance, etc.). MSE measures the mean squared difference between the model's predicted values ​​and the actual observed values, reflecting the accuracy of the model's predictions. The smaller the MSE, the closer the predicted value is to the actual value; therefore, it is a very intuitive and commonly used error metric.

[0179] Penalizing Large Errors: MSE (Mean Squared Error) penalizes larger errors more severely through the form of squared differences. This is particularly important in water quality monitoring because large errors can lead to significant misjudgments of pollution source location or concentration, thus affecting the accuracy of pollution source tracing. Therefore, MSE can effectively reduce such errors and improve the robustness of the model.

[0180] Good fit for continuous variables: Water quality factors (COD, ammonia nitrogen concentration) and time are continuous variables, and MSE is particularly suitable for processing continuous output data. Compared with other loss functions (such as cross-entropy), MSE is more suitable for regression problems such as water quality monitoring.

[0181] The model parameters are updated using the Backpropagation Through Time (BPTT) algorithm and a gradient descent optimizer (such as the Adam optimizer). The Adam optimizer formula is as follows:

[0182] m t =β1m t-1 +(1-β1)g t

[0183] v t =β2v t-1 +(1-β2)g t 2

[0184]

[0185]

[0186] Where, θ t The values ​​of the model parameters at time step t, which are the current weights; g t m is the current gradient calculated at time step t (i.e., the partial derivative of the loss function with respect to the parameters); t This is a first-moment estimate, an exponentially weighted moving average of the gradient (similar to the momentum term in momentum), and can also be understood as the "momentum" of the gradient; v t It is a second-moment estimate, which is an exponentially weighted moving average of the squared gradient, used to estimate the variance of the gradient; This is the bias correction value for the first-order moment estimation. The bias correction is to compensate for the bias caused by m in the early stages of the algorithm. t and v t Potential deviations that may result from initialization to 0; The bias correction value for the second-order moment estimate, and Similarly; α is the learning rate, controlling the step size of parameter updates; β1 is the exponentially weighted decay rate controlling the first-moment estimation, usually taken as close to 1, 0.9 in this example; β2 is the exponentially weighted decay rate controlling the second-moment estimation, usually taken as close to 1, 0.999 in this example; ∈ is a small constant added to prevent division by zero, usually taken as 10. -8 .

[0187] The reason for choosing the Backpropagation Through Time (BPTT) algorithm is its suitability for processing time series data: LSTM models need to process time series data of water quality factors, while BPTT is an extension of the standard backpropagation algorithm, suitable for processing sequential data. It propagates the error from the output layer back to the input layer through backpropagation, while taking into account the dependencies between each time step, thereby updating the model parameters.

[0188] Capturing Long-Term Dependencies: In tracing the sources of water pollution, changes in water quality factors often exhibit time-dependent characteristics, potentially influenced by upstream events or historical data. BPTT can help LSTM models effectively capture these long-term dependencies, enabling the models to more accurately predict future pollution levels based on past pollution trends.

[0189] Reasons for choosing the Adam optimizer: Automatic learning rate adjustment: The Adam optimizer is a gradient descent optimizer with an adaptive learning rate. It combines the advantages of momentum and RMSProp, automatically adjusting the learning rate for each parameter to accelerate convergence, making it particularly suitable for complex deep learning models like LSTM.

[0190] Optimization for sparse or noisy data: The Adam optimizer can smooth out the effects of noise and sparse data during gradient updates. Water quality monitoring data often has the problem of discontinuity or incompleteness. The Adam optimizer can help the model update parameters more stably and avoid large parameter fluctuations.

[0191] Fast convergence: Real-time performance and accuracy are crucial in water pollution source tracing tasks. The Adam optimizer uses momentum to accelerate gradient descent, enabling the model to converge in fewer iterations, thereby shortening the training time and improving the model's real-time predictive capabilities.

[0192] The model is iterated multiple times on the training set (Epochs), and evaluated on the validation set after each iteration. Hyperparameters (such as learning rate, number of LSTM layers, number of units, etc.) are adjusted to optimize model performance.

[0193] like Figure 4As shown, NSE and MSE metrics are used on the test set to evaluate model performance and ensure good generalization ability. In this example, NSE = 0.85, indicating good model prediction performance, and MSE = 0.03, indicating small model prediction error.

[0194] Step 4: Reverse tracing of pollution sources based on the LSTM model.

[0195] When a pollution incident occurs, the latest water quality monitoring data is obtained from monitoring stations along the Fudu River. The data should include key water quality parameters such as chemical oxygen demand (COD) and ammonia nitrogen concentration. The new data undergoes the same preprocessing steps, including normalization, to ensure consistency with the scale of the training data. The water quality data is serialized, generating input sequences according to time steps, ready to be fed into the LSTM model for prediction.

[0196] The model will output predicted changes in water quality factor concentrations, generating a series of time-series data reflecting the impact of potential pollution sources. The model's predictions are compared with residual data under different pollution scenarios stored in the database to identify the pollution scenario that best matches the current monitoring data.

[0197] Based on the comparison results, the pollution source scenario corresponding to the current monitoring data is determined, whether it is point source pollution or area source pollution. This process involves analyzing the differences (residuals) between the model output and known pollution scenarios in the database, and finding the scenario that best matches the actual situation. The pollution source types predicted by the model are then visualized using maps or charts for easy understanding and use by management personnel.

[0198] The actual test results and treatment effects are fed back to the model database to update the pollution scenario data, so as to continuously improve the model's predictive ability.

[0199] The above-described embodiments are merely illustrative of the implementation methods of the present invention, but should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the protection scope of the present invention.

Claims

1. A method of reverse tracking a source of water quality pollution, characterized by, The method comprises: obtaining pollution source characteristic parameters in water quality monitoring data; the pollution source characteristic parameters include the concentration, time and location of a pollution factor; constructing a model for describing the migration and diffusion of the pollution factor in a river basin according to a pollution diffusion equation; According to different pollution scenarios, the pollution source characteristic parameters of water quality monitoring data are input into the model, and according to the model, the concentration change curve of the pollution factor in response to the input is obtained. The concentration change curve of the pollution factor is the change curve of the concentration of the pollution factor at a distance from the pollution source , time . calculating residual values of observed values of the pollution factor concentration under each scenario and predicted values of the pollution factor concentration output by the model in response to the input and output; mapping the pollution source characteristic parameters input into the model, the pollution factor concentration change curve output by the model, the residual values and the pollution scenarios corresponding to the residual values, and storing them in a database; training a machine learning model using the data in the database, with the input format being time series data, the input data being time series data of the water quality factor concentration, and the output target being the pollution source characteristic parameters; inputting the measured time series data of the pollution factor concentration into the trained machine learning model, and outputting the pollution source characteristic parameters predicted by the machine learning model in response to the input; matching the pollution source characteristic parameters predicted by the machine learning model in the database, and obtaining the pollution scenarios corresponding to the matched pollution source characteristic parameters in the database; obtaining the location information of the pollution source according to the pollution source characteristic parameters predicted by the machine learning model, and obtaining the pollution scenario information according to the pollution scenarios corresponding to the matched pollution source characteristic parameters in the database; wherein the model for describing the migration and diffusion of the pollution factor in the river basin comprises an S-P model, which simulates the concentration change of the pollution factor under different pollution scenarios, establishes a comprehensive pollution scenario database, and covers various possible pollution types and sources, so that the type and source of the pollution factor can be quickly identified by matching with the pollution scenarios in the database under the condition of inputting limited monitoring data; The S-P model is represented by the following formula: wherein C is the concentration of the pollution factor at a distance from the pollution source, t is the time, C(t) is the pollution factor concentration curve, r is the distance from the pollution source, indicating the location, C0is the initial pollution factor concentration, t is the time, D is the pollution factor diffusion coefficient, V is the water flow velocity.

2. The water quality pollution source reverse tracking method according to claim 1, characterized in that, wherein The pollution scenarios include point source pollution scenarios and non-point source pollution scenarios.

3. The water quality pollution source reverse tracking method according to claim 1, characterized in that, The pollution factor includes any one or a combination of COD or ammonia nitrogen.

4. The water quality pollution source reverse tracking method according to claim 1, characterized in that, The method further comprises preprocessing the pollution source characteristic parameters, which comprises: standardizing the pollution source characteristic parameters; completing missing data points in the water quality monitoring data.

5. The water quality pollution source reverse tracking method according to claim 1, characterized in that, The method further comprises evaluating the fitting accuracy of the model for describing the migration and diffusion of the pollution factor in the river basin, which comprises: using the Nash efficiency coefficient (NSE) and the mean square error (MSE) statistical indicators to evaluate the fitting accuracy of the model; wherein the Nash efficiency coefficient (NSE) is used to evaluate the relative error of the predicted value of the model relative to the observed value; and the mean square error (MSE) is used to quantify the error between the predicted value and the observed value. wherein is the observation value at the th time point or location, is the prediction value at the th time point or location, is the average of the observation values, is the number of data points.

6. The water quality pollution source reverse tracking method according to claim 1, wherein, The machine learning model is the hidden layer and output layer of an LSTM model, which is represented by the following formula: In the formula, Indicates the hidden layer state. This represents the activation function. For input data, Indicates input The weight matrix, Indicates the previous moment The hidden state, Indicates the hidden state at the previous moment. The weight matrix, This represents the bias vector, used to add a constant adjustment value to the hidden state. For the predicted pollution source characteristics, This represents the weight matrix from the hidden state to the output, which will weigh the hidden state... Convert to output space, This represents the output bias term.

7. The water quality pollution source reverse tracking method according to claim 6, characterized in that, The LSTM model comprises an input layer, an LSTM layer and an output layer, wherein: the input layer accepts multi-dimensional time series data, each time step contains a plurality of input features, mainly including the concentration change of the monitored water quality factor in the river; The LSTM layer processes time series data, saves long-time dependent information through a memory unit, and controls the flow of information through a gate mechanism; the LSTM layer includes at least two LSTM units, and each LSTM unit includes an input gate, a forget gate and an output gate, and has a candidate memory unit state, a memory unit update and a hidden state update; The output layer is a full connection layer, which outputs a prediction value, and the activation function of the output layer is a linear activation function.

8. The water quality pollution source reverse tracking method according to claim 7, characterized in that, Wherein, The input gate of the LSTM unit is used to control the inflow of new information, and is represented by the following formula: where: is the activation value for the input gate, a value between 0 and 1 that controls how much new input information flows into the memory cell; is the activation function that compresses the input value to between 0 and 1; is the weight matrix for the input gate that maps the previous hidden state and the current input to the input gate; is the hidden state from the previous time step; is the input data for the current time step; is the bias term for the input gate; The forget gate of the LSTM unit is used to control the information in the forgotten memory unit, and is represented by the following formula: wherein, is an activation value of the forget gate, is a value between 0 and 1, controlling to what extent information in the memory cell at the previous time is retained or forgotten; is a weight matrix of the forget gate, used to map the previous hidden state and the current input to the forget gate; is a bias term of the forget gate; The output gate of the LSTM unit is used to control the output information, and is represented by the following formula: wherein, is an activation value for the output gate, a value between 0 and 1, controlling the extent to which information in the memory cell is output to the hidden state; is a weight matrix for the output gate, used to map the previous hidden state and the current input to the output gate; is a bias term for the output gate; The candidate memory unit state of the LSTM unit is represented by the following formula: wherein, is a candidate memory cell state, representing an updated latent memory state based on the current input and the hidden state of the previous time step; is a hyperbolic tangent activation function, compressing values to between -1 and 1; is a weight matrix for the candidate memory cell state; is a bias term for the candidate memory cell state; The memory unit update of the LSTM unit is represented by the following formula: wherein, is the memory cell state for the current time step, which represents the complete memory at the current time step, synthesizing the results of the forget gate and the input gate; is the memory cell state for the previous time step; denotes element-wise multiplication; The hidden state update of the LSTM unit is represented by the following formula: wherein, is the hidden state of the current time step, based on the computation results of the output gate and the memory cell state; is a non-linear transformation of the memory cell state, to adjust the magnitude of the output.

9. The water quality pollution source reverse tracking method according to claim 8, characterized in that, The use of the data in the database to train the machine learning model includes the following steps: The data for training is processed into a time series form; The data set is divided into a training set, a validation set and a test set; After the LSTM model is constructed, the model is trained, the mean square error (MSE) is selected as the loss function, and the error between the predicted value and the actual value of the model is measured, which is represented by the following formula: wherein, is the actual value, is the predicted value, is the number of samples; The back propagation algorithm and the gradient descent optimizer are used to update the model parameters, and the gradient descent optimizer is represented by the following formula: where, is the value of the model parameter at time step ; is the current gradient computed at time step ; is the first moment estimate; is the second moment estimate; is the bias correction value for the first moment estimate; is the bias correction value for the second moment estimate; is the learning rate; is the exponentially weighted decay rate that controls the first moment estimate; is the exponentially weighted decay rate that controls the second moment estimate; is a small constant added to prevent division by zero.

Citation Information

Patent Citations

  • River pollutant flux intelligent calculation and prediction method based on integrated neural network

    CN112906936A

  • Water quality prediction model migration condition selection method based on XGBoost model

    CN116128049A