SWMM simulation model approximation method based on sparse attention and physical embedding

By introducing sparse attention mechanism and physical constraint loss function into the SWMM simulation model, the Transformer model is constructed, which solves the problem of feature capture difficulties and low computational efficiency of traditional models when processing high-dimensional timing inputs, and achieves efficient and physically consistent SWMM simulation.

CN119416667AActive Publication Date: 2025-02-11HEBEI UNIV OF ENG

Patent Information

Application Number
CN202510018954.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-07
Publication Date
2025-02-11
Estimated Expiration
2045-01-07

AI Technical Summary

Technical Problem

Traditional SWMM simulation models are difficult to effectively capture key features when processing high-dimensional timing inputs, resulting in inconsistent output results with hydrodynamic laws. At the same time, the model is complex and the training and prediction time is long, making it difficult to meet the real-time simulation needs.

Method used

Using the SWMM simulation model approximation method based on sparse attention and physical embedding, the Transformer model is constructed and the sparse attention mechanism and physical constraint loss function are introduced to ensure that the model output complies with the laws of flow conservation and contaminant conservation.

Benefits of technology

Effectively process high-dimensional timing input, ensure the physical consistency of the output results, significantly improve computing efficiency, and is suitable for real-time dynamic simulation scenarios for regional drainage optimization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119416667A_ABST
    Figure CN119416667A_ABST
Patent Text Reader

Abstract

The invention discloses an SWMM simulation model approximation method based on sparse attention and physical embedding, belongs to the technical field of simulation modeling, and aims to effectively process high-dimensional time sequence input through a sparse attention mechanism and embed physical constraints to ensure physical consistency of model approximation and ensure that an output result conforms to the law of flow conservation and pollutant conservation. The SWMM behavior is accurately approached; according to the method, a complex simulation behavior of the SWMM is replaced by an efficient deep learning prediction model, the calculation efficiency is remarkably improved, the credibility of a prediction result is ensured, the method is suitable for a real-time simulation scene of regional drainage optimization, and real-time simulation support is provided for regional hydrological management.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of simulation modeling, and in particular relates to a SWMM simulation model approximation method based on sparse attention and physical embedding. Background Art

[0002] SWMM (Storm Water Management Model) is a dynamic simulation tool used to model stormwater runoff, underground drainage networks, river basins, and pollutant migration. Its input is regional terrain and pipe network attributes, rainfall data, etc., and its output is time series runoff, pipe load, and pollutant concentration. Traditional SWMM is based on physical equations for solution, and the calculation efficiency is low in complex areas. When using deep learning models for simulation, the time series and spatial feature dimensions of the input and output of the SWMM simulation model are high. It is difficult for ordinary machine learning models to effectively capture key features and ensure that the output results are consistent with the laws of hydrodynamics. Traditional deep learning models are highly complex, take a long time to train and predict, and are difficult to meet real-time simulation needs. Summary of the invention

[0003] In view of the above-mentioned deficiencies in the prior art, the SWMM simulation model approximation method based on sparse attention and physical embedding provided by the present invention solves the problems that, when using ordinary machine learning models in traditional simulation methods, it is difficult to effectively capture key features and ensure that the output results are consistent with the laws of hydrodynamics, and the model has high complexity, long training and prediction time, and is difficult to meet real-time simulation needs.

[0004] In order to achieve the above-mentioned invention object, the technical solution adopted by the present invention is: a SWMM simulation model approximation method based on sparse attention and physical embedding is used to realize real-time dynamic simulation of regional drainage optimization, including the following steps: S1. Based on the simulation purpose, determine the input and output of the SWMM simulation model and construct the data set; S2. Build a Transformer model based on sparse attention mechanism; S3. Use the constructed data set to train the Transformer model, and embed the energy conservation and pollutant migration laws into the Transformer model by designing a physical constraint loss function to obtain a prediction model for SWMM simulation. S4. The prediction model is encapsulated as a prediction API interface and integrated into the SWMM system to achieve real-time dynamic simulation of regional drainage optimization based on real-time input data streams.

