Underground water source water quality early warning method and system for environmental safety
By using Lasso regression and FISTA algorithm to screen key water quality indicators, and combining CNN and LSTM water pollution prediction models, the problem of slow response in traditional water quality early warning methods is solved, achieving efficient and accurate water quality early warning with real-time and forward-looking capabilities, thus protecting water source safety.
Patent Information
- Application Number
- CN202511027217.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-24
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2045-07-24
AI Technical Summary
Existing groundwater source water quality early warning methods rely on traditional monitoring means, which are slow to respond, have low monitoring frequency, cannot achieve real-time monitoring, and are difficult to detect potential pollution risks in a timely manner, 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 CN120911677A_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 ecosystem 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 makes it 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: First aspect: The groundwater source water quality early warning method for environmental safety provided by the embodiments of the present application comprises: S1: acquiring a plurality of water quality indexes of the groundwater source in different historical periods and index values corresponding to each water quality index; S2: Screen the water quality indexes by combining the Lasso regression model and the FISTA algorithm, and determine the key water quality indexes; S3: Construct a two-dimensional tensor according to the key water quality indexes and index values; S4: Construct a water pollution prediction model based on the CNN and the LSTM, and in combination with an attention mechanism; S5: Input the two-dimensional tensor into the water pollution prediction model to determine the pollution factor concentration; S6: Calculate the deviation of the pollution factor concentration and the pollution factor threshold value to determine the water quality risk level; S7: According to the water quality risk level, in combination with an early warning grading strategy, early warning is performed on the water quality of the groundwater source.
[0007] Optionally, the key water quality indexes specifically include dissolved oxygen, biological oxygen demand, total nitrogen, temperature, pH value, chemical oxygen demand, total phosphorus, and nitrogen-phosphorus ratio.
[0008] Optionally, the S2 specifically includes: S201: Perform normalization processing on each water quality index to generate a water quality index dictionary; S202: According to the water quality index dictionary, in combination with the Lasso regression model and the L1 regularization rule, determine a target function; S203: By the FISTA algorithm, screen each water quality index to determine the key water quality index, with the goal of minimizing the function value of the target function.
[0009] Optionally, the S203 specifically includes: S2031: Initialize the water quality index dictionary, regression coefficient, acceleration variable, and index set; S2032: According to the initialized regression coefficient, calculate the gradient of the target function; S2033: According to the gradient of the target function, determine the gradient projection; S2034: Through a soft threshold operation, update the gradient projection to generate a final regression coefficient; S2035: According to the final regression coefficient, in combination with the Nesterov acceleration method, dynamically screen each water quality index; S2036: Repeat S2032 to S2035 until the function value of the target function is less than a preset target function value, and determine the key water quality index.
[0010] 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.
[0011] Optionally, the S5 specifically includes: S501: inputting the two-dimensional tensor in the input layer; S502: extracting local features of the two-dimensional tensor through the first convolutional layer; S503: performing convolution operation on the feature map output by the first convolutional layer through the second convolutional layer to extract deep features; S504: extracting short-term time sequence features of the two-dimensional tensor through the first LSTM layer according to the deep features; S505: determining a plurality of hidden states of the two-dimensional tensor through the second LSTM layer according to the short-term time sequence features; S506: calculating attention weights of each hidden state through the attention layer to determine an output of the attention mechanism; S507: outputting the pollution factor concentration through the output layer according to the output of the attention mechanism.
[0012] Optionally, the S506 specifically includes: S5061: calculating attention weights of each hidden state; S5062: determining an output of the attention mechanism through weighted summation according to the attention weights.
[0013] Optionally, the early warning grading strategy includes green early warning, yellow early warning, orange early warning and red early warning.
[0014] Second aspect: The embodiment of the present application provides a groundwater source water quality early warning system for environmental safety, which comprises: a processor; a memory, wherein the memory is stored with computer readable instructions, and the computer readable instructions are executed by the processor to realize the groundwater source water quality early warning method for environmental safety according to the first aspect.
[0015] Third aspect: The embodiment of the present application provides a computer readable storage medium, which is stored with a computer program, and the program is executed by a processor to realize the groundwater source water quality early warning method for environmental safety according to the first aspect.
[0016] The technical scheme provided by the embodiment of the present application has at least the following beneficial effects: In the embodiment of the present application, by acquiring a plurality of water quality indexes of the groundwater source in different historical periods and index values corresponding to each water quality index, then combining the Lasso regression model and the FISTA algorithm, the water quality indexes are screened to determine the key water quality indexes, so as to ensure the most relevant data. And according to the key water quality indexes and the index values, a two-dimensional tensor is constructed, further, based on the CNN and the LSTM, combined with the attention mechanism, a water pollution prediction model is constructed, the two-dimensional tensor is input into the water pollution prediction model, the concentration of the pollution factor is determined, the deviation of the pollution factor concentration and the pollution factor threshold is calculated to determine the water quality risk level, finally, according to the water quality risk level, combined with the early warning grading strategy, the water quality of the groundwater source is early warned, efficient and accurate water quality monitoring and early warning are realized, real-time and forward-looking are possessed, potential pollution can be identified in advance, the cost of manual early warning is reduced, and the water source safety is protected. BRIEF DESCRIPTION OF DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0018] Figure 1 A flowchart of a groundwater source water quality early warning method for environmental safety provided by the embodiment of the present application is shown. Figure 2 A structure diagram of a groundwater source water quality early warning system for environmental safety provided by the embodiment of the present application is shown. DETAILED DESCRIPTION
[0019] The technical solutions in the present application will be described below with reference to the drawings.
[0020] In the embodiments of the present application, the words such as "example", "for example" are used to represent as an example, illustration or description. Any embodiment or design scheme described as "example" in the present application should not be interpreted as more preferred or more advantageous than other embodiments or design schemes. In fact, the word "example" is intended to present the concept in a specific way. In addition, in the embodiments of the present application, the meaning expressed by "and / or" can be both, or can be one of the two.
[0021] In the embodiments of the present application, "image" and "picture" can be used interchangeably, and it should be pointed out that their meanings are consistent when their differences are not emphasized.
[0022] In the embodiments of the present application, sometimes the subscript such as W1 can be written in the form of non-subscript such as W1, and their meanings are consistent when their differences are not emphasized.
[0023] In order to make the technical problems, technical solutions and advantages of the present application clearer, the following will be described in detail with reference to the drawings and specific embodiments.
[0024] Reference is made to the accompanying drawings and specific embodiments of the present application. Figure 1 , a flowchart of a groundwater source water quality early warning method for environmental safety provided by an embodiment of the present application is shown.
[0025] The embodiment of the present application provides a groundwater source water quality early warning method for environmental safety, which can be realized by a groundwater source water quality early warning device for environmental safety. The groundwater source water quality early warning device for environmental safety can be a terminal or a server. The processing flow of the groundwater source water quality early warning method for environmental safety can include the following steps: S1: Obtain a plurality of water quality indexes of the groundwater source in different historical periods and index values corresponding to each water quality index.
[0026] Wherein, the historical period refers to the water quality data collected in the past period of time, which reflects the change trend of water quality in different periods. The groundwater source refers to the place where groundwater is extracted for water supply or other purposes, and is usually the main source of groundwater resources. The water quality index is a characteristic data used to measure the quality of water body. Common water quality indexes include dissolved oxygen, pH value, temperature, total nitrogen, chemical oxygen demand (COD) and the like. The index value is the specific value corresponding to each water quality index, reflecting the water quality condition at a certain moment or period.
[0027] It should be noted that by collecting water quality data in different historical periods and analyzing the changes of each water quality index, comprehensive basic data can be provided for subsequent water quality analysis. This method can show the long-term change trend of water quality, which is helpful to identify potential pollution sources and pollution patterns, and provides sufficient historical basis for accurate prediction of the model.
[0028] S2: Screen the water quality indexes by combining the Lasso regression model and the FISTA algorithm, and determine the key water quality indexes.
[0029] wherein the Lasso regression model is a linear regression method that can perform variable selection in regression analysis by introducing an L1 regularization term, reducing the complexity of the model, and helping to identify key variables that have the most impact on the prediction results. The FISTA algorithm is an algorithm for solving sparse optimization problems, which can accelerate the variable screening process in Lasso regression and provide an efficient calculation method.
[0030] wherein the key water quality indicators refer to key indicators that have a significant impact on water quality changes.
[0031] It should be noted that by combining Lasso regression and FISTA algorithm, the most predictive key water quality indicators can be efficiently screened, avoiding data redundancy and noise interference with the model. This process improves the accuracy and efficiency of data processing, ensuring that subsequent model is based on the most relevant water quality indicators, improving the accuracy of water quality prediction.
[0032] In one possible implementation, the key water quality indicators specifically include: dissolved oxygen, biological oxygen demand, total nitrogen, temperature, pH value, chemical oxygen demand, total phosphorus, and nitrogen to phosphorus ratio.
[0033] wherein dissolved oxygen (DO, Dissolved Oxygen) refers to the dissolved oxygen content in water, which is an important indicator of water health. High concentration of dissolved oxygen means that the water body can support the survival of various aquatic organisms, while insufficient dissolved oxygen can lead to the death of aquatic organisms and poor water quality.
[0034] wherein biological oxygen demand (BOD, Biological Oxygen Demand) is the amount of oxygen consumed by microorganisms in water to decompose organic matter. A high BOD value usually means that there is more organic pollution in the water, and the water quality is poor.
[0035] wherein total nitrogen (TN, Total Nitrogen) refers to the total amount of all forms of nitrogen in water, including ammonia nitrogen, nitrate nitrogen, etc. Nitrogen is an important indicator of water pollution, and high nitrogen concentration can lead to water eutrophication and affect water quality.
[0036] wherein temperature (Temperature) directly affects the dissolved oxygen content and microbial activity in water. High water temperature can lead to a decrease in dissolved oxygen, affecting the survival of aquatic organisms.
[0037] wherein pH value (pH, Potential of Hydrogen) represents the acidity or alkalinity of water. Low pH value (acidic) or high pH value (alkaline) of water can adversely affect aquatic organisms and affect the stability of water quality.
[0038] Chemical Oxygen Demand (COD) refers to the amount of oxygen required to oxidize the organic matter in water. A high COD value indicates a higher level of pollutants in the water, and is often used in conjunction with BOD to assess the degree of water pollution.
[0039] Total Phosphorus (TP) is the sum of all forms of phosphorus in water. Phosphorus is an important factor in water eutrophication, and high concentrations of total phosphorus can lead to water eutrophication, promoting excessive growth of algae and reducing water quality.
[0040] Nitrogen-Phosphorus Ratio (N-P Ratio) is the mass ratio of nitrogen (N) to phosphorus (P) in water. The N-P ratio is important in assessing whether the water is in a state of eutrophication, and a low N-P ratio may lead to excessive algae growth and water quality deterioration.
[0041] In one possible implementation, S2 specifically includes: S201: Normalizing each water quality indicator to generate a water quality indicator dictionary.
[0042] Normalization is the process of adjusting the values of each water quality indicator to a unified scale, usually by scaling the data to the range of [0, 1] or [-1, 1], to avoid the impact of different scales of water quality indicators on subsequent analysis. The water quality indicator dictionary is a collection of all water quality indicators and their corresponding values. After normalization, each water quality indicator is assigned a standardized value for subsequent analysis and modeling.
[0043] S202: According to the water quality indicator dictionary, combining the Lasso regression model and the L1 regularization rule, determine the objective function:
[0044] wherein, P ( ) represents the objective function, Lambda represents the regularization parameter, D represents the water quality indicator dictionary, y represents the target variable, argmin represents the minimum value, x represents the regression coefficient, represents the residual sum of squares, represents the L1 regularization term.
[0045] 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.
[0046] 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.
[0047] 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.
[0048] In one possible implementation, S203 specifically includes: S2031: Initialize the water quality index dictionary, regression coefficients, acceleration variables, and index set.
[0049] 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.
[0050] S2032: Calculate the gradient of the objective function based on the initialized regression coefficients:
[0051] 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.
[0052] 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.
[0053] S2033: Determine the gradient projection based on the gradient of the objective function:
[0054] 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.
[0055] 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.
[0056] S2034: Update the gradient projection through a soft thresholding operation to generate the final regression coefficients.
[0057] 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.
[0058] 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.
[0059] S2035: Based on the final regression coefficients and combined with the Nesterov acceleration method, water quality indicators are dynamically screened.
[0060] 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.
[0061] S2036: repeating S2032 to S2035 until the function value of the objective function is less than a preset objective function value, and determining the key water quality index.
[0062] wherein the preset objective function value is a threshold in the optimization process, and when the value of the objective function is less than the value, it indicates that the optimization has converged, and the algorithm can stop running, considering that the optimal regression coefficient has been found.
[0063] wherein the size of the preset objective function value can be set by a person skilled in the art according to the actual situation, and the present application does not make any limitation.
[0064] It should be noted that first, the water quality index dictionary and the regression coefficient and other key parameters are initialized, laying the foundation for the optimization process. Through the calculation of the gradient of the objective function, the FISTA algorithm can accelerate the gradient descent process, thereby quickly approaching the optimal solution in each iteration. The soft threshold operation effectively performs feature selection, removing redundant water quality indicators and ensuring the simplicity and interpretability of the model. Combined with the Nesterov acceleration method, the optimization efficiency is further improved, ensuring that the optimal solution is obtained in fewer iterations. Through efficient optimization means, not only the calculation speed is improved, but also the most critical water quality indicators are selected, providing an accurate basis for subsequent pollution prediction and risk assessment.
[0065] S3: constructing a two-dimensional tensor according to the key water quality index and the index value.
[0066] wherein the two-dimensional tensor is a data structure in mathematics and calculation, which is usually used to store multi-dimensional arrays. Each row of the two-dimensional tensor may represent data at different time points, and each column represents different water quality indicators.
[0067] It should be noted that by organizing the key water quality indicators and their corresponding values into a two-dimensional tensor, a structured input data format is provided, which facilitates subsequent model processing. The two-dimensional tensor can effectively integrate the data of multiple water quality indicators, facilitating the model to identify the spatiotemporal variation rules of water quality. Such data representation not only improves data processing efficiency, but also provides a clear and unified input structure for deep learning models (such as CNN and LSTM), thereby enhancing the prediction ability and accuracy of the model. In addition, by constructing a two-dimensional tensor, the dynamic characteristics of water quality changes can be effectively captured in subsequent water quality prediction.
[0068] S4: constructing a water pollution prediction model based on CNN and LSTM combined with an attention mechanism.
[0069] CNN (Convolutional Neural Network) is a deep learning model widely used for processing image and time series data. It extracts local features of input data through multiple convolutional layers, effectively capturing spatial and temporal patterns. In water quality prediction, CNN can be used to extract local rules in water quality data, helping the model identify complex water quality change characteristics.
[0070] LSTM (Long Short-Term Memory) is a special type of recurrent neural network (RNN) designed to process and predict sequence data. It introduces a gating mechanism to avoid the gradient vanishing problem in traditional RNNs, effectively capturing long-term dependencies in time series. In water quality early warning, LSTM is used to learn the trend of water quality data over time and predict future water quality changes.
[0071] Attention mechanism is a computational method that simulates human visual focus, allowing the model to focus on the most relevant parts of input data when processing information. Through this mechanism, the model can adaptively adjust its focus and improve the identification of key features. For water quality early warning, attention mechanism can help the model focus on the indicators that most affect water quality changes.
[0072] 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 combines CNN, LSTM, and attention mechanism to accurately predict water pollution levels and provide early warnings.
[0073] It should be noted that by combining CNN, LSTM, and attention mechanism, an efficient water pollution prediction model is constructed. CNN can automatically extract local features from water quality data, helping the model identify subtle patterns in water quality changes; LSTM uses its powerful time series modeling capabilities to effectively capture temporal dependencies in water quality data and predict future water quality changes. Attention mechanism further enhances the model's ability to adaptively focus on the most critical features affecting water quality changes, avoiding information redundancy and noise. This multi-level, multi-mechanism combination ensures high accuracy and timeliness of water quality prediction, providing more accurate decision-making basis for water quality early warning systems.
[0074] 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.
[0075] In the water pollution prediction model, the input layer receives pre-processed water quality data, such as various water quality indicators and their corresponding time series or other related data. These data will be used as input to the network for further processing and prediction.
[0076] 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.
[0077] The second convolutional layer further processes the feature maps after convolution, extracting deeper features. By convolving the feature maps output by the first layer, the second convolutional layer can extract more complex and abstract features, enhancing the model's ability to understand water quality changes.
[0078] The first LSTM layer is used to capture the trend of water quality data over time. It can handle the time-dependent relationship in the data, so as to learn to predict future changes in water quality.
[0079] The second LSTM layer further learns the time series features of water quality data. By stacking multiple LSTM layers, the model can capture dependencies over longer time ranges, improving its ability to handle complex time series data.
[0080] The attention layer is a mechanism that focuses on important parts of the input data by assigning different weights. In water pollution prediction, the attention layer helps the model adaptively adjust the focus according to the importance of input features, ensuring that the model can focus on key indicators affecting water quality changes while ignoring noise or irrelevant parts.
[0081] The output layer outputs the final prediction results. In the water pollution prediction model, the output layer generates pollution factor concentration prediction values.
[0082] It should be noted that the water pollution prediction model combines CNN, LSTM and attention mechanisms to fully leverage the advantages of each layer structure. The convolutional layer (CNN) can extract local features from the data, allowing the model to identify subtle changes in water quality data; the LSTM layer processes the time series 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 ranges, improving prediction accuracy. The attention mechanism helps the model adaptively focus on the most important features, reducing information noise interference and enhancing the model's sensitivity to key water quality indicators. Finally, the output layer generates accurate water pollution prediction results, providing timely warning information. This structure improves the accuracy and efficiency of water quality prediction through multi-level and multi-dimensional processing, providing effective support for water source protection and pollution prevention.
[0083] S5: Input the two-dimensional tensor into the water pollution prediction model to determine the concentration of pollutants.
[0084] 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.
[0085] 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.
[0086] In one possible implementation, S5 specifically includes: S501: Input the two-dimensional tensor into the input layer.
[0087] S502: Extracting local features of the two-dimensional tensor through the first convolutional layer:
[0088] 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.
[0089] S503: The second convolutional layer performs a convolution operation on the feature map output by the first convolutional layer to extract deep features.
[0090] S504: Based on deep features, extract short-term temporal features of the two-dimensional tensor through the first LSTM layer.
[0091] S505: Based on short-term temporal characteristics, multiple hidden states of the two-dimensional tensor are determined through a second LSTM layer:
[0092] in, f texpress 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 time-based unit C t-1 express t Cell state at time -1 W C 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.
[0093] S506: Through the attention layer, calculate the attention weights of each hidden state and determine the output of the attention mechanism.
[0094] S507: Based on the output of the attention mechanism, the concentration of pollutants is output through the output layer.
[0095] 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.
[0096] In one possible implementation, S506 specifically includes: S5061: Calculate the attention weights for each hidden state:
[0097] 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.
[0098] S5062: Based on the attention weights, determine the output of the attention mechanism using a weighted summation method:
[0099] in, express t The output of the attention mechanism at any given moment express t Attention weight at any momentN The total number of time points is represented.
[0100] It should be noted that the output layer combines all the information to generate accurate pollution factor concentration predictions, providing reliable decision-making basis for water quality monitoring and early warning. This structure integrates local feature extraction, time series modeling and dynamic attention mechanism, providing an efficient and accurate solution for complex water quality prediction tasks.
[0101] S6: Calculate the deviation of the pollution factor concentration and the pollution factor threshold value, and determine the water quality risk level.
[0102] Wherein, the pollution factor threshold value is the preset pollution concentration limit value, exceeding which indicates that the water quality has exceeded the safety standard, which may lead to water pollution or ecological disaster. The threshold value is usually set based on environmental protection standards or historical data, and plays a warning role. The deviation can help quantify the degree of water quality deviation from the safety standard, providing a quantitative basis for water quality risk. The water quality risk level is evaluated according to the deviation of the pollution factor concentration and the pollution factor threshold value. It is usually divided into several levels (such as low, medium and high), indicating the degree of harm to water quality, helping relevant departments to take appropriate measures.
[0103] It should be noted that the deviation between the pollution factor concentration and the threshold value can accurately evaluate the risk level of water quality. This process compares the pollutant concentration with the preset safety standard, quantifies the risk level of water quality, and ensures the scientificity and operability of the early warning system. According to different deviations, the system can provide clear risk levels for water quality warning, helping relevant departments to take protective measures or start emergency response in time.
[0104] S7: According to the water quality risk level, combined with the early warning grading strategy, the water quality of the groundwater source is warned.
[0105] Wherein, the early warning grading strategy refers to taking different early warning measures according to different water quality risk levels. This strategy divides the water quality into several early warning levels (such as green, yellow, orange and red) according to the different risk levels of water quality, so that relevant departments can take appropriate preventive or emergency measures according to the early warning level.
[0106] It should be noted that by combining the water quality risk level and the early warning grading strategy, a scientific and systematic early warning mechanism for the water quality of the groundwater source is provided. When the pollution factor concentration of the water quality reaches a certain degree, the early warning grading strategy can start different emergency responses in time according to the water quality risk level. Through the clear grading strategy, relevant departments can quickly understand the pollution risk and take targeted measures to prevent the water quality from further deterioration or pollution spread. This method improves the sensitivity and accuracy of early warning, making the management of water source more efficient, ensuring the safety of public drinking water and the stability of ecological environment.
[0107] In one possible implementation, the early warning grading strategy includes green early warning, yellow early warning, orange early warning, and red early warning.
[0108] Among them, green early warning generally indicates that the water quality is good or the pollution risk is low, and the water body is within the safe range. At this time, no emergency measures need to be taken, but monitoring still needs to be maintained. Green early warning is a symbol of normal water quality.
[0109] Among them, yellow early warning indicates that the water quality is slightly polluted, although the water quality is still within the acceptable range, but has approached the dangerous level, and needs to be noticed and take certain monitoring measures. Yellow early warning is an early warning of potential risks.
[0110] Among them, orange early warning indicates that the water pollution is high, and the water quality has exceeded the safe range, and more stringent monitoring and prevention measures need to be taken. At this time, water source protection and pollution control should be strengthened to prevent the situation from further deteriorating.
[0111] Among them, red early warning is the highest level of early warning, indicating that the water pollution is serious, has reached or exceeded the dangerous level, and may cause great threat to human health and ecological environment. At this time, emergency measures such as water stop and pollution source treatment need to be taken immediately.
[0112] It should be noted that by setting different early warning levels (green, yellow, orange and red), the safety status of the water body can be accurately reflected according to the severity of water pollution. Each early warning level represents a different degree of pollution risk, ensuring that relevant departments can respond in a timely manner and take appropriate measures. The grading strategy makes water quality management more flexible and accurate, which can effectively prevent potential water quality problems from deteriorating and intervene through lower level early warning at the initial stage of pollution. Through this scientific and hierarchical early warning mechanism, the efficiency and effectiveness of water quality protection can be improved, ensuring water source safety and reducing the threat to public health.
[0113] In the embodiment of the present application, by acquiring a plurality of water quality indexes of the groundwater source in different historical periods and index values corresponding to each water quality index, then combining the Lasso regression model and the FISTA algorithm, the water quality indexes are screened to determine the key water quality indexes, so as to ensure the most relevant data. According to the key water quality indexes and the index values, a two-dimensional tensor is constructed, further, based on the CNN and the LSTM, the water body pollution prediction model is constructed by combining the attention mechanism, the two-dimensional tensor is input into the water body pollution prediction model to determine the pollution factor concentration, the deviation between the pollution factor concentration and the pollution factor threshold is calculated to determine the water quality risk level, finally, according to the water quality risk level, the water quality of the groundwater source is warned by combining the early warning grading strategy, efficient and accurate water quality monitoring and early warning are realized, real-time and foresight are achieved, potential pollution can be identified in advance, the cost of manual early warning is reduced, and water source safety is protected.
[0114] With reference to the accompanying drawings Figure 2 The accompanying drawings show a structure schematic diagram of a groundwater source water quality early warning system for environmental safety provided by the present application.
[0115] The present application also provides a groundwater source water quality early warning system 20 for environmental safety, applied to the groundwater source water quality early warning method for environmental safety described above, comprising: A processor 201.
[0116] A memory 202, the memory 202 stores computer readable instructions, when the computer readable instructions are executed by the processor 201, the groundwater source water quality early warning method for environmental safety of the method embodiment is realized.
[0117] The groundwater source water quality early warning system 20 for environmental safety provided by the present application can execute the groundwater source water quality early warning method for environmental safety described above, and realize the same or similar technical effects, to avoid repetition, the present application will not be described again.
[0118] The embodiment of the present application provides a computer readable storage medium, which stores a computer program, when the program is executed by a processor, the groundwater source water quality early warning method for environmental safety of the method embodiment is realized.
[0119] The computer readable storage medium provided by the present application can realize the steps and effects of the groundwater source water quality early warning method for environmental safety of the method embodiment described above, to avoid repetition, the present application will not be described again.
[0120] It should be appreciated that a processor in the embodiments of the present application can be a central processing unit (CPU). The processor can also be other general purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic, discrete hardware components, etc. The general purpose processor can be a microprocessor or the processor can be any conventional processor.
[0121] It should also be appreciated that the memory in the embodiments of the present application can be a volatile memory or a nonvolatile memory, or can include both volatile and nonvolatile memory. The nonvolatile memory can be a read-only memory (ROM), programmable ROM (PROM), erasable PROM (EPROM), electrically EPROM (EEPROM), or flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example, and not limitation, many forms of random access memory (RAM) are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchlink DRAM (SLDRAM), and direct rambus RAM (DR RAM).
[0122] The above-described embodiments can be implemented in whole or in part by software, hardware (such as a circuit), firmware, or any combination thereof. When implemented in software, the above-described embodiments can be implemented in the form of a computer program product. The 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, the processes or functions according to the embodiments of the present application are wholly or partially generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions can be transferred from one website, computer, server, or data center to another website, computer, server, or data center through a wired (for example, infrared, wireless, microwave, etc.) manner. The computer-readable storage medium can be any available medium accessible by a computer or a data storage device such as a server, data center, etc. containing one or more available medium collections. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium. The semiconductor medium can be a solid-state disk.
[0123] It should be understood that the term "and / or" herein merely describes an association relationship of associated objects, which means that there can be three relationships, for example, A and / or B can represent three cases of A alone, A and B together, and B alone, where A and B can be singular or plural. In addition, the character " / " herein generally represents an "or" relationship between the front and rear associated objects, but can also represent an "and / or" relationship, which can be understood in the context before and after.
[0124] In the present application, "at least one" means one or more, and "multiple" means two or more. "At least one of the following" or the like means any combination of the items, including any combination of single or multiple items. For example, at least one of a, b, or c can represent a, b, c, a-b, a-c, b-c, or a-b-c, where a, b, and c can be single or multiple.
[0125] It should be understood that in various embodiments of the present application, the size of the sequence number of the above-described processes does not mean the order of execution, and the execution order of the processes should be determined by their functions and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0126] Those skilled in the art can clearly understand that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are performed 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 implementation should not be considered beyond the scope of the present application.
[0127] Those skilled in the art can clearly understand that, for the convenience and brevity of the description, the specific working processes of the devices, apparatuses and units described above can refer to the corresponding processes in the foregoing method embodiments, which will not be repeated here.
[0128] In several embodiments provided by the present application, 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 schematic, for example, the division of units is only a logical function division, and actual implementation can have another division manner, for example, multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0129] The units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed on multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment scheme.
[0130] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically independently, or two or more units can be integrated into one unit.
[0131] If the functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application or the parts of the present application that essentially contribute to the prior art or the parts of the technical solutions can be embodied in the form of a software product, which is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various storage medium that can store program codes.
[0132] The above is only a specific embodiment of the present application, but the protection scope of the present application is not limited thereto, and any person skilled in the art can easily think of changes or replacements within the technical scope disclosed by the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
[0133] The following points need to be explained: (1) The drawings of the embodiments of the present application only involve the structures involved in the embodiments of the present application, and other structures can be referred to the general design.
[0134] (2) For the sake of clarity, the thickness of the layers or regions is exaggerated or reduced in the drawings used to describe the embodiments of the present application, that is, the drawings are not drawn according to the actual proportion. It can be understood that when an element such as a layer, a film, a region or a substrate is referred to as being located "on" or "under" another element, the element can be "directly" located on or under another element or there can be an intermediate element.
[0135] (3) In the case of no conflict, the embodiments of the present application and the features in the embodiments can be combined with each other to obtain new embodiments.
[0136] The above is only a specific embodiment of the present application, but the protection scope of the present application is not limited thereto, and the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. An environmental safety-oriented groundwater source water quality early warning method, characterized in that, The method comprises the following steps: S1: obtaining a plurality of water quality indexes of a groundwater source in different historical periods and index values corresponding to each water quality index; S2: screening each water quality index by combining a Lasso regression model and a FISTA algorithm to determine a key water quality index; S3: constructing a two-dimensional tensor according to the key water quality index and the index value corresponding to the key water quality index; S4: constructing a water pollution prediction model based on a CNN algorithm and an LSTM algorithm in combination with an attention mechanism; S5: inputting the two-dimensional tensor into the water pollution prediction model to determine a pollution factor concentration; S6: calculating the deviation of the pollution factor concentration and a pollution factor threshold to determine a water quality risk level; S7: warning the water quality of the groundwater source according to the water quality risk level in combination with a warning grading strategy.
2. The environmental safety-oriented groundwater resource site water quality early warning method according to claim 1, characterized by, The key water quality index specifically comprises dissolved oxygen, biological oxygen demand, total nitrogen, temperature, pH value, chemical oxygen demand, total phosphorus and nitrogen-phosphorus ratio.
3. The environmental safety-oriented groundwater resource site water quality early warning method according to claim 1, characterized by, The S2 specifically comprises: S201: normalizing each water quality index to generate a water quality index dictionary; S202: determining a target function according to the water quality index dictionary in combination with the Lasso regression model and an L1 regularization rule; S203: screening each water quality index by the FISTA algorithm to determine the key water quality index with the aim of minimizing the function value of the target function.
4. The environmental safety-oriented groundwater resource site water quality early warning method according to claim 3, characterized by, The S203 specifically comprises: S2031: initializing the water quality index dictionary, regression coefficient, acceleration variable and index set; S2032: calculating the gradient of the target function according to the initialized regression coefficient; S2033: determining the gradient projection according to the gradient of the target function; S2034: updating the gradient projection by a soft threshold operation to generate a final regression coefficient; S2035: dynamically screening each water quality index according to the final regression coefficient in combination with the Nesterov acceleration method; S2036: repeating S2032 to S2035 until the function value of the target function is less than a preset target function value to determine the key water quality index.
5. The environmental safety-oriented groundwater resource site water quality early warning method according to claim 1, characterized by, The water pollution prediction model comprises 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.
6. The environmental safety-oriented groundwater resource site water quality early warning method according to claim 5, characterized by, The S5 specifically comprises: S501: inputting the two-dimensional tensor in the input layer; S502: extracting local features of the two-dimensional tensor by the first convolutional layer; S503: performing convolutional operation on the feature map output by the first convolutional layer by the second convolutional layer to extract deep features; S504: extracting short-term time sequence features of the two-dimensional tensor by the first LSTM layer according to the deep features; S505: determining a plurality of hidden states of the two-dimensional tensor by the second LSTM layer according to the short-term time sequence features; S506: calculating attention weights of each hidden state by the attention layer to determine the output of the attention mechanism. S507: outputting the pollution factor concentration through the output layer according to the output of the attention mechanism.
7. The environmental safety-oriented groundwater resource site water quality early warning method according to claim 6, characterized by, The S506 specifically includes: S5061: calculating attention weights of each of the hidden states; S5062: determining the output of the attention mechanism through a weighted summation manner according to the attention weights.
8. The environmental safety-oriented groundwater resource site water quality early warning method according to claim 1, characterized by, The early warning grading strategy includes green early warning, yellow early warning, orange early warning and red early warning.
9. An environmental safety-oriented groundwater source site water quality early warning system, characterized by, It includes: a processor; a memory, the memory having computer readable instructions stored thereon, the computer readable instructions being executed by the processor to implement the environmental safety-oriented groundwater source water quality early warning method according to any one of claims 1 to 8.
10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the environmental safety-oriented groundwater source water quality early warning method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Water quality early warning method based on Informer model
CN114385614A
Single monitoring section time sequence multi-element water quality prediction method based on mixed attention mechanism
CN115689015A
Municipal garden water pollution monitoring system and method based on big data analysis
CN118886718A
Water environment index change trend prediction and model establishment method, equipment and medium
CN119272929A
Industrial wastewater treatment monitoring method and system based on LSTM
CN119337299A
Cited By
Sudden pollution abnormity early warning method and system for multi-dimensional water quality index correlation analysis
CN121616128A