Method for predicting urban drainage pipe network flow based on improved Transform neural network model

Through the improved Transformer neural network model and dynamic masking mechanism, combined with physical model initial training and online learning, the shortcomings of the existing urban drainage pipeline traffic prediction method in terms of data dependence, computing efficiency and dynamic adaptability are solved, and efficient, flexible and accurate traffic prediction is achieved.

CN119783564AActive Publication Date: 2025-04-08TSINGHUA SHENZHEN INTERNATIONAL GRADUATE SCHOOL

Patent Information

Application Number
CN202510285542.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-11
Publication Date
2025-04-08
Estimated Expiration
2045-03-11

AI Technical Summary

Technical Problem

The existing urban drainage pipeline traffic prediction methods have problems such as strong data dependence, low computing efficiency, limited modeling capabilities and poor dynamic adaptability, especially in the absence of data and pipeline network transformation scenarios, which are difficult to achieve accurate prediction.

Method used

Using a method based on the improved Transformer neural network model, arbitrary diachronous rainfall input is supported through dynamic masking mechanism and causal mask, combined with the physical model initial training and online learning mechanism, end-to-end modeling without pipeline parameters and second-level response prediction are realized.

Benefits of technology

It significantly improves the applicability in the data loss scenario, improves computing efficiency and modeling capabilities, realizes independent adaptation to changes in boundary conditions such as pipeline network siltation and transformation, and reduces the cost of intelligent transformation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119783564A_ABST
    Figure CN119783564A_ABST
Patent Text Reader

Abstract

The invention provides an urban drainage pipe network flow prediction method based on an improved Transform neural network model, and the method comprises the steps: S1, simulating the rainfall processes under different conditions through constructing a rainfall parameterization engine, and generating a rainfall data set; and S2, calculating the corresponding discharge port flow according to the rainfall data by using the calibrated physical model to form a flow data set. S3, preprocessing the data, including constructing a data set, deleting invalid data, and supplementing features and labels to form a training and verification data set; and S4, an RO-former model is constructed, the model adopts an encoder-decoder architecture, and rainfall and flow data are processed through a dynamic mask and a cross attention mechanism. And S5, training and optimizing the model through the loss function to obtain a model which can be used for predicting the urban drainage network flow in real time. The method improves the accuracy and efficiency of urban drainage pipe network flow prediction, and is of great significance to urban waterlogging early warning and drainage management.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a flow prediction technology for a city drainage network, and in particular to a method for predicting the flow of a city drainage network based on an improved Transformer neural network model. Background Art

[0002] The flow prediction of traditional urban drainage network is carried out through the runoff generation and confluence mechanism model. These runoff generation and confluence models mainly include two calculation parts: rainfall runoff generation and net rain runoff. In runoff generation calculation, commonly used methods include runoff coefficient method, infiltration curve method, full storage runoff 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 urban surface. In confluence calculation, hydrological methods such as inference formula method, isochrone method, linear or nonlinear reservoir method, Muskingum method, and hydrodynamic methods for solving Saint-Venant equation are used to calculate the confluence of urban areas. Mechanism model can analyze the various links of water body from rainfall, runoff generation, confluence to the final flow in the river channel, clearly explain the hydrodynamic and flow process of the river channel, and have important guiding significance in urban drainage system management and flood control decision-making. However, although the mechanism model has certain explanatory power, there are a series of problems and difficulties in the actual modeling process. Building an accurate runoff model requires a large amount of detailed input data, such as drainage system data, rainfall data, underlying surface data, etc., and when the model is large in scale, interface tools are required to assist in data input and management. Model pre-processing is complex and time-consuming, such as sorting out the topological relationship of the drainage system and dividing sub-catchment areas. There are many model parameters, and traditional manual parameter adjustment is inefficient and inaccurate, so optimization algorithms need to be introduced for auxiliary calibration. With the transformation of the combined sewer network, various interception devices are installed at the outlet of the network. 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 constructing the model; problems such as blockage and leakage in the actual operation of the network 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 is large in scale, solving the discretized algebraic equations also consumes a lot of computing resources.

