Drinking water quality safety detection and early warning system and method based on big data
Through big data technology, combined with principal component analysis, convolutional neural network and decision tree algorithm, real-time monitoring and early warning of water quality risks has been solved, and the traditional water quality detection methods cannot reflect water quality changes in real time, achieving timely and accurate monitoring of water quality and Automatic adjustment to ensure water quality safety.
Patent Information
- Application Number
- CN202411343933.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-25
- Publication Date
- 2025-01-03
AI Technical Summary
Traditional drinking water quality detection methods cannot reflect water quality changes in real time, and the laboratory analysis period is long, so it cannot respond to water quality abnormalities in a timely manner, resulting in an increase in water quality safety hazards and lack of a comprehensive and comprehensive analysis of environmental parameters on water quality.
Adopt a drinking water quality safety detection and early warning system based on big data, divide water quality detection points through the detection point spacing formula, combine principal component analysis, convolutional neural network, long and short-term memory network and decision tree algorithm to monitor water quality parameters in real time and predict water quality risks. , and automatically adjust environmental parameters to ensure that the water quality at the outlet meets the safety threshold.
Real-time and accurate monitoring and early warning of water quality conditions has been achieved, the timeliness and scientificity of water quality detection has been improved, ensuring that the water quality at the outlet is always within the safe range, and reducing the risk of water quality safety.
Smart Images

