Water quality prediction method and device of water supply equipment, storage medium and electronic terminal

By combining the support vector regression model SVR, particle swarm optimization algorithm PSO and simulated annealing algorithm SA, the parameters of the water quality prediction model are optimized, and the existing water quality prediction system is solved in terms of accuracy and real-timeness, and efficient water quality management and water supply safety guarantee are achieved.

CN120336719APending Publication Date: 2025-07-18SUZHOU VOCATIONAL UNIVERSITY (SUZHOU OPEN UNIVERSITY)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510444759.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-10
Publication Date
2025-07-18

AI Technical Summary

Technical Problem

The existing water quality prediction system is insufficient in processing complex nonlinear water quality data, making it difficult to fully capture the water quality changes laws, and the real-time and feedback abnormalities are not timely, affecting the safety of water supply.

Method used

The support vector regression model SVR is used to combine particle swarm optimization algorithm PSO and simulated annealing algorithm SA. The SVR parameters are optimized by embedding the probability jump characteristics and temperature control mechanism of the simulated annealing algorithm, and comprehensive analysis is carried out in combination with hierarchical analysis method to achieve water quality level evaluation.

Benefits of technology

It significantly improves the accuracy of water quality prediction, solves the problems of poor real-time performance and untimely feedback, provides accurate water quality management decision-making basis, and ensures water supply safety.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120336719A_ABST
    Figure CN120336719A_ABST
Patent Text Reader

Abstract

The invention discloses a water quality prediction method and device for water supply equipment, a storage medium and an electronic terminal. The water quality prediction method comprises the following steps: acquiring water quality data and preprocessing to obtain a data set; the method comprises the steps of establishing a support vector regression model SVR, establishing a particle swarm optimization algorithm PSO main framework, applying random disturbance of a simulated annealing algorithm SA to new positions of particles in each iteration of PSO, and embedding probability kick characteristics and a temperature control mechanism of SA into the iteration process of PSO to obtain optimal parameters. Training the SVR model based on the data set and the optimal parameters to obtain a water quality prediction model; and predicting the water supply equipment by using the water quality prediction model to obtain a water quality prediction result and a water quality grade. According to the method, the global search of the PSO and the local escape ability of the SA are combined, the PSO is prevented from being converged to a local optimal solution too early, the prediction precision is greatly improved, the problems that an existing system is poor in real-time performance and abnormal and untimely in water quality feedback are effectively solved, and water supply safety is powerfully guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of water quality prediction, and specifically to a water quality prediction method, device, storage medium and electronic terminal for water supply equipment. Background Art

[0002] In the field of water quality prediction, ensuring water supply safety is of great significance and is related to public health. Water quality prediction includes the detection and prediction of multiple key indicators such as pH value, dissolved oxygen, turbidity, and residual chlorine content. At present, common water quality analysis methods mainly include physical and chemical analysis methods and instrumental analysis methods. The former analyzes water quality components based on chemical reactions and physical characteristics measurements, and the latter accurately obtains index values with the help of advanced scientific instruments such as spectrometers and chromatographs. In the data processing link of water quality analysis and prediction, statistical analysis methods such as regression analysis and time series analysis, as well as machine learning methods such as neural networks and support vector machines, have been widely used.

[0003] However, there are many problems in the current water quality prediction system. From the perspective of data analysis and processing, traditional statistical analysis methods are difficult to deeply explore the complex internal relationships of data due to the limitations of their own principles and technologies when dealing with complex non-linear water quality data, resulting in the water quality prediction accuracy being difficult to reach the ideal level. Due to the influence of factors such as algorithm structure and optimization mechanism, a single machine learning model is extremely prone to falling into local optimal solutions and cannot comprehensively, dynamically and accurately capture the laws of water quality changes. In addition, some water quality prediction systems are limited by factors such as the performance of hardware devices, the bandwidth and stability of data transmission networks, and cannot collect, transmit and process water quality data in a timely manner. When abnormal water quality occurs, relevant information cannot be quickly fed back to the management department, resulting in a lag in emergency response, thus posing a potential threat to water supply safety. In addition, the existing water quality prediction system lacks a systematic integration and in-depth mining mechanism when comprehensively analyzing water quality parameters. Since the water quality situation is a complex system determined by the interaction and mutual influence of multiple parameters, the existing system is difficult to comprehensively and accurately evaluate the water quality situation of water supply equipment from the overall level, which is not conducive to formulating scientific and effective water quality guarantee strategies and measures.

[0004] Therefore, how to solve the deficiencies and shortcomings of the existing technology through an effective water quality prediction method has become an important problem that needs to be solved urgently by researchers in this field. Summary of the Invention

[0005] The object of the present invention is to provide a water quality prediction method, device, storage medium and electronic terminal for water supply equipment in view of the above problems.

[0006] The technical solution of the present invention is as follows: A water quality prediction method for a water supply device, comprising the following steps: obtaining water quality data of the water supply device, where the water quality data includes several water quality index data of the water supply device within a continuous time period, and preprocessing the water quality data to obtain a water quality data set; creating a support vector regression model SVR, establishing a main framework of a particle swarm optimization algorithm PSO, and in each iteration of the PSO, applying a random perturbation of a simulated annealing algorithm SA to the new position of the particle, and embedding the probability jump characteristic and temperature control mechanism of the SA into the iteration process of the PSO to obtain optimal parameters G best , based on the water quality data set and the optimal parameters G best training the support vector regression model SVR to obtain a water quality prediction model; using the water quality prediction model to predict the water supply device to obtain a water quality prediction result, and comprehensively analyzing the water quality of the water supply device based on the water quality prediction result to obtain a water quality grade.