[0003] Existing ideas for using machine learning methods to study urban drainage network flow prediction: With the widespread application of machine learning methods in the field of water science, this technology has gradually been introduced into the study of urban drainage network flow prediction. For example, Feng et al. (2023) used SWMM5.1 to establish a high-fidelity model of urban river hydrology and hydrodynamics, and simulated under different rainfall scenarios to obtain water level-flow data downstream of the upstream gate. Then, BP neural network and long short-term memory (LSTM) neural network were used to train data-driven models to replace the original mechanism model, which greatly optimized the calculation speed. Yundong Li (2024) established the LSTM-ACO model based on the training data of the SWMM-WASP mechanism coupling model, in which LSTM replaced the SWMM-WASP process model as a proxy model, and trained the process model boundary conditions and parameters as input and simulation results as output. The trained LSTM model can simulate the results of the process model in 1 minute, which takes 1.5-2 hours, and the fitting accuracy (R²) exceeds 99.9%; the ant colony optimization algorithm (ACO) is used to determine the optimal input parameter combination of the LSTM model. At present, the general method of using machine learning to predict hydrodynamic processes is basically: first establish and verify the rationality of the mechanism model, and then generate a data set based on the mechanism model to train the machine learning model. Although the computing speed of the machine learning model trained in this way is significantly improved, the SWMM flow generation model must be established first. However, due to data loss, deformation and damage of the pipe network after a period of construction, it is often difficult to build a satisfactory SWMM model. In addition, such models can usually only describe the hydrodynamic process of a single section, and cannot guide the flow prediction and flood control decision-making of the entire urban drainage system.

[0004] The current urban drainage system modeling faces four core challenges: traditional physical models (such as SWMM) rely on complete pipe network topology data, and their accuracy drops sharply due to data loss or failure in old urban areas or dynamically changing pipe network scenarios; the complex solution process based on the Saint-Venant equation takes up to minutes, which makes it difficult to meet the real-time requirements of urban waterlogging warnings; existing data-driven models (such as LSTM) are limited by fixed input lengths and cannot flexibly handle 1-6 hour long rainfall events, and sliding window sampling introduces noise data during non-rainfall periods; dynamic boundary conditions such as pipe network siltation and renovation lead to degradation of the long-term prediction capability 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 the present application, and therefore may include information that does not constitute prior art known to ordinary technicians in the field. Summary of the invention

[0006] The main purpose of the present invention is to overcome the defects existing in the above-mentioned background technology and provide a method for predicting the flow of urban drainage network based on the improved Transformer neural network model.

[0007] To achieve the above object, the present invention adopts the following technical solutions: A method for predicting the flow of urban drainage pipe network based on a modified Transformer neural network model comprises the following steps: S1. Rainfall data generation: Based on regional rainfall characteristics, a rainfall parameterization engine is constructed to simulate rainfall processes under different return periods, durations, and peak coefficients to generate representative rainfall data sets; S2, flow data simulation: input the generated rainfall data into the calibrated physical model, calculate the flow process of the corresponding outlet, and form a flow data set; S3, data preprocessing: construct a data set, take the rainfall process and outlet flow process as input and label, delete invalid data, complete features and labels, and form training and validation data sets; S4. Deep learning model construction: Build a RO-former model based on the encoder-decoder architecture, where the encoder identifies the valid data location through a dynamic mask mechanism, and the decoder adopts causal mask and dynamic length mask to support arbitrary rainfall input, and aligns rainfall features with flow response through a cross-attention mechanism; S5. Model training and optimization: Use the loss function to train and optimize the model. The trained model is used to predict the flow of urban drainage pipe networks.

[0008] Furthermore, in step S1, rainfall data is generated by simulating rainfall processes under different recurrence periods, durations and peak coefficients through a parameterized engine to generate a representative rainfall data set, and the number of rainfall fields is not less than a preset threshold.

[0009] Furthermore, in step S2, the flow data simulation calculates the flow process of the corresponding outlet by inputting the generated rainfall data into a calibrated physical model to form a flow data set, and the physical model is a calibrated hydrological and hydrodynamic model.

[0010] Furthermore, in step S3, data preprocessing includes constructing a data set, taking the rainfall process and the outlet flow process as input and labels, processing the data in batches through a data loader, and dynamically deleting invalid data, completing features and labels, and forming training and verification data sets.

[0011] Furthermore, in step S4, the encoder constructed by the deep learning model identifies the valid data position through a dynamic mask mechanism, and the encoder includes a multi-head attention module and a feedforward neural network module, wherein the multi-head attention module filters invalid data through a dynamic mask mechanism.

