Urban water consumption prediction method, system, equipment and medium based on transfer learning
By using a method based on transfer learning to predict urban water consumption, it solves the problem of prediction inaccuracy caused by differences in water use patterns and geographical distribution, and improves the applicability and accuracy of water consumption prediction.
Patent Information
- Application Number
- CN202410879620.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-02
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-07-02
AI Technical Summary
Existing urban water consumption prediction methods are not universal in different water use patterns and geographical distribution, resulting in insufficient prediction accuracy and applicability.
Using a method based on transfer learning, the source city and the target city are gridded to construct a first-level source domain and a first-level target domain, to obtain pipeline flow thresholds and node pressure thresholds, and combine historical water consumption data and influencing factor data to construct Develop a water consumption prediction model and train the model by matching pipeline constraints and water consumption losses in the source domain and target domain to improve the applicability and accuracy of the model.
It improves the regional applicability and accuracy of the water consumption prediction model, can more effectively handle different water use patterns and regional differences, and enhances the reliability of water consumption prediction.
Smart Images

Figure CN118428560B
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of water consumption prediction, and in particular to a method, system, device and medium for predicting urban water consumption based on transfer learning. Background Art
[0002] With the acceleration of urbanization and the continuous growth of population, the water demand of different water use modes (such as domestic water and industrial water) is also changing. Therefore, accurate prediction of urban water consumption is of great significance for urban water supply allocation and control, water resources management and water conservation.
[0003] At present, there are various methods for predicting urban water consumption, including time series analysis, regression analysis, machine learning, etc. Among them, machine learning can efficiently process and analyze a large amount of historical water use data and influencing factor data to predict water demand by constructing a water consumption prediction model. However, in practical applications, due to differences in water use patterns in different regions, such as some regions may be dominated by domestic water use, while other regions may have a large proportion of industrial water use, resulting in differences in the performance of water consumption prediction models under different water use patterns. In addition, since water consumption is affected by multiple factors such as industrial structure distribution, population distribution, seasonal precipitation, temperature changes, holidays, etc., and these factors may vary due to regional changes, the performance of water consumption prediction models in different regions may also vary.
[0004] Therefore, how to overcome the defect that water consumption prediction is not completely universal in terms of water consumption patterns and geographical distribution, and improve the prediction accuracy and applicability of urban water consumption has become a technical problem that needs to be urgently solved by technical personnel in this field. Summary of the invention
[0005] Based on this, it is necessary to provide a method, system, equipment and medium for predicting urban water consumption based on transfer learning to address the above technical problems.
[0006] A method for predicting urban water consumption based on transfer learning, the method comprising:
[0007] The source city and the target city are divided according to the set grid size to obtain multiple first-level source domains and first-level target domains;
[0008] Collect and obtain the pipeline flow threshold and pipeline node pressure threshold of the water supply network of each primary source domain and primary target domain, and construct the pipeline constraints of the primary source domain and the primary target domain respectively according to the pipeline flow threshold and pipeline node pressure threshold;
[0009] Collect and obtain historical water consumption data and influencing factor data of different water consumption modes in the water supply network of each primary source domain and primary target domain within a set time period, and obtain historical water consumption sequences and corresponding influencing factor sequences of different water consumption modes in the primary source domain and primary target domain by preprocessing the data; the water consumption modes include domestic water use and industrial water use;
[0010] By calculating the maximum mean difference between the historical water consumption series of any first-level source domain and any first-level target domain, a first-level source domain with the minimum maximum mean difference is determined for each first-level target domain as the matching source domain;
[0011] A water consumption prediction model is constructed for each matching source domain, and the historical water consumption sequences of different water consumption modes in the matching source domain and the corresponding influencing factor sequences are input into the water consumption prediction model for water consumption prediction. A first-class loss function is constructed based on the pipeline constraints and water consumption prediction losses of the matching source domain to train the water consumption prediction model, and a water consumption prediction model trained in the matching source domain is obtained; wherein the water consumption prediction model includes a domestic water consumption prediction model and an industrial water consumption prediction model;
[0012] The water consumption prediction model trained in the matching source domain is used as the initial water consumption prediction model of the first-level target domain corresponding to the matching source domain. The historical water consumption sequences of different water consumption modes in the first-level target domain and the corresponding influencing factor sequences are input into the initial water consumption prediction model for water consumption prediction. Based on the pipeline constraints and water consumption prediction losses of the first-level target domain, a second type of loss function is constructed to train the initial water consumption prediction model to obtain the water consumption prediction model trained in the first-level target domain. The water consumption of different water consumption modes in the first-level target domain within the target time is predicted based on the water consumption prediction model trained in the first-level target domain.
[0013] In one embodiment, the pipeline flow threshold and pipeline node pressure threshold of the water supply network of each primary source domain and primary target domain are collected and obtained, and the pipeline constraints of the primary source domain and the primary target domain are respectively constructed according to the pipeline flow threshold and the pipeline node pressure threshold, including:
[0014] The pipeline flow threshold and pipeline node pressure threshold of the water supply network of each primary source domain are collected and obtained, and the penalty function is used to define the pipeline flow threshold constraint and pipeline node pressure threshold constraint in the primary source domain respectively, and the pipeline constraint of the primary source domain is constructed, which is expressed as
[0015] ;
[0016] in, is the pipeline flow threshold constraint penalty function of the primary source domain, is the pipeline node pressure threshold constraint penalty function of the primary source domain, is the water supply pipeline collection of the primary source area, The first source domain The flow rate of a pipeline, The first source domain The maximum flow rate of a pipeline, The first source domain The minimum flow rate of a pipe, is the set of pipeline nodes in the first-level source domain, The first source domain The pressure at each pipeline node, The first source domain The maximum pressure of a pipeline node, The first source domain Minimum pressure of a pipeline node;
[0017] The pipeline flow threshold and pipeline node pressure threshold of the water supply network in each primary target domain are collected and obtained, and the penalty function is used to define the pipeline flow threshold constraint and pipeline node pressure threshold constraint in the primary target domain respectively, and the pipeline constraint of the primary target domain is constructed, which is expressed as
[0018] ;
[0019] in, is the pipeline flow threshold constraint penalty function of the first-level target domain, is the pipeline node pressure threshold constraint penalty function of the primary target domain, is the water supply pipeline set of the first-level target domain, The first target domain The flow rate of a pipeline, The first target domain The maximum flow rate of a pipeline, The first target domain The minimum flow rate of a pipe, is the pipeline node set of the first-level target domain, The first target domain The pressure at each pipeline node, The first target domain The maximum pressure of a pipeline node, The first target domain The minimum pressure at a pipeline node.
[0020] In one embodiment, historical water consumption data and influencing factor data of different water consumption modes in a set time period in the water supply network of each primary source domain and primary target domain are collected and obtained, and the historical water consumption sequence and the corresponding influencing factor sequence of different water consumption modes in the primary source domain and the primary target domain are obtained by preprocessing the data, including:
[0021] Collect and obtain historical domestic water consumption data and corresponding domestic water influencing factor data as well as historical industrial water consumption data and corresponding industrial water influencing factor data in the water supply network of each primary source domain and primary target domain within a set time period, and perform data cleaning;
[0022] The historical domestic water consumption data and the corresponding domestic water consumption influencing factor data in the primary source domain and the primary target domain are divided in chronological order with a set time step, and time-aligned based on a set time reference, to obtain a time-aligned historical domestic water consumption sequence and a corresponding domestic water consumption influencing factor sequence in the primary source domain and the primary target domain;
[0023] The historical industrial water consumption data and the corresponding industrial water use influencing factor data in the primary source domain and the primary target domain are divided in chronological order with a set time step, and time alignment is performed based on the set time reference to obtain the time-aligned historical industrial water consumption sequence and the corresponding industrial water use influencing factor sequence in the primary source domain and the primary target domain.
[0024] In one embodiment, by calculating the maximum mean difference of the historical water consumption series between any first-level source domain and any first-level target domain, a first-level source domain with the minimum maximum mean difference is determined for each first-level target domain as the matching source domain, including:
[0025] Calculate the mean difference of historical domestic water consumption in any first-level source domain and any first-level target domain within the same time step, and traverse all time steps to obtain the maximum mean difference of historical domestic water consumption series between any first-level source domain and any first-level target domain;
[0026] Calculate the mean difference of historical industrial water consumption in any first-level source domain and any first-level target domain within the same time step, and traverse all time steps to obtain the maximum mean difference of historical industrial water consumption series between any first-level source domain and any first-level target domain;
[0027] By combining and minimizing the maximum mean difference of the historical domestic water consumption series and the maximum mean difference of the historical industrial water consumption series, a first-level source domain with the smallest maximum mean difference after combination is determined for each first-level target domain as the matching source domain.
[0028] In one embodiment, a water consumption prediction model is constructed for each matching source domain, and the historical water consumption sequence of different water consumption modes in the matching source domain and the corresponding influencing factor sequence are input into the water consumption prediction model to predict water consumption, and a first-class loss function is constructed based on the pipeline constraint and water consumption prediction loss of the matching source domain to train the water consumption prediction model, so as to obtain a water consumption prediction model trained for the matching source domain, including:
[0029] A water consumption prediction model is constructed for each matching source domain, including a domestic water consumption prediction model and an industrial water consumption prediction model;
[0030] The time-aligned historical domestic water consumption sequence and the corresponding domestic water consumption influencing factor sequence in the matching source domain are input into the domestic water consumption prediction model to predict domestic water consumption, and the time-aligned historical industrial water consumption sequence and the corresponding industrial water consumption influencing factor sequence in the matching source domain are input into the industrial water consumption prediction model to predict industrial water consumption;
[0031] Pipeline constraints based on matching source domains , Match the predicted loss of domestic water consumption in the source domain and predicted losses of industrial water use matching the source domain The first type of loss function is constructed, and the water consumption prediction model is trained according to the first type of loss function until the preset number of training times is reached to obtain the water consumption prediction model trained in the matching source domain; wherein the first type of loss function is expressed as
[0032] ;
[0033] in, is a hyperparameter that adjusts the ratio between the pipeline constraints matching the source domain and the water consumption prediction loss, and .
[0034] In one of the embodiments, the network structures of the domestic water consumption prediction model and the industrial water consumption prediction model are consistent, and both consist of a first feature extraction layer, a second feature extraction layer, a cross attention layer, and an output layer;
[0035] Among them, the first feature extraction layer and the second feature extraction layer are used to extract the temporal and spatial distribution characteristics of the input historical water consumption sequence and the corresponding influencing factor sequence, respectively, and the first feature extraction layer and the second feature extraction layer are both composed of an LSTM layer and a CNN layer;
[0036] The cross attention layer is used to fuse the spatiotemporal distribution features output by the first feature extraction layer and the second feature extraction layer using the cross attention mechanism to obtain fused features;
[0037] The output layer is used to perform linear regression on the fused features using an activation function to obtain the predicted water consumption sequence.
[0038] In one embodiment, the water consumption prediction model trained in the matching source domain is used as the initial water consumption prediction model of the primary target domain corresponding to the matching source domain, the historical water consumption sequence of different water consumption modes in the primary target domain and the corresponding influencing factor sequence are input into the initial water consumption prediction model for water consumption prediction, and a second type of loss function is constructed based on the pipeline constraint and water consumption prediction loss of the primary target domain to train the initial water consumption prediction model, and the water consumption prediction model trained in the primary target domain is obtained, and the water consumption of different water consumption modes in the primary target domain within the target time is predicted according to the water consumption prediction model trained in the primary target domain, including:
[0039] The water consumption prediction model trained in the matching source domain is used as the initial water consumption prediction model of the first-level target domain corresponding to the matching source domain; wherein the initial water consumption prediction model includes an initial domestic water consumption prediction model and an initial industrial water consumption prediction model;
[0040] Input the time-aligned historical domestic water consumption sequence and the corresponding domestic water consumption influencing factor sequence in the primary target domain into the initial domestic water consumption prediction model to predict domestic water consumption, and input the time-aligned historical industrial water consumption sequence and the corresponding industrial water consumption influencing factor sequence in the primary target domain into the initial industrial water consumption prediction model to predict industrial water consumption;
[0041] Pipeline constraints based on primary target domain , Prediction of loss of domestic water consumption in the first-level target area And the predicted loss of industrial water consumption in the first-level target domain The second type of loss function is constructed, and the initial water consumption prediction model is trained according to the second type of loss function until the preset number of training times is reached, and the water consumption prediction model trained in the first-level target domain is trained, and the predicted domestic water consumption sequence and the predicted industrial water consumption sequence of the first-level target domain within the target time are predicted according to the water consumption prediction model trained in the first-level target domain; wherein, the second type of loss function is expressed as
[0042] ;
[0043] in, is a hyperparameter that adjusts the ratio between the pipeline constraint and the water consumption prediction loss in the primary objective domain, and .
[0044] A system for predicting urban water consumption based on transfer learning, the system comprising:
[0045] A grid division module is used to divide the source city and the target city according to the set grid size to obtain multiple first-level source domains and first-level target domains;
[0046] The pipeline constraint module is used to collect and obtain the pipeline flow threshold and pipeline node pressure threshold of the water supply network of each primary source domain and primary target domain, and construct the pipeline constraints of the primary source domain and the primary target domain respectively according to the pipeline flow threshold and pipeline node pressure threshold;
[0047] The data preprocessing module is used to collect and obtain the historical water consumption data and influencing factor data of different water consumption modes in the water supply network of each primary source domain and primary target domain within a set time period, and obtain the historical water consumption sequence and corresponding influencing factor sequence of different water consumption modes in the primary source domain and primary target domain by preprocessing the data; wherein the water consumption mode includes domestic water and industrial water;
[0048] A matching module is used to determine a first-level source domain with the smallest maximum mean difference as a matching source domain for each first-level target domain by calculating the maximum mean difference between the historical water consumption series of any first-level source domain and any first-level target domain;
[0049] A source domain training module is used to construct a water consumption prediction model for each matching source domain, input the historical water consumption sequence of different water consumption modes in the matching source domain and the corresponding influencing factor sequence into the water consumption prediction model for water consumption prediction, and construct a first-class loss function based on the pipeline constraint and water consumption prediction loss of the matching source domain to train the water consumption prediction model, so as to obtain a water consumption prediction model trained in the matching source domain; wherein the water consumption prediction model includes a domestic water consumption prediction model and an industrial water consumption prediction model;
[0050] The migration prediction module uses the water consumption prediction model trained in the matching source domain as the initial water consumption prediction model of the first-level target domain corresponding to the matching source domain, inputs the historical water consumption sequence of different water consumption modes in the first-level target domain and the corresponding influencing factor sequence into the initial water consumption prediction model for water consumption prediction, and constructs a second type of loss function based on the pipeline constraints and water consumption prediction losses of the first-level target domain to train the initial water consumption prediction model, and obtains the water consumption prediction model trained in the first-level target domain, and predicts the water consumption of different water consumption modes in the first-level target domain within the target time according to the water consumption prediction model trained in the first-level target domain.
[0051] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0052] The source city and the target city are divided according to the set grid size to obtain multiple first-level source domains and first-level target domains;
[0053] Collect and obtain the pipeline flow threshold and pipeline node pressure threshold of the water supply network of each primary source domain and primary target domain, and construct the pipeline constraints of the primary source domain and the primary target domain respectively according to the pipeline flow threshold and pipeline node pressure threshold;
[0054] Collect and obtain historical water consumption data and influencing factor data of different water consumption modes in the water supply network of each primary source domain and primary target domain within a set time period, and obtain historical water consumption sequences and corresponding influencing factor sequences of different water consumption modes in the primary source domain and primary target domain by preprocessing the data; the water consumption modes include domestic water use and industrial water use;
[0055] By calculating the maximum mean difference between the historical water consumption series of any first-level source domain and any first-level target domain, a first-level source domain with the minimum maximum mean difference is determined for each first-level target domain as the matching source domain;
[0056] A water consumption prediction model is constructed for each matching source domain, and the historical water consumption sequences of different water consumption modes in the matching source domain and the corresponding influencing factor sequences are input into the water consumption prediction model for water consumption prediction. A first-class loss function is constructed based on the pipeline constraints and water consumption prediction losses of the matching source domain to train the water consumption prediction model, and a water consumption prediction model trained in the matching source domain is obtained; wherein the water consumption prediction model includes a domestic water consumption prediction model and an industrial water consumption prediction model;
[0057] The water consumption prediction model trained in the matching source domain is used as the initial water consumption prediction model of the first-level target domain corresponding to the matching source domain. The historical water consumption sequences of different water consumption modes in the first-level target domain and the corresponding influencing factor sequences are input into the initial water consumption prediction model for water consumption prediction. Based on the pipeline constraints and water consumption prediction losses of the first-level target domain, a second type of loss function is constructed to train the initial water consumption prediction model to obtain the water consumption prediction model trained in the first-level target domain. The water consumption of different water consumption modes in the first-level target domain within the target time is predicted based on the water consumption prediction model trained in the first-level target domain.
[0058] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0059] The source city and the target city are divided according to the set grid size to obtain multiple first-level source domains and first-level target domains;
[0060] Collect and obtain the pipeline flow threshold and pipeline node pressure threshold of the water supply network of each primary source domain and primary target domain, and construct the pipeline constraints of the primary source domain and the primary target domain respectively according to the pipeline flow threshold and pipeline node pressure threshold;
[0061] Collect and obtain historical water consumption data and influencing factor data of different water consumption modes in the water supply network of each primary source domain and primary target domain within a set time period, and obtain historical water consumption sequences and corresponding influencing factor sequences of different water consumption modes in the primary source domain and primary target domain by preprocessing the data; the water consumption modes include domestic water use and industrial water use;
[0062] By calculating the maximum mean difference between the historical water consumption series of any first-level source domain and any first-level target domain, a first-level source domain with the minimum maximum mean difference is determined for each first-level target domain as the matching source domain;
[0063] A water consumption prediction model is constructed for each matching source domain, and the historical water consumption sequences of different water consumption modes in the matching source domain and the corresponding influencing factor sequences are input into the water consumption prediction model for water consumption prediction. A first-class loss function is constructed based on the pipeline constraints and water consumption prediction losses of the matching source domain to train the water consumption prediction model, and a water consumption prediction model trained in the matching source domain is obtained; wherein the water consumption prediction model includes a domestic water consumption prediction model and an industrial water consumption prediction model;
[0064] The water consumption prediction model trained in the matching source domain is used as the initial water consumption prediction model of the first-level target domain corresponding to the matching source domain. The historical water consumption sequences of different water consumption modes in the first-level target domain and the corresponding influencing factor sequences are input into the initial water consumption prediction model for water consumption prediction. Based on the pipeline constraints and water consumption prediction losses of the first-level target domain, a second type of loss function is constructed to train the initial water consumption prediction model to obtain the water consumption prediction model trained in the first-level target domain. The water consumption of different water consumption modes in the first-level target domain within the target time is predicted based on the water consumption prediction model trained in the first-level target domain.
[0065] The above-mentioned urban water consumption prediction method, system, device and medium based on transfer learning have the following technical effects compared with the existing technology:
[0066] 1. This application divides the source city and the target city into grids, so that when migrating, there is no need to consider the overall similarity of the city. Only the matching degree between the first-level source domain and the first-level target domain needs to be considered. The water consumption prediction model trained based on the matching source domain can be migrated to the corresponding first-level target domain, thereby improving the regional applicability of the water consumption prediction model.
[0067] 2. This application takes into account the different modes of urban water use, including domestic water and industrial water, and constructs a domestic water consumption prediction model and an industrial water consumption prediction model for each matching source domain for model training and water consumption prediction, thereby improving the applicability of the water consumption prediction model in water use modes.
[0068] 3. This application constructs pipeline constraints by combining the pipeline flow thresholds and pipeline node pressure thresholds of the water supply network of the matching source domain and the primary target domain, and designs a first type of loss function by combining the pipeline constraints of the matching source domain with the water consumption prediction loss. The second type of loss function is designed by combining the pipeline constraints of the primary target domain with the water consumption prediction loss, which are used for model training of the matching source domain and the primary target domain respectively. During the model training process, the pipeline constraints and water consumption prediction losses of different domains are comprehensively considered, making the model training more comprehensive and effective, and improving the accuracy and reliability of water consumption prediction. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] Figure 1 A schematic diagram of a flow chart of a method for predicting urban water consumption based on transfer learning in one embodiment;
[0070] Figure 2 A schematic diagram of the structure of a system for predicting urban water consumption based on transfer learning in one embodiment;
[0071] Figure 3 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0072] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0073] In one embodiment, Figure 1 As shown, a method for predicting urban water consumption based on transfer learning is provided, comprising the following steps:
[0074] Step S1, dividing the source city and the target city according to the set grid size to obtain multiple first-level source domains and first-level target domains.
[0075] Step S2, collecting and acquiring the pipeline flow threshold and pipeline node pressure threshold of the water supply network of each primary source domain and primary target domain, and constructing the pipeline constraints of the primary source domain and the primary target domain respectively according to the pipeline flow threshold and pipeline node pressure threshold.
[0076] Step S3, collect and obtain historical water consumption data and influencing factor data of different water use modes in the water supply network of each primary source domain and primary target domain within a set time period, and obtain historical water consumption sequences and corresponding influencing factor sequences of different water use modes in the primary source domain and primary target domain by preprocessing the data; wherein the water use mode includes domestic water and industrial water.
[0077] Step S4, by calculating the maximum mean difference of the historical water consumption series between any first-level source domain and any first-level target domain, a first-level source domain with the minimum maximum mean difference is determined for each first-level target domain as a matching source domain.
[0078] Step S5, construct a water consumption prediction model for each matching source domain, input the historical water consumption sequence of different water consumption modes in the matching source domain and the corresponding influencing factor sequence into the water consumption prediction model for water consumption prediction, and construct a first-class loss function based on the pipeline constraints and water consumption prediction losses of the matching source domain to train the water consumption prediction model, and obtain a water consumption prediction model trained in the matching source domain; wherein the water consumption prediction model includes a domestic water consumption prediction model and an industrial water consumption prediction model.
[0079] Step S6, using the water consumption prediction model trained in the matching source domain as the initial water consumption prediction model of the first-level target domain corresponding to the matching source domain, inputting the historical water consumption sequence of different water consumption modes in the first-level target domain and the corresponding influencing factor sequence into the initial water consumption prediction model for water consumption prediction, and constructing a second type of loss function based on the pipeline constraints and water consumption prediction losses of the first-level target domain to train the initial water consumption prediction model, and obtaining the water consumption prediction model trained in the first-level target domain, and predicting the water consumption of different water consumption modes in the first-level target domain within the target time according to the water consumption prediction model trained in the first-level target domain.
[0080] In one embodiment, step S2 specifically includes:
[0081] Step S21, collect and obtain the pipeline flow threshold and pipeline node pressure threshold of the water supply network of each primary source domain, and use the penalty function to define the pipeline flow threshold constraint and pipeline node pressure threshold constraint in the primary source domain respectively, and construct the pipeline constraint of the primary source domain, which is expressed as
[0082] ;
[0083] in, is the pipeline flow threshold constraint penalty function of the primary source domain, is the pipeline node pressure threshold constraint penalty function of the primary source domain, is the water supply pipeline collection of the primary source area, The first source domain The flow rate of a pipeline, The first source domain The maximum flow rate of a pipeline, The first source domain The minimum flow rate of a pipe, is the set of pipeline nodes in the first-level source domain, The first source domain The pressure at each pipeline node, The first source domain The maximum pressure of a pipeline node, The first source domain The minimum pressure at a pipeline node.
[0084] Step S22, collect and obtain the pipeline flow threshold and pipeline node pressure threshold of the water supply network of each primary target domain, and use the penalty function to define the pipeline flow threshold constraint and pipeline node pressure threshold constraint in the primary target domain respectively, and construct the pipeline constraint of the primary target domain, which is expressed as
[0085] ;
[0086] in, is the pipeline flow threshold constraint penalty function of the first-level target domain, is the pipeline node pressure threshold constraint penalty function of the primary target domain, is the water supply pipeline set of the first-level target domain, The first target domain The flow rate of a pipeline, The first target domain The maximum flow rate of a pipeline, The first target domain The minimum flow rate of a pipe, is the pipeline node set of the first-level target domain, The first target domain The pressure at each pipeline node, The first target domain The maximum pressure of a pipeline node, The first target domain The minimum pressure at a pipeline node.
[0087] Among them, the penalty function is used to define the pipeline constraints of the first-level source domain and the first-level target domain respectively, so that the pipeline constraints will be minimized during the model training optimization process to ensure that both the pipeline flow threshold constraint and the pipeline node pressure threshold constraint are met. If a constraint is violated, the corresponding penalty function term will increase, thereby promoting the optimization algorithm to find a solution that satisfies all constraints.
[0088] In one embodiment, step S3 specifically includes:
[0089] Step S31, collect and obtain the historical domestic water consumption data and the corresponding domestic water influencing factor data and the historical industrial water consumption data and the corresponding industrial water influencing factor data in the water supply network of each primary source domain and primary target domain within a set time period, and perform data cleaning. Data cleaning includes filling missing or abnormal data, clearing noise data and data format conversion, etc. Data cleaning can effectively improve the quality of water use data, help reduce prediction bias caused by data quality problems, and make the data more accurate and reliable.
[0090] Among them, the data on factors affecting domestic water use include population density, water price, season, holidays, daily maximum temperature, daily minimum temperature, precipitation, humidity, etc. The data on factors affecting industrial water use include industrial structure type, industrial scale, industrial capacity, season, climate factors, etc.
[0091] Step S32, divide the historical domestic water consumption data and the corresponding domestic water consumption influencing factor data in the primary source domain and the primary target domain in chronological order with a set time step, and perform time alignment based on a set time reference to obtain a time-aligned historical domestic water consumption sequence and a corresponding domestic water consumption influencing factor sequence in the primary source domain and the primary target domain.
[0092] Step S33, divide the historical industrial water consumption data and the corresponding industrial water influencing factor data in the primary source domain and the primary target domain in chronological order with a set time step, and perform time alignment based on the set time reference to obtain the time-aligned historical industrial water consumption sequence and the corresponding industrial water influencing factor sequence in the primary source domain and the primary target domain.
[0093] Through the time alignment operation, the historical water consumption data of the same water use mode and its corresponding influencing factor data are guaranteed to have the same time series in different domains, which enhances the consistency and comparability of the source domain and target domain data, eliminates the confusion and errors caused by time differences, and helps to perform subsequent transfer learning from the source domain to the target domain more accurately.
[0094] In one embodiment, step S4 specifically includes:
[0095] Step S41, calculate the mean difference of historical domestic water consumption in any first-level source domain and any first-level target domain within the same time step, and traverse all time steps to obtain the maximum mean difference of the historical domestic water consumption sequence between any first-level source domain and any first-level target domain.
[0096] Step S42, calculate the mean difference of the historical industrial water consumption in any first-level source domain and any first-level target domain within the same time step, and traverse all time steps to obtain the maximum mean difference of the historical industrial water consumption sequence between any first-level source domain and any first-level target domain.
[0097] Step S43, by combining and minimizing the maximum mean difference of the historical domestic water consumption series and the maximum mean difference of the historical industrial water consumption series, a first-level source domain with the smallest combined maximum mean difference is determined for each first-level target domain as a matching source domain.
[0098] It can be understood that by calculating and combining the maximum mean difference of the historical water consumption series of the two water consumption patterns, the similarity of water consumption patterns between different domains can be measured. Selecting the primary source domain with the smallest maximum mean difference after combination as the matching source domain means that the primary source domain with the highest similarity to the water consumption pattern of the primary target domain is selected for transfer learning, which helps to improve the generalization ability of the water consumption prediction model.
[0099] In one embodiment, step S5 specifically includes:
[0100] Step S51: construct a water consumption prediction model for each matching source domain, including a domestic water consumption prediction model and an industrial water consumption prediction model.
[0101] Step S52, input the time-aligned historical domestic water consumption sequence and the corresponding domestic water influencing factor sequence in the matching source domain into the domestic water consumption prediction model to predict domestic water consumption, and input the time-aligned historical industrial water consumption sequence and the corresponding industrial water influencing factor sequence in the matching source domain into the industrial water consumption prediction model to predict industrial water consumption.
[0102] Step S53: Pipeline constraints based on matching source domains , Match the predicted loss of domestic water consumption in the source domain and predicted losses of industrial water use matching the source domain The first type of loss function is constructed, and the water consumption prediction model is trained according to the first type of loss function until the preset number of training times is reached to obtain the water consumption prediction model trained in the matching source domain; wherein the first type of loss function is expressed as
[0103] ;
[0104] in, is a hyperparameter that adjusts the ratio between the pipeline constraints matching the source domain and the water consumption prediction loss, and .
[0105] Specifically, the network structures of the domestic water consumption prediction model and the industrial water consumption prediction model are consistent, both consisting of the first feature extraction layer, the second feature extraction layer, the cross attention layer, and the output layer;
[0106] Among them, the first feature extraction layer and the second feature extraction layer are used to extract the temporal and spatial distribution features of the input historical water consumption sequence and the corresponding influencing factor sequence, respectively, and the first feature extraction layer and the second feature extraction layer are composed of an LSTM (Long Short-Term Memory Network) layer and a CNN (Convolutional Neural Network) layer; the cross attention layer is used to use the cross attention mechanism to fuse the temporal and spatial distribution features output by the first feature extraction layer and the second feature extraction layer to obtain the fused features; the output layer is used to use the activation function to perform linear regression on the fused features to obtain the predicted water consumption sequence. Common activation functions include Sigmod function, Tanh function, and ReLU function.
[0107] In one embodiment, step S6 specifically includes:
[0108] Step S61, using the water consumption prediction model trained in the matching source domain as the initial water consumption prediction model of the primary target domain corresponding to the matching source domain; wherein the initial water consumption prediction model includes an initial domestic water consumption prediction model and an initial industrial water consumption prediction model.
[0109] Step S62, input the time-aligned historical domestic water consumption sequence and the corresponding domestic water consumption influencing factor sequence in the primary target domain into the initial domestic water consumption prediction model to perform domestic water consumption prediction, and input the time-aligned historical industrial water consumption sequence and the corresponding industrial water consumption influencing factor sequence in the primary target domain into the initial industrial water consumption prediction model to perform industrial water consumption prediction.
[0110] Step S63: Pipeline constraints based on the primary target domain , Prediction of loss of domestic water consumption in the first-level target area And the predicted loss of industrial water consumption in the first-level target domain The second type of loss function is constructed, and the initial water consumption prediction model is trained according to the second type of loss function until the preset number of training times is reached, and the water consumption prediction model trained in the first-level target domain is trained, and the predicted domestic water consumption sequence and the predicted industrial water consumption sequence of the first-level target domain within the target time are predicted according to the water consumption prediction model trained in the first-level target domain; wherein, the second type of loss function is expressed as
[0111] ;
[0112] in, is a hyperparameter that adjusts the ratio between the pipeline constraint and the water consumption prediction loss in the primary objective domain, and .
[0113] It should be understood that although Figure 1The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0114] In one embodiment, Figure 2 As shown, a system for predicting urban water consumption based on transfer learning is provided, including:
[0115] The grid division module 201 is used to divide the source city and the target city according to the set grid size to obtain multiple first-level source domains and first-level target domains.
[0116] The pipeline constraint module 202 is used to collect and obtain the pipeline flow threshold value and pipeline node pressure threshold value of the water supply network of each primary source domain and primary target domain, and construct the pipeline constraints of the primary source domain and the primary target domain respectively according to the pipeline flow threshold value and the pipeline node pressure threshold value.
[0117] The data preprocessing module 203 is used to collect and obtain the historical water consumption data and influencing factor data of different water use modes in the water supply network of each primary source domain and primary target domain within a set time period, and obtain the historical water consumption sequence and corresponding influencing factor sequence of different water use modes in the primary source domain and primary target domain by preprocessing the data; wherein the water use mode includes domestic water and industrial water.
[0118] The matching module 204 is used to determine a first-level source domain with the smallest maximum mean difference as a matching source domain for each first-level target domain by calculating the maximum mean difference of the historical water consumption series between any first-level source domain and any first-level target domain.
[0119] The source domain training module 205 is used to construct a water consumption prediction model for each matching source domain, input the historical water consumption sequence of different water consumption modes in the matching source domain and the corresponding influencing factor sequence into the water consumption prediction model for water consumption prediction, and construct a first-class loss function based on the pipeline constraints and water consumption prediction losses of the matching source domain to train the water consumption prediction model, so as to obtain a water consumption prediction model trained in the matching source domain; wherein the water consumption prediction model includes a domestic water consumption prediction model and an industrial water consumption prediction model.
[0120] The migration prediction module 206 uses the water consumption prediction model trained in the matching source domain as the initial water consumption prediction model of the first-level target domain corresponding to the matching source domain, inputs the historical water consumption sequence of different water consumption modes in the first-level target domain and the corresponding influencing factor sequence into the initial water consumption prediction model for water consumption prediction, and constructs a second type of loss function based on the pipeline constraints and water consumption prediction losses of the first-level target domain to train the initial water consumption prediction model, obtains the water consumption prediction model trained in the first-level target domain, and predicts the water consumption of different water consumption modes in the first-level target domain within the target time according to the water consumption prediction model trained in the first-level target domain.
[0121] For the specific limitations of the urban water consumption prediction system based on transfer learning, please refer to the limitations of the urban water consumption prediction method based on transfer learning above, which will not be repeated here. Each module in the above-mentioned urban water consumption prediction system based on transfer learning can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0122] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 3 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for predicting urban water consumption based on transfer learning is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0123] Those skilled in the art will understand that Figure 3 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0124] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0125] The source city and the target city are divided according to the set grid size to obtain multiple first-level source domains and first-level target domains;
[0126] Collect and obtain the pipeline flow threshold and pipeline node pressure threshold of the water supply network of each primary source domain and primary target domain, and construct the pipeline constraints of the primary source domain and the primary target domain respectively according to the pipeline flow threshold and pipeline node pressure threshold;
[0127] Collect and obtain historical water consumption data and influencing factor data of different water consumption modes in the water supply network of each primary source domain and primary target domain within a set time period, and obtain historical water consumption sequences and corresponding influencing factor sequences of different water consumption modes in the primary source domain and primary target domain by preprocessing the data; the water consumption modes include domestic water use and industrial water use;
[0128] By calculating the maximum mean difference between the historical water consumption series of any first-level source domain and any first-level target domain, a first-level source domain with the minimum maximum mean difference is determined for each first-level target domain as the matching source domain;
[0129] A water consumption prediction model is constructed for each matching source domain, and the historical water consumption sequences of different water consumption modes in the matching source domain and the corresponding influencing factor sequences are input into the water consumption prediction model for water consumption prediction. A first-class loss function is constructed based on the pipeline constraints and water consumption prediction losses of the matching source domain to train the water consumption prediction model, and a water consumption prediction model trained in the matching source domain is obtained; wherein the water consumption prediction model includes a domestic water consumption prediction model and an industrial water consumption prediction model;
[0130] The water consumption prediction model trained in the matching source domain is used as the initial water consumption prediction model of the first-level target domain corresponding to the matching source domain. The historical water consumption sequences of different water consumption modes in the first-level target domain and the corresponding influencing factor sequences are input into the initial water consumption prediction model for water consumption prediction. Based on the pipeline constraints and water consumption prediction losses of the first-level target domain, a second type of loss function is constructed to train the initial water consumption prediction model to obtain the water consumption prediction model trained in the first-level target domain. The water consumption of different water consumption modes in the first-level target domain within the target time is predicted based on the water consumption prediction model trained in the first-level target domain.
[0131] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0132] The source city and the target city are divided according to the set grid size to obtain multiple first-level source domains and first-level target domains;
[0133] Collect and obtain the pipeline flow threshold and pipeline node pressure threshold of the water supply network of each primary source domain and primary target domain, and construct the pipeline constraints of the primary source domain and the primary target domain respectively according to the pipeline flow threshold and pipeline node pressure threshold;
[0134] Collect and obtain historical water consumption data and influencing factor data of different water consumption modes in the water supply network of each primary source domain and primary target domain within a set time period, and obtain historical water consumption sequences and corresponding influencing factor sequences of different water consumption modes in the primary source domain and primary target domain by preprocessing the data; the water consumption modes include domestic water use and industrial water use;
[0135] By calculating the maximum mean difference between the historical water consumption series of any first-level source domain and any first-level target domain, a first-level source domain with the minimum maximum mean difference is determined for each first-level target domain as the matching source domain;
[0136] A water consumption prediction model is constructed for each matching source domain, and the historical water consumption sequences of different water consumption modes in the matching source domain and the corresponding influencing factor sequences are input into the water consumption prediction model for water consumption prediction. A first-class loss function is constructed based on the pipeline constraints and water consumption prediction losses of the matching source domain to train the water consumption prediction model, and a water consumption prediction model trained in the matching source domain is obtained; wherein the water consumption prediction model includes a domestic water consumption prediction model and an industrial water consumption prediction model;
[0137] The water consumption prediction model trained in the matching source domain is used as the initial water consumption prediction model of the first-level target domain corresponding to the matching source domain. The historical water consumption sequences of different water consumption modes in the first-level target domain and the corresponding influencing factor sequences are input into the initial water consumption prediction model for water consumption prediction. Based on the pipeline constraints and water consumption prediction losses of the first-level target domain, a second type of loss function is constructed to train the initial water consumption prediction model to obtain the water consumption prediction model trained in the first-level target domain. The water consumption of different water consumption modes in the first-level target domain within the target time is predicted based on the water consumption prediction model trained in the first-level target domain.
[0138] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0139] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0140] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for predicting urban water consumption based on transfer learning, characterized in that: The method comprises: The source city and the target city are divided according to the set grid size to obtain multiple first-level source domains and first-level target domains; Collect and obtain the pipeline flow threshold and pipeline node pressure threshold of the water supply network of each primary source domain and primary target domain, and construct the pipeline constraints of the primary source domain and the primary target domain respectively according to the pipeline flow threshold and pipeline node pressure threshold; Collect and obtain historical water consumption data and influencing factor data of different water consumption modes in a set time period in the water supply network of each primary source domain and primary target domain, and obtain historical water consumption sequences and corresponding influencing factor sequences of different water consumption modes in the primary source domain and primary target domain by preprocessing the data; wherein the water consumption mode includes domestic water and industrial water; By calculating the maximum mean difference between the historical water consumption series of any first-level source domain and any first-level target domain, a first-level source domain with the minimum maximum mean difference is determined for each first-level target domain as the matching source domain; A water consumption prediction model is constructed for each matching source domain, and the historical water consumption sequence of different water consumption modes in the matching source domain and the corresponding influencing factor sequence are input into the water consumption prediction model to predict water consumption, and a first-class loss function is constructed based on the pipeline constraint and water consumption prediction loss of the matching source domain to train the water consumption prediction model, so as to obtain a water consumption prediction model trained in the matching source domain; wherein the water consumption prediction model includes a domestic water consumption prediction model and an industrial water consumption prediction model; The water consumption prediction model trained in the matching source domain is used as the initial water consumption prediction model of the first-level target domain corresponding to the matching source domain, and the historical water consumption sequences of different water consumption modes in the first-level target domain and the corresponding influencing factor sequences are input into the initial water consumption prediction model to predict water consumption. Based on the pipeline constraints and water consumption prediction losses of the first-level target domain, a second type of loss function is constructed to train the initial water consumption prediction model to obtain the water consumption prediction model trained in the first-level target domain, and the water consumption of different water consumption modes in the first-level target domain within the target time is predicted according to the water consumption prediction model trained in the first-level target domain.
2. The method according to claim 1, characterized in that The pipeline flow thresholds and pipeline node pressure thresholds of the water supply network of each primary source domain and primary target domain are collected and obtained, and the pipeline constraints of the primary source domain and the primary target domain are respectively constructed according to the pipeline flow thresholds and pipeline node pressure thresholds, including: The pipeline flow threshold and pipeline node pressure threshold of the water supply network of each primary source domain are collected and obtained, and the penalty function is used to define the pipeline flow threshold constraint and pipeline node pressure threshold constraint in the primary source domain respectively, and the pipeline constraint of the primary source domain is constructed, which is expressed as in, is the pipeline flow threshold constraint penalty function of the primary source domain, is the pipeline node pressure threshold constraint penalty function of the primary source domain, is the water supply pipeline collection of the primary source area, The first source domain i The flow rate of a pipeline, The first source domain i The maximum flow rate of a pipeline, The first source domain i The minimum flow rate of a pipe, is the set of pipeline nodes in the first-level source domain, The first source domain j The pressure at each pipeline node, The first source domain j The maximum pressure of a pipeline node, The first source domain j Minimum pressure of a pipeline node; The pipeline flow threshold and pipeline node pressure threshold of the water supply network in each primary target domain are collected and obtained, and the penalty function is used to define the pipeline flow threshold constraint and pipeline node pressure threshold constraint in the primary target domain respectively, and the pipeline constraint of the primary target domain is constructed, which is expressed as in, is the pipeline flow threshold constraint penalty function of the first-level target domain, is the pipeline node pressure threshold constraint penalty function of the primary target domain, is the water supply pipeline set of the primary target domain, The first target domain n The flow rate of a pipeline, The first target domain n The maximum flow rate of a pipeline, The first target domain n The minimum flow rate of a pipe, is the pipeline node set of the first-level target domain, The first target domain m The pressure at each pipeline node, The first target domain m The maximum pressure of a pipeline node, The first target domain m The minimum pressure at a pipeline node.
3. The method according to claim 1, characterized in that The historical water consumption data and influencing factor data of different water consumption modes in the water supply network of each primary source domain and primary target domain within a set time period are collected and obtained, and the historical water consumption sequence and the corresponding influencing factor sequence of different water consumption modes in the primary source domain and primary target domain are obtained by preprocessing the data, including: Collect and obtain historical domestic water consumption data and corresponding domestic water influencing factor data as well as historical industrial water consumption data and corresponding industrial water influencing factor data in the water supply network of each primary source domain and primary target domain within a set time period, and perform data cleaning; The historical domestic water consumption data and the corresponding domestic water consumption influencing factor data in the primary source domain and the primary target domain are divided in chronological order with a set time step, and time-aligned based on a set time reference, to obtain a time-aligned historical domestic water consumption sequence and a corresponding domestic water consumption influencing factor sequence in the primary source domain and the primary target domain; The historical industrial water consumption data and the corresponding industrial water use influencing factor data in the primary source domain and the primary target domain are divided in chronological order with a set time step, and time alignment is performed based on the set time reference to obtain the time-aligned historical industrial water consumption sequence and the corresponding industrial water use influencing factor sequence in the primary source domain and the primary target domain.
4. The method according to claim 3, characterized in that By calculating the maximum mean difference between the historical water consumption series of any first-level source domain and any first-level target domain, a first-level source domain with the minimum maximum mean difference is determined for each first-level target domain as the matching source domain, including: Calculate the mean difference of historical domestic water consumption in any first-level source domain and any first-level target domain within the same time step, and traverse all time steps to obtain the maximum mean difference of historical domestic water consumption series between any first-level source domain and any first-level target domain; Calculate the mean difference of historical industrial water consumption in any first-level source domain and any first-level target domain within the same time step, and traverse all time steps to obtain the maximum mean difference of historical industrial water consumption series between any first-level source domain and any first-level target domain; By combining and minimizing the maximum mean difference of the historical domestic water consumption series and the maximum mean difference of the historical industrial water consumption series, a first-level source domain with the smallest maximum mean difference after combination is determined for each first-level target domain as the matching source domain.
5. The method according to claim 4, characterized in that A water consumption prediction model is constructed for each matching source domain, and the historical water consumption sequence of different water consumption modes in the matching source domain and the corresponding influencing factor sequence are input into the water consumption prediction model for water consumption prediction. A first-class loss function is constructed based on the pipeline constraint and water consumption prediction loss of the matching source domain to train the water consumption prediction model, and a water consumption prediction model trained for the matching source domain is obtained, including: A water consumption prediction model is constructed for each matching source domain, including a domestic water consumption prediction model and an industrial water consumption prediction model; Input the time-aligned historical domestic water consumption sequence and the corresponding domestic water consumption influencing factor sequence in the matching source domain into the domestic water consumption prediction model to predict domestic water consumption, and input the time-aligned historical industrial water consumption sequence and the corresponding industrial water consumption influencing factor sequence in the matching source domain into the industrial water consumption prediction model to predict industrial water consumption; Pipeline constraints based on matching source domains , Match the predicted loss of domestic water consumption in the source domain and predicted losses of industrial water use matching the source domain Construct a first type of loss function, and train the water consumption prediction model according to the first type of loss function until a preset number of training times is reached to obtain a water consumption prediction model trained in the matching source domain; wherein the first type of loss function is expressed as ; in, is a hyperparameter that adjusts the ratio between the pipeline constraints matching the source domain and the water consumption prediction loss, and .
6. The method according to claim 5, characterized in that The network structures of the domestic water consumption prediction model and the industrial water consumption prediction model are consistent, both consisting of a first feature extraction layer, a second feature extraction layer, a cross attention layer and an output layer; The first feature extraction layer and the second feature extraction layer are used to extract the temporal and spatial distribution characteristics of the input historical water consumption sequence and the corresponding influencing factor sequence, respectively, and the first feature extraction layer and the second feature extraction layer are both composed of an LSTM layer and a CNN layer; The cross attention layer is used to use the cross attention mechanism to perform feature fusion on the spatiotemporal distribution features output by the first feature extraction layer and the second feature extraction layer to obtain fused features; The output layer is used to perform linear regression on the fusion features using an activation function to obtain a predicted water consumption sequence.
7. The method according to claim 5, characterized in that The water consumption prediction model trained in the matching source domain is used as the initial water consumption prediction model of the primary target domain corresponding to the matching source domain, and the historical water consumption sequence of different water consumption modes in the primary target domain and the corresponding influencing factor sequence are input into the initial water consumption prediction model to predict water consumption, and a second type of loss function is constructed based on the pipeline constraint and water consumption prediction loss of the primary target domain to train the initial water consumption prediction model to obtain a water consumption prediction model trained in the primary target domain, and the water consumption of different water consumption modes in the primary target domain within a target time is predicted according to the water consumption prediction model trained in the primary target domain, including: The water consumption prediction model trained in the matching source domain is used as the initial water consumption prediction model of the primary target domain corresponding to the matching source domain; wherein the initial water consumption prediction model includes an initial domestic water consumption prediction model and an initial industrial water consumption prediction model; Input the time-aligned historical domestic water consumption sequence and the corresponding domestic water consumption influencing factor sequence in the primary target domain into the initial domestic water consumption prediction model to perform domestic water consumption prediction, and input the time-aligned historical industrial water consumption sequence and the corresponding industrial water consumption influencing factor sequence in the primary target domain into the initial industrial water consumption prediction model to perform industrial water consumption prediction; Pipeline constraints based on primary target domain , Prediction of loss of domestic water consumption in the first-level target area And the predicted loss of industrial water consumption in the first-level target domain A second type of loss function is constructed, and the initial water consumption prediction model is trained according to the second type of loss function until a preset number of training times is reached, and a water consumption prediction model trained in the first-level target domain is obtained through training, and the predicted domestic water consumption sequence and the predicted industrial water consumption sequence of the first-level target domain within the target time are predicted according to the water consumption prediction model trained in the first-level target domain; wherein the second type of loss function is expressed as ; in, is a hyperparameter that adjusts the ratio between the pipeline constraint and the water consumption prediction loss in the primary objective domain, and .
8. A city water consumption prediction system based on transfer learning, characterized in that: The system comprises: A grid division module is used to divide the source city and the target city according to the set grid size to obtain multiple first-level source domains and first-level target domains; A pipeline constraint module is used to collect and obtain the pipeline flow threshold and pipeline node pressure threshold of the water supply network of each primary source domain and primary target domain, and construct the pipeline constraints of the primary source domain and the primary target domain respectively according to the pipeline flow threshold and pipeline node pressure threshold; The data preprocessing module is used to collect and obtain the historical water consumption data and influencing factor data of different water consumption modes in the water supply network of each primary source domain and primary target domain within a set time period, and obtain the historical water consumption sequence and corresponding influencing factor sequence of different water consumption modes in the primary source domain and primary target domain by preprocessing the data; wherein the water consumption mode includes domestic water and industrial water; A matching module is used to determine a first-level source domain with the smallest maximum mean difference as a matching source domain for each first-level target domain by calculating the maximum mean difference between the historical water consumption series of any first-level source domain and any first-level target domain; A source domain training module is used to construct a water consumption prediction model for each matching source domain, input the historical water consumption sequence of different water consumption modes in the matching source domain and the corresponding influencing factor sequence into the water consumption prediction model to predict water consumption, and construct a first-class loss function based on the pipeline constraint and water consumption prediction loss of the matching source domain to train the water consumption prediction model, so as to obtain a water consumption prediction model trained in the matching source domain; wherein the water consumption prediction model includes a domestic water consumption prediction model and an industrial water consumption prediction model; The migration prediction module uses the water consumption prediction model trained in the matching source domain as the initial water consumption prediction model of the first-level target domain corresponding to the matching source domain, inputs the historical water consumption sequence of different water consumption modes in the first-level target domain and the corresponding influencing factor sequence into the initial water consumption prediction model for water consumption prediction, and constructs a second type of loss function based on the pipeline constraints and water consumption prediction losses of the first-level target domain to train the initial water consumption prediction model, and obtains the water consumption prediction model trained in the first-level target domain, and predicts the water consumption of different water consumption modes in the first-level target domain within the target time according to the water consumption prediction model trained in the first-level target domain.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Multi-region water demand prediction method for urban graded collaborative water supply
CN115630745A
Power short-term load prediction method based on deep reinforcement learning and transfer learning
CN116306229A
