A method, system and medium for predicting urban water demand based on zoning prediction and dynamic automatic adjustment

Through a method based on partition prediction and dynamic automatic adjustment, combined with DPC clustering, VAE feature selection and GAT-DLinear model, the problem that traditional water demand prediction models cannot effectively consider changes in regional and water use characteristics is solved, and high-precision and robust water demand prediction are achieved.

CN119026880BActive Publication Date: 2025-03-11POWERCHINA HUADONG ENG CORP LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411508439.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-28
Publication Date
2025-03-11
Estimated Expiration
2044-10-28

AI Technical Summary

Technical Problem

Traditional water-demand prediction models cannot effectively consider the changing trends of different regions and water use characteristics, and the model parameter adjustment is complex and relies on manual intervention, resulting in low prediction accuracy and difficult to promote and apply.

Method used

Using a method based on partition prediction and dynamic automatic adjustment, urban areas are divided into categories of different changing trends through DPC clustering analysis. Combined with VAE feature selection and Pearson correlation analysis, GAT-DLinear model is constructed, and the hyperparameters are optimized using the improved zebra optimization algorithm to achieve dynamic automatic adjustment.

Benefits of technology

It improves the accuracy and robustness of urban water demand prediction, reduces manual intervention, realizes automatic adjustment of model parameters, and enhances the reliability of prediction results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119026880B_ABST
    Figure CN119026880B_ABST
Patent Text Reader

Abstract

The present invention provides a method, system and medium for predicting urban water demand based on zoning prediction and dynamic automatic adjustment, the method comprising: firstly obtaining the water consumption of urban residents and storing water data; performing DPC clustering on the monthly water consumption data; secondly adopting the VAE method to extract features of data with different change trends, and then performing Pearson correlation analysis, and then using the extracted key influencing factors to predict the monthly water demand of each region using the GAT-DLinear model, optimizing the GAT-DLinear model using the IZOA algorithm, and then judging whether the monthly prediction accuracy of this type is greater than 10% according to the NRMSE index, if so, constructing a target equation to optimize the parameters that need to be adjusted in the model again through the IZOA algorithm, and inputting the optimized parameter set into the prediction model again until the accuracy meets the threshold requirement, and outputting the final water demand prediction results of each partition. The present invention has the advantages of automation and self-adaptation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a method for predicting urban water demand, and in particular to a method, system and medium for predicting urban water demand based on zoning prediction and dynamic automatic adjustment. Technical Background

[0002] With the growth of global population and the irrational use of water resources, many places are facing water shortage problems. Therefore, real-time and accurate water demand forecasting is essential for building an efficient water resource management system. Artificial intelligence-based water demand forecasting can improve the accuracy and timeliness of water demand forecasting by leveraging its powerful data mining capabilities. However, with the rapid development of artificial intelligence, the water demand forecasting model based on artificial intelligence still has some shortcomings.

[0003] Traditional machine learning models do not consider the problem of different regions and different water use characteristics. They all send water use data to a certain model for prediction, and do not consider the impact of the size of water use change trends on the prediction results. During training, they cannot fully explore the time dependence and spatial correlation characteristics of the data, nor do they consider the impact of factors affecting residents' water use on the prediction results. The prediction results are highly random. In fact, water use data will change with water prices, temperature, consumption levels, washing time, and population size. On the other hand, in actual water demand prediction, due to the complex model structure, there are many parameters that need to be manually adjusted within the model, and the model parameter adjustment and operation require a high level of personnel. Therefore, manual adjustment may lead to poor prediction results of the model and fail to achieve the desired results. Therefore, the prediction method cannot be further promoted and applied in practice. Summary of the invention

[0004] The first purpose of the present invention is to solve the problems raised in the background technology and to provide a method for predicting urban water demand based on zoning prediction and dynamic automatic adjustment, in the hope of improving the impact of different regions and different water use characteristics, as well as the impact of factors affecting residents' water use on the prediction results, so as to effectively improve the accuracy of urban water demand prediction.

[0005] To this end, the above-mentioned purpose of the present invention is achieved through the following technical solutions:

[0006] A method for predicting urban water demand based on zoning prediction and dynamic automatic adjustment comprises the following steps:

[0007] S1. Obtain the daily water consumption of urban residents, store water data, and upload the water data to the cloud, obtain the residents' water consumption in the cloud, and divide the original data into three parts;

[0008] S2. Use the average monthly water consumption as the basis for the division of the pre-processed historical water consumption data to perform DPC clustering on the historical water consumption data of multiple areas in the city, and cluster these areas into three categories: large change trend, small change trend, and stable change;

[0009] S3, perform VAE feature selection on all residential water use data of the three areas clustered in S2, and perform Pearson correlation analysis on the influencing factors affecting residential water use, including temperature, water price, consumption level, washing time, and population;

[0010] S4, construct the GAT-DLinear model based on the key influencing factors extracted by the Pearson correlation analysis in S3 and the three types of residential water use data, and use the GAT-DLinear model to train the water use data;

[0011] S5, using Bernoulli chaotic mapping and polynomial mutation operator to improve the zebra optimization algorithm;

[0012] S6. Optimizing the hyperparameters of the GAT-DLinear model using an improved zebra optimization algorithm, wherein the hyperparameters include a learning rate, a number of graph attention layers, and a hidden layer dimension;

[0013] S7. Use the GAT-DLinear model after hyperparameter optimization to train water use data to achieve the effect of dynamically and automatically adjusting water demand data according to the prediction results. First, after training, use the data of the validation set according to the clustering results to determine whether the prediction accuracy NRMSE is greater than 10%. If it is less than 10%, output the result; if it is greater than the threshold, construct the target equation with the parameters in the prediction model and optimize it again through the IZOA algorithm input into the optimization model, input the optimized hyperparameter set into the prediction model again, and make the next round of prediction for the data of this month by adjusting the model parameters, so as to judge until the requirements are met, and finally output the final water demand prediction results for each partition.

[0014] While adopting the above technical solutions, the present invention may also adopt or combine the following technical solutions:

[0015] As a preferred technical solution of the present invention: step S1 specifically includes the following process:

[0016] S101, use the flow meter to record the daily water consumption of residents, then connect to the STM32 microcontroller to store the data through the microcontroller;

[0017] S102, connecting the stored residential water use data to Alibaba Cloud through the wireless communication function of the ESP8266 chip, and uploading the residential water use data to the cloud so that the data can be obtained anytime and anywhere in the cloud;

[0018] S103. Divide the acquired raw data into three parts, namely 60% training set, 20% validation set and 20% test set, wherein the training set is used for model construction, the validation set is used for component selection for further decomposition and hyperparameter selection, and the test set is used for model verification.

[0019] As a preferred technical solution of the present invention: step S2 specifically includes the following process:

[0020] S201. When calculating the dynamic K value, first calculate the water samples of the two areas. and The Euclidean distance between them forms a distance matrix , and then find the points that satisfy the following conditions :

[0021] (1)

[0022] in, Represents two water samples and The Euclidean distance between It is the distance The nearest point, is the adjustment coefficient, and all points that meet the above conditions are Dynamic K nearest neighbors;

[0023] S202: When performing local density calculation, dynamic K nearest neighbors are introduced to calculate the local density of the sample point. , the calculation formula is as follows:

[0024] (2)

[0025] Among them, PK(i) is the point Dynamic K nearest neighbors, is the similarity coefficient, Yes and The distance between them, σ=n / 100;

[0026] S203, calculate relative distance , For sample points The distance to a point that is closer and has a higher density than the local density is as shown in formula (3):

[0027] (3)

[0028] in, , express and The maximum and minimum distances between yes The local density of the point, yes The local density of the point, Represents the maximum local density of the sample;