[0012] Furthermore, in step S4, the decoder adopts causal mask and dynamic length mask, supports arbitrary duration rainfall input, and aligns rainfall features with flow response through a cross-attention mechanism, and the decoder includes a multi-head self-attention module and a cross-attention module.

[0013] Furthermore, in step S4, the cross-attention layer adopts a dynamic key-value pair selection mechanism to automatically select the relevant time segment of the encoder output according to the current decoding position to achieve accurate alignment of rainfall characteristics and flow response.

[0014] Furthermore, the RO-former model based on the encoder-decoder architecture, wherein: The encoder part includes multiple encoder layers. Each encoder layer consists of a multi-head self-attention module and a feedforward neural network module. The multi-head self-attention module filters invalid data through a dynamic mask mechanism, and the feedforward neural network module optimizes the training process through residual connections and normalization layers. The decoder part includes multiple layers of decoder layers. Each decoder layer consists of a multi-head self-attention module, a cross-attention module, and a feedforward neural network module. The multi-head self-attention module uses causal mask and dynamic length mask, and only pays attention to historical information at the current moment. The cross-attention module aligns the rainfall characteristics output by the encoder with the traffic response of the decoder through a dynamic key-value pair selection mechanism. Position encoding is applied to the input of the encoder and decoder respectively to capture the temporal information in the time series; Linear transformations are applied to the input and output of the encoder and decoder respectively to adjust the feature dimension; A masking mechanism is used in the decoder to mask future information so that the model makes predictions based only on historical data during training.

[0015] Furthermore, in step S5, the model training and optimization adopts mean square error as the loss function, and the model performance is evaluated in combination with the Nash efficiency coefficient, and the optimizer adopts a warm-up decay learning rate scheduling strategy to gradually adjust the learning rate to improve the model training efficiency.

[0016] Furthermore, in step S5, 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.

[0017] The present invention has the following beneficial effects: The present invention proposes an intelligent modeling method for urban drainage systems based on a dynamic mask RO-former, which systematically solves the limitations of traditional models through the "generation-simulation-learning" trinity technical framework. Compared with the prior art, the present invention has the following significant advantages: 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-cooperative optimization": in terms of data dependence, it abandons the strong demand of traditional physical models for pipeline network topology data, realizes end-to-end modeling without pipeline network parameters, and significantly improves the applicability of data-missing scenarios such as old urban areas and newly built areas; in terms of computing efficiency, it compresses the time required for a single prediction from 22 seconds of SWMM to 0.6 seconds (36 times faster), meeting the requirements of urban waterlogging warning. Respond to demand in seconds; in terms of modeling capabilities, it breaks through the limitations of fixed input and output lengths of models such as LSTM, supports rainfall input of any duration of 1-6 hours through elastic position encoding and dynamic masking mechanisms, avoids noise interference from sliding window sampling, and changes the MSE index from divergence to convergence; in terms of dynamic adaptability, it integrates physical model initial training and online learning mechanisms to achieve autonomous adaptation to changes in boundary conditions such as pipe network siltation and transformation; in terms of engineering deployment, it 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 to reduce 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.

[0018] Other beneficial effects of the embodiments of the present invention will be further described below. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] 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.

[0020] Figure 2 Technology roadmap for sampling traditional sliders.

[0021] Figure 3 RO-former architecture diagram of an embodiment of the present invention.

[0022] Figure 4A-4L This is a comparison chart between the slider window sampling method and the variable length sampling method. DETAILED DESCRIPTION

[0023] The following is a detailed description of the embodiments of the present invention. It should be emphasized that the following description is only exemplary and is not intended to limit the scope and application of the present invention.

[0024] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.

[0025] See also Figure 1 The embodiment of the present invention provides a method for predicting the flow of an urban drainage network based on an improved Transformer neural network model, comprising the following steps: Step S1, rainfall data generation: Based on regional rainfall characteristics, a rainfall parameterization engine is constructed to simulate rainfall processes under different recurrence periods, durations and peak coefficients to generate a representative rainfall data set.

[0026] Specifically, in step S1, rainfall data is generated by simulating rainfall processes under different recurrence periods, durations and peak coefficients through a parameterized engine to generate a representative rainfall data set, and the number of rainfall fields is not less than a preset threshold.