[0005] Furthermore, in step S1, the input of the SWMM simulation model includes meteorological data, regional attributes and pipe network parameters; the output of the SWMM simulation model includes hydrological response data and pollutant migration data.

[0006] Furthermore, in step S1, the method for constructing the data set is: The regional drainage scenario is determined, the corresponding output data under various input conditions are generated, and the time series of the input data are divided into fixed windows to obtain the corresponding relationship between the input and output data under the fixed windows, and the constructed data set is obtained.

[0007] Furthermore, in step S2, the Transformer model includes an input encoding module, a sparse attention mechanism module, a feedforward neural network, a physical mechanism embedding module, and an output decoding module; The input encoding module is used to encode the input of the model into high-dimensional features; The sparse attention mechanism module is used to capture short-term and long-term dependencies of high-dimensional features; The feedforward neural network is used to perform position-independent nonlinear transformation on high-dimensional features based on captured short-term and long-term dependencies; The physical mechanism embedding module is used to introduce hydraulic laws through regularization constraints; The output decoding module is used to output the predicted target.

[0008] Furthermore, the high-dimensional features encoded by the input encoding module It is expressed as:

[0009]

[0010]

[0011] In the formula, represents the embedding vector formed by the embedding vector corresponding to the encoded time position and the time series, represents the embedding vector of the time series mapped by the fully connected layer, represents a function that encodes the temporal position, represents the shared embedding of static features mapped through independent fully connected layers, Represents the pipe network parameters, Represents area attributes.

[0012] Furthermore, the sparse attention mechanism module adopts a multi-head attention mechanism, which is expressed as:

[0013] In the formula, represents the output of the sparse attention mechanism module, Indicates splicing, represents the weight matrix, Indicates the 1st~ h The output of each head is represented as:

[0014]

[0015]

[0016] In the formula, Indicates local attention. represents global attention, represents the local and global attention weight coefficients, represents the attention query vector in the attention mechanism, Indicates the attention mechanism The key vector of the step, The key vector representing the global attention, represents the dimension of the query vector in the attention mechanism, Represents the transposition character, represents the time step, Indicates a time offset.

[0017] Furthermore, the feedforward neural network performs an independent nonlinear transformation on the high-dimensional features of each time step, which is expressed as:

[0018] In the formula, represents a two-layer feedforward neural network, Represents the high-dimensional features obtained by encoding, representing the t information about a location.

[0019] Furthermore, the Transformer model also includes: performing residual connection and layer normalization processing on the output of the sparse attention mechanism module and the feedforward neural network, which is expressed as:

[0020]

[0021] In the formula, represents the result of performing residual connection on the output of the sparse attention mechanism module, represents the output of the sparse attention mechanism module, Represents high-dimensional features, represents the result of residual connection of feedforward neural network, represents the output of the feedforward neural network, Representation layer normalization.

[0022] Furthermore, the physical constraint loss function is:

[0023]

[0024]

[0025] In the formula, represents the mean square error between the model prediction and the true output, represents the water conservation loss function, represents the pollutant conservation loss function, Respectively and The weight coefficient of Indicates the inflow flow, Indicates outflow flow, represents the pollutant concentration of the inflow, represents the pollutant concentration of the outflow flow, Indicates the change in the amount of water stored, represents the change in the amount of pollutants stored, and Respectively represent the inlet and outlet number sets of the water flow in the model, Indicates the entry number. Indicates the exit number.

[0026] Furthermore, the step S3 further includes: The prediction model is validated using prediction accuracy and dynamic correlation as validation indicators.

[0027] The beneficial effects of the present invention are: (1) The proposed method effectively processes high-dimensional time series inputs through a sparse attention mechanism and embeds physical constraints to ensure the physical consistency of the model approximation, ensuring that the output results comply with the flow conservation and pollutant conservation laws and accurately approximate the SWMM behavior.

[0028] (2) The method of the present invention replaces the complex simulation behavior of SWMM with an efficient deep learning prediction model, which significantly improves the computational efficiency and ensures the credibility of the prediction results. It is suitable for real-time simulation scenarios of regional drainage optimization and provides real-time simulation support for regional hydrological management. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1Flowchart of the SWMM simulation model approximation method based on sparse attention and physical embedding. DETAILED DESCRIPTION