[0029] S204, select its cluster center, specifically calculate The decision value of The maximum change rate of the 50 sample points. The point with the maximum change rate q is the dividing value between the cluster center and the non-cluster center. , select Value greater than The points are taken as cluster centers, where ;

[0030] S205, after finding the cluster center, classify the non-cluster center points into one category with the corresponding cluster center points based on the dynamic K nearest neighbors and cluster center distance factors;

[0031] S206, the remaining points are allocated to the cluster with higher local density closest to them. After all the data are divided, DPC clustering is completed, and these areas of the city are clustered into three categories: large change trend, small change trend and stable change.

[0032] As a preferred technical solution of the present invention: step S3 specifically includes the following process:

[0033] S301, respectively encode the three types of water consumption data, wherein the encoder includes four convolutional layers, and a fully connected layer with 256 neurons is connected after the convolutional layer;

[0034] S302, decoding the encoded data, the decoder input dimension is 10, which also includes a fully connected layer with 256 neurons;

[0035] S303, gradient back propagation: The loss function is calculated by decoding the output data and the input original data, and the network weights are updated by back propagation. The network weights are initialized using the Glorot uniform distribution method. After repeated training, the decoder learns the mapping law of the data.

[0036] S304, generate data, that is, extract the decoder as the VAE generation model, extract a set of feature vectors from the Gaussian distribution as the model input, and obtain new data after feature extraction that conforms to the probability distribution of the training data set, determine the input dimension of each variable, and obtain the eigenvalues ​​and eigenvectors of the covariance matrix to calculate the correlation of the variables;

[0037] S305. Perform Pearson correlation analysis on the influencing factors of each type of data. The influencing factors include temperature, water price, consumption level, washing time, and population. The Pearson correlation analysis is shown in formula (4).

[0038] (4)

[0039] in, For variables The covariance of , For variables The respective standard deviations, , For variables their respective expectations;

[0040] S306. For each type of influencing factor, the key influencing factors of the data are extracted by calculating the Pearson correlation coefficient. Those greater than 0.7 are retained as key influencing factors, and those less than 0.7 are deleted;

[0041] S307, clustering the water use data into three types and extracting the key influencing factors to construct a GAT-DLinear model.

[0042] S401. When using the graph attention network model to predict residents' water demand, first input data, the input data includes static data and dynamic data, wherein the static data includes location information of different areas of the city, and the dynamic data includes key influencing factors of residents' water demand at each location screened after Pearson correlation analysis;

[0043] S402. Build property graph To capture the dynamic characteristics of residential water use data in time and space, V represents the node of the attribute graph, E represents the edge of the attribute graph; the water use location is represented as a graph node, and each node It has an associated static feature vector and a set of dynamic features in the form of a matrix, the former containing position information and the latter containing S types of key influencing factors;

[0044] S403, modeling and defining the geographical proximity between different water use areas, and describing the connection between nodes with edge weights; after inputting the above information, using the ReLU activation function to calculate the attention weight , using the Softmax function combined Calculating attention score , then the weight of the edge between nodes i and j can be defined It is expressed as follows:

[0045] (5)

[0046] in, represents the geographical distance between water use location i and water use location j; Represents the standard deviation of the distance between n water-using areas; ε is the threshold. If the distance is less than the threshold, it is assumed that the two water-using areas are not connected to ensure the sparsity of the graph structure;

[0047] S404, Spatial Dependency Modeling. Spatial correlation is a key issue in predicting water consumption data of residents in various regions. By considering spatial similarity, the proposed model can evaluate the changes in water consumption of residents in similar locations, thereby more accurately predicting the water demand of residents in various regions. Specifically, a multi-layer graph attention network GAT is used to extract spatiotemporal features from the attribute graph. Each position receives information from adjacent positions based on similarity, and the embedded information of each node is updated by aggregating adjacent nodes. At the tth time step, the input of node i is expressed as , where M represents the time step of the input window, represents the region where node i is located, S represents S-type key influencing factors, and the specific steps are as follows:

[0048] S40401, inputting historical features into the attribute graph;

[0049] S40402. Apply the graph attention mechanism to calculate the attention value of each node, expressed as ,in, Representation Node i The domain where you are located, is the output dimension of the GAT layer; a multi-head mechanism is used to calculate K independent attention scores in order to calculate , the attention weight of the kth head between node i and node j , calculated as follows:

[0050] (6)

[0051] in, represents the LeakyReLU activation function, is the attention matrix of the kth head; is the linear transformation weight matrix of the kth head, converting the input dimension to the output dimension; Represents a serial operation, , Respectively represent nodes i ,node j In the t Input at time steps;

[0052] S40403. Calculate attention score , the expression is as follows:

[0053] (7)

[0054] Among them, softmax is the activation function, is the attention weight of the kth head between node i and node j, represents the attention weight of the kth head between node i and node n. Each edge of node i has an attention score score, which is used to evaluate how much information should be aggregated from the neighboring node j;

[0055] S40404. Add all embedding vectors from multiple heads to establish the final representation of node i as follows:

[0056] (8)

[0057] in, represents all embedded information of node i, C is the number of heads, K is the independent attention score, N is the number of nodes, is the linear transformation weight matrix of the kth head, represents the input of node i;