[0027] Step S2, flow data simulation: input the generated rainfall data into the calibrated physical model, calculate the flow process of the corresponding outlet, and form a flow data set; Specifically, in step S2, the flow data simulation is performed by inputting the generated rainfall data into a calibrated physical model to calculate the flow process of the corresponding outlet to form a flow data set, and the physical model is a calibrated hydrological and hydrodynamic model.

[0028] Step S3, data preprocessing: construct a data set, take the rainfall process and outlet flow process as input and label, delete invalid data, complete features and labels, and form training and verification data sets.

[0029] Specifically, in step S3, data preprocessing includes constructing a data set, taking the rainfall process and the outlet flow process as input and labels, processing the data in batches through a data loader, and dynamically deleting invalid data, completing features and labels, and forming training and verification data sets.

[0030] Step S4, deep learning model construction: construct a RO-former model based on an encoder-decoder architecture, in which the encoder identifies valid data locations through a dynamic mask mechanism, and the decoder adopts causal masks and dynamic length masks to support arbitrary rainfall inputs, and aligns rainfall features with flow responses through a cross-attention mechanism; Specifically, in step S4, the encoder constructed by the deep learning model identifies the valid data position through a dynamic mask mechanism, and the encoder includes a multi-head attention module and a feedforward neural network module, wherein the multi-head attention module filters invalid data through a dynamic mask mechanism. The decoder adopts causal mask and dynamic length mask, supports arbitrary duration rainfall input, and aligns rainfall features with flow response through a cross-attention mechanism, and the decoder includes a multi-head self-attention module and a cross-attention module. The cross-attention layer adopts a dynamic key-value pair selection mechanism to automatically select the relevant time segment of the encoder output according to the current decoding position to achieve accurate alignment of rainfall features with flow response.

[0031] like Figure 3 As shown, in a preferred embodiment of the present invention, the RO-former model based on the encoder-decoder architecture, wherein the encoder part includes multiple layers of encoder layers, each encoder layer is composed of a multi-head self-attention module and a feedforward neural network module, and the multi-head self-attention module filters invalid data through a dynamic mask mechanism, and the feedforward neural network module optimizes the training process through residual connections and normalization layers; wherein the decoder part includes multiple layers of decoder layers, each decoder layer is composed of a multi-head self-attention module, a cross-attention module and a feedforward neural network module, wherein the multi-head self-attention module adopts causal mask and dynamic length mask, and only pays attention to historical information at the current moment, and the cross-attention module aligns the rainfall characteristics output by the encoder with the traffic response of the decoder through a dynamic key-value pair selection mechanism; position encoding is applied to the input of the encoder and the decoder respectively, for capturing the timing information in the time series; linear transformation is applied to the input and output of the encoder and the decoder respectively, for adjusting the feature dimension; the masking mechanism is used in the decoder to shield future information so that the model can make predictions based only on historical data during training.

[0032] Step S5, model training and optimization: use the loss function to train and optimize the model, and the trained model is used for urban drainage network flow prediction.

[0033] 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.

[0034] 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.

[0035] The specific embodiments and experiments of the present invention are further described below.

[0036] 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.

[0037] 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.

[0038] Generate-Simulate: First, we build a parameterized engine for Chicago rain patterns. First, we determine the coefficients for building Chicago rain patterns based on regional rainfall characteristics (such as the rainstorm intensity formula published by local government departments), such as the rainstorm formula:

[0039] Then, according to the rainstorm intensity formula, simulate the rainfall process with different return periods (1-100 years), various durations (1-6 hours), and different peak coefficients. Use a corrected physical model (such as SWMM) to calculate the flow process of the corresponding outlet under different rainfall processes. In order to make the rainfall representative, the number of rainfall fields should not be less than 500.

[0040] study: Use pytorch to build Dataset. The Dataset class reads the data of rainfall process and outlet flow process, and returns the rainfall process and outlet flow process of the corresponding number for each index input. Then build Dataloader according to the built Dataset. The function of dataloader is to input the data of dataset into the model in batches. Before dataloader outputs data, collate_fn is used to delete the invalid zero after the outlet. Then, the features (each batch of rainfall process) and labels (each batch of outlet flow process) are padded with 1 to obtain src and tgt tensors, and the labels (each batch of outlet flow process) are padded with 0 again to obtain real_data tensor. Use the above method to construct training data set and verification data set, where the data of training data set is obtained by simulation, and the data of verification data set is constructed by real rainfall-outlet data.