[0030] The specific implementation modes of the present invention are described below so that those skilled in the art can understand the present invention. However, it should be clear that the present invention is not limited to the scope of the specific implementation modes. For those of ordinary skill in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the attached claims, these changes are obvious, and all inventions and creations utilizing the concept of the present invention are protected.

[0031] The embodiment of the present invention provides a SWMM simulation model approximation method based on sparse attention and physical embedding, such as Figure 1 As shown in the figure, the real-time dynamic simulation for realizing regional drainage optimization includes the following steps: S1. Based on the simulation purpose, determine the input and output of the SWMM simulation model and construct the data set; S2. Build a Transformer model based on sparse attention mechanism; S3. Use the constructed data set to train the Transformer model, and embed the energy conservation and pollutant migration laws into the Transformer model by designing a physical constraint loss function to obtain a prediction model for SWMM simulation. S4. The prediction model is encapsulated as a prediction API interface and integrated into the SWMM system to achieve real-time dynamic simulation of regional drainage optimization based on real-time input data streams.

[0032] In step S1 of the embodiment of the present invention, the input of the SWMM simulation model includes meteorological data, regional attributes and pipe network parameters; the output of the SWMM simulation model includes hydrological response data and pollutant migration data.

[0033] Specifically, meteorological data are data in the form of time series, including rainfall intensity and evaporation; regional attributes are static characteristics, including terrain parameters (slope, elevation and area) and soil properties (permeability, initial water content and saturated hydraulic conductivity); pipeline network attributes are static characteristics, including pipeline parameters (length, diameter and roughness coefficient) and node initial water level; hydrological response data are data in the form of time series, including pipeline flow and node water depth; pollutant migration data are data in the form of time series, specifically node pollutant concentration.

[0034] The method to construct the dataset is: The regional drainage scenario is determined, the corresponding output data under various input conditions are generated, and the time series of the input data are divided into fixed windows to obtain the corresponding relationship between the input and output data under the fixed windows, and the constructed data set is obtained.

[0035] In step S2 of the embodiment of the present invention, the Transformer model includes an input encoding module, a sparse attention mechanism module, a feedforward neural network, a physical mechanism embedding module, and an output decoding module; Among them, the input encoding module is used to encode the input of the model into high-dimensional features; the sparse attention mechanism module is used to capture the short-term and long-term dependencies of high-dimensional features; the feedforward neural network is used to perform position-independent nonlinear transformation of high-dimensional features according to the captured short-term and long-term dependencies; the physical mechanism embedding module is used to introduce hydraulic laws through regularization constraints; and the output decoding module is used to output the predicted target.

[0036] In this embodiment, the high-dimensional features encoded by the input encoding module It is expressed as:

[0037]

[0038]

[0039] In the formula, represents the embedding vector formed by the embedding vector corresponding to the encoded time position and the time series, represents the embedding vector of the time series mapped by the fully connected layer, represents a function that encodes the temporal position, represents the shared embedding of static features mapped through independent fully connected layers, Represents the pipe network parameters, Represents area attributes.

[0040] Among them, the time position is encoded using sine and cosine functions, and the formula is:

[0041] In this embodiment, the sparse attention mechanism module adopts a multi-head attention mechanism, which is expressed as:

[0042] In the formula, represents the output of the sparse attention mechanism module, Indicates splicing, represents the weight matrix, Indicates the 1st~ h The output of each head is represented as:

[0043]

[0044]

[0045] In the formula, Indicates local attention. represents global attention, represents the local and global attention weight coefficients, represents the attention query vector in the attention mechanism, Indicates the attention mechanism The key vector of the step, The key vector representing the global attention, represents the dimension of the query vector in the attention mechanism, Represents the transposition character, represents the time step, Represents the time offset. Local attention refers to calculating the correlation between each time step t and the nearest w time steps in the sliding window; global attention refers to selecting key frames (such as rainfall peak points) to form global key-value pairs and model long-term dependencies.

[0046] In this embodiment, the feedforward neural network performs an independent nonlinear transformation on the high-dimensional features of each time step, which is expressed as:

[0047] In the formula, represents a two-layer feedforward neural network, Represents the high-dimensional features obtained by encoding, representing the t information about a location.

[0048] In this embodiment, the Transformer model also includes: performing residual connection and layer normalization processing on the output of the sparse attention mechanism module and the feedforward neural network, which is expressed as:

[0049]

[0050] In the formula, represents the result of performing residual connection on the output of the sparse attention mechanism module, represents the output of the sparse attention mechanism module, Represents high-dimensional features, represents the result of residual connection of feedforward neural network, represents the output of the feedforward neural network, Representation layer normalization.

[0051] In this embodiment, in the output decoding module, the encoded information passed through the above modules is decoded and output as pipeline flow, water depth and pollutants as output prediction targets.

[0052] In this embodiment, during the model training process, the flow conservation and pollutant migration laws are embedded into the model by designing a physical constraint function; specifically, the physical constraint loss function is:

[0053]

[0054]

[0055] In the formula, represents the mean square error between the model prediction and the true output, represents the water conservation loss function, represents the pollutant conservation loss function, Respectively and The weight coefficient of Indicates the inflow flow, Indicates outflow flow, represents the pollutant concentration of the inflow, represents the pollutant concentration of the outflow flow, Indicates the change in the amount of water stored, represents the change in the amount of pollutants stored, and Respectively represent the inlet and outlet number sets of the water flow in the model, Indicates the entry number. Indicates the exit number.

[0056] In this embodiment, the Transformer model is trained using the AdamW optimizer in a distributed GPU cluster, and the learning rate is adjusted using cosine annealing.

[0057] In step S3 of this embodiment, the following steps are also included: The prediction model is validated using prediction accuracy and dynamic correlation as validation indicators.

[0058] In step S4 of the embodiment of the present invention, the prediction model is encapsulated as an API interface and integrated into the SWMM system to provide a hybrid simulation model, realize an automated model calibration interface, adapt to new regional scenarios, and realize real-time dynamic simulation of regional drainage optimization based on real-time input data streams.

[0059] The present invention uses specific embodiments to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

[0060] Those skilled in the art will appreciate that the embodiments described herein are intended to help readers understand the principles of the present invention, and should be understood that the protection scope of the present invention is not limited to such specific statements and embodiments. Those skilled in the art can make various other specific variations and combinations that do not deviate from the essence of the present invention based on the technical revelations disclosed by the present invention, and these variations and combinations are still within the protection scope of the present invention.

Claims

1. A SWMM simulation model approximation method based on sparse attention and physical embedding, characterized in that: The real-time dynamic simulation for regional drainage optimization includes the following steps: S1. Based on the simulation purpose, determine the input and output of the SWMM simulation model and construct the data set; S2. Build a Transformer model based on sparse attention mechanism; S3. Use the constructed data set to train the Transformer model, and embed the energy conservation and pollutant migration laws into the Transformer model by designing a physical constraint loss function to obtain a prediction model for SWMM simulation. S4. The prediction model is encapsulated as a prediction API interface and integrated into the SWMM system to achieve real-time dynamic simulation of regional drainage optimization based on real-time input data stream.

2. The SWMM simulation model approximation method based on sparse attention and physical embedding according to claim 1, characterized in that: In step S1, the input of the SWMM simulation model includes meteorological data, regional attributes and pipe network parameters; the output of the SWMM simulation model includes hydrological response data and pollutant migration data.

3. The SWMM simulation model approximation method based on sparse attention and physical embedding according to claim 2, characterized in that: In step S1, the method for constructing the data set is: The regional drainage scenario is determined, the corresponding output data under various input conditions are generated, and the time series of the input data are divided into fixed windows to obtain the corresponding relationship between the input and output data under the fixed windows, and the constructed data set is obtained.

4. The SWMM simulation model approximation method based on sparse attention and physical embedding according to claim 1, characterized in that: In step S2, the Transformer model includes an input encoding module, a sparse attention mechanism module, a feedforward neural network, a physical mechanism embedding module and an output decoding module; The input encoding module is used to encode the input of the model into high-dimensional features; The sparse attention mechanism module is used to capture short-term and long-term dependencies of high-dimensional features; The feedforward neural network is used to perform position-independent nonlinear transformation on high-dimensional features based on captured short-term and long-term dependencies; The physical mechanism embedding module is used to introduce hydraulic laws through regularization constraints; The output decoding module is used to output the predicted target.