[0007] As an improvement of an embodiment of the present invention, the "preprocessing the water quality data to obtain a water quality data set" specifically includes: performing the following first operation on all the water quality data: using the KNN algorithm to remove noise and outliers in the water quality data to obtain the cleaned water quality data, and using the formula: performing normalization processing on all the cleaned water quality data to obtain a water quality data set, where x is the cleaned water quality data, x min is the minimum value of the index to which x belongs, x max is the maximum value of the index to which x belongs, and x norm is the normalized data.

[0008] As an improvement of an embodiment of the present invention, the "creating a support vector regression model SVR" specifically includes: The support vector regression model SVR is: s.t.y i -(w·φ(x i )+b)≤∈+ξ i , where x i is the input vector, y i is the output vector, w is the weight vector, b is the bias term, ∈ is the insensitive parameter, ξ i , are all slack variables, C is the regularization parameter, φ(x i ) is the feature space after kernel function mapping; x i ∈R l , y i ∈R, ξ i ≥0, C∈[0.1,100], ∈∈[0.01,1]; the prediction function is: where \(K(x i ,x j )\) is the kernel function, and \(\alpha i , are all dual variables.

[0009] As an improvement of the embodiment of the present invention, it specifically includes: the kernel function of the support vector regression model SVR is a radial basis kernel function: \(K(x i ,x j ) = \exp(-\gamma||x i - x j || 2 )\), where \(\gamma\) is a parameter of the kernel function, and \(||x i - x j || 2 is the square of the Euclidean distance between samples \(x i \) and \(x j \) in the water quality dataset; \(\gamma\in[0.001, 10]\).

[0010] As an improvement of the embodiment of the present invention, it specifically includes: "establish the main framework of the particle swarm optimization algorithm PSO, and in each iteration of the PSO, apply random perturbations of the simulated annealing algorithm SA to the new positions of the particles, and embed the probability jump characteristic and temperature control mechanism of the SA into the iteration process of the PSO to obtain the optimal parameter \(G best " specifically includes:

[0011] Establish the main framework of the particle swarm optimization algorithm PSO, with the mean square error of the support vector regression model SVR as the optimization objective, where is the output value of the support vector regression model SVR; set the parameters of the particle swarm optimization algorithm PSO, and the parameters of the particle swarm optimization algorithm PSO at least include: the number of particles \(N\), the inertia weight \(w ′ , the learning factor \(c1\) and the learning factor \(c2\); set the parameters of the simulated annealing algorithm SA, and the simulated annealing algorithm SA at least includes: the initial temperature \(T0\), the initial perturbation ratio \(D0\), the lowest temperature \(T min and the maximum number of iterations \(iter max ; randomly generate \(N\) particles \(particle1\), \(particle2\), \(\cdots\), \(particle N \), and the initial position i and the initial velocity of each particle \(particle Calculate the initial fitness of each particle \(particle i and continuously perform iterative optimization until the temperature \(T k drops to the preset lowest temperature \(T min or reaches the maximum number of iterations \(iter\)max , output the optimal parameter G best ; where both i and k are natural numbers, 1 ≤ i ≤ N, T k is the temperature of the k-th generation; the iterative optimization process is as follows: for the temperature T of the k-th generation k , use PSO to update the velocity and position of the particle particle i : Among them, and are the velocity and position of the particle particle u in the k-th generation respectively; c1 is the learning factor that controls the influence of individual learning, c2 is the learning factor that controls the influence of social learning; r1 and r2 are both random numbers between [0, 1]; pbest i is the individual optimal position of the particle particle i , and the initial value is the initial position gbest is the global optimal position,[[]]

[0012] gbest = min(MSE(pbest1), MSE(pbest2),..., MSE(pbest N )); Based on the simulated annealing algorithm, based on the initial perturbation ratio D0, any parameter in the updated position randomly varies within the corresponding perturbation preset range to obtain x i ′. If any parameter of x i ′ exceeds the preset range, then the parameter takes the boundary value; where the parameters in are C, ∈, γ, and the parameters in x i ′ are C, ∈, γ, and the corresponding perturbation preset range of the parameters is (the parameter - D0, the parameter + D0); calculate MSE2 corresponding to x i ′ and corresponding MSE1, the difference ΔE = MSE2 - MSE1; if ΔE < 0, then accept the new solution and update the position of the particle particle i If ΔE ≥ 0, then calculate the acceptance probability If P > rand(0, 1), then accept the new solution and update the position of the particle particle Otherwise, keep the original position i If the fitness of the new solution is better than pbest , then update If the pbest i of the particle particle If the pbest i of the particle particle iIf the fitness is better than the current gbest, then update gbest = min(MSE(pbest1), MSE(pbest2),..., MSE(pbest N )); where rand() is a random function;

[0013] Adopt exponential cooling, T k+1 = αT k , and terminate if gbest has not been updated for multiple consecutive generations, where α is the cooling coefficient.

[0014] As an improvement of the embodiment of the present invention, the value range of the number of particles N is 20 to 50.

[0015] As an improvement of the embodiment of the present invention, "performing comprehensive analysis on the water quality of the water supply equipment based on the water quality prediction result to obtain the water quality grade" specifically includes: using the analytic hierarchy process to determine the weight of each index in the water quality prediction result, calculating the water quality comprehensive evaluation index WQI to obtain the water quality grade, and giving an early warning if WQI < 0.6.

[0016] To achieve one of the above-mentioned invention purposes, an embodiment of the present invention provides a water quality prediction device for a water supply equipment, including the following modules: a data acquisition module, configured to acquire the water quality data of the water supply equipment, and preprocess the water quality data to obtain a water quality data set; a model creation module, configured to create a support vector regression model SVR, and optimize the parameters of the support vector regression model SVR by using an iterative embedding optimization mechanism, specifically including: establishing the main framework of the particle swarm optimization algorithm PSO, and in each iteration of PSO, applying a random perturbation of the simulated annealing algorithm SA to the new position of the particle, and embedding the probability jump characteristic and temperature control mechanism of SA into the iterative process of PSO to obtain the optimal parameter G best , and training the support vector regression model SVR based on the water quality data set and the optimal parameter G best to obtain a water quality prediction model; a water quality prediction module, configured to use the water quality prediction model to predict the water supply equipment to obtain a water quality prediction result, and perform comprehensive analysis on the water quality of the water supply equipment based on the water quality prediction result to obtain the water quality grade.

[0017] To achieve one of the above-mentioned invention purposes, an embodiment of the present invention provides a storage medium storing program instructions, and when the program instructions are executed, the water quality prediction method described in any one of the above is implemented.

[0018] To achieve one of the above-mentioned invention purposes, an embodiment of the present invention provides an electronic terminal, including a processor and a memory, the memory stores program instructions, and the processor runs the program instructions to implement the water quality prediction method described in any one of the above.

[0019] The water quality prediction method, device, storage medium and electronic terminal of the water supply equipment provided by the embodiments of the present invention have the following advantages: This application embeds the probability jump characteristic and temperature control mechanism of the simulated annealing algorithm SA into the iterative process of the particle swarm optimization algorithm PSO, combines the fast global search ability of PSO and the local escape ability of SA, avoids PSO from prematurely converging to the local optimal solution, significantly enhances the model's ability to capture and fit complex water quality change laws, and compared with traditional statistical analysis methods, the prediction accuracy is greatly improved. The comprehensive analysis based on the prediction results effectively solves the problems of poor real-time performance and untimely feedback of water quality anomalies in the existing system, provides a precise decision-making basis for water quality management, dynamically evaluates the water quality of water supply equipment in all aspects, and effectively guarantees water supply safety. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 It is a schematic flowchart of the water quality prediction method of the water supply equipment described in the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0021] The present invention will be described in detail below in conjunction with the specific embodiments shown in the drawings. However, these embodiments do not limit the present invention, and any structural, method, or functional transformation made by those of ordinary skill in the art based on these embodiments is included in the protection scope of the present invention.

[0022] If the present invention involves directions (such as up, down, left, right, front, back, outside, inside, etc.) when expressing, the involved directions need to be defined.

[0023] The scope of the embodiments herein includes the entire scope of the claims and all available equivalents of the claims. Herein, terms such as "first", "second", etc. are only used to distinguish one element from another element, and do not require or imply any actual relationship or order between these elements. In fact, the first element can also be called the second element, and vice versa. Moreover, the terms "comprising", "including" or any other variant thereof are intended to cover non-exclusive inclusion, so that a structure, device or equipment including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such structure, device or equipment. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of another identical element in the structure, device or equipment including the said element. The embodiments herein are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other.

[0024] The terms "longitudinal", "lateral", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", etc. in this text indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings. They are only for the convenience of describing this text and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be construed as a limitation to the present invention. In the description of this text, unless otherwise specified and defined, the terms "installed", "connected", "coupled" should be understood in a broad sense. For example, it can be a mechanical connection or an electrical connection, or it can be the communication inside two elements. It can be directly connected or indirectly connected through an intermediate medium. For those of ordinary skill in the art, the specific meanings of the above terms can be understood according to specific circumstances.

[0025] Embodiment 1 of the present invention provides a water quality prediction method for a water supply device, as Figure 1 shown, which includes the following steps:

[0026] Step 101: Obtain the water quality data of the water supply device. The water quality data includes several water quality index data of the water supply device within a continuous time period, and preprocess the water quality data to obtain a water quality data set;

[0027] In practice, the water quality indexes can include indexes for describing water quality such as pH value of acidity and alkalinity, dissolved oxygen, turbidity, conductivity, temperature, and residual chlorine. The corresponding water quality index data is obtained through each water quality index sensor installed in the water supply device. Table 1 shows the measurement ranges and measurement accuracies of each water quality index sensor.

[0028] Table 1 Statistical table of measurement ranges and measurement accuracies of each water quality index sensor

[0029] Sensor Name Measurement Range Measurement Accuracy pH Sensor 0~14.00pH ±0.02pH Dissolved Oxygen Sensor 0-20mg / L ±0.5mg / L Turbidity Sensor 0~40NTU ±1% Conductivity Sensor 0~5000uS / cm ±1.5% Temperature Sensor 0~50℃ ±0.5℃ Residual Chlorine Sensor 0-20mg / L ±2%

[0030] Step 102: Create a support vector regression model SVR, establish the main framework of the particle swarm optimization algorithm PSO. In each iteration of the PSO, apply a random perturbation of the simulated annealing algorithm SA to the new position of the particle, and embed the probability jump characteristic and temperature control mechanism of the SA into the iterative process of the PSO to obtain the optimal parameter G best , and based on the water quality data set and the optimal parameter G best train the support vector regression model SVR to obtain a water quality prediction model;

[0031] Here, the Support Vector Regression (SVR) model is a regression analysis model based on support vector machines, which can effectively handle nonlinear regression problems and achieve data fitting by constructing an optimal hyperplane. The Particle Swarm Optimization (PSO) algorithm simulates the foraging behavior of bird flocks, searches for the optimal solution through cooperation and competition among particles in the solution space, and is used to globally tune the parameters of SVR to initially determine a relatively optimal parameter range. The Simulated Annealing (SA) algorithm is derived from the principle of solid annealing. Starting from the initial solution, it gradually accepts better solutions as the temperature drops, applies random perturbations to the optimized parameters obtained by PSO, so that the parameters of the SVR model are comprehensively optimized and avoid falling into local optimal solutions.

[0032] In practice, for the water quality dataset collected from water supply equipment, first initialize the parameters of the SVR model, use the PSO algorithm to search in a large parameter space, embed the simulated annealing algorithm SA during the PSO iteration process, and further perform local search in its neighborhood to finally obtain the optimal parameter G. best Use the optimal parameter G best Combine with the water quality dataset to train the SVR model, so as to obtain a water quality prediction model with better performance, which can better adapt to complex and changeable water quality data, accurately capture the water quality change law, and significantly improve the water quality prediction accuracy.

[0033] Step 103: Use the water quality prediction model to predict the water supply equipment to obtain a water quality prediction result, and comprehensively analyze the water quality of the water supply equipment based on the water quality prediction result to obtain a water quality grade. Specifically, use the Analytic Hierarchy Process to determine the weight of each index in the water quality prediction result, calculate the water quality comprehensive evaluation index WQI to obtain the water quality grade, and issue a warning if WQI < 0.6.

[0034] Here, the Analytic Hierarchy Process is a decision-making method that decomposes the elements related to the decision into levels such as goals, criteria, and solutions, and conducts qualitative and quantitative analysis on this basis. It makes the various factors in complex problems organized by dividing them into ordered levels that are interconnected, directly and effectively combines expert opinions and the objective judgment results of analysts according to the subjective judgment structure of a certain objective reality, and quantitatively describes the importance of pairwise comparison of elements at one level.

[0035] In practice, first construct a hierarchical structure model including the target layer: water quality comprehensive evaluation, and the criterion layer: various water quality indicators. Use the 1-9 scale method to compare the importance of six indicators pairwise, and construct a 6×6 judgment matrix A = (a ij) Normalize the judgment matrix \(A\) column by column, and calculate the mean value of each row to obtain the preliminary weight vector \(w = [w_1, w_2, w_3, w_4, w_5, w_6]\).

[0036] After that, normalize the preliminary weight vector \(w\) so that \(\sum w\) i = 1. Calculate the maximum eigenvalue Consistency index Random consistency index \(RI\) (\(RI = 1.24\) when \(n = 6\)): The matrix \(A\) passes the consistency test. After that, select positive or negative standardization according to the index properties. Table 2 shows the standardization methods for each index.

[0037] Table 2 Standardization methods for each index

[0038]

[0039] The comprehensive water quality evaluation index Determine the water quality level according to the preset range. If \(WQI < 0.6\), give an alarm. The alarm methods can include sound, light, text message, APP push, email, and on-site display screen alarm. The sound alarm emits a sound signal with a specific frequency, rhythm, or intensity to intuitively and immediately prompt relevant personnel of the abnormal water quality situation. Different alarm levels can correspond to different sound modes to achieve efficient reminder. The light alarm uses the change of light color and the adjustment of the flashing frequency to transmit the alarm information. For example, red usually represents a severe alarm, and yellow corresponds to a general alarm, so as to enhance visual recognition. The text message alarm contains the key information such as abnormal water quality indicators, occurrence location, and alarm level in the text, which is sent to the mobile communication devices of relevant personnel to ensure that they can also know in time remotely. The APP push alarm uses a dedicated mobile application program, which can not only push alarm messages, but also display rich content such as detailed water quality data charts and historical data comparisons, facilitating users to comprehensively grasp the water quality situation. The email alarm sends an email containing attachments such as water quality prediction data reports and analysis charts to the specified email address, which is suitable for transmitting detailed alarm reports to multiple personnel or departments. The on-site display screen alarm can set up a display screen at prominent positions such as the monitoring room of the water supply plant to display the water quality prediction data and alarm information in real time, and distinguish different alarm levels through eye-catching colors and fonts, facilitating on-site staff to monitor at any time.

[0040] Table 3 Water quality level classification table

[0041] WQI Range Water Quality Grade Description 0.8~1.0 Excellent Meets Class I standards and is suitable for direct drinking 0.6~0.8 Good Meets Class II standards and requires conventional treatment 0.4~0.6 Medium Meets Class III standards and requires advanced treatment 0.2~0.4 Poor Meets Class IV standards and is only suitable for industrial use 0.0~0.2 Extremely Poor Seriously polluted and prohibited from use

[0042] Table 3 is the water quality grade classification table. Here, the water quality early warning can also be based on the "Surface Water Environment Quality Standard" (GB3838-2002) and the "Sanitary Standard for Drinking Water" (GB 5749-2022), combined with the actual requirements of water quality management, for six key indicators including pH value of acidity and alkalinity, dissolved oxygen, turbidity, conductivity, temperature, and residual chlorine, to clarify the threshold values of Class I water and the setting of early warning threshold values, as shown in Table 4:

[0043] Table 4 Water Quality Early Warning Threshold Table

[0044]

[0045] In this embodiment, the "preprocessing the water quality data to obtain a water quality data set" specifically includes: performing the following first operation on all the water quality data: using the KNN algorithm to remove the noise and outliers in the water quality data to obtain the cleaned water quality data, using the formula: performing normalization processing on all the cleaned water quality data to obtain a water quality data set, where x is the cleaned water quality data, x min is the minimum value of the index to which x belongs, x max is the maximum value of the index to which x belongs, x norm is the data after normalization.

[0046] Here, the core of the K-Nearest Neighbors (KNN) algorithm is to given a training data set, for a new input instance, find the K nearest instances to this instance in the training data set. If the majority of these K instances belong to a certain category, then classify this input instance into this category. When processing water quality data, it is used to identify and remove noise and outliers. First, determine the value of k. k is usually an odd number to avoid a tie in classification. The value of k can be determined through cross-validation. Then calculate the Euclidean distance between each data point and other data points. For each data point, find its k nearest neighbors, and use the mean and standard deviation of the distances between the data point and its nearest neighbors to determine the threshold. According to the distance of the nearest neighbors, determine whether the data point is noise or an outlier. Process the detected noise and outlier data, and these data points can be deleted. Utilize the time series characteristics of the data and fill in the missing values through linear interpolation method to obtain the cleaned water quality data. After that, perform normalization processing on the cleaned water quality data. For example, if the dissolved oxygen data after cleaning is 5mg / L, the minimum value of this index is 2mg / L, and the maximum value is 8mg / L, substitute into the formula: Calculate, that is, (5 - 2) / (8 - 2) = 0.5, to obtain the corresponding data after normalization. After processing all the cleaned water quality data, a water quality data set is formed.

[0047] In this embodiment, the "creation of the support vector regression model SVR" specifically includes: The support vector regression model SVR is as follows: s.t..y i -(w·φ(x i )+b)≤∈+ξ i ,, where x i is the input vector, y i is the output vector, w is the weight vector, b is the bias term, ∈ is the insensitive parameter, ξ i , are all slack variables, C is the regularization parameter, φ(x i ) is the feature space after kernel function mapping; x i ∈R l , y i ∈R, ξ i ≥0, C∈[0.1,100], ∈∈[0.01,1]; The kernel function of the support vector regression model SVR is the radial basis kernel function: K(x i ,x j )=exp(-γ||x i -x j || 2 ), where γ is the parameter of the kernel function, ||x i -x j || 2 is the square of the Euclidean distance between the samples x i and x j in the water quality dataset; γ∈[0.001,10], and the prediction function is: where K(x i ,x j ) is the kernel function, α i , are all dual variables.

[0048] Here, the radial basis kernel function is a non-linear kernel function with powerful non-linear mapping ability. It can map the linearly inseparable water quality data in the low-dimensional space to the high-dimensional space to achieve linear separability, greatly enhancing the model's ability to handle non-linear relationships and overcoming the difficulties of traditional methods when facing complex non-linear water quality data. At the same time, the characteristic of this function to calculate similarity based on the radial distance of data points makes the model sensitive to the local characteristics of the data, can better adapt to the changes of water quality data at different times and under different conditions, enhances the generalization ability of the model, and comprehensively improves the reliability and stability of the water quality prediction system, providing strong support for ensuring water supply safety.

[0049] In this embodiment, "establishing the main framework of the Particle Swarm Optimization (PSO) algorithm, and in each iteration of the PSO, applying a random perturbation of the Simulated Annealing (SA) algorithm to the new position of the particle, and embedding the probability jump characteristic and temperature control mechanism of the SA into the iteration process of the PSO to obtain the optimal parameter G" specifically includes: establishing the main framework of the Particle Swarm Optimization (PSO) algorithm, with the mean square error of the Support Vector Regression (SVR) model as the optimization target, where is the output value of the Support Vector Regression (SVR) model; setting the parameters of the Particle Swarm Optimization (PSO) algorithm, where the parameters of the Particle Swarm Optimization (PSO) algorithm at least include: the number of particles N, the inertia weight w, the learning factor c1, and the learning factor c2; setting the parameters of the Simulated Annealing (SA) algorithm, where the Simulated Annealing (SA) algorithm at least includes: the initial temperature T0, the initial perturbation ratio D0, the lowest temperature T, and the maximum number of iterations iter; randomly generating N particles particle1, particle2,..., particleN, and the initial position and initial velocity of each particle particlei; preferably, the value range of N is 20 - 50, calculating the initial fitness of each particle particlei, and continuously performing iterative optimization until the temperature T drops to the preset lowest temperature T or reaches the maximum number of iterations iter, and outputting the optimal parameter G; where both i and k are natural numbers, 1 ≤ i ≤ N, and Tk is the temperature of the k-th generation; the iterative optimization process is as follows: for the temperature Tk of the k-th generation, using the PSO to update the velocity and position of the particle particlei: where and are the velocity and position of the particle particlei in the k-th generation respectively; c1 is the learning factor controlling the influence of individual learning, c2 is the learning factor controlling the influence of social learning; r1 and r2 are both random numbers between [0, 1]; pbest is the individual optimal position of the particle particlei, and the initial value is the initial position; gbest is the global optimal position. best Specifically, it includes: establishing the main framework of the Particle Swarm Optimization (PSO) algorithm, with the mean square error of the Support Vector Regression (SVR) model as the optimization target, where is the output value of the Support Vector Regression (SVR) model; setting the parameters of the Particle Swarm Optimization (PSO) algorithm, where the parameters of the Particle Swarm Optimization (PSO) algorithm at least include: the number of particles N, the inertia weight w ′ , the learning factor c1, and the learning factor c2; setting the parameters of the Simulated Annealing (SA) algorithm, where the Simulated Annealing (SA) algorithm at least includes: the initial temperature T0, the initial perturbation ratio D0, the lowest temperature T min and the maximum number of iterations iter max ; randomly generating N particles particle1, particle2,..., particle N , and the initial position i and initial velocity of each particle particle Preferably, the value range of N is 20 - 50, calculating the initial fitness of each particle particle i , and continuously performing iterative optimization until the temperature T k drops to the preset lowest temperature T min or reaches the maximum number of iterations iter max , and outputting the optimal parameter G best ; where both i and k are natural numbers, 1 ≤ i ≤ N, T k is the temperature of the k-th generation; the iterative optimization process is as follows: for the temperature T k of the k-th generation, using the PSO to update the velocity and position of the particle particle i : Where and are the velocity and position of the particle particle i in the k-th generation respectively; c1 is the learning factor controlling the influence of individual learning, c2 is the learning factor controlling the influence of social learning; r1 and r2 are both random numbers between [0, 1]; pbest i is the individual optimal position of the particle particle i , and the initial value is the initial position gbest is the global optimal position,

[0050] gbest=min(MSE(pbest1),MSE(pbest2),...,MSE(pbest N )); Based on the simulated annealing algorithm, the initial disturbance ratio D0 is used as the basis for updating the position Any parameter in is randomly changed within the corresponding preset range of disturbance, and x i ′, if x i If any parameter of ' exceeds the preset range, the parameter takes the boundary value; wherein, The parameters in are C,∈,γ,x i The parameter in ′ is C,∈,γ, and the preset range of disturbance corresponding to the parameter is (the parameter -D0, the parameter +D0); calculate x i ′ corresponds to MSE2 and Corresponding MSE1, the difference ΔE = MSE2-MSE1; if ΔE < 0, accept the new solution and update the particle i Location If ΔE ≥ 0, calculate the acceptance probability If P>rand(0,1), accept the new solution and update the particle i Location Otherwise keep the original position If the fitness of the new solution is better than pbest i , then update If the particle i pbest i If the fitness is better than the current gbest, update gbest = min(MSE(pbest1), MSE(pbest2), ..., MSE(pbest N )); where rand() is a random function; exponential cooling is used, T k+1 =αT k , if gbest is not updated for several consecutive generations, it will terminate, where α is the cooling coefficient.

[0051] In practice, each particle i Represents a set of SVR parameters (C,∈,γ), for particle i Assign a random speed to each particle. i The position and velocity can be expressed as: i =(x i1 ,x i2 ,x i3 ), v i =(v i1 ,v i2 ,v i3), where i represents the index of the particle; x i1 , x i2 and x i3 respectively represent the positions of the particle particle i , that is, the values of C, ∈, and γ, which are randomly initialized within the parameter range; v i1 , v i2 and v i3 respectively represent the velocity of particle i, which is initialized to zero or a small random value. The initial temperature T0 needs to be high enough to ensure that the solution space can be fully explored in the initial stage. The calculation method is as follows: Starting from the initial solution of PSO, N = 100 neighborhood solutions are randomly generated, and the objective function value MSE of each solution is calculated. Calculate the average value ΔE avg of all positive objective function differences ΔE. The initial probability of accepting inferior solutions P0 = 0.8, adopt exponential cooling T k+1 = αT k , set the cooling coefficient α = 0.95, the lowest temperature: T min = 10 -5 , the maximum number of iterations: iter max = 1000, the initial perturbation ratio D0 = 10%. For each generation of temperature T k , update the velocity and position of the particle: The inertia weight w ′ adopts a non-linear decreasing strategy and is adjusted by introducing a Gaussian function: where w ′ (k) is the inertia weight at the k-th iteration, w ′ max is the maximum value of the inertia weight, k is the current iteration number, and K max is the maximum number of iterations. The learning factors c1 and c2 adopt a dynamic adjustment strategy, where c1 decreases linearly and c2 increases linearly: where c1(k) and c2(k) are the learning factors at the k-th iteration; and are the maximum and minimum values of the learning factor c1, and are the maximum and minimum values of the learning factor c2. If the parameters exceed the range, they are reset to the boundary values. On this basis, a random perturbation is added to the updated position with the initial perturbation ratio D0 to obtain x i ′, and each parameter randomly varies within ±10% of its current value, x i ′ = (x i1 ′, x i2 ′, x i3 ′), and the formula is as follows: If the parameter after perturbation exceeds the preset range, truncate it to the boundary value.

[0052] Table 5 Comparison and Verification of Optimization Effects

[0053] Optimization Method MSE Training Time (s) Number of Support Vectors Default Parameters 3.25 2.1 120 Grid Search 2.58 180 95 Separate PSO 2.41 45 88 PSO-SA 2.12 60 75

[0054] Table 5 is a comparison and verification table of the optimization effects of common parameter optimization methods. It can be seen that the MSE of PSO-SA is reduced by 17.8% compared with grid search and 12.0% compared with PSO alone; the number of support vectors is reduced, the model is sparser, and the generalization ability is improved. The calculation time is between PSO and grid search, but the accuracy is significantly improved. It can be understood that the hybrid optimization of PSO-SA significantly improves the accuracy and robustness of the SVR water quality prediction model by combining the fast search of the particle swarm and the global exploration ability of the annealing algorithm, and is especially suitable for the prediction of water quality indicators with small and medium-sized data sets and obvious nonlinear characteristics.

[0055] Table 6 Response Time Statistics Table

[0056] Average Response Time Average Response Time Maximum Response Time Single Prediction + Evaluation + Early Warning 2.8 seconds 4.1 seconds 100 Concurrent Requests 3.5 seconds 6.2 seconds

[0057] Table 6 shows the response time statistics obtained in a specific test environment, where the specific test environment is: Intel Xeon E5-2678v3 server, 64GB memory, and the operating system is CentOS7.6; the software uses Python3.8, combined with Scikit-learn and Redis for real-time data caching. The test scenarios include a concurrent test that simulates 100 sensors reporting data simultaneously to test the system throughput and a single-request test that measures the end-to-end delay of a single piece of data from input to output warning result. The test results show that the average response time for single prediction, evaluation, and warning is 2.8 seconds, and the maximum response time is 4.1 seconds; the average response time for 100 concurrent requests is 3.5 seconds, and the maximum response time is 6.2 seconds. It can be understood that the water quality prediction method described in the present invention can not only quickly process a single piece of data and timely feedback water quality anomalies, but also has a powerful parallel processing ability, can stably handle high loads, reduce water supply interruption accidents caused by excessive water quality, and effectively ensure the efficient and reliable operation of large-scale water quality prediction.

[0058] Table 7 Comparison of Prediction Results of Different Models on the Same Data Set

[0059] Model MSE MAE R Number of Support Vectors Traditional SVR 2.58 1.32 0.82 135 PSO-SA-SVR 1.74 0.89 0.91 78

[0060] Table 7 shows the comparison of the prediction results between the traditional SVR model and the SVR model of the present invention for the same dataset. The dataset uses the water quality dataset of a water plant from January 2022 to June 2023, and the ratio of the training set to the test set is 8:2. The result comparison shows that, compared with the traditional SVR model, the mean square error MSE of the SVR model of the present invention is reduced by 32.6%, the mean absolute error MAE is reduced, and the coefficient of determination R 2 is increased by 10.9%, the generalization ability is enhanced, the number of support vectors is reduced by 42%, and the real-time prediction calculation load is reduced.

[0061] Embodiment 2 of the present invention provides a water quality prediction device for a water supply device, including the following modules: a data acquisition module, configured to acquire the water quality data of the water supply device and preprocess the water quality data to obtain a water quality dataset; a model creation module, configured to create a support vector regression model SVR and optimize the parameters of the support vector regression model SVR by using an iterative embedding optimization mechanism, specifically including: establishing the main framework of the particle swarm optimization algorithm PSO, and in each iteration of the PSO, applying a random perturbation of the simulated annealing algorithm SA to the new position of the particle, and embedding the probability jump characteristic and temperature control mechanism of the SA into the iterative process of the PSO to obtain the optimal parameter G best Based on the water quality dataset and the optimal parameter G best training the support vector regression model SVR to obtain a water quality prediction model; a water quality prediction module, configured to use the water quality prediction model to predict the water supply device to obtain a water quality prediction result, and comprehensively analyze the water quality of the water supply device based on the water quality prediction result to obtain a water quality grade.

[0062] Embodiment 3 of the present invention provides a storage medium storing program instructions, and when the program instructions are executed, the water quality prediction method described in any one of the above is implemented.

[0063] Embodiment 4 of the present invention provides an electronic terminal, including a processor and a memory, the memory stores program instructions, and the processor runs the program instructions to implement the water quality prediction method described in any one of the above.

[0064] It should be understood that although this specification is described according to embodiments, not each embodiment only contains an independent technical solution. This narrative way of the specification is only for clarity. Those skilled in the art should regard the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.

[0065] The series of detailed descriptions listed above are only specific descriptions of the feasible implementation manners of the present invention, and they are not intended to limit the protection scope of the present invention. Any equivalent implementation manners or modifications made without departing from the technical spirit of the present invention shall be included within the protection scope of the present invention.

Claims

1. A water quality prediction method for a water supply device, characterized in that, It includes the following steps: Obtain the water quality data of the water supply equipment, where the water quality data includes several water quality index data of the water supply equipment within a preset time period, and preprocess the water quality data to obtain a water quality data set; Create a support vector regression model SVR, establish the main framework of the particle swarm optimization algorithm PSO. In each iteration of PSO, apply a random perturbation of the simulated annealing algorithm SA to the new position of the particle, and embed the probability jump characteristic and temperature control mechanism of SA into the iterative process of PSO to obtain the optimal parameter G best , based on the water quality data set and the optimal parameter G best Train the support vector regression model SVR to obtain a water quality prediction model; Use the water quality prediction model to predict the water supply equipment to obtain a water quality prediction result, and comprehensively analyze the water quality of the water supply equipment based on the water quality prediction result to obtain a water quality grade.

2. The water quality prediction method according to claim 1, wherein The step of "preprocessing the water quality data to obtain a water quality data set" specifically includes: performing the following first operation on all the water quality data: using the KNN algorithm to remove noise and outliers from the water quality data to obtain the cleaned water quality data, and using the formula: performing normalization processing on all the cleaned water quality data to obtain a water quality data set, where x is the cleaned water quality data, x min is the minimum value of the index to which x belongs, x max is the maximum value of the index to which x belongs, x norm is the normalized data.

3. The water quality prediction method according to claim 1, wherein The "create support vector regression model SVR" specifically includes: The support vector regression model SVR is: where x i is the input vector, y i is the output vector, w is the weight vector, b is the bias term, ∈ is the insensitive parameter, ξ i , are all slack variables, C is the regularization parameter, φ(x i ) is the feature space after kernel function mapping; x ii ∈R l , y i ∈R, ξ i ≥0, The prediction function is as follows: where K(x i , x j ) is the kernel function, and α i , are all dual variables.

4. The water quality prediction method according to claim 3, characterized in that The kernel function of the support vector regression model SVR is the radial basis kernel function: K(x i ,x j ) = exp(-γ||x i -x j || 2 ), where γ is the parameter of the kernel function, and ||x i -x j || 2 is the square of the Euclidean distance between samples x i and x j in the water quality dataset; γ ∈ [0.001, 10].

5. The water quality prediction method according to claim 4, wherein Establish the main framework of the Particle Swarm Optimization (PSO) algorithm. In each iteration of the PSO, apply random perturbations of the Simulated Annealing (SA) algorithm to the new positions of the particles, and embed the probability jump characteristic and temperature control mechanism of the SA into the iterative process of the PSO to obtain the optimal parameter G best "Specifically, it includes: Establish the main framework of the Particle Swarm Optimization (PSO) algorithm, with the mean square error of the Support Vector Regression (SVR) model as the optimization objective, where is the output value of the Support Vector Regression (SVR) model; Set the parameters of the Particle Swarm Optimization (PSO) algorithm. The parameters of the PSO algorithm at least include: the number of particles N, the inertia weight w ′ , the learning factor c1, and the learning factor c2; set the parameters of the Simulated Annealing (SA) algorithm. The SA algorithm at least includes: the initial temperature T0, the initial perturbation ratio D0, the lowest temperature T min , and the maximum number of iterations iter max ; Randomly generate N particles particle1, particle2, ..., particle N , and the initial position of each particle particle i and the initial velocity Calculate the initial fitness of each particle particle i and continuously perform iterative optimization until the temperature T k drops to the preset minimum temperature T min or reaches the maximum number of iterations iter max , and output the optimal parameter G best ; where both i and k are natural numbers, 1 ≤ i ≤ N, T k is the temperature of the k-th generation;​ The iterative optimization process is as follows: For the k-th generation temperature T k , use PSO to update the velocity and position of particle i : where and are the velocity and position of particle i in the k-th generation respectively; c1 is the learning factor controlling the influence of individual learning, c2 is the learning factor controlling the influence of social learning; r1 and r2 are both random numbers between [0, 1]; pbest i is the individual optimal position of particle i , and its initial value is the initial position gbest is the global optimal position, gbest = min(MSE(pbest1), MSE(pbest2),..., MSE(pbest N )); Based on the simulated annealing algorithm, starting from the initial perturbation ratio D0, any parameter in the updated position is randomly varied within the corresponding preset perturbation range to obtain x i '. If any parameter of x i ' exceeds the preset range, then the parameter takes the boundary value; where the parameters in are C, ∈, γ, and the parameters in x i ' are C, ∈, γ, and the preset perturbation range corresponding to the parameters is (the parameter - D0, the parameter + D0); Calculate x i The corresponding MSE2 and The corresponding MSE1, the difference ΔE = MSE2 - MSE1; if ΔE < 0, then accept the new solution and update the position of the particle particle i of the position If ΔE ≥ 0, then calculate the acceptance probability If P > rand(0, 1), then accept the new solution and update the position of the particle particle i of the position Otherwise, retain the original position If the fitness of the new solution is better than pbest i , then update If the particle particle i of pbest i The fitness is better than the current gbest, then update gbest = min(MSE(pbest1), MSE(pbest2),..., MSE(pbest N )); where rand() is a random function; Using exponential cooling, T k+1 = αT k , and terminate if gbest has not been updated for multiple consecutive generations, where α is the cooling coefficient.

6. The water quality prediction method according to claim 5, wherein The value range of the number of particles N is 20 to 50.

7. The water quality prediction method according to claim 1, wherein The "comprehensively analyze the water quality of the water supply equipment based on the water quality prediction result to obtain a water quality grade" specifically includes: Use the analytic hierarchy process to determine the weight of each index in the water quality prediction result, calculate the water quality comprehensive evaluation index WQI to obtain the water quality grade, and issue a warning if WQI < 0.

6.

8. A water quality prediction device for a water supply device, characterized in that, It includes the following modules: A data acquisition module, configured to obtain the water quality data of the water supply equipment and preprocess the water quality data to obtain a water quality data set; A model creation module, which is used to create a support vector regression model (SVR), and adopts an iterative embedding optimization mechanism to optimize the parameters of the support vector regression model (SVR). Specifically, it includes: establishing the main framework of the particle swarm optimization algorithm (PSO). In each iteration of the PSO, a random perturbation of the simulated annealing algorithm (SA) is applied to the new position of the particle, and the probability jump characteristic and temperature control mechanism of the SA are embedded into the iterative process of the PSO to obtain the optimal parameter G best , based on the water quality data set and the optimal parameter G best train the support vector regression model (SVR) to obtain a water quality prediction model; A water quality prediction module, configured to use the water quality prediction model to predict the water supply equipment to obtain a water quality prediction result, and comprehensively analyze the water quality of the water supply equipment based on the water quality prediction result to obtain a water quality grade.

9. A storage medium stores program instructions, characterized in that, When the program instructions are executed, the water quality prediction method described in any one of claims 1 to 7 is implemented.

10. An electronic terminal, characterized in that, It includes a processor and a memory, the memory stores program instructions, and the processor runs the program instructions to implement the water quality prediction method described in any one of claims 1 to 7.