[0041] Table 1 Training configuration details

[0042] Build a deep learning network RO-former (Rainfall Outfall-former) that can dynamically process inputs of different lengths (rainfall process) and outputs of different lengths (outlet flow process): RO-former adopts an encoder-decoder architecture, with the encoder on the left and the decoder on the right.

[0043] Figure 3It is the RO-former architecture diagram of the preferred embodiment. Specifically, in the encoder part: the encoder is composed of multiple layers of encoder layers, each layer of encoder layer includes a multi-head self-attention module and a feedforward neural network module. The multi-head self-attention module filters invalid data through a dynamic mask mechanism. The dynamic mask mechanism automatically adjusts the attention range by identifying the valid positions (non-filled areas) in the input data to ensure that the model only focuses on valid data. The feedforward neural network module optimizes the training process through residual connections and normalization layers, where the residual connection is used to alleviate the gradient vanishing problem, and the normalization layer is used to prevent gradient explosion and accelerate model convergence. In the decoder part: the decoder is composed of multiple layers of decoder layers, each layer of decoder layer includes a multi-head self-attention module, a cross attention module and a feedforward neural network module. The multi-head self-attention module adopts causal mask and dynamic length mask. The causal mask ensures that only historical information is paid attention to at the current moment, and the dynamic length mask automatically adjusts the attention range by identifying the valid positions (non-filled areas) 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 to achieve precise alignment of rainfall features and flow response.

[0044] Position encoding is applied to the input of the encoder and decoder respectively to capture the timing information in the time series. Position encoding is generated by sine and cosine functions to ensure that the model can distinguish input data at different time steps. Linear transformation is applied to the input and output of the encoder and decoder respectively to adjust the feature dimension. The input of the encoder maps single-channel data to a high-dimensional space through a linear transformation, and the output of the decoder maps high-dimensional features back to single-channel data through a linear transformation. The masking mechanism is used in the decoder to mask future information to ensure that the model makes predictions based only on historical data during training. The masking mechanism sets the attention score of future time steps to negative infinity, making it impossible for the model to access future information when predicting the current time step.

[0045] The encoder gets a batch of label data from the dataloader and identifies the positions filled with 1 in each rainfall to get the encoder mask tensor.

[0046] The src tensor is linearly changed from a single channel to 64 channels, and sinusoidal position encoding is added. The encoder mask tensor is a dynamic length encoding mechanism that determines a Boolean tensor by identifying valid data positions (non-1 areas) in the src tensor. The transformed src tensor is then passed to the encoder, which consists of two major parts: a multi-head attention module consisting of a multi-head attention mechanism + residual links, standardization, and a feedforward neural network module consisting of a position feedforward neural network + residual links, standardization. When the encoder calculates the attention mechanism, when calculating the attention score, the mask tensor is applied to the attention score matrix. Specifically, if a position is marked as invalid by the mask (such as a fill position or a future position), the attention score of the position is set to a very small value (such as -inf), so that when the attention weight is calculated by the Softmax function, the weight of the position will approach zero.

[0047] The decoder receives the tgt tensor as the initial input, and is also input into the multi-head self-attention module after linear transformation and position encoding. 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 paid attention to at the current moment, and the dynamic length mask automatically adjusts the attention range by identifying the valid data position (non-1 area) in tgt. The cross-attention mask tensor is the same as the encoder mask tensor. The cross-attention layer establishes a connection between the encoder and the decoder to align the rainfall characteristics with the flow response. This part adopts a dynamic key-value pair selection mechanism to automatically select the encoder output related time segment according to the current decoding position. The feedforward neural network layer consists of two fully connected layers and an activation function, which is expressed as follows:

[0048] Where x is the input tensor and o is the output tensor. And the shape of the tensor remains unchanged after passing through the feedforward neural network.

[0049] The decoder output is linearly transformed from 64 channels to a single channel, and the sequence of predicted values ​​starts from the number of bos minus one, and the length is consistent with the actual sequence length. i It refers to a number of data before the time series to be predicted. When the time series is the outlet flow, it refers to the outlet flow sequence of a number of time steps before rainfall. In the present invention, i=1.