[0058] S405, extracting the spatial feature information of the water use area from the attribute graph by GAT (each node The key influencing factors with relevant information are used as the input of the DLinear model. A graph model is established for the water use data problem. The multi-layer graph attention network uses the characteristics of different weights assigned to different nodes to update the vector representation of each node by paying attention to the characteristics of the neighboring nodes of each node, thereby extracting graph information.

[0059] S406, DLinear model decomposes the time series into trend series and residual series, and then uses two single-layer linear networks to model the two series to complete the prediction task. For a time series containing D variables, the historical data Predicting future data ;

[0060] S407, DLinear model first decomposes historical time series data into trend data and the remaining data Two parts, and then apply a single-layer linear network to the two decomposed sequences respectively:

[0061] (9)

[0062] (10)

[0063] in, , is the weight of a single-layer linear network, is the domain of the linear network, L and are the length of historical time series and the length of future time series respectively; and Represents the value of the variable at the time step;

[0064] S408, the final output is the sum of the output results of the two single-layer linear networks:

[0065] (11).

[0066] As a preferred technical solution of the present invention: step S5 specifically includes the following process:

[0067] S501: The ZOA algorithm is initialized and improved by using Bernoulli chaotic mapping to improve the global search and optimization capabilities of the algorithm. The expression of Bernoulli chaotic mapping is as follows:

[0068] (12)

[0069] in, is the current value of the kth generation chaotic sequence generated, For control parameters, generally When it is around 0.5, better traversability can be achieved;

[0070] S502: In order to further improve the global search capability and solution diversity of the algorithm, a polynomial mutation operator is introduced into the algorithm to expand the search range, so that it has a certain local random search capability. A polynomial mutation operator is introduced into the zebra optimal position in the ZOA algorithm. The formula is as follows:

[0071] (13)

[0072] Where q is as follows:

[0073] (14)

[0074] Where: q is the mutation operator of the best position of the zebra; is the optimal individual position before mutation; is the optimal individual position after mutation; , are the upper and lower limits of the position respectively; is a random number between [0, 1]; is the distribution index; , is the mutation operator, , .

[0075] As a preferred technical solution of the present invention: step S6 specifically includes the following process:

[0076] S601. In the first stage, the population members are updated according to the simulation of zebra behavior when searching for food; in IZOA, the best member of the population is considered to be the pioneer zebra and leads other population members to its position in the search space. Therefore, the position update of zebras in the foraging stage can be modeled using formulas (15) and (16):

[0077] (15)

[0078] (16)

[0079] in, Indicates Only zebra The latest position of the dimension value, Indicates Only zebra The location of the dimension value, is the optimal zebra with the lowest current fitness Dimension value, I is a random value belonging to the set {1, 2}, and rand is a random number between [0, 1]; It is the pioneer zebra position, represents the new position of the i-th zebra in the foraging phase, represents the Pioneer Zebra objective function value, Represents the new objective function value of Pioneer Zebra;

[0080] S602. In the second stage, the defense strategy of zebras against predator attacks is simulated to update the positions of IZOA population members in the search space. In the IZOA design, it is assumed that one of the following two situations occurs with the same probability:

[0081] (1) The lion attacks the zebra, so the zebra chooses the escape strategy. In the first strategy, when the zebra is attacked by the lion, the strategy can be modeled using the pattern S1 in formula (17).

[0082] (2) When other small predators attack zebras, the zebras will choose an attack strategy; use mode S2 in formula (17) to model this strategy:

[0083] (17)

[0084] (18)

[0085] in, Indicates the second stage Only zebra The latest position of the dimension value, Indicates Only zebra The location of the dimension value, R is a constant of 0.01, r is a random number between [0, 1], t is the current iteration number, T is the maximum number of iterations, is the switching probability between the two strategies, and its value is a random number between [0, 1]. The state of the zebra being attacked. I is a random value belonging to the set {1, 2}, It is the pioneer zebra position, Indicates i The new position of the zebra in the defense phase, represents the Pioneer Zebra objective function value, Represents the new objective function value of Pioneer Zebra;

[0086] S603. When updating the position of the zebra, if the objective function of the zebra in the new position has a better value, the new position is accepted. The new position is the hyperparameter of the GAT-DLinear model. The update condition is modeled using formula (19):

[0087] (19)

[0088] in, Indicates i Only the new position of the updated zebra, represents the Pioneer Zebra objective function value, Represents the new objective function value of Pioneer Zebra.

[0089] As a preferred technical solution of the present invention: step S7 specifically includes the following process:

[0090] S701, using the data of the validation set to determine whether the prediction accuracy NRMSE is greater than 10%, if it is less than the threshold, output the result; if it is greater than the threshold, perform S702 for optimization;

[0091] S702, re-construct the target equation of the model using the predicted value and the true value. The equation mainly considers the accuracy of the model. The target equation is as follows:

[0092] (20)

[0093] In the formula, N represents the population size, Represents multiple influences included in the water demand forecast model Adjustable parameters, including the attention mechanism matrix of the GAT model , linear transformation weight matrix , the historical time series length and future time series length of the DLinear model;

[0094] S703, using the IZOA algorithm to optimize the target equation MA The adjustable parameters are then used to determine whether the optimized GAT-DLinear model is greater than the threshold. If so, dynamic adjustment is performed.

[0095] S704: until the monthly water demand data of all regions is less than the threshold, the final water demand forecast results of each sub-region are output.

[0096] The second object of the present invention is to provide an urban water demand prediction system based on zoning prediction and dynamic automatic adjustment.

[0097] To this end, the above-mentioned purpose of the present invention is achieved through the following technical solutions:

[0098] An urban water demand forecasting system based on zoning forecasting and dynamic automatic adjustment includes the following modules:

[0099] A data acquisition module, which is used to obtain the daily water consumption of urban residents and divide the original data into three parts;

[0100] A cluster analysis module, which is used to perform DPC clustering on the historical water use data of multiple areas in the city using the average monthly water use as the basis for division of the pre-processed historical water use data, and cluster these areas into three categories: large change trend, small change trend and stable change;

[0101] A correlation analysis module, which is used to perform VAE feature selection on all residential water use data of the three types of areas clustered by the cluster analysis module, and to perform Pearson correlation analysis on the influencing factors affecting residential water use, including temperature, water price, consumption level, washing time, and population;

[0102] A GAT-DLinear model construction module, wherein the GAT-DLinear model construction module is used to construct a GAT-DLinear model based on the key influencing factors extracted by the correlation analysis module and three types of residential water use data, and use the GAT-DLinear model to train the water use data;

[0103] A zebra optimization algorithm improvement module, wherein the zebra optimization algorithm improvement module uses Bernoulli chaotic mapping and polynomial mutation operators to improve the zebra optimization algorithm;

[0104] A hyperparameter optimization module, wherein the hyperparameter optimization module is used to optimize the hyperparameters of the GAT-DLinear model using the zebra optimization algorithm improved by the zebra optimization algorithm improvement module, wherein the hyperparameters include a learning rate, a number of graph attention layers, and a hidden layer dimension;

[0105] A water demand prediction module is used to train water use data using the GAT-DLinear model optimized by the hyperparameter optimization module. After training, the data of the validation set is used to determine whether the prediction accuracy NRMSE is greater than 10% according to the clustering results. If it is less than 10%, the result is output; if it is greater than the threshold, the parameters in the prediction model are used to construct the target equation and the input optimization model is optimized again through the IZOA algorithm. The optimized hyperparameter set is input into the prediction model again, and the next round of prediction of the data for this month is carried out by adjusting the model parameters until the requirements are met, and finally the final water demand prediction results of each partition are output.

[0106] Another object of the present invention is to provide a computer-readable storage medium.

[0107] To this end, the above-mentioned purpose of the present invention is achieved through the following technical solutions:

[0108] A computer-readable storage medium, characterized in that: a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the urban water demand prediction method based on zoning prediction and dynamic automatic adjustment as described above are implemented.

[0109] The present invention provides a method, system and medium for predicting urban water demand based on zoning prediction and dynamic automatic adjustment. The method comprises: firstly obtaining daily water consumption of urban residents and storing water data, uploading the water data to the cloud, obtaining the water consumption of residents in the cloud, and dividing the original data into three parts; then using the water consumption data as the basis for division to perform DPC clustering on the urban monthly water consumption data, and dividing the water consumption data of various areas of the city into three categories according to different change trends: large change trend, small change trend and change stability; secondly using the VAE method to extract features from the water consumption data with different change trends, and then performing Pearson correlation analysis. The water demand data and the extracted key influencing factors are then used to predict the monthly water demand of each region using the GAT-DLinear model. The IZOA algorithm is used to optimize the GAT-DLinear model to obtain preliminary prediction results. The performance evaluation NRMSE is used to determine whether the monthly prediction accuracy is greater than 10%. If so, the parameters in the prediction model are used to construct the target equation, and the parameters that need to be manually adjusted in the model are optimized again using the IZOA algorithm. The optimized parameter set is input into the prediction model again, and the monthly data is predicted again by adjusting the model parameters until the prediction accuracy meets the threshold requirements. Finally, the final water demand prediction results for each partition are output.

[0110] Compared with the prior art, the present invention has the following significant advantages:

[0111] 1) The present invention proposes a method for clustering different characteristics of residents' water use data based on the DPC clustering method. In order to reduce the problem of reduced water demand prediction accuracy caused by different characteristics of water use data, after obtaining historical data, the present invention establishes a DPC clustering analysis that considers the water use change trend characteristics for different water use characteristics, taking into account the actual situation of residents' water demand, and improving the accuracy and robustness of the model.

[0112] 2) Residential water use data is diverse, uncertain, large in volume, and time-varying. Taking into account the spatiotemporal correlation characteristics between different regions, the present invention innovatively uses GAT to capture the spatial dependency characteristics between multiple water use areas, and fully considers the key influencing factors of its water use data. The key influencing factors are also modeled by GAT, and the feature information extracted by GAT from the attribute graph is used as the input of Reformer to establish a GAT-Dlinear prediction model.

