An environment safety-oriented groundwater source water quality early warning method and system
By combining the Lasso regression model and the FISTA algorithm to screen key water quality indicators, and constructing a CNN and LSTM water pollution prediction model, the problems of slow response and low monitoring frequency in traditional water quality early warning methods are solved, and efficient and accurate water quality early warning and real-time monitoring are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-24
- Publication Date
- 2026-03-24
AI Technical Summary
Existing groundwater source water quality early warning methods rely on traditional monitoring means, which suffer from slow response, low monitoring frequency, inability to achieve real-time monitoring, and difficulty in accurately predicting dynamic changes in water quality, thus affecting the accuracy and timeliness of early warnings.
Key water quality indicators were screened using the Lasso regression model and the FISTA algorithm. A water pollution prediction model based on CNN and LSTM was constructed. By combining the attention mechanism, the pollution prediction model was input with a two-dimensional tensor to calculate the concentration of pollutants and the threshold deviation. Early warning was then issued in conjunction with an early warning grading strategy.
It achieves efficient and accurate water quality monitoring and early warning, with real-time and forward-looking capabilities, enabling early identification of potential pollution, reducing the cost of manual early warning, and protecting water source safety.
Smart Images

Figure CN120911677B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of environmental protection and water quality safety, in particular to a groundwater source water quality early warning method and system for environmental safety. BACKGROUND
[0002] The environmental safety refers to the goal and application of the method is to protect the environmental safety, especially to ensure the water quality is not polluted, to protect the ecological environment and public health, the groundwater source refers to the place where the groundwater is extracted and used as water source, usually used for water supply, irrigation, etc. The groundwater source water quality early warning method for environmental safety is to ensure that the water quality of the groundwater source is at a safe level, and to give an early warning when the water quality is polluted or has potential risks.
[0003] Groundwater is an important source of drinking water in many areas, when the water quality is polluted, not only the ecological system of the water source will be affected, but also the health of human beings will be directly threatened, therefore, timely finding the water quality problem and taking effective measures to protect the water source is not only important for the water quality itself, but also helps to protect the ecological environment and avoid the occurrence of ecological disasters, so as to protect the public drinking water safety.
[0004] However, the existing groundwater source water quality early warning method mostly relies on traditional monitoring means, such as periodic water quality sampling and laboratory analysis, these methods have problems of slow response, low monitoring frequency, etc. Due to the spatial and temporal heterogeneity of water quality changes, the traditional method cannot realize real-time monitoring, which leads to the inability to timely discover potential pollution risks. In addition, many existing methods lack the big data analysis ability for the diversity and complexity of pollution factors, which makes it difficult to accurately predict the dynamic changes of water quality, thereby affecting the accuracy and timeliness of the early warning. SUMMARY
[0005] In view of the technical problems that the existing groundwater source water quality early warning method mostly relies on traditional monitoring means, has problems of slow response, low monitoring frequency, etc., and due to the spatial and temporal heterogeneity of water quality changes, the traditional method cannot realize real-time monitoring, which leads to the inability to timely discover potential pollution risks, and it is difficult to accurately predict the dynamic changes of water quality, thereby affecting the accuracy and timeliness of the early warning, the present application provides a groundwater source water quality early warning method and system for environmental safety.
[0006] The technical scheme provided by the embodiments of the present application is as follows:
[0007] First aspect:
[0008] The groundwater source water quality early warning method for environmental safety provided by the embodiments of the present application comprises:
[0009] S1: Obtain multiple water quality indicators and corresponding values for each water quality indicator from groundwater sources in different historical periods;
[0010] S2: Combining the Lasso regression model and the FISTA algorithm, water quality indicators are screened to determine key water quality indicators;
[0011] S3: Construct a two-dimensional tensor based on key water quality indicators and their values;
[0012] S4: Based on CNN and LSTM, combined with the attention mechanism, a water pollution prediction model is constructed;
[0013] S5: Input the two-dimensional tensor into the water pollution prediction model to determine the concentration of pollutants;
[0014] S6: Calculate the deviation between the concentration of pollutants and the threshold of pollutants to determine the water quality risk level;
[0015] S7: Based on the water quality risk level and combined with the early warning classification strategy, issue early warnings for the water quality of groundwater sources.
[0016] Optionally, the key water quality indicators specifically include: dissolved oxygen, biological oxygen demand, total nitrogen, temperature, pH, chemical oxygen demand, total phosphorus, and nitrogen-to-phosphorus ratio.
[0017] Optionally, S2 specifically includes:
[0018] S201: Normalize each of the water quality indicators to generate a water quality indicator dictionary;
[0019] S202: Determine the objective function based on the water quality index dictionary, combined with the Lasso regression model and L1 regularization rule;
[0020] S203: With the objective of minimizing the function value of the objective function, the FISTA algorithm is used to screen each of the water quality indicators to determine the key water quality indicators.
[0021] Optionally, S203 specifically includes:
[0022] S2031: Initialize the water quality index dictionary, regression coefficients, acceleration variables, and index set;
[0023] S2032: Calculate the gradient of the objective function based on the initialized regression coefficients;
[0024] S2033: Determine the gradient projection based on the gradient of the objective function;
[0025] S2034: Update the gradient projection through a soft thresholding operation to generate the final regression coefficients;
[0026] S2035: Based on the final regression coefficients and combined with the Nesterov acceleration method, each of the water quality indicators is dynamically screened.
[0027] S2036: Repeat S2032 to S2035 until the function value of the objective function is less than the preset objective function value, and determine the key water quality index.
[0028] Optionally, the water pollution prediction model includes: an input layer, a first convolutional layer, a second convolutional layer, a first LSTM layer, a second LSTM layer, an attention layer, and an output layer.
[0029] Optionally, S5 specifically includes:
[0030] S501: Input the two-dimensional tensor into the input layer;
[0031] S502: Extract local features of the two-dimensional tensor through the first convolutional layer;
[0032] S503: The feature map output by the first convolutional layer is convolved through the second convolutional layer to extract deep features;
[0033] S504: Based on the deep features, extract the short-term temporal features of the two-dimensional tensor through the first LSTM layer;
[0034] S505: Based on the short-term temporal characteristics, determine multiple hidden states of the two-dimensional tensor through the second LSTM layer;
[0035] S506: Calculate the attention weights of each hidden state through the attention layer, and determine the output of the attention mechanism;
[0036] S507: Based on the output of the attention mechanism, the concentration of the pollutant is output through the output layer.
[0037] Optionally, S506 specifically includes:
[0038] S5061: Calculate the attention weights for each of the hidden states;
[0039] S5062: Determine the output of the attention mechanism by weighted summation based on the attention weights.
[0040] Optionally, the early warning classification strategy includes: green warning, yellow warning, orange warning, and red warning.
[0041] The second aspect:
[0042] This invention provides a groundwater source water quality early warning system for environmental safety, comprising:
[0043] processor;
[0044] The memory stores computer-readable instructions, which, when executed by a processor, implement a groundwater source water quality early warning method for environmental safety, as described in the first aspect.
[0045] Third aspect:
[0046] The present invention provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the groundwater source water quality early warning method for environmental safety as described in the first aspect.
[0047] The beneficial effects of the technical solutions provided by the embodiments of the present invention include at least the following:
[0048] In this embodiment of the invention, multiple water quality indicators and their corresponding values for groundwater sources from different historical periods are obtained. Then, using a Lasso regression model and the FISTA algorithm, the water quality indicators are screened to determine key indicators, ensuring that the most relevant data is focused on. Based on the key water quality indicators and their values, a two-dimensional tensor is constructed. Further, based on CNN and LSTM, and combined with an attention mechanism, a water pollution prediction model is built. The two-dimensional tensor is input into the water pollution prediction model to determine the concentration of pollutants. By calculating the deviation between the pollutant concentration and the pollutant threshold, the water quality risk level is determined. Finally, based on the water quality risk level and combined with an early warning grading strategy, an early warning is issued for the water quality of groundwater sources. This achieves efficient and accurate water quality monitoring and early warning, possessing real-time and forward-looking capabilities, enabling early identification of potential pollution, reducing the cost of manual early warning, and protecting water source safety. Attached Figure Description
[0049] To more clearly illustrate the technical solutions in 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.
[0050] Figure 1 A flowchart illustrating a groundwater source water quality early warning method for environmental safety provided in an embodiment of the present invention;
[0051] Figure 2 This is a schematic diagram of a groundwater source water quality early warning system for environmental safety, provided as an embodiment of the present invention. Detailed Implementation
[0052] The technical solution of the present invention will now be described with reference to the accompanying drawings.
[0053] In embodiments of the present invention, words such as "exemplarily," "for example," etc., are used to indicate that something is an example, illustration, or description. Any embodiment or design described as "exemplary" in the present invention should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of the word "exemplary" is intended to present the concept in a concrete manner. Furthermore, in embodiments of the present invention, the meaning expressed by "and / or" can be both, or either one.
[0054] In the embodiments of this invention, the terms "image" and "picture" may sometimes be used interchangeably. It should be noted that, without emphasizing the distinction between them, they convey the same meaning. Similarly, the terms "of," "corresponding (relevant)," and "corresponding" may sometimes be used interchangeably. It should be noted that, without emphasizing the distinction between them, they convey the same meaning.
[0055] In this embodiment of the invention, sometimes a subscript such as W1 may be written in a non-subscript form such as W1. When the difference is not emphasized, the meaning they express is the same.
[0056] To make the technical problems, technical solutions and advantages of the present invention clearer, a detailed description will be given below in conjunction with the accompanying drawings and specific embodiments.
[0057] Reference manual attached Figure 1 The diagram shows a flowchart of a groundwater source water quality early warning method for environmental safety provided by an embodiment of the present invention.
[0058] This invention provides a groundwater source quality early warning method for environmental safety. This method can be implemented using an environmentally safe groundwater source quality early warning device, which can be a terminal or a server. The processing flow of the environmentally safe groundwater source quality early warning method may include the following steps:
[0059] S1: Obtain multiple water quality indicators and corresponding values for each water quality indicator from groundwater sources at different historical periods.
[0060] Historical periods refer to water quality data collected over a specific time period, reflecting trends in water quality over different timeframes. Groundwater sources refer to locations where groundwater is extracted for water supply or other uses, and are typically the primary source of groundwater resources. Water quality indicators are characteristic data used to measure water quality; common indicators include dissolved oxygen, pH, temperature, total nitrogen, and chemical oxygen demand (COD). Indicator values are specific numerical values corresponding to each water quality indicator, reflecting the water quality status at a particular moment or period.
[0061] It should be noted that by collecting water quality data from different historical periods and analyzing the changes in various water quality indicators, comprehensive basic data can be provided for subsequent water quality analysis. This method can demonstrate long-term trends in water quality, help identify potential pollution sources and pollution patterns, and provide sufficient historical evidence for the model's accurate predictions.
[0062] S2: Combining the Lasso regression model and the FISTA algorithm, water quality indicators are screened to determine key water quality indicators.
[0063] Lasso regression is a linear regression method that, by introducing an L1 regularization term, enables variable selection in regression analysis, reduces model complexity, and helps identify the key variables that have the greatest impact on prediction results. The FISTA algorithm, used to solve sparse optimization problems, accelerates the variable selection process in Lasso regression, providing an efficient computational method.
[0064] Among them, key water quality indicators refer to key indicators that have a significant impact on changes in water quality.
[0065] It should be noted that by combining Lasso regression and the FISTA algorithm, the most predictive key water quality indicators can be efficiently selected, avoiding data redundancy and noise interference with the model. This process improves the accuracy and efficiency of data processing, ensuring that subsequent models are built on the most relevant water quality indicators, thus enhancing the accuracy of water quality predictions.
[0066] In one possible implementation, key water quality indicators specifically include: dissolved oxygen, biological oxygen demand, total nitrogen, temperature, pH, chemical oxygen demand, total phosphorus, and nitrogen-to-phosphorus ratio.
[0067] Dissolved oxygen (DO) refers to the amount of oxygen dissolved in water and is an important indicator of water health. High concentrations of dissolved oxygen mean that the water can support the survival of various aquatic organisms, while insufficient dissolved oxygen can lead to the death of aquatic organisms and deterioration of water quality.
[0068] Biological oxygen demand (BOD) is the amount of oxygen consumed by microorganisms in water as they decompose organic matter. A high BOD value usually indicates that there is a lot of organic pollution in the water, and the water quality is poor.
[0069] Total nitrogen (TN) refers to the total amount of nitrogen in water bodies in all forms, including ammonia nitrogen and nitrate nitrogen. Nitrogen is an important indicator of water pollution; excessively high nitrogen concentrations can lead to eutrophication and affect water quality.
[0070] Temperature directly affects the dissolved oxygen content and microbial activity in water bodies. Excessively high water temperatures can lead to a decrease in dissolved oxygen, impacting the survival of aquatic organisms.
[0071] pH (Potential of Hydrogen) indicates the acidity or alkalinity of water. A pH that is too low (acidic) or too high (alkaline) can negatively impact aquatic life and affect water quality stability.
[0072] Chemical Oxygen Demand (COD) refers to the amount of oxygen required for organic matter in water to be oxidized by an oxidant. A high COD value indicates a higher level of pollutants in the water and is often used together with BOD to assess the degree of water pollution.
[0073] Total phosphorus (TP) is the sum of all forms of phosphorus in a water body. Phosphorus is a major factor in eutrophication; excessively high total phosphorus concentrations can lead to eutrophication, promote excessive algal growth, and degrade water quality.
[0074] The nitrogen-phosphorus ratio (NPR) is the mass ratio of nitrogen (N) to phosphorus (P) in a water body. The NPR is important for assessing whether a water body is in a eutrophic state; an excessively low NPR may lead to excessive algal growth and water quality deterioration.
[0075] In one possible implementation, S2 specifically includes:
[0076] S201: Normalize each water quality indicator to generate a water quality indicator dictionary.
[0077] Normalization adjusts the values of various water quality indicators to a uniform scale, typically by scaling the data to the range of [0,1] or [-1,1] to avoid the influence of different scales on subsequent analysis. A water quality indicator dictionary is a collection containing all water quality indicators and their corresponding values. After normalization, each water quality indicator is assigned a standardized value for subsequent analysis and modeling.
[0078] S202: Based on the water quality index dictionary, combined with the Lasso regression model and L1 regularization rule, determine the objective function:
[0079]
[0080] in, P ( ) represents the objective function. Lambda Represents the regularization parameter. D A dictionary of water quality indicators. y Let argmin represent the target variable, and argmin represent taking the minimum value. x Represents the regression coefficient. Represents the sum of squared residuals. This represents the L1 regularization term.
[0081] L1 regularization is a penalty term added to a regression model to control its complexity. It works by summing the absolute values of the regression coefficients and applying a weighted penalty, causing some coefficients to approach zero, thus achieving feature selection and reducing redundant features. The objective function is a mathematical expression typically used to measure model performance. The objective function of a Lasso regression model consists of two parts: the prediction error (sum of squared residuals) and the L1 regularization term. The goal is to minimize the value of the objective function by adjusting the model parameters, thereby obtaining the optimal regression coefficients.
[0082] S203: With the objective of minimizing the function value of the objective function, the FISTA algorithm is used to screen each of the water quality indicators to determine the key water quality indicators.
[0083] It should be noted that combining the advantages of the Lasso regression model and the FISTA algorithm can efficiently screen key indicators that significantly impact water quality changes from high-dimensional data. Normalization ensures that all water quality indicators are analyzed on the same scale, avoiding bias caused by differences in data scale. Lasso regression uses L1 regularization for feature selection, effectively removing redundant information and improving the model's interpretability and predictive ability.
[0084] In one possible implementation, S203 specifically includes:
[0085] S2031: Initialize the water quality index dictionary, regression coefficients, acceleration variables, and index set.
[0086] In Lasso regression, regression coefficients describe the contribution of each water quality indicator to the predicted target (e.g., pollution concentration). Accelerator variables in FISTA (Fast Iterative Shrinkage-Thresholding Algorithm) are used to accelerate the gradient descent process. The index set is a collection used to label water quality indicators. During feature selection, the index set helps distinguish which water quality indicators are selected for the model and which are removed.
[0087] S2032: Calculate the gradient of the objective function based on the initialized regression coefficients:
[0088]
[0089] in, Theta r Indicates the first r The gradient at the next iteration D r-1 Indicates the first r Water quality index dictionary at -1st iteration x r-1 Indicates the first r -1 regression coefficients at iteration number -1.
[0090] The gradient of the objective function is the derivative of the objective function with respect to the regression coefficients. It represents the direction in which the objective function changes most rapidly at the current regression coefficient values. During optimization, the gradient is used to indicate how to adjust the regression coefficients to minimize the objective function.
[0091] S2033: Determine the gradient projection based on the gradient of the objective function:
[0092]
[0093] in, z r Indicates the first r Gradient projection at the next iteration Indicates the first r Transpose of the water quality index dictionary at iteration -1 T This indicates the transpose operation.
[0094] Gradient projection is the operation of projecting gradient values onto a set of constraints during gradient descent, and is typically used to handle L1 regularization problems. It helps ensure that regression coefficients meet sparsity constraints during optimization.
[0095] S2034: Update the gradient projection through a soft thresholding operation to generate the final regression coefficients.
[0096]
[0097] in, x r Indicates the first r The regression coefficients at the next iteration, i.e., the final regression coefficients. Indicates soft threshold operation. L r Indicates the first r The step size of the next iteration.
[0098] Soft thresholding is a technique used during optimization to prune regression coefficients. It compresses small values in the regression coefficients to zero and retains coefficients greater than a certain threshold. This helps in feature selection by removing unimportant water quality indicators.
[0099] S2035: Based on the final regression coefficients and combined with the Nesterov acceleration method, water quality indicators are dynamically screened.
[0100] Nesterov acceleration is an optimization technique that accelerates the gradient descent process and improves convergence speed by predicting a weighted combination of the current gradient and the gradient from the previous step. It helps the algorithm find the optimal solution faster.
[0101] S2036: Repeat S2032 to S2035 until the function value of the objective function is less than the preset objective function value, and determine the key water quality index.
[0102] The preset objective function value is a threshold in the optimization process. When the value of the objective function is less than this value, it means that the optimization has converged, the algorithm can stop running, and it is considered that the optimal regression coefficient has been found.
[0103] Those skilled in the art can set the value of the preset objective function according to the actual situation, and the present invention does not impose any limitations.
[0104] It should be noted that, firstly, key parameters such as the water quality index dictionary and regression coefficients were initialized, laying the foundation for the optimization process. By calculating the gradient of the objective function, the FISTA algorithm accelerates the gradient descent process, thus quickly approaching the optimal solution in each iteration. Soft thresholding effectively selects features, removing redundant water quality indices and ensuring the simplicity and interpretability of the model. Combined with Nesterov acceleration, optimization efficiency is further improved, ensuring that the optimal solution is obtained in a fewer iterations. Through efficient optimization methods, not only is the computation speed improved, but the selection of the most critical water quality indices is also ensured, providing an accurate basis for subsequent pollution prediction and risk assessment.
[0105] S3: Construct a two-dimensional tensor based on key water quality indicators and their values.
[0106] Two-dimensional tensors are a data structure in mathematics and computation, typically used to store multidimensional arrays. Each row of a two-dimensional tensor may represent data at different points in time, while each column represents a different water quality indicator.
[0107] It's important to note that organizing key water quality indicators and their corresponding values into two-dimensional tensors provides a structured input data format, facilitating subsequent model processing. Two-dimensional tensors effectively integrate data from multiple water quality indicators, enabling models to identify spatiotemporal patterns of water quality variation. This data representation not only improves data processing efficiency but also provides a clear and unified input structure for deep learning models (such as CNNs and LSTMs), thereby enhancing the model's predictive power and accuracy. Furthermore, constructing two-dimensional tensors allows for the effective capture of the dynamic characteristics of water quality changes in subsequent water quality predictions.
[0108] S4: Based on CNN and LSTM, combined with the attention mechanism, a water pollution prediction model is constructed.
[0109] Among them, CNN (Convolutional Neural Network) is a deep learning model widely used for processing image and time series data. It extracts local features from input data through multiple convolutional layers, effectively capturing spatial and temporal patterns. In water quality prediction, CNN can be used to extract local patterns in water quality data, helping the model identify complex water quality change characteristics.
[0110] Among them, LSTM (Long Short-Term Memory) is a special type of recurrent neural network (RNN) specifically designed for processing and predicting sequential data. It avoids the vanishing gradient problem present in traditional RNNs by introducing a gating mechanism, effectively capturing long-term dependencies in time series data. In water quality early warning systems, LSTM is used to learn the changing trends of water quality data over time and predict future water quality changes.
[0111] The attention mechanism, a computational method that mimics human visual focusing, allows the model to prioritize the most relevant parts of the input data when processing information. Through this mechanism, the model can adaptively adjust its focus, improving its ability to identify key features. For water quality early warning, the attention mechanism helps the model focus on the indicators that most significantly impact water quality changes.
[0112] The water pollution prediction model is a mathematical model that analyzes water quality data to predict water quality changes and pollution trends. In this step, the model uses a combination of CNN and LSTM with an attention mechanism to accurately predict the pollution level of water bodies and provide early warnings.
[0113] It should be noted that a highly efficient water pollution prediction model was constructed by combining CNN, LSTM, and an attention mechanism. CNN can automatically extract local features from water quality data, helping the model identify subtle patterns in water quality changes; LSTM utilizes its powerful time series modeling capabilities to effectively capture the time dependencies in water quality data and predict future water quality changes. The attention mechanism further enhances the model's capabilities, enabling it to adaptively focus on the most critical features related to water quality changes, avoiding information redundancy and noise. This multi-layered, multi-mechanism combination ensures high accuracy and timeliness of water quality prediction, providing more precise decision-making basis for water quality early warning systems.
[0114] In one possible implementation, the water pollution prediction model includes: an input layer, a first convolutional layer, a second convolutional layer, a first LSTM layer, a second LSTM layer, an attention layer, and an output layer.
[0115] In the water pollution prediction model, the input layer receives preprocessed water quality data, such as various water quality indicators and their corresponding time series or other relevant data. This data will serve as input to the network for further processing and prediction.
[0116] The first convolutional layer extracts local features from the input data through convolution operations. In water pollution prediction, the first convolutional layer helps identify possible local changes and patterns in water quality data.
[0117] The second convolutional layer further processes the convolutional feature map to extract deeper features. By convolving the feature map output from the first layer, the second convolutional layer can extract more complex and abstract features, thereby enhancing the model's ability to understand water quality changes.
[0118] The first LSTM layer is used to capture the trend of water quality data over time. It can handle the temporal dependencies in the data, thereby learning to predict future changes in water quality.
[0119] The second LSTM layer further delves into the time-series characteristics of the water quality data. By stacking multiple LSTM layers, the model can capture dependencies over a longer time span, improving its ability to process complex time-series data.
[0120] The attention layer is a mechanism that assigns different weights to focus on important parts of the input data. In water pollution prediction, the attention layer helps the model adaptively adjust its focus based on the importance of the input features, ensuring that the model can focus on key indicators affecting water quality changes while ignoring noise or irrelevant parts.
[0121] The output layer outputs the final prediction results. In the water pollution prediction model, the output layer generates predicted values for pollutant concentrations.
[0122] It should be noted that the water pollution prediction model fully leverages the advantages of each layer by combining CNN, LSTM, and attention mechanisms. Convolutional layers (CNN) extract local features from the data, enabling the model to identify subtle changes in water quality data; LSTM layers process the temporal features of water quality data, capturing time dependencies and predicting future water quality trends. By stacking multiple LSTM layers, the model can handle dependencies over longer time periods, improving prediction accuracy. The attention mechanism helps the model adaptively focus on the most important features, reducing interference from information noise and enhancing the model's sensitivity to key water quality indicators. Finally, the output layer generates accurate water pollution prediction results, providing timely early warning information. This structure, through multi-layered and multi-dimensional processing, improves the accuracy and efficiency of water quality prediction, providing effective support for water source protection and pollution prevention.
[0123] S5: Input the two-dimensional tensor into the water pollution prediction model to determine the concentration of pollutants.
[0124] Pollutant concentration refers to the concentration of pollutants (such as nitrogen, phosphorus, and heavy metals) in water bodies. Accurate prediction of pollutant concentrations is crucial for assessing the degree of water pollution and issuing early warnings in water quality early warning systems.
[0125] It should be noted that a two-dimensional tensor is input into a water pollution prediction model, which is then used to accurately predict pollutant concentrations. The two-dimensional tensor integrates multiple water quality indicators and their variation patterns into a unified data structure, enabling the model to handle multi-dimensional data inputs and fully consider the complexity and spatiotemporal variations of water quality. Through efficient data transmission at the input layer, the model can directly acquire structured water quality information for processing, thereby improving the accuracy and timeliness of predictions.
[0126] In one possible implementation, S5 specifically includes:
[0127] S501: Input the two-dimensional tensor into the input layer.
[0128] S502: Extracting local features of the two-dimensional tensor through the first convolutional layer:
[0129]
[0130] in, U l Indicates the first l The output of each convolutional kernel is the feature map. ELU Represents the activation function of the exponential linear unit. W l Indicates the first l The weight matrix of each convolutional kernel. X This represents the input two-dimensional tensor. b l Indicates the first l The bias vector of each convolution kernel This indicates a convolution operation.
[0131] S503: The second convolutional layer performs a convolution operation on the feature map output by the first convolutional layer to extract deep features.
[0132] S504: Based on deep features, extract short-term temporal features of the two-dimensional tensor through the first LSTM layer.
[0133] S505: Based on short-term temporal characteristics, multiple hidden states of the two-dimensional tensor are determined through a second LSTM layer:
[0134]
[0135] in, f t express t The activation output vector of the time-forget gate. Sigma This represents the sigmoid activation function. W f The weight matrix represents the forget gate. h t-1 express t The hidden state at time -1 express t The feature vector at time step, b f The bias term representing the forget gate. i t express t The activation-output vector of the input gate at each time step. W i This represents the weight matrix of the input gate. b i This represents the bias term of the input gate. express t Candidate state of unit at time step C t-1 express t Cell state at time -1 WC The weight matrix represents the candidate cell state. b C Bias terms representing candidate cell states. C t express t The unit status is updated in real time. o t express t The activation output vector of the output gate at each time step. W o This represents the weight matrix of the output gate. b o This represents the bias term of the output gate. h t express t The hidden state at any given moment.
[0136] S506: Through the attention layer, calculate the attention weights of each hidden state and determine the output of the attention mechanism.
[0137] S507: Based on the output of the attention mechanism, the concentration of pollutants is output through the output layer.
[0138] It should be noted that by combining a hierarchical structure with multiple technologies, the advantages of each layer are fully utilized, significantly improving the accuracy of water quality prediction. Convolutional layers (CNNs) effectively extract local features from water quality data and identify important patterns; LSTM layers, by capturing long-term dependencies in time series data, can handle the dynamic changes in water quality over time. Through a combination of forget gates, input gates, and output gates, LSTM layers can flexibly choose to retain and forget information, enabling the model to better adapt to water quality changes across different time spans. The attention mechanism further enhances the model's performance by dynamically focusing on important time steps and features, improving the model's prediction accuracy.
[0139] In one possible implementation, S506 specifically includes:
[0140] S5061: Calculate the attention weights for each hidden state:
[0141]
[0142]
[0143] in, express t Time of the first k The attention weights for each input feature, where exp represents the exponential function. express t Time of the first k Importance scores of each input feature express t Time of the first i Importance scores of each input feature i =1,2,…, n , n Indicates the number of input features. v e This represents the parameter vector used to calculate the importance score. W e This represents the weight matrix used to adjust the importance scores of the input features. U e This represents the weight matrix used to perform a linear transformation on the hidden state at the current time step. b e This represents the bias term that shifts the weighted sum.
[0144] S5062: Based on the attention weights, determine the output of the attention mechanism using a weighted summation method:
[0145]
[0146] in, express t The output of the attention mechanism at any given moment express t Attention weight at any moment N Indicates the total number of moments.
[0147] It should be noted that the output layer combines all information to generate accurate predictions of pollutant concentrations, providing a reliable basis for water quality monitoring and early warning. This structure integrates local feature extraction, time series modeling, and dynamic attention mechanisms, providing an efficient and accurate solution for complex water quality prediction tasks.
[0148] S6: Calculate the deviation between the concentration of pollutants and the threshold of pollutants to determine the water quality risk level.
[0149] Among them, the pollutant threshold is a preset limit for the concentration of pollutants. Exceeding this value indicates that the water quality has exceeded safety standards, which may lead to water source pollution or ecological disaster. Thresholds are usually set based on environmental protection standards or historical data, serving as a warning. Deviation helps quantify the degree to which water quality deviates from safety standards, providing a quantitative basis for water quality risk. The water quality risk level is assessed based on the deviation between the pollutant concentration and the pollutant threshold. It is usually divided into multiple levels (such as low, medium, and high) to indicate the degree of harm to the water quality and help relevant departments take appropriate countermeasures.
[0150] It should be noted that by calculating the deviation between pollutant concentrations and thresholds, the risk level of water quality can be accurately assessed. This process compares pollutant concentrations with preset safety standards, quantifies the risk level of water quality, and ensures the scientific validity and operability of the early warning system. Based on different deviations, the system can provide a clear risk level for water quality warnings, helping relevant departments to take timely protective measures or activate emergency responses.
[0151] S7: Based on the water quality risk level and combined with the early warning classification strategy, issue early warnings for the water quality of groundwater sources.
[0152] The early warning grading strategy refers to taking different early warning measures based on different water quality risk levels. This strategy divides water quality into multiple early warning levels (e.g., green, yellow, orange, red) according to different levels of risk, so that relevant departments can take corresponding preventive or emergency measures based on the early warning level.
[0153] It should be noted that by combining water quality risk levels with early warning grading strategies, a scientific and systematic early warning mechanism is provided for groundwater source areas. When the concentration of pollutants in the water reaches a certain level, the early warning grading strategy can promptly activate different emergency responses based on the water quality risk level. Through a clear grading strategy, relevant departments can quickly understand the pollution risk and take targeted measures to prevent further deterioration of water quality or the spread of pollution. This method improves the sensitivity and accuracy of early warnings, making source water management more efficient and ensuring public drinking water safety and ecological stability.
[0154] In one possible implementation, the warning classification strategy includes: green warning, yellow warning, orange warning, and red warning.
[0155] A green alert typically indicates that the water quality is good or the risk of pollution is low, and the water body is within a safe range. No emergency measures are needed at this time, but monitoring should still be maintained. A green alert is a sign that the water quality is in a normal state.
[0156] A yellow alert indicates slight water pollution. Although the water quality is still within acceptable limits, it is approaching a dangerous level, requiring attention and monitoring measures. A yellow alert serves as an early warning of potential risks.
[0157] An orange alert indicates a high level of water pollution, with water quality exceeding safe limits, requiring stricter monitoring and preventative measures. At this time, source water protection and pollution control should be strengthened to prevent further deterioration.
[0158] A red alert is the highest level of warning, indicating severe water pollution that has reached or exceeded dangerous levels, posing a significant threat to human health and the ecological environment. In such cases, immediate emergency measures are required, such as shutting off water supply and treating the source of pollution.
[0159] It should be noted that by setting different warning levels (green, yellow, orange, and red), the safety status of water bodies can be accurately reflected according to the severity of water pollution. Each warning level represents a different degree of pollution risk, ensuring that relevant departments can respond promptly and take appropriate measures. This tiered strategy makes water quality management more flexible and precise, effectively preventing the potential deterioration of water quality problems and enabling intervention through lower-level warnings in the early stages of pollution. This scientific and hierarchical warning mechanism improves the efficiency and effectiveness of water quality protection, ensuring water source safety and reducing threats to public health.
[0160] In this embodiment of the invention, multiple water quality indicators and their corresponding values for groundwater sources from different historical periods are obtained. Then, using a Lasso regression model and the FISTA algorithm, the water quality indicators are screened to determine key indicators, ensuring focus on the most relevant data. Based on the key water quality indicators and their values, a two-dimensional tensor is constructed. Further, based on CNN and LSTM, and combined with an attention mechanism, a water pollution prediction model is built. The two-dimensional tensor is input into the water pollution prediction model to determine the concentration of pollutants. By calculating the deviation between the pollutant concentration and the pollutant threshold, the water quality risk level is determined. Finally, based on the water quality risk level and combined with an early warning grading strategy, an early warning is issued for the groundwater source. This achieves efficient and accurate water quality monitoring and early warning, possessing real-time and forward-looking capabilities, enabling early identification of potential pollution, reducing the cost of manual early warning, and protecting water source safety.
[0161] Reference manual attached Figure 2 The diagram shows a structural schematic of a groundwater source water quality early warning system for environmental safety provided by the present invention.
[0162] This invention also provides a groundwater source water quality early warning system 20 for environmental safety, applied to the aforementioned groundwater source water quality early warning method for environmental safety, comprising:
[0163] Processor 201.
[0164] The memory 202 stores computer-readable instructions. When the computer-readable instructions are executed by the processor 201, they implement the groundwater source water quality early warning method for environmental safety as described in the method embodiment.
[0165] The groundwater source water quality early warning system 20 provided by the present invention can execute the above-mentioned groundwater source water quality early warning method for environmental safety and achieve the same or similar technical effects. To avoid duplication, the present invention will not elaborate further.
[0166] This invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the groundwater source water quality early warning method for environmental safety as described in the method embodiment.
[0167] The present invention provides a computer-readable storage medium that can implement the steps and effects of the groundwater source water quality early warning method for environmental safety as described in the above method embodiments. To avoid repetition, the present invention will not repeat the details.
[0168] It should be understood that the processor in the embodiments of the present invention can be a central processing unit (CPU), or it can be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.
[0169] It should also be understood that the memory in the embodiments of the present invention can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous DRAM (DDR SDRAM), enhanced synchronous DRAM (ESDRAM), synchronous linked DRAM (SLDRAM), and direct rambus RAM (DR RAM).
[0170] The above embodiments can be implemented, in whole or in part, by software, hardware (such as circuits), firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented, in whole or in part, as a computer program product. A computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, all or part of the flow or function according to the embodiments of the present invention is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. Computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., infrared, wireless, microwave, etc.) means. A computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more sets of available media. Available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media. Semiconductor media can be solid-state drives.
[0171] It should be understood that the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. A and B can be singular or plural. Additionally, the character " / " in this article generally indicates an "or" relationship between the preceding and following related objects, but it can also represent an "and / or" relationship. Please refer to the context for a more accurate understanding.
[0172] In this invention, "at least one" means one or more, and "more than one" means two or more. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of a single item or a plurality of items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be a single item or multiple items.
[0173] It should be understood that, in various embodiments of the present invention, the sequence number of each process does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0174] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0175] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the devices, apparatuses, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0176] In the embodiments provided by this invention, it should be understood that the disclosed devices, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0177] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0178] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0179] 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.
[0180] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
[0181] The following points need to be explained:
[0182] (1) The accompanying drawings of the embodiments of the present invention only involve the structures involved in the embodiments of the present invention. Other structures can refer to the general design.
[0183] (2) For clarity, the thickness of layers or regions is enlarged or reduced in the drawings used to describe embodiments of the invention, i.e., these drawings are not drawn to scale. It is understood that when an element such as a layer, film, region or substrate is referred to as being “above” or “below” another element, the element may be “directly” located “above” or “below” the other element or there may be intermediate elements.
[0184] (3) Where there is no conflict, the embodiments of the present invention and the features in the embodiments can be combined with each other to obtain new embodiments.
[0185] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. The scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A water quality early warning method for groundwater sources aimed at environmental safety, characterized in that, include: S1: Obtain multiple water quality indicators of groundwater sources in different historical periods and the corresponding indicator values of each water quality indicator; S2: Combining the Lasso regression model and the FISTA algorithm, the water quality indicators are screened to determine the key water quality indicators; S3: Construct a two-dimensional tensor based on the key water quality indicators and their corresponding values; S4: Based on CNN and LSTM algorithms, combined with attention mechanism, a water pollution prediction model is constructed; The water pollution prediction model includes: an input layer, a first convolutional layer, a second convolutional layer, a first LSTM layer, a second LSTM layer, an attention layer, and an output layer. The input layer receives pre-processed water quality data. The first convolutional layer extracts local features from the input data through convolution operations; The second convolutional layer further processes the convolutional feature map to extract deeper features; The first LSTM layer is used to capture the trend of water quality data over time; The second LSTM layer further learns the time-series features of the water quality data; The attention layer is a mechanism that focuses on important parts of the input data by assigning different weights; The output layer generates predicted values of pollutant concentrations. S5: Input the two-dimensional tensor into the water pollution prediction model to determine the concentration of pollutants; S6: Calculate the deviation between the concentration of the pollutant and the threshold of the pollutant to determine the water quality risk level; S7: Based on the water quality risk level and in conjunction with the early warning classification strategy, issue an early warning for the water quality of the groundwater source. Specifically, S2 includes: S201: Normalize each of the water quality indicators to generate a water quality indicator dictionary; S202: Based on the aforementioned water quality index dictionary, and combined with the Lasso regression model and L1 regularization rule, determine the objective function: ; Where P() represents the objective function, λ represents the regularization parameter, D represents the dictionary of water quality indicators, y represents the target variable, argmin represents the minimum value, and x represents the regression coefficient. Represents the sum of squared residuals. Represents the L1 regularization term; S203: With the objective of minimizing the function value of the objective function, the FISTA algorithm is used to screen each of the water quality indicators to determine the key water quality indicators.
2. The water quality early warning method for groundwater sources oriented towards environmental safety according to claim 1, characterized in that, The key water quality indicators specifically include: dissolved oxygen, biological oxygen demand, total nitrogen, temperature, pH, chemical oxygen demand, total phosphorus, and nitrogen-to-phosphorus ratio.
3. The water quality early warning method for groundwater sources oriented towards environmental safety according to claim 1, characterized in that, S203 specifically includes: S2031: Initialize the water quality index dictionary, regression coefficients, acceleration variables, and index set; S2032: Calculate the gradient of the objective function based on the initialized regression coefficients: ; Where, θ r Let D represent the gradient at the r-th iteration. r-1 Let x represent the dictionary of water quality indicators at the (r-1)th iteration. r-1 Represents the regression coefficients at the (r-1)th iteration; S2033: Determine the gradient projection based on the gradient of the objective function: ; Among them, z r This represents the gradient projection at the r-th iteration. This represents the transpose of the water quality index dictionary at the (r-1)th iteration, where T represents the transpose operation; S2034: Update the gradient projection through a soft thresholding operation to generate the final regression coefficients: ; Where, x r This represents the regression coefficient at the r-th iteration, i.e., the final regression coefficient. Indicates soft thresholding operation, L r This represents the step size of the r-th iteration; S2035: Based on the final regression coefficients and combined with the Nesterov acceleration method, each of the water quality indicators is dynamically screened. S2036: Repeat S2032 to S2035 until the function value of the objective function is less than the preset objective function value, and determine the key water quality index.
4. The water quality early warning method for groundwater sources oriented towards environmental safety according to claim 1, characterized in that, S5 specifically includes: S501: Input the two-dimensional tensor into the input layer; S502: Extract local features of the two-dimensional tensor through the first convolutional layer; S503: The feature map output by the first convolutional layer is convolved through the second convolutional layer to extract deep features; S504: Based on the deep features, extract the short-term temporal features of the two-dimensional tensor through the first LSTM layer; S505: Based on the short-term temporal characteristics, determine multiple hidden states of the two-dimensional tensor through the second LSTM layer; S506: Through the attention layer, calculate the attention weight of each of the hidden states, and determine the output of the attention mechanism; S507: Based on the output of the attention mechanism, the concentration of the pollutant is output through the output layer.
5. The water quality early warning method for groundwater sources oriented towards environmental safety according to claim 4, characterized in that, Specifically, S506 includes: S5061: Calculate the attention weights for each of the hidden states; S5062: Based on the attention weights, determine the output of the attention mechanism by weighted summation.
6. The water quality early warning method for groundwater sources oriented towards environmental safety according to claim 1, characterized in that, The early warning classification strategy includes: green warning, yellow warning, orange warning, and red warning.
7. A water quality early warning system for groundwater sources aimed at environmental safety, characterized in that, include: processor; A memory storing computer-readable instructions, which, when executed by the processor, implement a water quality early warning method for groundwater sources oriented towards environmental safety as described in any one of claims 1 to 6.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by the processor, the program implements a water quality early warning method for groundwater sources with environmental safety as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Municipal garden water pollution monitoring system and method based on big data analysis
CN118886718A
Industrial wastewater treatment monitoring method and system based on LSTM
CN119337299A
Method and model for inverting key parameters in underground water pollutant biodegradation numerical model based on neural network algorithm
CN119558171A
Low-dose CT reconstruction method and system based on global optimization iteration deep learning
CN120047568A