5. The SWMM simulation model approximation method based on sparse attention and physical embedding according to claim 4, characterized in that: The high-dimensional features encoded by the input encoding module It is expressed as: In the formula, represents the embedding vector formed by the embedding vector corresponding to the encoded time position and the time series, represents the embedding vector of the time series mapped by the fully connected layer, represents a function that encodes the temporal position, represents the shared embedding of static features mapped through independent fully connected layers, Represents the pipe network parameters, Represents area attributes.

6. The SWMM simulation model approximation method based on sparse attention and physical embedding according to claim 4, characterized in that: The sparse attention mechanism module adopts a multi-head attention mechanism, which is expressed as: In the formula, represents the output of the sparse attention mechanism module, Indicates splicing, represents the weight matrix, Indicates the 1st~ h The output of each head is represented as: In the formula, Indicates local attention. represents global attention, represents the local and global attention weight coefficients, represents the attention query vector in the attention mechanism, Indicates the attention mechanism The key vector of the step, The key vector representing the global attention, represents the dimension of the query vector in the attention mechanism, Represents the transposition character, represents the time step, Indicates a time offset.

7. The SWMM simulation model approximation method based on sparse attention and physical embedding according to claim 4, characterized in that: The feedforward neural network performs an independent nonlinear transformation on the high-dimensional features of each time step, which can be expressed as: In the formula, represents a two-layer feedforward neural network, Represents the high-dimensional features obtained by encoding, representing the t location information.

8. The SWMM simulation model approximation method based on sparse attention and physical embedding according to claim 4, characterized in that: The Transformer model also includes: residual connection and layer normalization processing of the output of the sparse attention mechanism module and the feedforward neural network, which is expressed as: In the formula, represents the result of performing residual connection on the output of the sparse attention mechanism module, represents the output of the sparse attention mechanism module, Represents high-dimensional features, represents the result of residual connection of feedforward neural network, represents the output of the feedforward neural network, Representation layer normalization.

9. The SWMM simulation model approximation method based on sparse attention and physical embedding according to claim 4, characterized in that: The physical constraint loss function is: In the formula, represents the mean square error between the model prediction and the true output, represents the water conservation loss function, represents the pollutant conservation loss function, Respectively and The weight coefficient of Indicates the inflow flow, Indicates outflow flow, represents the pollutant concentration of the inflow, represents the pollutant concentration of the outflow flow, Indicates the change in the amount of water stored, represents the change in the amount of pollutants stored, and Respectively represent the inlet and outlet number sets of the water flow in the model, Indicates the entry number. Indicates the exit number.

10. The SWMM simulation model approximation method based on sparse attention and physical embedding according to claim 1, characterized in that: The step S3 further includes: The prediction model is validated using prediction accuracy and dynamic correlation as validation indicators.

Citation Information

Patent Citations

  • Water quality prediction method based on Transform sparse attention mechanism

    CN116050571A

  • Industrial process fault detection method based on local information enhancement and sparse attention mechanism

    CN117216555A

  • Urban water network multi-scale flood control and drainage joint optimization scheduling method and system

    CN117236673A

  • Flood prediction method and device, electronic equipment and readable storage medium

    CN117556255A

  • Power grid facility waterlogging disaster intelligent prediction method and device based on fluid large model

    CN118735046A

Cited By

  • Supply chain modeling method based on platform operation mode and carbon transaction policy

    CN119831620A

  • Drainage basin runoff prediction method and system fusing graph attention network and physical constraint

    CN121390393A

  • A method and system for predicting watershed runoff by fusing graph attention network and physical constraints

    CN121390393B

  • Flood disaster real-time early warning and dynamic decision-making method based on distributed optical fibers

    CN121502305A

  • Real-time flood disaster warning and dynamic decision-making method based on distributed optical fiber

    CN121502305B