A method for predicting the flow rate of urban drainage pipe networks based on an improved Transformer neural network model
Through the improved Transformer neural network model and RO-former architecture, the data dependence and computing efficiency problems in the flow prediction of urban drainage pipelines are solved, and the second-level response and flexible adaptation are achieved, providing a new paradigm for urban drainage system optimization.
Patent Information
- Application Number
- CN202510285542.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-11
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2045-03-11
AI Technical Summary
The existing technology has problems such as strong data dependence, low computing efficiency, poor dynamic adaptability and high deployment costs in urban drainage pipeline traffic prediction, especially in old urban areas and dynamically changing pipeline scenarios.
The improved Transformer neural network model is adopted to generate representative rainfall data by constructing a rainfall parameterization engine, and the traffic prediction is performed in combination with the RO-former model of the encoder-decoder architecture. The rainfall and traffic data are processed using dynamic masks and cross attention mechanisms to achieve end-to-end modeling and second-level response.
It realizes efficient and accurate traffic prediction in old urban areas and dynamically changing scenarios, and has a second-level response capability, reducing dependence and deployment costs on professional software, and improving the flexibility and adaptability of the model.
Smart Images

Figure CN119783564B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technology of urban drainage network flow prediction, and particularly to a method for predicting the flow of urban drainage network based on an improved Transformer neural network model. Background Art
[0002] Traditional urban drainage network flow prediction is carried out through runoff generation and concentration mechanism models. These runoff generation and concentration models mainly include two calculation parts: rainfall runoff generation and net rainfall concentration. In runoff generation calculation, common methods include runoff coefficient method, infiltration curve method, full storage runoff generation method, SCS curve method, etc. These methods are widely used in runoff generation calculation in urban areas, but their calculation accuracy is affected by the complex characteristics of the urban surface. In concentration calculation, hydrological methods such as rational formula method, isochrone method, linear or nonlinear reservoir method, Muskingum method, etc., as well as hydrodynamic methods for solving the Saint-Venant equation are used to calculate the concentration situation in urban areas. The mechanism model can analyze each link of water body from rainfall, runoff generation, concentration to finally flowing in the river channel, clearly explain the river channel hydrodynamics and flow process, and has important guiding significance in urban drainage system management and flood control decision-making. However, although the mechanism model has a certain interpretability, there are a series of problems and difficulties in the actual modeling process. Building an accurate runoff generation and concentration model requires a large amount of detailed input data, such as drainage system data, rainfall data, underlying surface data, etc., and when the model scale is large, interface tools are needed to assist data input and management. The pre-processing work of the model is complex and time-consuming, such as sorting out the drainage system topological relationship, dividing sub-catchments, etc. There are many model parameters, and the traditional manual parameter adjustment is inefficient and inaccurate, and optimization algorithms need to be introduced for auxiliary calibration. With the transformation of combined sewer networks, various interception devices are installed at the network outlets, and their hydraulic characteristics are different from those of conventional outlets, which are difficult to generalize in the model and may affect the simulation accuracy; the continuous transformation of the network also increases the difficulty of accurately building the model; problems such as network blockage and leakage in actual operation are also difficult to consider in the model, resulting in differences between the simulation results and the monitoring values. In addition, when the river network scale is large, solving the discretized algebraic equations also requires a large amount of computing resources.
[0003] Existing ideas for studying urban drainage network flow prediction using machine learning methods: With the wide application of machine learning methods in the field of water science, this technology has gradually been introduced into urban drainage network flow prediction research. For example, Feng et al. (in 2023) established a high-fidelity model of urban river hydrology and hydrodynamics using SWMM5.1, simulated it under different rainfall scenarios, obtained water level-flow data downstream of the upstream gate, and then used a BP neural network and a long short-term memory (LSTM) neural network to train a data-driven model to replace the original mechanism model respectively, significantly optimizing the calculation speed. Yundong Li (in 2024) established an LSTM-ACO model based on the training data of the SWMM-WASP mechanism coupling model. Among them, LSTM was used as a surrogate model to replace the SWMM-WASP process model, and the boundary conditions and parameters of the process model were used as inputs and the simulation results were used as outputs for training. The trained LSTM model could simulate the results that the process model needed 1.5 - 2 hours in 1 minute, and the fitting accuracy (R²) exceeded 99.9%; the ant colony optimization algorithm (ACO) was used to determine the optimal combination of input parameters of the LSTM model. The general method of applying machine learning to predict hydrodynamic processes currently is basically: first establish and verify the rationality of the mechanism model, and then generate a dataset based on the mechanism model to train the machine learning model. Although the operation speed of the machine learning model trained in this way has been significantly improved, it is necessary to first establish a SWMM runoff model. However, due to data loss, pipeline network deformation and damage, etc. after a period of engineering construction, it is often difficult to construct a satisfactory SWMM model. In addition, such models usually can only describe the hydrodynamic process of a single cross-section and cannot guide the flow prediction and flood control decision-making of the entire urban drainage system.
[0004] There are four core challenges in the current urban drainage system modeling: Traditional physical models (such as SWMM) rely on complete pipeline network topology data, and the accuracy drops sharply due to data loss or invalidation in old urban areas or dynamically changing pipeline network scenarios; The complex solution process based on the Saint-Venant equation takes up to minutes, which is difficult to meet the real-time requirements of waterlogging warning; Existing data-driven models (such as LSTM) are limited by a fixed input length, unable to flexibly process variable-length rainfall events of 1 - 6 hours, and the sliding window sampling introduces non-rainfall period noise data; Dynamic boundary condition changes such as pipeline network siltation and transformation lead to the degradation of the long-term prediction ability of the SWMM model.
[0005] It should be noted that the information disclosed in the above background technology section is only used for understanding the background of this application, and therefore may include information that does not constitute the prior art known to those of ordinary skill in the art. Summary of the Invention
[0006] The main objective of the present invention is to overcome the deficiencies in the above-mentioned background art and provide a method for predicting the flow rate of urban drainage pipe networks based on an improved Transformer neural network model.
[0007] To achieve the above objective, the present invention adopts the following technical solutions:
[0008] A method for predicting the flow rate of urban drainage pipe networks based on an improved Transformer neural network model, comprising the following steps:
[0009] S1. Rainfall data generation: Based on the regional rainfall characteristics, a rainfall parameterization engine is constructed to simulate rainfall processes under different return periods, durations, and peak coefficients, and a representative rainfall dataset is generated;
[0010] S2. Flow data simulation: The generated rainfall data is input into a calibrated physical model to calculate the flow process corresponding to the drainage outlet, forming a flow dataset;
[0011] S3. Data preprocessing: A dataset is constructed, with the rainfall process and the drainage outlet flow process as input and labels. Invalid data is deleted, and features and labels are supplemented to form training and validation datasets;
[0012] S4. Deep learning model construction: An RO-former model based on the encoder-decoder architecture is constructed. The encoder identifies the positions of valid data through a dynamic masking mechanism, and the decoder uses causal masking and dynamic length masking to support rainfall inputs of any duration. The rainfall features are aligned with the flow response through a cross-attention mechanism;
[0013] S5. Model training and optimization: The model is trained and optimized using a loss function, and the trained model is used for predicting the flow rate of urban drainage pipe networks.
[0014] Further, in step S1, the rainfall data generation simulates rainfall processes under different return periods, durations, and peak coefficients through a parameterization engine to generate a representative rainfall dataset, and the number of rainfall fields is not less than a preset threshold.
[0015] Further, in step S2, the flow data simulation forms a flow dataset by inputting the generated rainfall data into a calibrated physical model to calculate the flow process corresponding to the drainage outlet, and the physical model is a calibrated hydro-hydraulic model.
[0016] Further, in step S3, the data preprocessing includes constructing a dataset, using the rainfall process and the drainage outlet flow process as input and labels, batch-processing the data through a data loader, dynamically deleting invalid data, and supplementing features and labels to form training and validation datasets.
[0017] Further, in the step S4, the encoder of the deep learning model construction identifies the valid data positions through a dynamic masking mechanism, and the encoder includes a multi-head attention module and a feed-forward neural network module, wherein the multi-head attention module filters out the invalid data through the dynamic masking mechanism.
[0018] Further, in the step S4, the decoder adopts a causal mask and a dynamic length mask, supports arbitrary historical rainfall input, and aligns the rainfall features with the flow response through a cross-attention mechanism, and the decoder includes a multi-head self-attention module and a cross-attention module.
[0019] Further, in the step S4, the cross-attention layer adopts a dynamic key-value pair selection mechanism to automatically select the relevant time segments of the encoder output according to the current decoding position, so as to achieve the precise alignment of the rainfall features and the flow response.
[0020] Further, for the RO-former model based on the encoder-decoder architecture, where:
[0021] The encoder part includes multiple encoder layers, and each encoder layer is composed of a multi-head self-attention module and a feed-forward neural network module, and the multi-head self-attention module filters out the invalid data through a dynamic masking mechanism, and the feed-forward neural network module optimizes the training process through residual connections and normalization layers;
[0022] The decoder part includes multiple decoder layers, and each decoder layer is composed of a multi-head self-attention module, a cross-attention module and a feed-forward neural network module, wherein the multi-head self-attention module adopts a causal mask and a dynamic length mask, and only focuses on historical information at the current moment, and the cross-attention module aligns the rainfall features output by the encoder with the flow response of the decoder through a dynamic key-value pair selection mechanism;
[0023] The positional encoding is applied to the inputs of the encoder and the decoder respectively to capture the timing information in the time series;
[0024] The linear transformation is applied to the inputs and outputs of the encoder and the decoder respectively to adjust the feature dimensions;
[0025] The masking mechanism in the decoder is used to mask future information, so that the model makes predictions only based on historical data during training.
[0026] Further, in the step S5, the mean squared error is used as the loss function for model training and optimization, the Nash efficiency coefficient is combined to evaluate the model performance, and the optimizer adopts a warm-up decay learning rate scheduling strategy to gradually adjust the learning rate to improve the model training efficiency.
[0027] Furthermore, in step S5, the trained model is encapsulated in a lightweight manner, supporting second-level traffic prediction and edge device deployment, and the model prediction results are used for real-time traffic monitoring and waterlogging warning of urban drainage pipe networks.
[0028] The present invention has the following beneficial effects:
[0029] The present invention proposes an intelligent modeling method for urban drainage systems based on dynamic masked RO-former, which systematically solves the limitations of traditional models through a trinity technical framework of "generation - simulation - learning". Compared with the prior art, the significant advantages of the present invention are as follows:
[0030] Compared with traditional physical models (such as SWMM) and existing data-driven methods (such as LSTM, RR-former), the present invention systematically breaks through the limitations of traditional technologies through the full-chain innovation of "dynamic rainfall generation - elastic modeling - collaborative optimization": in terms of data dependence, it abandons the strong demand for pipe network topology data in traditional physical models, realizes end-to-end modeling without pipe network parameters, and significantly improves the applicability in data-deficient scenarios such as old urban areas and newly built areas; in terms of computational efficiency, it compresses the single prediction time from 22 seconds of SWMM to 0.6 seconds (a 36-fold speed increase), meeting the second-level response requirements for waterlogging warning; in terms of modeling ability, it breaks through the limitations of fixed input and output lengths of models such as LSTM, supports rainfall input with any duration from 1 to 6 hours through elastic position encoding and dynamic masking mechanism, avoids the noise interference of sliding window sampling, and changes the MSE index from divergence to convergence; in terms of dynamic adaptability, it integrates the initial training of physical models and online learning mechanisms to achieve autonomous adaptation to boundary condition changes such as pipe network siltation and transformation; in terms of engineering deployment, through lightweight encapsulation and edge computing adaptation, it gets rid of the dependence on professional hydrological software, can be deployed to flood control terminal devices, and reduces the cost of intelligent transformation. The present invention combines high efficiency, robustness and flexibility, providing a new paradigm for the optimization of urban drainage systems.
[0031] Other beneficial effects in the embodiments of the present invention will be further described below. Description of the Drawings
[0032] Figure 1 It is a flowchart of the method for predicting the flow of urban drainage pipe networks based on the improved Transformer neural network model in the embodiments of the present invention.
[0033] Figure 2 It is a technical roadmap of traditional slider sampling.
[0034] Figure 3 It is an architecture diagram of RO-former in the embodiments of the present invention.
[0035] Figures 4A - 4LIt is a comparison chart of the slider window sampling method and the variable-length sampling method. Specific Embodiments
[0036] The following provides a detailed description of the embodiments of the present invention. It should be emphasized that the following description is merely exemplary and not intended to limit the scope of the present invention and its applications.
[0037] In addition, the terms "first" and "second" are only used for descriptive purposes and should not be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include one or more of such features. In the description of the embodiments of the present invention, "a plurality" means two or more unless otherwise specifically defined.
[0038] Refer to Figure 1 , an embodiment of the present invention provides a method for predicting the flow rate of an urban drainage pipe network based on an improved Transformer neural network model, including the following steps:
[0039] Step S1, rainfall data generation: Based on the regional rainfall characteristics, a rainfall parameterization engine is constructed to simulate the rainfall process under different return periods, durations, and peak coefficients, and a representative rainfall data set is generated.
[0040] Specifically, in the step S1, the rainfall data generation simulates the rainfall process under different return periods, durations, and peak coefficients through the parameterization engine to generate a representative rainfall data set, and the number of rainfall fields is not less than a preset threshold.
[0041] Step S2, flow rate data simulation: The generated rainfall data is input into a calibrated physical model, and the flow rate process corresponding to the drainage outlet is calculated to form a flow rate data set;
[0042] Specifically, in the step S2, the flow rate data simulation forms a flow rate data set by inputting the generated rainfall data into a calibrated physical model and calculating the flow rate process corresponding to the drainage outlet, and the physical model is a calibrated hydro-hydraulic model.
[0043] Step S3, data preprocessing: A data set is constructed, with the rainfall process and the drainage outlet flow rate process as input and label, invalid data is deleted, features and labels are filled, and a training and validation data set is formed.
[0044] Specifically, in the step S3, the data preprocessing includes constructing a data set, using the rainfall process and the drainage outlet flow rate process as input and label, batch-processing the data through a data loader, dynamically deleting invalid data, filling features and labels, and forming a training and validation data set.
[0045] Step S4, Deep learning model construction: Construct an RO-former model based on the encoder-decoder architecture. The encoder identifies the positions of valid data through a dynamic masking mechanism, and the decoder uses causal masking and dynamic length masking to support rainfall inputs of any duration. The rainfall features are aligned with the flow response through a cross-attention mechanism.
[0046] Specifically, in step S4, the encoder of the deep learning model construction identifies the positions of valid data through a dynamic masking mechanism. The encoder includes a multi-head attention module and a feed-forward neural network module, where the multi-head attention module filters out invalid data through the dynamic masking mechanism. The decoder uses causal masking and dynamic length masking to support rainfall inputs of any duration, and aligns the rainfall features with the flow response through a cross-attention mechanism. The decoder includes a multi-head self-attention module and a cross-attention module. The cross-attention layer uses a dynamic key-value pair selection mechanism to automatically select relevant time segments of the encoder output according to the current decoding position to achieve precise alignment of rainfall features and flow response.
[0047] As Figure 3 shown, in a preferred embodiment of the present invention, the RO-former model based on the encoder-decoder architecture, where the encoder part includes multiple encoder layers, each encoder layer is composed of a multi-head self-attention module and a feed-forward neural network module, and the multi-head self-attention module filters out invalid data through a dynamic masking mechanism, and the feed-forward neural network module optimizes the training process through residual connections and normalization layers; the decoder part includes multiple decoder layers, each decoder layer is composed of a multi-head self-attention module, a cross-attention module and a feed-forward neural network module, where the multi-head self-attention module uses causal masking and dynamic length masking, and only focuses on historical information at the current moment, and the cross-attention module aligns the rainfall features output by the encoder with the flow response of the decoder through a dynamic key-value pair selection mechanism; positional encoding is applied to the inputs of the encoder and decoder respectively to capture the temporal information in the time series; linear transformation is applied to the inputs and outputs of the encoder and decoder respectively to adjust the feature dimensions; the masking mechanism in the decoder is used to mask future information so that the model only makes predictions based on historical data during training.
[0048] Step S5, Model training and optimization: Use a loss function to train and optimize the model, and the trained model is used for urban drainage network flow prediction.
[0049] In a preferred embodiment, in step S5, the model training and optimization uses mean square error as the loss function, uses the Adam optimizer, combines the Nash efficiency coefficient to evaluate the model performance, and the optimizer uses a warm-up decay learning rate scheduling strategy to gradually adjust the learning rate to improve the model training efficiency. The trained model supports second-level flow prediction and edge device deployment through lightweight packaging, and the model prediction results are used for real-time flow monitoring and waterlogging warning of urban drainage networks.
[0050] The intelligent modeling method of urban drainage system based on dynamic mask RO-former in the present invention systematically solves the limitations of traditional models through the technical framework of "generation-simulation-learning". Compared with traditional physical models such as SWMM and existing data-driven methods such as LSTM and RR-former, the present invention has achieved significant technical breakthroughs in many aspects. First, in terms of data dependence, the present invention abandons the strong demand for pipe network topology data and realizes end-to-end modeling without pipe network parameters, which significantly improves the applicability in data-missing scenarios such as old urban areas and newly built areas. Secondly, in terms of computational efficiency, the present invention compresses the single prediction time from 22 seconds of SWMM to 0.6 seconds, speeding up by 36 times, meeting the second-level response requirements of urban waterlogging warning. In terms of modeling capabilities, the present invention breaks through the limitations of fixed input and output lengths of models such as LSTM, supports arbitrary rainfall input of 1-6 hours through elastic position encoding and dynamic masking mechanisms, avoids noise interference of sliding window sampling, and changes the prediction error index MSE from divergence to convergence. In terms of dynamic adaptability, the present invention integrates the initial training of the physical model with the online learning mechanism, and realizes the autonomous adaptation to changes in boundary conditions such as pipe network siltation and transformation. Finally, in terms of engineering deployment, the present invention gets rid of the dependence on professional hydrological software through lightweight packaging and edge computing adaptation, and can be deployed to flood control terminal equipment, reducing the cost of intelligent transformation. These advantages of the present invention make it both efficient, robust and flexible, providing a new paradigm for the optimization of urban drainage systems.
[0051] The specific embodiments and experiments of the present invention are further described below.
[0052] Figure 1 This is a flow chart of a method for predicting the flow of an urban drainage network based on an improved Transformer neural network model according to an embodiment of the present invention. Figure 2 Technology roadmap for sampling traditional sliders.
[0053] The present invention proposes an intelligent modeling method for urban drainage system based on dynamic mask RO-former, which systematically solves the limitations of traditional models through the "generation-simulation-learning" trinity technical framework.
[0054] Generate-Simulate:
[0055] First, construct a parametric engine for the Chicago rainfall pattern. First, determine the coefficients for constructing the Chicago rainfall pattern based on regional rainfall characteristics (such as the rainfall intensity formula issued by local government departments). For example, the rainfall formula:
[0056]
[0057] Then, simulate rainfall processes with different return periods (1 - 100 years), various durations (1 - 6 hours), and different peak coefficients according to the rainfall intensity formula. Use a calibrated physical model (such as SWMM) to calculate the flow processes at corresponding outfalls under different rainfall processes. To make the rainfall have a certain representativeness, the number of rainfall fields should not be less than 500.
[0058] Learning:
[0059] Use PyTorch to construct a Dataset. The Dataset class reads the data of the rainfall process and the outfall flow process, and returns the corresponding rainfall process and outfall flow process for each input index. Then, construct a Dataloader based on the already constructed Dataset. The function of the Dataloader is to input the data of the dataset into the model in batches. Before the Dataloader outputs the data, use collate_fn to delete the invalid zeros after the outfall, and then pad the features (each batch of rainfall processes) and labels (each batch of outfall flow processes) with 1 to obtain the src and tgt tensors. Pad the labels (each batch of outfall flow processes) with 0 once again to obtain the real_data tensor. Use the above method to construct the training dataset and the validation dataset. The data of the training dataset is obtained by simulation, and the data of the validation dataset is constructed from real rainfall - outfall data.
[0060] Table 1 Training Configuration Details
[0061]
[0062] Construct a deep learning network RO - former (Rainfall Outfall - former) that can dynamically process inputs of different lengths (rainfall processes) and outputs of different lengths (outfall flow processes): RO - former adopts an encoder - decoder architecture, with the encoder on the left and the decoder on the right.
[0063] Figure 3RO-former architecture diagram for the preferred embodiment. Specifically, in the encoder part: The encoder consists of multiple encoder layers, and each encoder layer includes a multi-head self-attention module and a feed-forward neural network module. The multi-head self-attention module filters out invalid data through a dynamic masking mechanism. The dynamic masking mechanism automatically adjusts the attention range by identifying the valid positions (non-padding regions) in the input data, ensuring that the model only focuses on valid data. The feed-forward neural network module optimizes the training process through residual connections and normalization layers. The residual connection is used to alleviate the vanishing gradient problem, and the normalization layer is used to prevent gradient explosion and accelerate model convergence. In the decoder part: The decoder consists of multiple decoder layers, and each decoder layer includes a multi-head self-attention module, a cross-attention module, and a feed-forward neural network module. The multi-head self-attention module uses a causal mask and a dynamic length mask. The causal mask ensures that only historical information is focused on at the current moment, and the dynamic length mask automatically adjusts the attention range by identifying the valid positions (non-padding regions) in the output data. The cross-attention module aligns the rainfall features output by the encoder with the flow response of the decoder through a dynamic key-value pair selection mechanism. The dynamic key-value pair selection mechanism automatically selects the relevant time segments of the encoder output according to the current decoding position, achieving precise alignment of rainfall features and flow response.
[0064] Positional encoding is applied to the inputs of both the encoder and the decoder respectively to capture the temporal information in the time series. The positional encoding is generated through sine and cosine functions to ensure that the model can distinguish the input data at different time steps. Linear transformations are applied to the inputs and outputs of both the encoder and the decoder respectively to adjust the feature dimensions. The input of the encoder maps the single-channel data to a high-dimensional space through a linear transformation, and the output of the decoder maps the high-dimensional features back to single-channel data through a linear transformation. The masking mechanism in the decoder is used to mask future information to ensure that the model makes predictions only based on historical data during training. The masking mechanism sets the attention scores of future time steps to negative infinity, so that the model cannot access future information when predicting the current time step.
[0065] The encoder obtains a batch of labeled data from the dataloader, identifies the positions filled with 1 in each rainfall, and obtains the encoder mask tensor.
[0066] The src tensor is linearly transformed from a single channel to 64 channels, and sinusoidal positional encoding is added. The encoder mask tensor is a dynamic length encoding mechanism that determines a boolean tensor by identifying the valid data positions (non-1 regions) in the src tensor. Then the transformed src tensor is passed into the encoder, which consists of two main parts. The multi-head attention module is composed of the multi-head attention mechanism + residual connection and normalization, and the feed-forward neural network module is composed of the positional feed-forward neural network + residual connection and normalization. When the encoder calculates the attention mechanism and computes the attention scores, the mask tensor is applied to the attention score matrix. Specifically, if a certain position is masked as invalid (such as a padding position or a future position), the attention score at that position is set to a very small value (such as -inf). In this way, when calculating the attention weights through the Softmax function, the weight at that position will approach zero.
[0067] The decoder receives the tgt tensor as the initial input. After passing through linear transformation and positional encoding, it is input into the multi-head self-attention module. The mask tensor of the decoder is divided into a self-attention mask tensor and a cross-attention mask tensor. The self-attention mask tensor adopts a dual mechanism of causal mask + dynamic length mask. The causal mask ensures that only historical information can be attended to at the current moment, and the dynamic length mask automatically adjusts the attention range by identifying the valid data positions (non-1 regions) in the tgt. The cross-attention mask tensor is the same as the encoder mask tensor. The cross-attention layer establishes the connection between the encoder and the decoder, aligning the rainfall features with the flow response. This part adopts a dynamic key-value pair selection mechanism to automatically select relevant time segments of the encoder output according to the current decoding position. The feed-forward neural network layer includes two fully connected layers and an activation function, which can be expressed by the formula:
[0068]
[0069] where x is the input tensor and o is the output tensor. And the shape of the tensor remains unchanged after passing through the feed-forward neural network.
[0070] The output of the decoder is linearly transformed to change from 64 channels to a single channel. The sequence of predicted values starts from one less than the number of the bos, and the length is the same as the actual sequence length. bos i refers to a number of data before the time series to be predicted. When the time series is the outfall flow rate, it refers to the outfall flow rate sequence at several time steps before rainfall. In the present invention, i = 1.
[0071] The mean squared error (MSE) is used to compare the error between the predicted time series and the true series, and the MSE and Nash-Sutcliffe Efficiency (NSE) are used to evaluate the error between the predicted series and the true series.
[0072] Use the Adam optimizer with an initial learning rate of 10 -3 , and adopt a warm-up and decay strategy for the learning scheduler. In the first 25% of the training epochs, the learning rate gradually increases linearly from a small value to the initial learning rate. After exceeding the warm-up rounds, the learning rate enters the decay stage, and the learning rate gradually decreases in an exponential decay manner.
[0073] Finally, the model is lightweight packaged to support second-level (0.6 seconds / run) traffic prediction and edge device deployment.
[0074] Advantages of the present invention compared with the prior art:
[0075] Compared with traditional physical models (such as SWMM) and existing data-driven methods (such as LSTM, RR-former), the present invention systematically breaks through the limitations of traditional technologies through the full-chain innovation of "dynamic rainfall generation - elastic modeling - collaborative optimization": in terms of data dependence, it abandons the strong demand of traditional physical models for pipe network topology data, realizes end-to-end modeling without pipe network parameters, and significantly improves the applicability in data-deficient scenarios such as old urban areas and newly built areas; in terms of computational efficiency, it compresses the single prediction time from 22 seconds of SWMM to 0.6 seconds (a 36-fold speed increase), meeting the second-level response requirements of waterlogging early warning; in terms of modeling ability, it breaks through the limitations of models such as LSTM with fixed input and output lengths, supports rainfall input with any duration from 1 to 6 hours through elastic position encoding and dynamic masking mechanisms, avoids the noise interference of sliding window sampling, and makes the MSE index change from divergence to convergence; in terms of dynamic adaptability, it integrates the initial training of physical models and the online learning mechanism to achieve autonomous adaptation to boundary condition changes such as pipe network siltation and transformation; in terms of engineering deployment, through lightweight packaging and edge computing adaptation, it gets rid of the dependence on professional hydrological software, can be deployed to flood control terminal devices, and reduces the cost of intelligent transformation. The present invention combines high efficiency, robustness and flexibility, providing a new paradigm for the optimization of urban drainage systems.
[0076] Table 2 Types, characteristics and limitations of current mainstream modeling methods
[0077]
[0078] Example:
[0079] According to the publicly available rainfall intensity formula
[0080]
[0081] Determine the coefficients: a = 4079.423, c = 0.722, b = 21.575, n = 0.887. The Chicago rainfall pattern can be derived from the rainfall formula:
[0082] The instantaneous expression before the peak of the Chicago rainfall pattern hydrograph is:
[0083] (2 - 3)
[0084] The instantaneous rainfall intensity expression after the peak is:
[0085] (2 - 4)
[0086] By changing the recurrence interval P and the peak coefficient r, the rainfall sequences under different scenarios can be determined. The rainfall sequences are put into the calibrated physical model to calculate the pipe network outfall flow sequences. The rainfall - pipe network outfall flow sequences are put into the R0 - former model and the parameters are updated by forward propagation.
[0087] Compare with the traditional time - series model with equal input and output lengths.
[0088] Figures 4A - 4L Show the experimental effect comparison between the sliding window sampling method and the variable - length sampling method.
[0089] The embodiment of the present invention also provides a storage medium for storing a computer program, which when executed, at least executes the method as described above.
[0090] The embodiment of the present invention also provides a control device, including a processor and a storage medium for storing a computer program; wherein, the processor is used to execute the computer program to at least execute the method as described above.
[0091] The embodiment of the present invention also provides a processor, which executes a computer program to at least execute the method as described above.
[0092] The storage medium can be implemented by any type of non-volatile storage device, or a combination thereof. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a ferromagnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The storage medium described in the embodiments of the present invention is intended to include, but is not limited to, these and any other suitable types of memories.
[0093] In several embodiments provided by the present invention, it should be understood that the disclosed systems and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the couplings, direct couplings, or communication connections between the various components shown or discussed can be through some interfaces. The indirect couplings or communication connections of devices or units can be electrical, mechanical, or other forms.
[0094] The units described above as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units; some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0095] In addition, in each embodiment of the present invention, the functional units can all be integrated in one processing unit, or each unit can be separately used as a unit, or two or more units can be integrated in one unit; the above integrated units can be implemented in the form of hardware, or in the form of hardware plus software functional units.
[0096] Those of ordinary skill in the art can understand that all or part of the steps to implement the above method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps including those of the above method embodiments; and the aforementioned storage medium includes: various media that can store program codes, such as removable storage devices, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs.
[0097] Alternatively, if the above integrated units are implemented in the form of software function modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solutions of the embodiments of the present invention, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in the various embodiments of the present invention. And the aforementioned storage medium includes: various media that can store program codes, such as removable storage devices, ROM, RAM, magnetic disks, or optical discs.
[0098] The methods disclosed in several method embodiments provided by the present invention can be arbitrarily combined without conflict to obtain new method embodiments.
[0099] The features disclosed in several product embodiments provided by the present invention can be arbitrarily combined without conflict to obtain new product embodiments.
[0100] The features disclosed in several method or device embodiments provided by the present invention can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0101] The above content is a further detailed description of the present invention in combination with specific preferred implementation manners. It cannot be determined that the specific implementation of the present invention is only limited to these descriptions. For those skilled in the technical field to which the present invention pertains, without departing from the concept of the present invention, several equivalent substitutions or obvious variations can be made, and as long as the performance or use is the same, they should all be regarded as belonging to the protection scope of the present invention.
Claims
1. A method for predicting the flow rate of urban drainage pipe networks based on an improved Transformer neural network model, characterized in that, It includes the following steps: S1. Rainfall data generation: Based on the regional rainfall characteristics, a rainfall parameterization engine is constructed to simulate the rainfall processes under different return periods, durations, and peak coefficients, and a representative rainfall dataset is generated; S2. Flow data simulation: The generated rainfall data is input into a calibrated physical model, and the flow process corresponding to the outfall is calculated to form a flow dataset; S3. Data preprocessing: A dataset is constructed, with the rainfall process and the outfall flow process as input and label, invalid data is deleted, and features and labels are supplemented to form training and validation datasets; among them, taking the rainfall process and the outfall flow process as input and label, deleting invalid data, and supplementing features and labels includes batch processing the data through a data loader, and dynamically deleting invalid data and supplementing features and labels; S4. Deep learning model construction: Construct an RO-former model based on the encoder-decoder architecture, where the encoder identifies the positions of valid data through a dynamic masking mechanism, the decoder adopts causal masking and dynamic length masking, supports rainfall inputs of any duration, and aligns rainfall features with flow responses through a cross-attention mechanism; For the RO-former model based on the encoder-decoder architecture, where: The encoder part includes multiple encoder layers, each encoder layer consists of a multi-head self-attention module and a feed-forward neural network module, and the multi-head self-attention module filters invalid data through a dynamic masking mechanism, and the feed-forward neural network module optimizes the training process through residual connections and normalization layers; The decoder part includes multiple decoder layers, each decoder layer consists of a multi-head self-attention module, a cross-attention module, and a feed-forward neural network module, where the multi-head self-attention module adopts causal masking and dynamic length masking, and only focuses on historical information at the current moment, and the cross-attention module aligns the rainfall features output by the encoder with the flow responses of the decoder through a dynamic key-value pair selection mechanism; Position encoding is applied to the inputs of both the encoder and the decoder to capture the temporal information in the time series; Linear transformation is applied to the inputs and outputs of both the encoder and the decoder to adjust the feature dimensions; The masking mechanism in the decoder is used to mask future information so that the model makes predictions only based on historical data during training; S5. Model training and optimization: Use a loss function to train and optimize the model, and the trained model is used for urban drainage network flow prediction.
2. The method according to claim 1, wherein In step S1, the rainfall data generation simulates the rainfall processes under different return periods, durations, and peak coefficients through a parameterization engine to generate a representative rainfall dataset, and the number of rainfall fields is not less than a preset threshold.
3. The method according to claim 1, characterized in that, In step S2, the flow data simulation forms a flow dataset by inputting the generated rainfall data into a calibrated physical model and calculating the flow process corresponding to the outfall, and the physical model is a calibrated hydro-hydraulic model.
4. The method according to claim 1, characterized in that In the step S4, the encoder of the deep learning model construction identifies the positions of valid data through a dynamic masking mechanism, and the encoder includes a multi-head attention module and a feed-forward neural network module, wherein the multi-head attention module filters out invalid data through the dynamic masking mechanism.
5. The method according to claim 1, characterized in that, In the step S4, the decoder adopts a causal mask and a dynamic length mask, supports arbitrary historical rainfall inputs, and aligns rainfall features with flow responses through a cross-attention mechanism, and the decoder includes a multi-head self-attention module and a cross-attention module.
6. The method according to claim 1, wherein In the step S4, the cross-attention layer adopts a dynamic key-value pair selection mechanism to automatically select relevant time segments of the encoder output according to the current decoding position to achieve precise alignment of rainfall features with flow responses.
7. The method according to any one of claims 1 to 6, characterized in that In the step S5, mean squared error is used as the loss function for model training and optimization, and the Nash efficiency coefficient is combined to evaluate the model performance, and the optimizer adopts a warm-up decay learning rate scheduling strategy to gradually adjust the learning rate to improve the model training efficiency.
8. The method according to any one of claims 1 to 6, characterized in that In the step S5, the trained model is encapsulated in a lightweight manner, supports second-level flow prediction and edge device deployment, and the model prediction results are used for real-time flow monitoring and waterlogging warning of urban drainage pipe networks.
Citation Information
Patent Citations
Autoregressive visual target tracking algorithm based on token fusion
CN119477974A