[0050] 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.

[0051] The initial learning rate of the Adam optimizer is 10 -3 , the learning scheduler adopts a warm-up and decay strategy. In the first 25% of the training epochs, the learning rate gradually increases linearly from a smaller value to the initial learning rate. After exceeding the number of warm-up rounds, the learning rate enters the decay phase, and the learning rate gradually decreases in an exponential decay manner.

[0052] Finally, the model is lightweight and packaged to support second-level (0.6 seconds / time) traffic prediction and edge device deployment.

[0053] Compared with the prior art, the present invention has the following advantages: 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-cooperative optimization": in terms of data dependence, it abandons the strong demand of traditional physical models for pipeline network topology data, realizes end-to-end modeling without pipeline network parameters, and significantly improves the applicability of data-missing scenarios such as old urban areas and newly built areas; in terms of computing efficiency, it compresses the time required for a single prediction from 22 seconds of SWMM to 0.6 seconds (36 times faster), meeting the requirements of urban waterlogging warning. Respond to demand in seconds; in terms of modeling capabilities, it breaks through the limitations of fixed input and output lengths of models such as LSTM, supports rainfall input of any duration of 1-6 hours through elastic position encoding and dynamic masking mechanisms, avoids noise interference from sliding window sampling, and changes the MSE index from divergence to convergence; in terms of dynamic adaptability, it integrates physical model initial training and online learning mechanisms to achieve autonomous adaptation to changes in boundary conditions such as pipe network siltation and transformation; in terms of engineering deployment, it 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 to reduce 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.

[0054] Table 2 Types, characteristics and limitations of current mainstream modeling methods

[0055] Examples: According to the public rainstorm intensity formula

[0056] Determination coefficient: a=4079.423, c=0.722, b=21.575, n=0.887. The Chicago rain pattern can be derived from the rainstorm formula: The instantaneous expression before the peak of the Chicago rain process line is: (2-3) The expression of post-peak instantaneous rainfall intensity is: (2-4) Changing the return period P and the peak coefficient r can determine the rainfall sequence in different scenarios. Put the rainfall sequence into the calibrated physical model and calculate the pipe network outlet flow sequence. Put the rainfall-pipe network outlet flow sequence into the R0-former model and update the parameters in the direction of propagation.

[0057] Compare with the traditional time series model with equal input and output lengths.

[0058] Figure 4A-4L The experimental results of the slider window sampling method and the variable length sampling method are compared.

[0059] An embodiment of the present invention further provides a storage medium for storing a computer program, which at least performs the above method when executed.

[0060] An embodiment of the present invention further provides a control device, comprising a processor and a storage medium for storing a computer program; wherein the processor is configured to execute at least the method described above when executing the computer program.

[0061] An embodiment of the present invention further provides a processor, wherein the processor executes a computer program and at least executes the method described above.

[0062] 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 magnetic random access memory (FRAM), a ferromagnetic random access memory (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 memory.

[0063] In the 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 only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: 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 coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0064] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0065] In addition, all functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0066] A person skilled in the art can understand that: all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), disks or optical disks, etc. Various media that can store program codes.

[0067] Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for 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 each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.

[0068] The methods disclosed in the several method embodiments provided by the present invention can be arbitrarily combined without conflict to obtain new method embodiments.

[0069] The features disclosed in several product embodiments provided by the present invention can be arbitrarily combined without conflict to obtain new product embodiments.

[0070] 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.

[0071] The above contents are further detailed descriptions of the present invention in combination with specific preferred embodiments, and it cannot be determined that the specific implementation of the present invention is limited to these descriptions. For those skilled in the art of the present invention, several equivalent substitutions or obvious variations can be made without departing from the concept of the present invention, and the performance or use is the same, which should be regarded as belonging to the protection scope of the present invention.

Claims