[0113] 3) The parameter dynamic automatic adjustment method proposed in the present invention has the advantages of automation and self-adaptation. The effectiveness of model prediction is measured based on the accuracy of the data, and the target equation is constructed accordingly for the data with low accuracy. Then, the IZOA algorithm is used to optimize the adjustable parameters, and the accuracy of the prediction is increased by automatically adjusting the model parameters. BRIEF DESCRIPTION OF THE DRAWINGS

[0114] Figure 1 It is a flowchart of a method for predicting urban water demand based on zoning prediction and dynamic automatic adjustment provided in an embodiment of the present invention.

[0115] Figure 2 Schematic diagram of the GAT-DLinear model in an embodiment of the present invention.

[0116] Figure 3 It is a framework diagram of the improved zebra optimization algorithm in the embodiment of the present invention.

[0117] Figure 4 This is a graph of prediction error indicators for different models.

[0118] Figure 5 This is a line comparison chart of the model prediction value and the true value provided by the present invention. DETAILED DESCRIPTION

[0119] The present invention will be described in further detail with reference to the accompanying drawings and specific embodiments.

[0120] like Figure 1 As shown, a method for predicting urban water demand based on zoning prediction and dynamic automatic adjustment includes the following steps:

[0121] S1. Use flow meter to detect the daily water consumption of urban residents, then store the water consumption data through STM32, and upload the data to the cloud through ESP8266 chip, obtain the water consumption of residents in the cloud, and divide the original data into three parts;

[0122] Specifically, the process includes the following:

[0123] S101, use the flow meter to record the daily water consumption of residents, then connect to the STM32 microcontroller to store the data through the microcontroller;

[0124] S102, connecting the stored residential water use data to Alibaba Cloud through the wireless communication function of the ESP8266 chip, and uploading the residential water use data to the cloud so that the data can be obtained anytime and anywhere in the cloud;

[0125] S103. Divide the acquired raw data into three parts, namely 60% training set, 20% validation set and 20% test set, wherein the training set is used for model construction, the validation set is used for component selection for further decomposition and hyperparameter selection, and the test set is used for model verification.

[0126] S2. Use the average monthly water consumption as the basis for the division of the pre-processed historical water consumption data to perform DPC clustering on the historical water consumption data of multiple areas in the city, and cluster these areas into three categories: large change trend, small change trend, and stable change;

[0127] Specifically, the process includes the following:

[0128] S201. When calculating the dynamic K value, first calculate the water samples of the two areas. and The Euclidean distance between them forms a distance matrix , and then find the points that satisfy the following conditions :

[0129] (1)

[0130] in, Represents two water samples and The Euclidean distance between It is the distance The nearest point, is the adjustment coefficient, and all points that meet the above conditions are Dynamic K nearest neighbors;

[0131] S202: When performing local density calculation, dynamic K nearest neighbors are introduced to calculate the local density of the sample point. , the calculation formula is as follows:

[0132] (2)

[0133] Among them, PK(i) is the point Dynamic K nearest neighbors, is the similarity coefficient, Yes and The distance between them, σ=n / 100;

[0134] S203, calculate relative distance , For sample points The distance to a point that is closer and has a higher density than the local density is as shown in formula (3):

[0135] (3)

[0136] in, , express and The maximum and minimum distances between yes The local density of the point, yes The local density of the point, Represents the maximum local density of the sample;

[0137] S204, select its cluster center, specifically calculate The decision value of The maximum change rate of the 50 sample points. The point with the maximum change rate q is the dividing value between the cluster center and the non-cluster center. , select Value greater than The points are taken as cluster centers, where ;

[0138] S205, after finding the cluster center, classify the non-cluster center points into one category with the corresponding cluster center points based on the dynamic K nearest neighbors and cluster center distance factors;

[0139] S206, the remaining points are allocated to the cluster with higher local density closest to them. After all the data are divided, DPC clustering is completed, and these areas of the city are clustered into three categories: large change trend, small change trend and stable change.

[0140] S3, perform VAE feature selection on all residential water use data clustered into three types of areas, and perform Pearson correlation analysis on the influencing factors affecting residential water use, including temperature, water price, consumption level, washing time, and population size;

[0141] Specifically, the process includes the following:

[0142] S301, respectively encode the three types of water consumption data, wherein the encoder includes four convolutional layers, and a fully connected layer with 256 neurons is connected after the convolutional layer;

[0143] S302, decoding the encoded data, the decoder input dimension is 10, which also includes a fully connected layer with 256 neurons;

[0144] S303, gradient back propagation: The loss function is calculated by decoding the output data and the input original data, and the network weights are updated by back propagation. The network weights are initialized using the Glorot uniform distribution method. After repeated training, the decoder learns the mapping law of the data.

[0145] S304, generate data, that is, extract the decoder as the VAE generation model, extract a set of feature vectors from the Gaussian distribution as the model input, and obtain new data after feature extraction that conforms to the probability distribution of the training data set, determine the input dimension of each variable, and obtain the eigenvalues ​​and eigenvectors of the covariance matrix to calculate the correlation of the variables;

[0146] S305. Perform Pearson correlation analysis on the influencing factors of each type of data. The influencing factors include temperature, water price, consumption level, washing time, and population. The Pearson correlation analysis is shown in formula (4).

[0147] (4)

[0148] in, For variables The covariance of , For variables The respective standard deviations, , For variables their respective expectations;

[0149] S306. For each type of influencing factor, the key influencing factors of the data are extracted by calculating the Pearson correlation coefficient. Those greater than 0.7 are retained as key influencing factors, and those less than 0.7 are deleted;

[0150] S307, clustering the water use data into three types and extracting the key influencing factors to construct a GAT-DLinear model.

[0151] S4, based on the key influencing factors extracted by Pearson correlation analysis in S3 and the three types of residential water use data, a GAT-DLinear model was constructed (GAT-DLinear model is as follows Figure 2 As shown in Figure 2), and the GAT-DLinear model was used to train the water use data;

[0152] Specifically, the process includes the following:

[0153] S401. When using the graph attention network model to predict residents' water demand, first input data, the input data includes static data and dynamic data, wherein the static data includes location information of different areas of the city, and the dynamic data includes key influencing factors of residents' water demand at each location screened after Pearson correlation analysis;

[0154] S402. Build property graph To capture the dynamic characteristics of residential water use data in time and space, V represents the node of the attribute graph, E represents the edge of the attribute graph; the water use location is represented as a graph node, and each node It has an associated static feature vector and a set of dynamic features in the form of a matrix, the former containing position information and the latter containing S types of key influencing factors;

[0155] S403, modeling and defining the geographical proximity between different water use areas, and describing the connection between nodes with edge weights; after inputting the above information, using the ReLU activation function to calculate the attention weight , using the Softmax function combined Calculating attention score , then the weight of the edge between nodes i and j can be defined It is expressed as follows:

[0156] (5)

[0157] in, represents the geographical distance between water use location i and water use location j; Represents the standard deviation of the distance between n water-using areas; ε is the threshold. If the distance is less than the threshold, it is assumed that the two water-using areas are not connected to ensure the sparsity of the graph structure;

[0158] S404, Spatial Dependency Modeling. Spatial correlation is a key issue in predicting water consumption data of residents in various regions. By considering spatial similarity, the proposed model can evaluate the changes in water consumption of residents in similar locations, thereby more accurately predicting the water demand of residents in various regions. Specifically, a multi-layer graph attention network GAT is used to extract spatiotemporal features from the attribute graph. Each position receives information from adjacent positions based on similarity, and the embedded information of each node is updated by aggregating adjacent nodes. At the tth time step, the input of node i is expressed as , where M represents the time step of the input window, represents the region where node i is located, S represents S-type key influencing factors, and the specific steps are as follows:

[0159] S40401, inputting historical features into the attribute graph;

[0160] S40402. Apply the graph attention mechanism to calculate the attention value of each node, expressed as ,in, Representation Node i The domain where you are located, is the output dimension of the GAT layer; a multi-head mechanism is used to calculate K independent attention scores in order to calculate , the attention weight of the kth head between node i and node j , calculated as follows:

[0161] (6)

[0162] in, represents the LeakyReLU activation function, is the attention matrix of the kth head; is the linear transformation weight matrix of the kth head, converting the input dimension to the output dimension; Represents a serial operation, , Respectively represent nodes i ,node j In the t Input at time steps;

[0163] S40403. Calculate attention score , the expression is as follows:

[0164] (7)

[0165] Among them, softmax is the activation function, is the attention weight of the kth head between node i and node j, represents the attention weight of the kth head between node i and node n. Each edge of node i has an attention score score, which is used to evaluate how much information should be aggregated from the neighboring node j;

[0166] S40404. Add all embedding vectors from multiple heads to establish the final representation of node i as follows:

[0167] (8)

[0168] in, represents all embedded information of node i, C is the number of heads, N is the number of nodes, is the linear transformation weight matrix of the kth head, represents the input of node i;

[0169] S405, using the spatial feature information of the water use area extracted by GAT from the attribute graph as the input of the DLinear model, and establishing a graph model for the water use data problem. The multi-layer graph attention network uses the characteristics of assigning different weights to different nodes, and updates the vector representation of each node by paying attention to the features of the neighboring nodes of each node to extract the graph information;

[0170] S406, DLinear model decomposes the time series into trend series and residual series, and then uses two single-layer linear networks to model the two series to complete the prediction task. For a time series containing D variables, the historical data Predicting future data ;

[0171] S407, DLinear model first decomposes historical time series data into trend data and the remaining data Two parts, and then apply a single-layer linear network to the two decomposed sequences respectively:

[0172] (9)

[0173] (10)

[0174] in, , is the weight of a single-layer linear network, is the domain L of linear networks and are the length of historical time series and the length of future time series respectively; and represents the value of the variable at the time step;

[0175] S408, the final output is the sum of the output results of the two single-layer linear networks:

[0176] (11).

[0177] S5, such as Figure 3 As shown in the figure, the zebra optimization algorithm is improved by using Bernoulli chaotic mapping and polynomial mutation operator;

[0178] Specifically, the process includes the following:

[0179] S501: The ZOA algorithm is initialized and improved by using Bernoulli chaotic mapping to improve the global search and optimization capabilities of the algorithm. The expression of Bernoulli chaotic mapping is as follows:

[0180] (12)

[0181] in, is the current value of the kth generation chaotic sequence generated, For control parameters, generally When it is around 0.5, better traversability can be achieved;

[0182] S502: In order to further improve the global search capability and solution diversity of the algorithm, a polynomial mutation operator is introduced into the algorithm to expand the search range, so that it has a certain local random search capability. A polynomial mutation operator is introduced into the zebra optimal position in the ZOA algorithm. The formula is as follows:

[0183] (13)

[0184] Where q is as follows:

[0185] Where: qis the mutation operator of the best position of the zebra; is the optimal individual position before mutation; is the optimal individual position after mutation; , are the upper and lower limits of the position respectively; is a random number between [0, 1]; is the distribution index; , is the mutation operator, , .

[0186] S6. Optimizing the hyperparameters of the GAT-DLinear model using an improved zebra optimization algorithm, wherein the hyperparameters include a learning rate, a number of graph attention layers, and a hidden layer dimension;

[0187] Specifically, the process includes the following:

[0188] S601. In the first stage, the population members are updated according to the simulation of zebra behavior when searching for food; in IZOA, the best member of the population is considered to be the pioneer zebra and leads other population members to its position in the search space. Therefore, the position update of zebras in the foraging stage can be modeled using formulas (15) and (16):

[0189] (15)

[0190] (16)

[0191] in, Indicates Only zebra The latest position of the dimension value, Indicates Only zebra The location of the dimension value, is the optimal zebra with the lowest current fitness Dimension value, I is a random value belonging to the set {1, 2}, and rand is a random number between [0, 1]; It is the pioneer zebra position, represents the new position of the i-th zebra in the foraging phase, represents the Pioneer Zebra objective function value, Represents the new objective function value of Pioneer Zebra;

[0192] S602. In the second stage, the defense strategy of zebras against predator attacks is simulated to update the positions of IZOA population members in the search space. In the IZOA design, it is assumed that one of the following two situations occurs with the same probability:

[0193] (1) The lion attacks the zebra, so the zebra chooses the escape strategy. In the first strategy, when the zebra is attacked by the lion, the strategy can be modeled using the pattern S1 in formula (17).

[0194] (2) When other small predators attack zebras, the zebras will choose an attack strategy; use mode S2 in formula (17) to model this strategy:

[0195] (17)

[0196] (18)

[0197] in, Indicates the second stage Only zebra The latest position of the dimension value, Indicates Only zebra The location of the dimension value, R is a constant of 0.01, r is a random number between [0, 1], t is the current iteration number, T is the maximum number of iterations, is the switching probability between the two strategies, and its value is a random number between [0, 1]. The state of the zebra being attacked. I is a random value belonging to the set {1, 2}, It is the pioneer zebra position, Indicates i The new position of the zebra in the defense phase, represents the Pioneer Zebra objective function value, Represents the new objective function value of Pioneer Zebra.

[0198] S603. When updating the position of the zebra, if the objective function of the zebra in the new position has a better value, the new position is accepted. The new position is the hyperparameter of the GAT-DLinear model. The update condition is modeled using formula (19):

[0199] (19)

[0200] in, Indicates i The new position of the zebra after the update, represents the Pioneer Zebra objective function value, Represents the new objective function value of Pioneer Zebra

[0201] S7. Use the GAT-DLinear model after hyperparameter optimization to train water use data to achieve the effect of dynamically and automatically adjusting water demand data according to the prediction results. First, after training, use the data of the validation set according to the clustering results to determine whether the prediction accuracy NRMSE is greater than 10%. If it is less than 10%, output the result; if it is greater than the threshold, construct the target equation with the parameters in the prediction model and optimize it again through the IZOA algorithm input into the optimization model, input the optimized hyperparameter set into the prediction model again, and make the next round of prediction for the data of this month by adjusting the model parameters, so as to judge until the requirements are met, and finally output the final water demand prediction results for each partition.

[0202] Specifically, the process includes the following:

[0203] S701, using the data of the validation set to determine whether the prediction accuracy NRMSE is greater than 10%, if it is less than the threshold, output the result; if it is greater than the threshold, perform S702 for optimization;

[0204] S702, re-construct the target equation of the model using the predicted value and the true value. The equation mainly considers the accuracy of the model. The target equation is as follows:

[0205] (20)

[0206] In the formula, N represents the population size, Represents multiple influences included in the water demand forecast model Adjustable parameters, including the attention mechanism matrix of the GAT model , linear transformation weight matrix , the historical time series length and future time series length of the DLinear model;

[0207] S703, using the IZOA algorithm to optimize the target equation MA The adjustable parameters are then used to determine whether the optimized GAT-DLinear model is greater than the threshold. If so, dynamic adjustment is performed.

[0208] S704: until the monthly water demand data of all regions is less than the threshold, the final water demand forecast results of each sub-region are output.