Figure CN119246789A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of big data, and in particular to a drinking water quality safety detection and early warning system and method based on big data. Background Art
[0002] With the acceleration of urbanization and the continuous scarcity of water resources, the safety of drinking water quality has received increasing attention. Traditional drinking water quality testing mainly relies on regular manual sampling and laboratory analysis. Although it can ensure the accuracy of water quality monitoring to a certain extent, it also has many shortcomings. First, the manual sampling frequency is low and cannot reflect water quality changes in real time; second, the laboratory analysis cycle is long and cannot respond to abnormal water quality in a timely manner; finally, there are certain errors in manual operation, which may lead to a decrease in the reliability of monitoring results.
[0003] Traditional monitoring methods often involve periodic sampling and are unable to provide real-time data, which results in the inability to detect and respond to water quality changes in a timely manner, thereby increasing water quality safety risks. The long cycle of laboratory analysis may result in the failure to take appropriate measures in a timely manner when water quality is abnormal, increasing risks. Monitoring is mostly focused on specific water quality parameters, and fails to comprehensively analyze the relationship between multiple water quality indicators, affecting the accuracy of the overall water quality assessment. The lack of analysis of the impact of environmental parameters on water quality may lead to deviations between monitoring results and actual conditions. Summary of the invention
[0004] The purpose of the present invention is to provide a drinking water quality safety detection and early warning system and method based on big data to solve the problems raised in the prior art.
[0005] To achieve the above object, the present invention provides the following technical solutions:
[0006] A drinking water quality safety detection and early warning method based on big data, the method comprising the following steps:
[0007] S100, using the test point spacing formula, dividing the water quality test points of the water supply pipe according to the ramp angle, the location of the water source and the water flow speed, setting the water quality test points, and numbering the water quality test points from near to far according to the distance from the water source;
[0008] S200, collecting water quality parameters according to the set water quality detection points, performing normalization processing, using principal component analysis to determine the weight of each water quality parameter, and calculating the water quality index of different water quality detection points; using a convolutional neural network, inputting the ramp angle, ramp material, water quality index and location of different water quality detection point areas, analyzing historical data, and obtaining the water quality difference of different water quality detection points in the ramp;
[0009] S300, according to the water quality difference of different water quality detection points, obtain the water quality parameter change trend from the water source to the water outlet, collect the environmental parameters of the surrounding environment of different water quality detection points, combine the water quality parameter change trend with the environmental parameters, and obtain the influence function of the environmental parameters on the water quality parameters; when the water quality parameters of the water outlet do not meet the safety threshold, warn the relevant personnel, and based on the influence function of the environmental parameters on the water quality parameters, automatically use the equipment to adjust the environmental parameters of the corresponding water quality detection point until the water quality parameters of the water outlet meet the safety threshold;
[0010] S400, based on the influence function of environmental parameters on water quality parameters and the changing trend of water quality parameters, use long short-term memory network to monitor water quality parameters in real time and predict water quality risks; when adjusting the environmental parameters of water quality detection points, use the intelligent recommendation algorithm based on decision tree to evaluate the effects of different adjustment strategies, select the optimal solution to implement, and ensure that the water quality at the outlet always remains within the safety threshold.
[0011] According to step S100, the ramp angle α is the inclination angle of the water supply pipe relative to the horizontal plane; the steeper the slope, the faster the water flow rate changes, and the greater the impact on water quality; the location P0 of the water source is obtained, and the change in water quality is most stable at a location close to the water source, and the farther away from the water source, the greater the impact on water quality; the water flow rate v of the current section is the flow rate of water in the water supply pipe, and the faster the water flow rate, the shorter the time it takes for water quality to change; the detection point spacing formula is used to deduce the spacing between detection points according to the ramp angle α and the water flow rate v of the current section:
[0012]
[0013] Among them, d q is the distance between the qth detection point and the previous detection point, L is the total length of the water supply pipeline, N is the total number of detection points set, k1 is the influence coefficient related to the ramp angle, which indicates the adjustment weight of the ramp angle on the detection point spacing, k2 is the influence coefficient related to the water flow velocity, which indicates the adjustment weight of the water flow velocity on the detection point spacing, v is the water flow velocity of the current section, v max is the maximum water flow velocity in the water supply pipe;
[0014] The water quality testing points are numbered sequentially from the water source to the pipeline terminal, and the numbers are sorted based on the distance between the testing point and the water source.
[0015] According to step S200, the water quality parameters include pH, dissolved oxygen, total dissolved solids, biological oxygen demand, chemical oxygen demand and turbidity; each water quality variable in the water quality parameters is normalized using minimum-maximum normalization, and the formula is as follows:
[0016]
[0017] Among them, X is the original value of a water quality variable in the water quality parameters, X max is the maximum value of the water quality variable, X min is the minimum value of the water quality variable. The normalized value X′ of the water quality variable is between [0,1];
[0018] Use principal component analysis to determine the weight of each water quality variable, calculate the covariance matrix of each water quality variable, perform eigenvalue decomposition on the covariance matrix to obtain eigenvectors and eigenvalues, and determine the main components based on the size of the eigenvalues. The size of the eigenvalue corresponding to each eigenvector determines the contribution of the water quality variable to the total water quality change.
[0019] The weight vector obtained by principal component analysis is W = (w1, w2, ..., w6), where w1 to w6 correspond to the contribution of pH, dissolved oxygen, total dissolved solids, biological oxygen demand, chemical oxygen demand and turbidity respectively;
[0020] According to the normalized value and weight of each water quality variable, the water quality index WQI is calculated using the weighted average method, and the formula is as follows: X′ i is the original value of a water quality variable in the i-th water quality parameter.
[0021] In the convolutional layer of the convolutional neural network, the ramp angle, ramp material, water quality index and location of different water quality detection point areas can affect the water quality parameters. The convolution kernel gradually extracts the local features of each detection point by sliding on the input multi-dimensional data. Through the convolution operation, the convolutional neural network can capture the water quality differences between adjacent detection points. When the water quality index between the detection points changes, the convolution kernel can extract the spatial difference information and retain the current difference through the processing of the next layer for further water quality difference calculation.
[0022] Through the pooling layer, the maximum pooling operation is performed. According to the ramp material and water quality changes in the water quality detection point area, the pooling layer retains the part with the largest water quality change in each area; the fully connected layer connects all input features through the weight matrix, associates the ramp angle, ramp material, water quality index and position of each detection point, and evaluates the contribution of different features to the overall water quality through the combination of different features; the fully connected layer integrates the local features and spatial position features of each water quality detection point to generate the water quality difference of different water quality detection points in the ramp;
[0023] When performing feature association, the ramp angle, ramp material, water quality index and location of each detection point are used as input feature vectors. After each feature is processed by the previous convolutional layer and pooling layer, the corresponding local features are extracted. The fully connected layer uses a weight matrix to linearly transform the input features. Each input feature is multiplied by other features through the weight matrix to form a new feature vector. This process allows the model to comprehensively analyze the relationship between various features in a higher dimension.
[0024] The fully connected layer evaluates the linear combination of all input features. By calculating the weighted sum, the model can summarize the effects of different features to generate a comprehensive feature vector. By applying the activation function ReLU, nonlinear characteristics are introduced into the model, further enhancing the combination effect of different features, allowing the model to capture the complex relationship between features.
[0025] The accuracy is evaluated by calculating the error between the predicted water quality difference and the historical true value, and the MSE loss function is used to evaluate the accuracy. According to the result of the loss function, the gradient descent optimization algorithm is used to adjust the weights of the convolution kernel and the fully connected layer.
[0026] According to step S300, the water quality change trend from the water source to the water outlet is calculated based on the water quality parameters of different water quality detection points, which describes the change of water quality parameters with distance, expressed as: WQI(x)=a*x+b, where WQI(x) represents the trend function of the water quality index changing with distance x, a represents the change rate of the water quality difference, and b represents the water quality index of the first water quality detection point;
[0027] Setting: E j =[e j1 , e j2 , ..., e jm ] represents the environmental parameters around the jth water quality detection point, e j1 , e j2 , ..., e jm Represents the first to mth environmental variables in the environmental parameters around the jth water quality detection point. The impact of environmental parameters on water quality is described by the linear regression model as follows:
[0028] ΔK j =α′1*e j 1+α′2*e j2 +...+α′ m *e jm +c, where ΔK j Indicates the degree of influence of environmental parameters on water quality parameters, α′1, α′2, ..., α′ mis the regression coefficient, reflecting the impact of the first to mth environmental variables on water quality, and c is the bias term, reflecting the part that cannot be explained by environmental parameters. The environmental impact function on water quality is constructed through the environmental parameters of different detection points: K(x, E) = WQI(x) + ΔK j .
[0029] The water quality test point at the outlet is numbered N, and its water quality parameter G N Each water quality variable in the water quality parameter should be within the range of the safety threshold of the corresponding water quality variable. When the water quality parameters at the outlet do not meet the safety requirements, an early warning is issued to the relevant personnel, and the water quality is optimized by adjusting the environmental parameters of the relevant water quality detection points. The target water quality parameter that needs to be adjusted is set as G target , by changing the environmental parameters, so that: G N =G target ;
[0030] According to the influence degree of environmental parameters on water quality parameters ΔK j , find the environmental parameters by solving the following equations to make the water quality parameters at the outlet meet the safety threshold:
[0031] G target -WQI(x)=α′1*e N1 +α′2*e N2 +...+α′ m *e Nm +c
[0032] Solve to get the adjusted environmental parameter E′N=[e′ N1 , e′ N2 , ..., e′ Nm ], automatically use relevant equipment to adjust the environmental parameters near the outlet until the water quality parameters reach the target water quality parameters G target .
[0033] According to step S400, water quality parameters and environmental parameters are arranged in chronological order to form time series input data; the input of the long short-term memory network is time series data composed of water quality parameters and environmental parameters of several time steps, and each time step represents all water quality parameters and environmental parameters at a sampling moment; the hidden layer learns how water quality parameters change with time and environmental parameters through the memory and forgetting mechanism, allowing the model to capture the long-term and short-term dependencies of water quality changes; the output of the model is the predicted value of the water quality parameter in a certain period of time in the future. If the predicted value exceeds the preset safety threshold, it will be judged that there is a potential water quality risk and a warning will be issued to relevant personnel in advance.
[0034] The Long Short-Term Memory Network (LSTM) stores information through cell states, which are used in time series and can pass on long-term memory. This allows the model to retain information about early water quality changes and form an understanding of long-term dependence on water quality. The input gate controls how new information is added to the cell state. By weighting the current input features and the previous hidden state, the model determines which new information is useful and updates the memory. The forget gate controls which information in the cell state needs to be discarded. By evaluating the previous cell state, the forget gate determines which no longer relevant information can be cleared. This allows the model to ignore no longer important historical data when faced with new environments and conditions.
[0035] The output gate controls which information will be used to generate the current hidden state, i.e., the output. By combining the current input and the updated cell state, the model is able to generate dynamic outputs based on the current environment and historical information, reflecting the current water quality conditions. Through the above mechanism, LSTM can effectively capture the changing trends and short-term fluctuations of water quality parameters at different time points, while taking into account long-term influencing factors. This enables the model to make full use of historical data and provide accurate early warning information when predicting water quality risks.
[0036] According to step S400, a training data set for a decision tree model is constructed, including: historical water quality monitoring data, adjustment strategies and results, and changes in environmental factors, wherein the historical water quality monitoring data records water quality parameters and corresponding environmental parameters at each water quality detection point, the adjustment strategies and results indicate which adjustment strategies were used in the previous adjustment process, and changes in water quality parameters after the implementation of the strategies, and changes in environmental factors indicate how changes in environmental factors during the adjustment period affect water quality parameters;
[0037] In the decision tree model, the target variable is whether the water quality has recovered to a safe threshold. The input features include environmental parameters, water quality parameters, adjustment strategies, and historical feedback data. Using the input features and target variables, a classification decision tree is trained. The model learns which adjustment strategy can most effectively restore water quality under different environmental and water quality conditions.
[0038] When real-time monitoring shows that water quality parameters do not meet safety thresholds, the strategy is evaluated through the following steps:
[0039] Based on the current environmental parameters and water quality parameters, a series of candidate strategies are generated, each strategy includes different combinations; for each candidate strategy, it is input into the trained decision tree model together with the current environmental parameters and water quality parameters. The decision tree evaluates the effect of each candidate strategy based on historical data and rules, and outputs a prediction result, which is a binary classification result of "whether the water quality can be restored to a safe threshold", and also gives the success rate of the strategy;
[0040] The decision tree makes decisions in sequence according to the conditions of each input feature, and gradually refines to specific strategy results along different node paths; after predicting the effect of each candidate strategy, the strategy with the best predicted effect is selected as the optimal solution. The selection of the optimal solution is based on the following criteria:
[0041] This solution has the highest success rate for water quality restoration. When the effects are the same, the solution with lower implementation cost is given priority. Considering the time dimension of the execution strategy, the solution with the fastest response is given priority. After selecting the optimal solution, the corresponding equipment is automatically called to execute the strategy. After several adjustments, if it is determined that all alternative strategies cannot restore water quality, an abnormal warning will be issued to relevant personnel for manual intervention.
[0042] A drinking water quality safety detection and early warning system based on big data, including:
[0043] Water quality detection point division module: including: detection point spacing calculation unit and detection point setting unit; wherein, the detection point spacing calculation unit uses the detection point spacing formula to divide the water quality detection points of the water supply pipe according to the ramp angle, the location of the water source and the water flow speed; the detection point setting unit sets the water quality detection points, and each water quality detection point is numbered from near to far according to the distance from the water source;
[0044] Water quality parameter collection and analysis module: including: water quality parameter collection unit, data normalization processing unit, principal component analysis unit and convolutional neural network analysis unit; wherein, the water quality parameter collection unit collects water quality parameters according to the set water quality detection points, the data normalization processing unit performs normalization processing, the principal component analysis unit uses principal component analysis to determine the weight of each water quality parameter, calculates the water quality index of different water quality detection points, and the convolutional neural network analysis unit uses convolutional neural network to input the ramp angle, ramp material, water quality index and position of different water quality detection point areas, analyzes historical data, and obtains the water quality difference of different water quality detection points in the ramp;
[0045] Water quality change trend and environmental impact analysis module: including: water quality parameter change trend calculation unit, environmental parameter collection unit, influence function construction unit, safety threshold monitoring and early warning unit and automatic adjustment unit; wherein, the water quality parameter change trend calculation unit obtains the water quality parameter change trend from the water source to the outlet according to the water quality difference of different water quality detection points, the environmental parameter collection unit collects the environmental parameters of the surrounding environment of different water quality detection points, the influence function construction unit combines the water quality parameter change trend with the environmental parameters to obtain the influence function of the environmental parameters on the water quality parameters, the safety threshold monitoring and early warning unit warns the relevant personnel when the water quality parameters of the outlet do not meet the safety threshold, and the automatic adjustment unit automatically uses the equipment to adjust the environmental parameters of the corresponding water quality detection point based on the influence function of the environmental parameters on the water quality parameters until the water quality parameters of the outlet meet the safety threshold;
[0046] Decision optimization module: including: water quality risk prediction unit and decision tree evaluation unit; among them, the water quality risk prediction unit uses a long short-term memory network to monitor water quality parameters in real time and predict water quality risks based on the influence function of environmental parameters on water quality parameters and the changing trend of water quality parameters. When the decision tree evaluation unit adjusts the environmental parameters of the water quality detection point, it uses an intelligent recommendation algorithm based on a decision tree to evaluate the effects of different adjustment strategies, selects the optimal solution for implementation, and ensures that the water quality at the outlet always remains within the safety threshold.
[0047] Compared with the prior art, the present invention has the following beneficial effects:
[0048] 1. The present invention combines multiple water quality parameters and environmental parameters, uses principal component analysis and convolutional neural network for comprehensive evaluation, and can more accurately reflect the water quality status.
[0049] 2. The present invention uses machine learning algorithms such as long short-term memory networks to monitor and predict water quality risks in real time, thereby improving the timeliness and accuracy of early warning.
[0050] 3. The present invention uses an intelligent recommendation algorithm based on a decision tree to evaluate the effects of different adjustment strategies, select the optimal solution for implementation, and improve the scientificity and effectiveness of decision-making. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 A schematic diagram of the steps of a drinking water quality safety detection and early warning method based on big data of the present invention;
[0052] Figure 2 This is a system structure diagram of a drinking water quality safety detection and early warning system based on big data in the present invention. DETAILED DESCRIPTION
[0053] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0054] Example: Figure 1-Figure 2 As shown, the present invention provides a technical solution.
[0055] According to one embodiment of the present invention, Figure 1 A step diagram of a drinking water quality safety detection and early warning method based on big data is shown in the figure. A drinking water quality safety detection and early warning method based on big data comprises the following steps:
[0056] S100, using the test point spacing formula, dividing the water quality test points of the water supply pipe according to the ramp angle, the location of the water source and the water flow speed, setting the water quality test points, and numbering the water quality test points from near to far according to the distance from the water source;
[0057] S200, collecting water quality parameters according to the set water quality detection points, performing normalization processing, using principal component analysis to determine the weight of each water quality parameter, and calculating the water quality index of different water quality detection points; using a convolutional neural network, inputting the ramp angle, ramp material, water quality index and location of different water quality detection point areas, analyzing historical data, and obtaining the water quality difference of different water quality detection points in the ramp;
[0058] S300, according to the water quality difference of different water quality detection points, obtain the water quality parameter change trend from the water source to the water outlet, collect the environmental parameters of the surrounding environment of different water quality detection points, combine the water quality parameter change trend with the environmental parameters, and obtain the influence function of the environmental parameters on the water quality parameters; when the water quality parameters of the water outlet do not meet the safety threshold, warn the relevant personnel, and based on the influence function of the environmental parameters on the water quality parameters, automatically use the equipment to adjust the environmental parameters of the corresponding water quality detection point until the water quality parameters of the water outlet meet the safety threshold;
[0059] S400, based on the influence function of environmental parameters on water quality parameters and the changing trend of water quality parameters, use long short-term memory network to monitor water quality parameters in real time and predict water quality risks; when adjusting the environmental parameters of water quality detection points, use the intelligent recommendation algorithm based on decision tree to evaluate the effects of different adjustment strategies, select the optimal solution to implement, and ensure that the water quality at the outlet always remains within the safety threshold.
[0060] In this embodiment, according to step S100, the ramp angle α=15°, the position P0 of the water source is obtained, the water flow velocity v of the current section is 3m / s, and the detection point spacing formula is used to deduce the spacing between the detection points according to the ramp angle α and the water flow velocity v of the current section:
[0061]
[0062]
[0063] Among them, d q is the distance between the qth detection point and the previous detection point, L is the total length of the water supply pipeline, N is the total number of detection points set, k1 is the influence coefficient related to the ramp angle, which indicates the adjustment weight of the ramp angle on the detection point spacing, k2 is the influence coefficient related to the water flow velocity, which indicates the adjustment weight of the water flow velocity on the detection point spacing, v is the water flow velocity of the current section, v max is the maximum water velocity in the water supply pipe; this means that the distance between each detection point is about 131.4 meters.
[0064] The water quality testing points are numbered sequentially from the water source to the pipeline terminal, and the numbers are sorted based on the distance between the testing point and the water source.
[0065] According to step S200, the water quality parameters include pH, dissolved oxygen, total dissolved solids, biological oxygen demand, chemical oxygen demand and turbidity; in this embodiment, pH: 7.8, dissolved oxygen (DO, mg / L): 6.2, total dissolved solids (TDS, mg / L): 500, biological oxygen demand (BOD, mg / L): 3.5, chemical oxygen demand (COD, mg / L): 15, turbidity (NTU): 4.5.
[0066] Each water quality variable in the water quality parameters is normalized using minimum-maximum normalization, and the formula is as follows:
[0067]
[0068] Among them, X is the original value of a water quality variable in the water quality parameters, X max is the maximum value of the water quality variable, X min is the minimum value of the water quality variable. The normalized value X′ of the water quality variable is between [0,1];
[0069] Among them, the pH value X min =6.5,X max =9.0, dissolved oxygen X min =4.0,X max =10.0, total dissolved solids X min =300,Xmax =1000, biological oxygen demand X min , X max =10.0, chemical oxygen demand X min =10,X max =50, turbidity X min =1.0,X max =10.0; after minimum-maximum normalization, X′ of pH = 0.52, X′ of dissolved oxygen = 0.367, X′ of total dissolved solids = 0.286, X′ of biological oxygen demand = 0.1875, X′ of chemical oxygen demand = 0.125, and X′ of turbidity = 0.389.
[0070] Use principal component analysis to determine the weight of each water quality variable, calculate the covariance matrix of each water quality variable, perform eigenvalue decomposition on the covariance matrix to obtain eigenvectors and eigenvalues, and determine the main components based on the size of the eigenvalues. The size of the eigenvalue corresponding to each eigenvector determines the contribution of the water quality variable to the total water quality change.
[0071] The weight vector obtained by principal component analysis is w = (0.25, 0.20, 0.15, 0.10, 0.20, 0.10), where w1 to w6 correspond to the contribution of pH, dissolved oxygen, total dissolved solids, biological oxygen demand, chemical oxygen demand, and turbidity, respectively;
[0072] According to the normalized value and weight of each water quality variable, the water quality index WQI is calculated using the weighted average method, and the formula is as follows: ,
[0073] X′ i is the original value of a water quality variable in the i-th water quality parameter.
[0074] In the convolution layer of the convolutional neural network, the ramp angle, ramp material, water quality index and location of different water quality detection point areas can affect the water quality parameters. The convolution kernel gradually extracts the local features of each detection point by sliding on the input multi-dimensional data; through the convolution operation, the convolutional neural network can capture the water quality differences between adjacent detection points. When the water quality index between the detection points changes, the convolution kernel can extract the spatial difference information and retain the current difference through the processing of the next layer for further water quality difference calculation; the convolution kernel size is 3*3.
[0075] Through the pooling layer, the maximum pooling operation is performed. According to the ramp material and water quality changes in the water quality detection point area, the pooling layer retains the part with the largest water quality change in each area; the fully connected layer connects all input features through the weight matrix, associates the ramp angle, ramp material, water quality index and position of each detection point, and evaluates the contribution of different features to the overall water quality through the combination of different features; the fully connected layer integrates the local features and spatial position features of each water quality detection point to generate the water quality difference of different water quality detection points in the ramp;
[0076] The accuracy is evaluated by calculating the error between the predicted water quality difference and the historical true value, and the MSE loss function is used to evaluate the accuracy. According to the result of the loss function, the gradient descent optimization algorithm is used to adjust the weights of the convolution kernel and the fully connected layer.
[0077] The water quality difference predicted by the model is very close to the true value, and the MSE loss is small, which shows that the convolutional neural network can effectively extract the local features between the water quality detection points and make reasonable feature combinations through the fully connected layer. By applying the gradient descent optimization algorithm, the CNN model gradually converges, improving the accuracy of water quality difference prediction. The pooling layer effectively retains the influence of ramp material and ramp angle on water quality changes, allowing the model to focus on the key features in the area, further improving the effect of water quality prediction.
[0078] In this embodiment, according to step S300, the water quality change trend from the water source to the water outlet is calculated according to the water quality parameters of different water quality detection points, which describes the change of water quality parameters with distance, expressed as: WQI(x)=a*x+b=-0.001*x+0.8, wherein WQI(x) represents the trend function of the water quality index changing with distance x, a represents the rate of change of the water quality difference, which is set to -0.001, indicating that the water quality gradually decreases with increasing distance, and b represents the water quality index of the first water quality detection point;
[0079] Setting: E j =[e j1 , e j2 , ..., e jm ] represents the environmental parameters around the jth water quality detection point, e j1 , e j2 , ..., e jm Represents the first to mth environmental variables in the environmental parameters around the jth water quality detection point. The impact of environmental parameters on water quality is described by the linear regression model as follows:
[0080] ΔK j =α′1-e j1 +α′2*e j2 +...+α′ m *ejm +c
[0081] Among them, ΔK j Indicates the degree of influence of environmental parameters on water quality parameters, α′1, α′2, ..., α′ m is the regression coefficient, reflecting the impact of the first to mth environmental variables on water quality, and c is the bias term, reflecting the part that cannot be explained by environmental parameters. The environmental impact function on water quality is constructed through the environmental parameters of different detection points: K(x, E) = WQI(x) + ΔK j .
[0082] The water quality detection point number of the outlet is N=5. The water quality does not meet the requirements and is lower than the safety threshold of 0.7. It needs to be optimized. N Each water quality variable in the water quality parameter should be within the range of the safety threshold of the corresponding water quality variable. When the water quality parameters at the outlet do not meet the safety requirements, an early warning is issued to the relevant personnel, and the water quality is optimized by adjusting the environmental parameters of the relevant water quality detection points. The target water quality parameter that needs to be adjusted is set as G target By changing the environmental parameters, we can make GN = G target ;
[0083] According to the influence degree of environmental parameters on water quality parameters ΔK j , find the environmental parameters by solving the following equations to make the water quality parameters at the outlet meet the safety threshold:
[0084] G target -WQI(x)=α′1*e N1 +α′2*e N2 +...+α′ m *e Nm +c
[0085] Solve to get the adjusted environmental parameter E′ N =[e′ N1 , e′ N2 , ..., e′ Nm ], corresponding to: the temperature drops to 25 degrees Celsius, the humidity rises to 70, the pollutant concentration decreases to 50ppm, and the relevant equipment is automatically used to adjust the environmental parameters near the outlet until the water quality parameters reach the target water quality parameters G target Before adjustment, the outlet WQI = 0.3, which does not meet the safety threshold. After adjustment, the outlet WQI = 0.75, which meets the safety threshold.
[0086] According to step S400, water quality parameters and environmental parameters are arranged in chronological order to form time series input data; the input of the long short-term memory network is time series data composed of water quality parameters and environmental parameters of several time steps, and each time step represents all water quality parameters and environmental parameters at a sampling moment; the hidden layer learns how water quality parameters change with time and environmental parameters through the memory and forgetting mechanism, allowing the model to capture the long-term and short-term dependencies of water quality changes; the output of the model is the predicted value of the water quality parameter in a certain period of time in the future. If the predicted value exceeds the preset safety threshold, it will be judged that there is a potential water quality risk and a warning will be issued to relevant personnel in advance.
[0087] The Long Short-Term Memory Network (LSTM) stores information through cell states, which are used in time series and can pass on long-term memory. This allows the model to retain information about early water quality changes and form an understanding of long-term dependence on water quality. The input gate controls how new information is added to the cell state. By weighting the current input features and the previous hidden state, the model determines which new information is useful and updates the memory. The forget gate controls which information in the cell state needs to be discarded. By evaluating the previous cell state, the forget gate determines which no longer relevant information can be cleared. This allows the model to ignore no longer important historical data when faced with new environments and conditions.
[0088] The output gate controls which information will be used to generate the current hidden state, i.e., the output. By combining the current input and the updated cell state, the model is able to generate dynamic outputs based on the current environment and historical information, reflecting the current water quality conditions. Through the above mechanism, LSTM can effectively capture the changing trends and short-term fluctuations of water quality parameters at different time points, while taking into account long-term influencing factors. This enables the model to make full use of historical data and provide accurate early warning information when predicting water quality risks.
[0089] According to step S400, a training data set for a decision tree model is constructed, including: historical water quality monitoring data, adjustment strategies and results, and changes in environmental factors, wherein the historical water quality monitoring data records water quality parameters and corresponding environmental parameters at each water quality detection point, the adjustment strategies and results indicate which adjustment strategies were used in the previous adjustment process, and changes in water quality parameters after the implementation of the strategies, and changes in environmental factors indicate how changes in environmental factors during the adjustment period affect water quality parameters;
[0090] In the decision tree model, the target variable is whether the water quality has recovered to a safe threshold. The input features include environmental parameters, water quality parameters, adjustment strategies, and historical feedback data. Using the input features and target variables, a classification decision tree is trained. The model learns which adjustment strategy can most effectively restore water quality under different environmental and water quality conditions.
[0091] When real-time monitoring shows that water quality parameters do not meet safety thresholds, the strategy is evaluated through the following steps:
[0092] Based on the current environmental parameters and water quality parameters, a series of candidate strategies are generated, each strategy includes different combinations; for each candidate strategy, it is input into the trained decision tree model together with the current environmental parameters and water quality parameters. The decision tree evaluates the effect of each candidate strategy based on historical data and rules, and outputs a prediction result, which is a binary classification result of "whether the water quality can be restored to a safe threshold", and also gives the success rate of the strategy;
[0093] The decision tree makes decisions in sequence according to the conditions of each input feature, and gradually refines to specific strategy results along different node paths; after predicting the effect of each candidate strategy, the strategy with the best predicted effect is selected as the optimal solution. The selection of the optimal solution is based on the following criteria:
[0094] This solution has the highest success rate for water quality restoration. When the effects are the same, the solution with lower implementation cost is given priority. Considering the time dimension of the execution strategy, the solution with the fastest response is given priority. After selecting the optimal solution, the corresponding equipment is automatically called to execute the strategy. After several adjustments, if it is determined that all alternative strategies cannot restore water quality, an abnormal warning will be issued to relevant personnel for manual intervention.
[0095] A drinking water quality safety detection and early warning system based on big data, including:
[0096] Water quality detection point division module: including: detection point spacing calculation unit and detection point setting unit; wherein, the detection point spacing calculation unit uses the detection point spacing formula to divide the water quality detection points of the water supply pipe according to the ramp angle, the location of the water source and the water flow speed; the detection point setting unit sets the water quality detection points, and each water quality detection point is numbered from near to far according to the distance from the water source;
[0097] Water quality parameter collection and analysis module: including: water quality parameter collection unit, data normalization processing unit, principal component analysis unit and convolutional neural network analysis unit; wherein, the water quality parameter collection unit collects water quality parameters according to the set water quality detection points, the data normalization processing unit performs normalization processing, the principal component analysis unit uses principal component analysis to determine the weight of each water quality parameter, calculates the water quality index of different water quality detection points, and the convolutional neural network analysis unit uses convolutional neural network to input the ramp angle, ramp material, water quality index and position of different water quality detection point areas, analyzes historical data, and obtains the water quality difference of different water quality detection points in the ramp;
[0098] Water quality change trend and environmental impact analysis module: including: water quality parameter change trend calculation unit, environmental parameter collection unit, influence function construction unit, safety threshold monitoring and early warning unit and automatic adjustment unit; wherein, the water quality parameter change trend calculation unit obtains the water quality parameter change trend from the water source to the outlet according to the water quality difference of different water quality detection points, the environmental parameter collection unit collects the environmental parameters of the surrounding environment of different water quality detection points, the influence function construction unit combines the water quality parameter change trend with the environmental parameters to obtain the influence function of the environmental parameters on the water quality parameters, the safety threshold monitoring and early warning unit warns the relevant personnel when the water quality parameters of the outlet do not meet the safety threshold, and the automatic adjustment unit automatically uses the equipment to adjust the environmental parameters of the corresponding water quality detection point based on the influence function of the environmental parameters on the water quality parameters until the water quality parameters of the outlet meet the safety threshold;
[0099] Decision optimization module: including: water quality risk prediction unit and decision tree evaluation unit; among them, the water quality risk prediction unit uses a long short-term memory network to monitor water quality parameters in real time and predict water quality risks based on the influence function of environmental parameters on water quality parameters and the changing trend of water quality parameters. When the decision tree evaluation unit adjusts the environmental parameters of the water quality detection point, it uses an intelligent recommendation algorithm based on a decision tree to evaluate the effects of different adjustment strategies, selects the optimal solution for implementation, and ensures that the water quality at the outlet always remains within the safety threshold.
[0100] In this embodiment, the total length of the water supply pipeline is 500 meters, and the initial water quality parameters and environmental parameters are detected at 5 water quality detection points. The initial WQI at the outlet detection point (500 meters) is 0.3, which is lower than the safety threshold of 0.7. Based on the water quality monitoring data of the past 30 minutes, the LSTM model predicts that the WQI of the outlet may further drop to 0.25 in the next 10 minutes. The system issues a water quality risk warning, prompting relevant personnel to adjust the environmental parameters.
[0101] The decision tree model evaluates the effects of different adjustment strategies based on changes in environmental parameters. Specific strategies include: lowering temperature, increasing humidity, and reducing pollutant concentrations. Each strategy is scored based on the degree of improvement in WQI, and the scores are as follows: lowering temperature: score 70, increasing humidity: score 85, reducing pollutant concentrations: score 95. The decision tree evaluation unit selects the strategy with the highest score, namely reducing pollutant concentrations, as the optimal adjustment solution.
[0102] The system automatically reduces the pollutant concentration near the outlet from 100ppm to 50ppm. The temperature and humidity remain unchanged. The adjusted environmental parameters are input into the water quality risk prediction unit to re-predict the water quality index (WQI). The results show that after the adjustment, the WQI at the outlet is increased to 0.75, meeting the safety threshold requirements.
[0103] It will be apparent to those skilled in the art that the invention is not limited to the details of the exemplary embodiments described above and that the invention can be implemented in other specific forms without departing from the spirit or essential features of the invention. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description, and it is intended that all variations falling within the meaning and scope of the equivalent elements of the claims be included in the invention. Any reference numeral in a claim should not be considered as limiting the claim to which it relates.
Claims
1. A drinking water quality safety detection and early warning method based on big data, characterized in that: The method comprises the following steps: S100, using the test point spacing formula, dividing the water quality test points of the water supply pipe according to the ramp angle, the location of the water source and the water flow speed, setting the water quality test points, and numbering the water quality test points from near to far according to the distance from the water source; S200, collecting water quality parameters according to the set water quality detection points, performing normalization processing, using principal component analysis to determine the weight of each water quality parameter, and calculating the water quality index of different water quality detection points; using a convolutional neural network, inputting the ramp angle, ramp material, water quality index and location of different water quality detection point areas, analyzing historical data, and obtaining the water quality difference of different water quality detection points in the ramp; S300, according to the water quality difference of different water quality detection points, obtain the water quality parameter change trend from the water source to the water outlet, collect the environmental parameters of the surrounding environment of different water quality detection points, combine the water quality parameter change trend with the environmental parameters, and obtain the influence function of the environmental parameters on the water quality parameters; when the water quality parameters of the water outlet do not meet the safety threshold, warn the relevant personnel, and based on the influence function of the environmental parameters on the water quality parameters, automatically use the equipment to adjust the environmental parameters of the corresponding water quality detection point until the water quality parameters of the water outlet meet the safety threshold; S400, based on the influence function of environmental parameters on water quality parameters and the changing trend of water quality parameters, use long short-term memory network to monitor water quality parameters in real time and predict water quality risks; when adjusting the environmental parameters of water quality detection points, use the intelligent recommendation algorithm based on decision tree to evaluate the effects of different adjustment strategies, select the optimal solution to implement, and ensure that the water quality at the outlet always remains within the safety threshold.
2. The drinking water quality safety detection and early warning method based on big data according to claim 1 is characterized by: According to step S100, the ramp angle α is the inclination angle of the water supply pipe relative to the horizontal plane; the steeper the slope, the faster the water flow rate changes, and the greater the impact on water quality; the location P0 of the water source is obtained, and the change in water quality is most stable at a location close to the water source, and the farther away from the water source, the greater the impact on water quality; the water flow rate v of the current section is the flow rate of water in the water supply pipe, and the faster the water flow rate, the shorter the time it takes for water quality to change; the detection point spacing formula is used to deduce the spacing between detection points according to the ramp angle α and the water flow rate v of the current section: Among them, d q is the distance between the qth detection point and the previous detection point, L is the total length of the water supply pipeline, N is the total number of detection points set, k1 is the influence coefficient related to the ramp angle, which indicates the adjustment weight of the ramp angle on the detection point spacing, k2 is the influence coefficient related to the water flow velocity, which indicates the adjustment weight of the water flow velocity on the detection point spacing, v is the water flow velocity of the current section, v max is the maximum water flow velocity in the water supply pipe; The water quality testing points are numbered sequentially from the water source to the pipeline terminal, and the numbers are sorted based on the distance between the testing point and the water source.
3. The drinking water quality safety detection and early warning method based on big data according to claim 1 is characterized by: According to step S200, the water quality parameters include pH, dissolved oxygen, total dissolved solids, biological oxygen demand, chemical oxygen demand and turbidity; each water quality variable in the water quality parameters is normalized using minimum-maximum normalization, and the formula is as follows: Among them, X is the original value of a water quality variable in the water quality parameters, X max is the maximum value of the water quality variable, X min is the minimum value of the water quality variable. The normalized value X′ of the water quality variable is between [0,1]; Use principal component analysis to determine the weight of each water quality variable, calculate the covariance matrix of each water quality variable, perform eigenvalue decomposition on the covariance matrix to obtain eigenvectors and eigenvalues, and determine the main components based on the size of the eigenvalues. The size of the eigenvalue corresponding to each eigenvector determines the contribution of the water quality variable to the total water quality change. The weight vector obtained by principal component analysis is W = (w1, w2, ..., w6), where w1 to w6 correspond to the contribution of pH, dissolved oxygen, total dissolved solids, biological oxygen demand, chemical oxygen demand and turbidity respectively; According to the normalized value and weight of each water quality variable, the water quality index WQI is calculated using the weighted average method, and the formula is as follows: X′ i is the original value of a water quality variable in the i-th water quality parameter.
4. The drinking water quality safety detection and early warning method based on big data according to claim 3 is characterized by: In the convolutional layer of the convolutional neural network, the ramp angle, ramp material, water quality index and location of different water quality detection point areas can affect the water quality parameters. The convolution kernel gradually extracts the local features of each detection point by sliding on the input multi-dimensional data. Through the convolution operation, the convolutional neural network can capture the water quality differences between adjacent detection points. When the water quality index between the detection points changes, the convolution kernel can extract the spatial difference information and retain the current difference through the processing of the next layer for further water quality difference calculation. Through the pooling layer, the maximum pooling operation is performed. According to the ramp material and water quality changes in the water quality detection point area, the pooling layer retains the part with the largest water quality change in each area; the fully connected layer connects all input features through the weight matrix, associates the ramp angle, ramp material, water quality index and position of each detection point, and evaluates the contribution of different features to the overall water quality through the combination of different features; the fully connected layer integrates the local features and spatial position features of each water quality detection point to generate the water quality difference of different water quality detection points in the ramp; The accuracy is evaluated by calculating the error between the predicted water quality difference and the historical true value, and the MSE loss function is used to evaluate the accuracy. According to the result of the loss function, the gradient descent optimization algorithm is used to adjust the weights of the convolution kernel and the fully connected layer.
5. The drinking water quality safety detection and early warning method based on big data according to claim 1 is characterized by: According to step S300, the water quality change trend from the water source to the water outlet is calculated based on the water quality parameters of different water quality detection points, which describes the change of water quality parameters with distance, expressed as: WQI(x)=a*x+b, where WQI(x) represents the trend function of the water quality index changing with distance x, a represents the change rate of the water quality difference, and b represents the water quality index of the first water quality detection point; Setting: E j =[e j1 , e j2 , ..., e jm ] represents the environmental parameters around the jth water quality detection point, e j1 , e j2 , ..., e jm Represents the first to mth environmental variables in the environmental parameters around the jth water quality detection point. The impact of environmental parameters on water quality is described by the linear regression model as follows: ΔK j =α′1-e j1 +α′2*e j2 +...+α′ m *And jm +c Among them, ΔK j Indicates the degree of influence of environmental parameters on water quality parameters, α′1, α′2, ..., α′ m is the regression coefficient, reflecting the impact of the first to mth environmental variables on water quality, and c is the bias term, reflecting the part that cannot be explained by environmental parameters. The environmental impact function on water quality is constructed through the environmental parameters of different detection points: K(x, E) = WQI(x) + ΔK j .
6. The drinking water quality safety detection and early warning method based on big data according to claim 5 is characterized by: The water quality test point at the outlet is numbered N, and its water quality parameter G N Each water quality variable in the water quality parameter should be within the range of the safety threshold of the corresponding water quality variable. When the water quality parameters at the outlet do not meet the safety requirements, an early warning is issued to the relevant personnel, and the water quality is optimized by adjusting the environmental parameters of the relevant water quality detection points. The target water quality parameter that needs to be adjusted is set as G target , by changing the environmental parameters, so that: G N =G target ; According to the influence degree of environmental parameters on water quality parameters ΔK j , find the environmental parameters by solving the following equations to make the water quality parameters at the outlet meet the safety threshold: G target -WQI(x)=α′1*e N1 +α′2*e N2 +…+a′ m *he Nm +c Solve to get the adjusted environmental parameter E′ N =[e′ N1 , e′ N2 , ..., e′ Nm ], automatically use relevant equipment to adjust the environmental parameters near the outlet until the water quality parameters reach the target water quality parameters G target .
7. The drinking water quality safety detection and early warning method based on big data according to claim 1 is characterized by: According to step S400, the water quality parameters and environmental parameters are arranged in chronological order to form time series input data; the input of the long short-term memory network is the time series data composed of water quality parameters and environmental parameters of several time steps, and each time step represents all water quality parameters and environmental parameters at a sampling moment; the hidden layer learns how the water quality parameters change with time and environmental parameters through a memory and forgetting mechanism, allowing the model to capture the long-term and short-term dependencies of water quality changes; The output of the model is the predicted value of water quality parameters in a certain period of time in the future. If the predicted value exceeds the preset safety threshold, it will be judged that there is a potential water quality risk and a warning will be issued to relevant personnel in advance.
8. The drinking water quality safety detection and early warning method based on big data according to claim 7 is characterized by: According to step S400, a training data set for a decision tree model is constructed, including: historical water quality monitoring data, adjustment strategies and results, and changes in environmental factors, wherein the historical water quality monitoring data records water quality parameters and corresponding environmental parameters at each water quality detection point, the adjustment strategies and results indicate which adjustment strategies were used in the previous adjustment process, and changes in water quality parameters after the implementation of the strategies, and changes in environmental factors indicate how changes in environmental factors during the adjustment period affect water quality parameters; In the decision tree model, the target variable is whether the water quality has recovered to a safe threshold. The input features include environmental parameters, water quality parameters, adjustment strategies, and historical feedback data. Using the input features and target variables, a classification decision tree is trained. The model learns which adjustment strategy can most effectively restore water quality under different environmental and water quality conditions.
9. The drinking water quality safety detection and early warning method based on big data according to claim 8 is characterized by: When real-time monitoring shows that water quality parameters do not meet safety thresholds, the strategy is evaluated through the following steps: Based on the current environmental parameters and water quality parameters, a series of candidate strategies are generated, each strategy includes different combinations; for each candidate strategy, it is input into the trained decision tree model together with the current environmental parameters and water quality parameters. The decision tree evaluates the effect of each candidate strategy based on historical data and rules, and outputs a prediction result, which is a binary classification result of "whether the water quality can be restored to the safety threshold", and also gives the success rate of the strategy; The decision tree makes decisions in sequence according to the conditions of each input feature, and gradually refines to specific strategy results along different node paths; after predicting the effect of each candidate strategy, the strategy with the best predicted effect is selected as the optimal solution. The selection of the optimal solution is based on the following criteria: This solution has the highest success rate for water quality restoration. When the effects are the same, the solution with lower implementation cost is given priority. Considering the time dimension of the execution strategy, the solution with the fastest response is given priority. After selecting the optimal solution, the corresponding equipment is automatically called to execute the strategy. After several adjustments, if it is determined that all alternative strategies cannot restore water quality, an abnormal warning will be issued to relevant personnel for manual intervention.
10. A drinking water quality safety detection and early warning system based on big data, using a drinking water quality safety detection and early warning method based on big data according to any one of claims 1 to 9, characterized in that: include: Water quality detection point division module: including: detection point spacing calculation unit and detection point setting unit; wherein, the detection point spacing calculation unit uses the detection point spacing formula to divide the water quality detection points of the water supply pipe according to the ramp angle, the location of the water source and the water flow speed; the detection point setting unit sets the water quality detection points, and each water quality detection point is numbered from near to far according to the distance from the water source; Water quality parameter collection and analysis module: including: water quality parameter collection unit, data normalization processing unit, principal component analysis unit and convolutional neural network analysis unit; wherein, the water quality parameter collection unit collects water quality parameters according to the set water quality detection points, the data normalization processing unit performs normalization processing, the principal component analysis unit uses principal component analysis to determine the weight of each water quality parameter, calculates the water quality index of different water quality detection points, and the convolutional neural network analysis unit uses convolutional neural network to input the ramp angle, ramp material, water quality index and position of different water quality detection point areas, analyzes historical data, and obtains the water quality difference of different water quality detection points in the ramp; Water quality change trend and environmental impact analysis module: including: water quality parameter change trend calculation unit, environmental parameter collection unit, influence function construction unit, safety threshold monitoring and early warning unit and automatic adjustment unit; wherein, the water quality parameter change trend calculation unit obtains the water quality parameter change trend from the water source to the outlet according to the water quality difference of different water quality detection points, the environmental parameter collection unit collects the environmental parameters of the surrounding environment of different water quality detection points, the influence function construction unit combines the water quality parameter change trend with the environmental parameters to obtain the influence function of the environmental parameters on the water quality parameters, the safety threshold monitoring and early warning unit warns the relevant personnel when the water quality parameters of the outlet do not meet the safety threshold, and the automatic adjustment unit automatically uses the equipment to adjust the environmental parameters of the corresponding water quality detection point based on the influence function of the environmental parameters on the water quality parameters until the water quality parameters of the outlet meet the safety threshold; Decision optimization module: including: water quality risk prediction unit and decision tree evaluation unit; among them, the water quality risk prediction unit uses a long short-term memory network to monitor water quality parameters in real time and predict water quality risks based on the influence function of environmental parameters on water quality parameters and the changing trend of water quality parameters. When the decision tree evaluation unit adjusts the environmental parameters of the water quality detection point, it uses an intelligent recommendation algorithm based on a decision tree to evaluate the effects of different adjustment strategies, selects the optimal solution for implementation, and ensures that the water quality at the outlet always remains within the safety threshold.
Citation Information
Cited By
Linkage control method, device and equipment of purification and humidification system and storage medium
CN119508987A
Intelligent detection method and system for key risk object sample in water source
CN119903966A
Water body environment collaborative detection method and system based on multi-target task
CN120706821A