1. A method for predicting urban drainage network flow based on a modified Transformer neural network model, characterized in that: The following steps are involved: S1. Rainfall data generation: Based on regional rainfall characteristics, a rainfall parameterization engine is constructed to simulate rainfall processes under different return periods, durations, and peak coefficients to generate representative rainfall data sets; S2, flow data simulation: input the generated rainfall data into the calibrated physical model, calculate the flow process of the corresponding outlet, and form a flow data set; S3, data preprocessing: construct a data set, take the rainfall process and outlet flow process as input and label, delete invalid data, complete features and labels, and form training and validation data sets; S4. Deep learning model construction: Build a RO-former model based on the encoder-decoder architecture, where the encoder identifies the valid data location through a dynamic mask mechanism, and the decoder adopts causal mask and dynamic length mask to support arbitrary rainfall input, and aligns rainfall features with flow response through a cross-attention mechanism; S5. Model training and optimization: Use the loss function to train and optimize the model. The trained model is used to predict the flow of urban drainage pipe networks.

2. The method according to claim 1, characterized in that In step S1, rainfall data is generated by simulating rainfall processes under different recurrence periods, durations and peak coefficients through a parameterized engine to generate a representative rainfall data set, 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 is performed by inputting the generated rainfall data into a calibrated physical model to calculate the flow process of the corresponding outlet to form a flow data set, and the physical model is a calibrated hydrological and hydrodynamic model.

4. The method according to claim 1, characterized in that: In step S3, data preprocessing includes constructing a data set, taking the rainfall process and the outlet flow process as input and labels, processing the data in batches through a data loader, and dynamically deleting invalid data, completing features and labels, and forming training and verification data sets.

5. The method according to claim 1, characterized in that In step S4, the encoder constructed by the deep learning model identifies the valid data position through a dynamic mask mechanism, and the encoder includes a multi-head attention module and a feedforward neural network module, wherein the multi-head attention module filters invalid data through a dynamic mask mechanism.

6. The method according to claim 1, characterized in that In step S4, the decoder adopts causal mask and dynamic length mask, supports arbitrary duration rainfall input, and aligns rainfall features with flow response through a cross attention mechanism, and the decoder includes a multi-head self-attention module and a cross attention module.

7. The method according to claim 1, characterized in that In step S4, the cross-attention layer adopts a dynamic key-value pair selection mechanism to automatically select the relevant time segment of the encoder output according to the current decoding position to achieve accurate alignment of rainfall characteristics and flow response.

8. The method according to any one of claims 1 to 7, characterized in that: The RO-former model based on the encoder-decoder architecture, wherein: The encoder part includes multiple encoder layers. Each encoder layer consists of a multi-head self-attention module and a feedforward neural network module. The multi-head self-attention module filters invalid data through a dynamic mask mechanism, and the feedforward neural network module optimizes the training process through residual connections and normalization layers. The decoder part includes multiple layers of decoder layers. Each decoder layer consists of a multi-head self-attention module, a cross-attention module, and a feedforward neural network module. The multi-head self-attention module uses causal mask and dynamic length mask, and only pays attention to historical information at the current moment. The cross-attention module aligns the rainfall characteristics output by the encoder with the traffic response of the decoder through a dynamic key-value pair selection mechanism. Position encoding is applied to the input of the encoder and decoder respectively to capture the temporal information in the time series; Linear transformations are applied to the input and output of the encoder and decoder respectively to adjust the feature dimension; A masking mechanism is used in the decoder to mask future information so that the model makes predictions based only on historical data during training.

9. The method according to any one of claims 1 to 7, characterized in that: In step S5, the mean square error is used as the loss function for model training and optimization, and the model performance is evaluated in combination with the Nash efficiency coefficient. The optimizer adopts a warm-up decay learning rate scheduling strategy to gradually adjust the learning rate to improve the model training efficiency.

10. The method according to any one of claims 1 to 7, characterized in that: In step S5, the trained model is lightweight and encapsulated to support 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 networks.

Citation Information

Patent Citations

  • Shielding image recognition model training method and device, equipment and medium

    CN116311106A

  • Neural network architecture training method for traffic participant motion prediction

    CN118036664A

  • Autoregressive visual target tracking algorithm based on token fusion

    CN119477974A

Cited By

  • Monitoring point layout method for defect diagnosis of drainage pipe network

    CN120217610A

  • Engineering progress intelligent supervision system and method based on big data

    CN120611429A

  • Drainage pipe network overflow prediction method based on Phy-STNN model

    CN120873424A

  • A method for predicting overflow in drainage pipe networks based on the Phy-STNN model

    CN120873424B

  • A method and device for co-warning of liquid level and flow of municipal drainage pipe network

    CN122508389A