[0209] In order to verify the accuracy of the urban water demand prediction model (DPC-VAE-GAT-DLinear) proposed in the present invention in predicting urban water demand, and to confirm its effectiveness and improvement potential in the field of water demand prediction, a water demand data set of a county in Jixi City, Heilongjiang Province was selected as the research object. The 726 months of residential water demand data collected by the station from January 1959 to June 2018 were used as analysis samples. The DPC-VAE-GAT-DLinear model was successfully constructed using the MATLAB programming language to develop the algorithm, and compared with four other prediction models, namely, extreme learning machine (ELM), long short-term memory network (LSTM), GAT-DLinear and VAE-GAT-DLinear. Through comparative analysis, it was found that the DPC-VAE-GAT-DLinear model provided by the present invention has higher accuracy than the other four models, and has certain advantages in urban water demand prediction. Table 1 shows the evaluation indicators of various different models, including the values ​​of RMSE (root mean square error), MAE (mean absolute error), MAPE (mean absolute percentage error) and NSE (Nash coefficient).

[0210] Table 1 Statistical table of performance indicators of the present invention model and the control group model

[0211] Model RMSE MAE NSE MAPE Long Short-Term Memory (LSTM) 19.594 13.753 0.873 0.048 Extreme Learning Machine (ELM) 18.078 12.640 0.894 0.046 GAT-DLinear 17.010 12.376 0.905 0.048 VAE-GAT-DLinear 15.128 11.160 0.918 0.042 DPC-VAE-IZOA-GAT-DLinear 12.913 9.246 0.952 0.035

[0212] In order to display the error index value more intuitively, Figure 4 The MAE, MAPE, RMSE and NSE values ​​of the five models are shown in bar charts, area charts, vertical bar charts and radar charts. Figure 4 It can be concluded that the DPC-VAE-IZOA-GAT-DLinear model provided by the present invention has the smallest MAPE, MAE and RMSE, which are 12.913, 9.246 and 0.035 respectively, and the largest NSE. In terms of NSE index, the hybrid model index provided by the present invention reaches 0.952, far exceeding GAT-DLinear and other models. In contrast, the long short-term memory network (LSTM) model performed the worst among the five models. In terms of single model prediction, the GAT-DLinear model has better prediction effects than the long short-term memory network (LSTM) model and the extreme learning machine (ELM) model. GAT-DLinear compares the GAT-DLinear and VAE-GAT-DLinear models, showing that VAE feature extraction can effectively improve the model prediction accuracy, and compared with the VAE-GAT-DLinear model, DPC-VAE-IZOA-GAT-DLinear also has a good improvement effect, indicating that the DPC clustering method and IZOA algorithm of the present invention have good effects on water demand prediction.

[0213] In order to more intuitively demonstrate the prediction results of the prediction model provided by the present invention and further verify the effectiveness of the proposed model, Figure 5 A line chart comparing the single-step prediction results and the true value of the DPC-VAE-IZOA-GAT-DLinear prediction model provided by the present invention is given. Figure 5 It can be clearly seen that the water level prediction value is basically consistent with the actual value, which fully proves the effectiveness of the model proposed in this invention.

[0214] The above-mentioned specific implementation methods are used to explain the present invention and are only preferred embodiments of the present invention, rather than limiting the present invention. Any modifications, equivalent substitutions, improvements, etc. made to the present invention within the spirit of the present invention and the protection scope of the claims shall fall within the protection scope of the present invention.

Claims

1. A method for predicting urban water demand based on zoning prediction and dynamic automatic adjustment, characterized in that: The following steps are involved: S1. Obtain the daily water consumption of urban residents, store water data, upload water data to the cloud, obtain residents' water consumption in the cloud, and divide the original data into three parts; S2. Use the average monthly water consumption as the basis for the division of the pre-processed historical water consumption data to perform DPC clustering on the historical water consumption data of multiple areas in the city, and cluster these areas into three categories: large change trend, small change trend, and stable change; S3, perform VAE feature selection on all residential water use data clustered into three types of areas in S2, and perform Pearson correlation analysis on the influencing factors affecting residential water use, including temperature, water price, consumption level, washing time, and population size; S4, construct the GAT-DLinear model based on the key influencing factors extracted by the Pearson correlation analysis in S3 and the three types of residential water use data, and use the GAT-DLinear model to train the water use data; S5, using Bernoulli chaotic mapping and polynomial mutation operator to improve the zebra optimization algorithm; S6. Optimizing the hyperparameters of the GAT-DLinear model using an improved zebra optimization algorithm, wherein the hyperparameters include a learning rate, a number of graph attention layers, and a hidden layer dimension; S7. Use the GAT-DLinear model after hyperparameter optimization to train the water use data to achieve the effect of dynamically and automatically adjusting the water demand data according to the prediction results. First, after training, use the data of the validation set according to the clustering results to determine whether the prediction accuracy NRMSE is greater than 10%. If less than 10%, the result is output; if greater than the threshold, the parameters in the prediction model are used to construct the target equation and then optimized by the IZOA algorithm and input into the optimization model again. The optimized hyperparameter set is input into the prediction model again, and the next round of prediction of the data for this month is made by adjusting the model parameters to determine until the requirements are met, and finally the final water demand prediction results of each partition are output; Step S4 specifically includes the following process: S401. When using the graph attention network model to predict residents' water demand, first input data, the input data includes static data and dynamic data, wherein the static data includes location information of different areas of the city, and the dynamic data includes key influencing factors of residents' water demand at each location screened after Pearson correlation analysis; S402: Construct an attribute graph G(V,E) to capture the dynamic characteristics of residential water use data in time and space, where V represents the node of the attribute graph and E represents the edge of the attribute graph; the water use location is represented as a graph node, and each node V i It has an associated static feature vector and a set of dynamic features in the form of a matrix, the former containing position information and the latter containing S types of key influencing factors; S403, modeling and defining the geographical proximity between different water use areas, and describing the connection between nodes by edge weights; after inputting the above information, using the ReLU activation function to calculate the attention weight Use Softmax function combined Calculating attention score Then we can define the weight W of the edge between nodes i and j i,j It is expressed as follows: Where dist(i,j) represents the geographical distance between water use location i and water use location j; σ represents the standard deviation of the distance between n water use areas; ε is the threshold. If the distance is less than the threshold, it is assumed that the two water use areas are not connected to ensure the sparsity of the graph structure. S404, Spatial Dependency Modeling. Spatial correlation is a key issue in predicting water consumption data of residents in various regions. By considering spatial similarity, the proposed model can evaluate the changes in water consumption of residents in similar locations, thereby more accurately predicting the water demand of residents in various regions. Specifically, a multi-layer graph attention network GAT is used to extract spatiotemporal features from the attribute graph. Each position receives information from adjacent positions based on similarity, and the embedded information of each node is updated by aggregating adjacent nodes. At the tth time step, the input of node i is expressed as Where M represents the time step of the input window, Q represents the region where the node i is located, and S represents the S-type key influencing factors. The specific steps are as follows: S40401, inputting historical features into the attribute graph; S40402. Apply the graph attention mechanism to calculate the attention value of each node, expressed as in, represents the domain where node i is located, O z is the output dimension of the GAT layer; a multi-head mechanism is used to calculate independent attention scores in order to calculate The attention weight of the kth head between node i and node j The calculation is as follows: Where LeakyReLU(·) represents the LeakyReLU activation function, is the attention matrix of the kth head; is the linear transformation weight matrix of the kth head, converting the input dimension into the output dimension; Represents a serial operation, Respectively represent the input of node i and node j at the tth time step; S40403. Calculate attention score The expression is as follows: Among them, softmax is the activation function, is the attention weight of the kth head between node i and node j, represents the attention weight of the kth head between node i and node n. Each edge of node i has an attention score score, which is used to evaluate how much information should be aggregated from the neighboring node j; S40404. Add all embedding vectors from multiple heads to establish the final representation of node i as follows: in, represents all embedded information of node i, C is the number of heads, K is the independent attention score, N is the number of nodes, is the linear transformation weight matrix of the kth head, represents the input of node i; S405, using the spatial feature information of the water use area extracted by GAT from the attribute graph as the input of the DLinear model, and establishing a graph model for the water use data problem. The multi-layer graph attention network uses the characteristics of assigning different weights to different nodes, and updates the vector representation of each node by paying attention to the features of the neighboring nodes of each node to extract the graph information; S406, DLinear model decomposes the time series into trend series and residual series, and then uses two single-layer linear networks to model the two series to complete the prediction task. For a time series containing D variables, the historical data E is used to predict the future data. S407, DLinear model first decomposes historical time series data into trend data and the remaining data E s =EE t Two parts, and then apply a single-layer linear network to the two decomposed sequences respectively: Among them, ξ s ,ξ t is the weight of a single-layer linear network, is the domain of the linear network, L and are the length of historical time series and the length of future time series respectively; E s and E t Represents the value of the variable at the time step; S408, the final output is the sum of the output results of the two single-layer linear networks:

2. The method according to claim 1, characterized in that Step S1 specifically includes the following process: S101, use the flow meter to record the daily water consumption of residents, then connect to the STM32 microcontroller to store the data through the microcontroller; S102, connecting the stored residential water use data to Alibaba Cloud through the wireless communication function of the ESP8266 chip, and uploading the residential water use data to the cloud so that the data can be obtained anytime and anywhere in the cloud; S103, dividing the acquired raw data into three parts, namely 60% training set, 20% validation set and 20% test set, wherein the training set is used for model construction, the validation set is used for component selection for further decomposition and hyperparameter selection, and the test set is used for model verification.

3. The method according to claim 1, characterized in that Step S2 specifically includes the following process: S201, when calculating the dynamic K value, first calculate the water samples x of the two areas i and x j The Euclidean distance between them forms the distance matrix L n×n , and then find a point x that satisfies the following conditions i : dist(x i ,x j )≤(1+η)*dist(x i ,x1) (1) Among them, dist(x i ,x j ) represents two water samples x i and x j The Euclidean distance between them, x1 is the distance x i The nearest point, η is the adjustment coefficient, and all points that meet the above conditions are x i Dynamic K nearest neighbors; S202: When performing local density calculation, dynamic K nearest neighbors are introduced to calculate the local density p of the sample point. i , the calculation formula is as follows: Where PK(i) is the point x i The dynamic K nearest neighbors, β is the similarity coefficient, d ij It is point x i and x j The distance between them, σ = n / 100; S203, calculate relative distance δ i , δ i is the sample point x i The distance to a point that is higher in density and closer than the local density is as shown in formula (3): Among them, max(d ij ), min(d ij ) represents x i and x j The maximum and minimum distance between i is x i Point local density, p j is x j The local density of the point, max(p) represents the maximum local density of the sample; S204, select its cluster center, specifically calculate x i The decision value of γ i The maximum change rate of the 50 sample points. The point with the maximum change rate q is the dividing value γ between the cluster center and the non-cluster center p , select γ i Value greater than γ p The point is taken as the cluster center point, where γ i =p i ·δ i ; S205, after finding the cluster center, classify the non-cluster center points into one category with the corresponding cluster center points based on the dynamic K nearest neighbors and cluster center distance factors; S206, the remaining points are allocated to the cluster with higher local density closest to them. After all the data are divided, DPC clustering is completed, and these areas of the city are clustered into three categories: large change trend, small change trend and stable change.

4. The method according to claim 1, characterized in that: Step S3 specifically includes the following process: S301, respectively encode the three types of water consumption data, wherein the encoder includes four convolutional layers, and a fully connected layer with 256 neurons is connected after the convolutional layer; S302, decoding the encoded data, the decoder input dimension is 10, which also includes a fully connected layer with 256 neurons; S303, gradient back propagation: The loss function is calculated by decoding the output data and the input original data, and the network weights are updated by back propagation. The network weights are initialized using the Glorot uniform distribution method. After repeated training, the decoder learns the mapping law of the data. S304, generate data, that is, extract the decoder as the VAE generation model, extract a set of feature vectors from the Gaussian distribution as the model input, and obtain new data after feature extraction that conforms to the probability distribution of the training data set, determine the input dimension of each variable, and obtain the eigenvalues ​​and eigenvectors of the covariance matrix to calculate the correlation of the variables; S305, respectively conduct Pearson correlation analysis with the influencing factors of each type of data, the influencing factors include temperature, water price, consumption level, washing time, and population size. The Pearson correlation analysis is shown in formula (4): Among them, cov(μ,ν) is the covariance of variables μ,ν, σ μ , σ ν are the standard deviations of the variables μ and ν, are the expectations of variables μ,ν respectively; S306. For each type of influencing factor, the key influencing factors of the data are extracted by calculating the Pearson correlation coefficient. μν Those greater than 0.7 are retained as key influencing factors, and those less than 0.7 are deleted; S307, clustering the water use data into three types and extracting the key influencing factors to construct a GAT-DLinear model.

5. The method according to claim 1, characterized in that Step S5 specifically includes the following process: S501: The ZOA algorithm is initialized and improved by using Bernoulli chaotic mapping to improve the global search and optimization capabilities of the algorithm. The expression of Bernoulli chaotic mapping is as follows: Among them, b k is the current value of the kth generation chaotic sequence, λ is the control parameter, and better ergodicity can be obtained when λ is around 0.5; S502: In order to further improve the global search capability and solution diversity of the algorithm, a polynomial mutation operator is introduced into the algorithm to expand the search range, so that it has a certain local random search capability. A polynomial mutation operator is introduced into the zebra optimal position in the ZOA algorithm. The formula is as follows: b k+1 =b k +q·(u k -l k ) (13) Where q is as follows: Where: q is the variation operator of the zebra's optimal position; b k is the optimal individual position before mutation; b k+1 is the optimal individual position after mutation; u k , l k are the upper and lower limits of the position respectively; u is a random number between [0, 1]; η is the distribution index; q1, q2 are mutation operators, q1 = (b k -l k ) / (u k -l k ), q2=(u k -b k ) / (u k -l k ).

6. The method according to claim 1, characterized in that Step S6 specifically includes the following process: S601. In the first stage, the population members are updated according to the simulation of zebra behavior when searching for food; in IZOA, the best member of the population is considered to be the pioneer zebra and leads other population members to its position in the search space. Therefore, the position update of zebras in the foraging stage can be modeled using formulas (15) and (16): in, represents the latest position of the β-dimensional value of the αth zebra, b α,β represents the position of the β-dimensional value of the αth zebra, pZ β is the β-dimensional value of the optimal zebra with the lowest current fitness, I is a random value belonging to the set {1, 2}, and rand is a random number between [0, 1]; B i It is the pioneer zebra position, represents the new position of the i-th zebra in the foraging phase, F i represents the Pioneer Zebra objective function value, F i new,P1 Represents the new objective function value of Pioneer Zebra; S602. In the second stage, the defense strategy of zebras against predator attacks is simulated to update the positions of IZOA population members in the search space. In the IZOA design, it is assumed that one of the following two situations occurs with the same probability: (1) The lion attacks the zebra, so the zebra chooses the escape strategy. In the first strategy, when the zebra is attacked by the lion, the mode S1 in formula (17) can be used to model the strategy. (2) When other small predators attack zebras, the zebras will choose an attack strategy. The strategy is modeled using the mode S2 in formula (17): in, represents the latest position of the β-dimensional value of the αth zebra in the second stage, b α,β represents the position of the β-dimensional value of the αth zebra, R is a constant of 0.01, r is a random number between [0, 1], t is the current iteration number, T is the maximum iteration number, P s is the switching probability between the two strategies, and its value is a random number between [0, 1], AZ β is the state of the attacked zebra, I is a random value belonging to the set {1, 2}, B i It is the pioneer zebra position, represents the new position of the i-th zebra in the defense phase, F i represents the Pioneer Zebra objective function value, F i new,P2 Represents the new objective function value of Pioneer Zebra; S603. When updating the position of the zebra, if the objective function of the zebra in the new position has a better value, the new position is accepted. The new position is the hyperparameter of the GAT-DLinear model. The update condition is modeled using formula (19): in, represents the new position of the i-th updated zebra, F i represents the Pioneer Zebra objective function value, F i new,P3 Represents the new objective function value of Pioneer Zebra.

7. The method according to claim 1, characterized in that Step S7 specifically includes the following process: S701, using the data of the validation set to determine whether the prediction accuracy NRMSE is greater than 10%, if less than the threshold, output the result; if greater than the threshold, perform S702 for optimization; S702, re-construct the target equation of the model using the predicted value and the true value. The equation mainly considers the accuracy of the model. The target equation is as follows: In the formula, N represents the population size, y pre Represents the multiple impacts y included in the water demand prediction model pre Adjustable parameters, including the attention mechanism matrix of the GAT model Linear transformation weight matrix W z k , the historical time series length and future time series length of the DLinear model; S703, using the IZOA algorithm to optimize the y in the target equation MA pre The adjustable parameters are then used to determine whether the optimized GAT-DLinear model is greater than the threshold. If so, dynamic adjustment is performed. S704: until the monthly water demand data of all regions is less than the threshold, the final water demand forecast results of each sub-region are output.

8. An urban water demand forecasting system based on zoning forecasting and dynamic automatic adjustment, characterized in that: Includes the following modules: A data acquisition module, which is used to obtain the daily water consumption of urban residents and divide the original data into three parts; A cluster analysis module, which is used to perform DPC clustering on the historical water use data of multiple areas in the city using the average monthly water use as the basis for division of the pre-processed historical water use data, and cluster these areas into three categories: large change trend, small change trend and stable change; A correlation analysis module, which is used to perform VAE feature selection on all residential water use data of the three types of areas clustered by the cluster analysis module, and to perform Pearson correlation analysis on the influencing factors affecting residential water use, including temperature, water price, consumption level, washing time, and population; A GAT-DLinear model construction module, wherein the GAT-DLinear model construction module is used to construct a GAT-DLinear model based on the key influencing factors extracted by the correlation analysis module and three types of residential water use data, and use the GAT-DLinear model to train the water use data; The specific execution process of the GAT-DLinear model building module is as follows: S401. When using the graph attention network model to predict residents' water demand, first input data, the input data includes static data and dynamic data, wherein the static data includes location information of different areas of the city, and the dynamic data includes key influencing factors of residents' water demand at each location screened after Pearson correlation analysis; S402: Construct an attribute graph G(V,E) to capture the dynamic characteristics of residential water use data in time and space, where V represents the node of the attribute graph and E represents the edge of the attribute graph; the water use location is represented as a graph node, and each node V i It has an associated static feature vector and a set of dynamic features in the form of a matrix, the former containing position information and the latter containing S types of key influencing factors; S403, modeling and defining the geographical proximity between different water use areas, and describing the connection between nodes with edge weights; after inputting the above information, using the ReLU activation function to calculate the attention weight Use Softmax function combined Calculating attention score Then we can define the weight W of the edge between nodes i and j i,j It is expressed as follows: Where dist(i,j) represents the geographical distance between water use location i and water use location j; σ represents the standard deviation of the distance between n water use areas; ε is the threshold. If the distance is less than the threshold, it is assumed that the two water use areas are not connected to ensure the sparsity of the graph structure. S404, Spatial Dependency Modeling. Spatial correlation is a key issue in predicting water consumption data of residents in various regions. By considering spatial similarity, the proposed model can evaluate the changes in water consumption of residents in similar locations, thereby more accurately predicting the water demand of residents in various regions. Specifically, a multi-layer graph attention network GAT is used to extract spatiotemporal features from the attribute graph. Each position receives information from adjacent positions based on similarity, and the embedded information of each node is updated by aggregating adjacent nodes. At the tth time step, the input of node i is expressed as Where M represents the time step of the input window, Q represents the region where the node i is located, and S represents the S-type key influencing factors. The specific steps are as follows: S40401, inputting historical features into the attribute graph; S40402. Apply the graph attention mechanism to calculate the attention value of each node, expressed as in, represents the domain where node i is located, O z is the output dimension of the GAT layer; a multi-head mechanism is used to calculate independent attention scores in order to calculate z t i , the attention weight of the kth head between node i and node j The calculation is as follows: Where LeakyReLU(·) represents the LeakyReLU activation function, is the attention matrix of the kth head; is the linear transformation weight matrix of the kth head, converting the input dimension into the output dimension; Represents a serial operation, Respectively represent the input of node i and node j at the tth time step; S40403. Calculate attention score The expression is as follows: Among them, softmax is the activation function, is the attention weight of the kth head between node i and node j, represents the attention weight of the kth head between node i and node n. Each edge of node i has an attention score score, which is used to evaluate how much information should be aggregated from the neighboring node j; S40404. Add all embedding vectors from multiple heads to establish the final representation of node i as follows: in, represents all embedded information of node i, C is the number of heads, K is the independent attention score, N is the number of nodes, is the linear transformation weight matrix of the kth head, represents the input of node i; S405, using the spatial feature information of the water use area extracted by GAT from the attribute graph as the input of the DLinear model, and establishing a graph model for the water use data problem. The multi-layer graph attention network uses the characteristics of assigning different weights to different nodes, and updates the vector representation of each node by paying attention to the features of the neighboring nodes of each node to extract the graph information; S406, DLinear model decomposes the time series into trend series and residual series, and then uses two single-layer linear networks to model the two series to complete the prediction task. For a time series containing D variables, the historical data E is used to predict the future data. S407, DLinear model first decomposes historical time series data into trend data and the remaining data E s =EE t Two parts, and then apply a single-layer linear network to the two decomposed sequences respectively: Among them, ξ s ,ξ t is the weight of a single-layer linear network, is the domain of the linear network, L and are the length of historical time series and the length of future time series respectively; E s and E t Represents the value of the variable at the time step; S408, the final output is the sum of the output results of the two single-layer linear networks: A zebra optimization algorithm improvement module, wherein the zebra optimization algorithm improvement module uses Bernoulli chaotic mapping and polynomial mutation operators to improve the zebra optimization algorithm; A hyperparameter optimization module, wherein the hyperparameter optimization module is used to optimize the hyperparameters of the GAT-DLinear model using the zebra optimization algorithm improved by the zebra optimization algorithm improvement module, wherein the hyperparameters include a learning rate, a number of graph attention layers, and a hidden layer dimension; A water demand prediction module is used to train water use data using the GAT-DLinear model optimized by the hyperparameter optimization module. After training, the data of the validation set is used to determine whether the prediction accuracy NRMSE is greater than 10% according to the clustering results. If it is less than 10%, the result is output; if it is greater than the threshold, the parameters in the prediction model are used to construct the target equation and the input optimization model is optimized again through the IZO A algorithm. The optimized hyperparameter set is input into the prediction model again, and the next round of prediction of the data for this month is carried out by adjusting the model parameters until the requirements are met, and finally the final water demand prediction results of each partition are output.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the urban water demand prediction method based on zoning prediction and dynamic automatic adjustment as described in any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Distributed energy system optimal configuration method based on improved zebra optimization algorithm

    CN117892959A