Reservoir dam break early warning method and system, electronic equipment and storage medium
By combining the Apache Spark module with the LSTM model, multimodal feature fusion and dynamic threshold adjustment of reservoir dam failure risk were achieved, solving the problems of high false alarm rate and poor timeliness of traditional reservoir early warning systems, and improving the accuracy and flexibility of reservoir safety management.
Patent Information
- Application Number
- CN202511170742.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-20
- Publication Date
- 2025-10-31
AI Technical Summary
Existing reservoir early warning systems rely on traditional threshold alarm methods and lack the ability to deeply integrate and correlate multi-source heterogeneous monitoring data. They are unable to adapt to the time-varying nature of reservoir operation and the uncertainty of sudden risks, resulting in high false alarm rates and poor early warning timeliness.
Data processing is performed using the Apache Spark module. Through the collaborative optimization of temporary tables and Spark stream processing, combined with the LSTM model for multimodal feature fusion, and dynamic adjustment of thresholds, real-time assessment of dam failure risk and determination of multi-level risk levels are achieved.
It significantly improves the accuracy and reliability of risk prediction, reduces the false alarm rate, enhances the scientific nature and timeliness of early warning, and supports the adaptability to diverse data storage environments and the portability of the system.
Smart Images

Figure CN120875577A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of reservoir early warning technology, and in particular to a method, system, electronic device and storage medium for early warning of reservoir dam failure. Background Technology
[0002] Reservoirs, as crucial water infrastructure, serve multiple functions including flood control, water supply, power generation, and ecological regulation. Their safe operation directly impacts the safety of downstream residents' lives and property, as well as socio-economic stability. In recent years, influenced by climate change, extreme rainfall events have become more frequent, exacerbating the risks to reservoirs, such as flood over-storage, dam leakage, and structural damage. Simultaneously, some older reservoirs, due to low construction standards and long-term operational aging, have further increased safety hazards. Therefore, establishing an efficient and accurate reservoir early warning system to enable early prediction and rapid response to risks such as floods, leakage, and structural safety has become an urgent need for water conservancy project management.
[0003] Currently, reservoir early warning mainly relies on traditional monitoring methods and single analysis approaches, which have significant technical limitations. Traditional methods primarily use threshold-based alarms (such as triggering an alarm when the water level exceeds a set value), lacking the ability to deeply integrate and correlate multi-source heterogeneous monitoring data. Although some schemes introduce simple statistical models (such as moving averages and analysis of variance), they are difficult to adapt to the time-varying nature of reservoir operation and the uncertainty of sudden risks, resulting in high false alarm rates and poor early warning timeliness. Summary of the Invention
[0004] To address the aforementioned problems in the existing technology, this invention provides a method, system, electronic device, and storage medium for early warning of reservoir dam failures. The technical problem to be solved by this invention is achieved through the following technical solution: The first aspect of this invention provides a method for early warning of reservoir dam failure, comprising the following steps: The Apache Spark module retrieves the current dataset after the furthest time from the source database based on the furthest time in the first temporary table; wherein, the first temporary table includes a station identification number field and a timestamp field; the time in the timestamp field is the latest time of the collected station data; The Apache Spark module updates the second temporary intermediate table based on the current dataset and generates update instructions for the target database; wherein, the second temporary intermediate table is stored in the target database, and the structure of the second temporary intermediate table is the same as the structure of the target table in the target database; the first temporary table and the second temporary table are pre-created. The target database updates the target table according to the update instruction to obtain the input dataset; wherein, the target table includes an hourly rainfall table, an hourly reservoir water level table, and an hourly weir and sluice gate water level table; The Apache Spark module associates the training dataset with time and station identification number and then inputs it into the LSTM model for training until the loss function meets the convergence condition, thus obtaining the target LSTM model. The Apache Spark module preprocesses the input dataset by associating it with time and station identification number to obtain input features; The prediction module inputs the input features into the target LSTM model and outputs the dam failure risk value; The calculation module determines the target weight of the dynamic threshold based on the dam failure risk value, and calculates the current dynamic threshold based on the target weight; The determination module determines the dam failure risk level based on the current dynamic threshold or the dam failure risk value.
[0005] In one embodiment of the present invention, the Apache Spark module updates the second temporary intermediate table based on the current dataset and generates an update instruction for the target database, including: The Apache Spark module performs linear interpolation on the missing data in the current dataset to obtain the complete data; The Apache Spark module deletes the data from the second temporary intermediate table and writes the complete data into the second temporary intermediate table; The Apache Spark module generates update instructions for the target database based on the second temporary intermediate table; The Apache Spark module writes the update command to the target database.
[0006] In one embodiment of the present invention, the method further includes: The Apache Spark module updates the first temporary table with the latest time of the complete data.
[0007] In one embodiment of the present invention, the Apache Spark module preprocesses the input dataset by associating it with time and station identification number to obtain input features, including: The Apache Spark module associates the input dataset with time and station identification number to obtain associated data; The Apache Spark module calculates the reservoir flow difference, upstream and downstream water level difference, reservoir capacity ratio, and reservoir water level ratio based on the associated data, and obtains the hourly cumulative rainfall, reservoir water level, and total gate flow as initial features. The Apache Spark module normalizes the initial features to obtain the input features.
[0008] In one embodiment of the present invention, the calculation module determines a target weight for the dynamic threshold based on the dam failure risk value, and calculates the current dynamic threshold based on the target weight, including: The calculation module determines that when the dam failure risk value is greater than the first preset threshold, the first preset weight set is used as the target weight of the dynamic threshold. The calculation module determines that when the dam failure risk value is greater than the second preset threshold, the second preset weight set is used as the target weight of the dynamic threshold. The calculation module determines that when the dam failure risk value is less than or equal to the second preset threshold, the third preset weight set is used as the target weight of the dynamic threshold; wherein, the first preset threshold is greater than the second preset threshold; The calculation module calculates the current dynamic threshold based on the target weight.
[0009] In one embodiment of the present invention, the formula for calculating the current dynamic threshold is: in, , , This represents the target weight.
[0010] In one embodiment of the present invention, the determining module determines the dam failure risk level based on the current dynamic threshold or the dam failure risk value, including: The determination module determines that when the dam failure risk value is greater than the third preset threshold or the current dynamic threshold is greater than the fourth preset threshold, the dam failure risk level is determined to be high. The determination module determines that when the dam failure risk value is greater than the fifth preset threshold or the current dynamic threshold is greater than the sixth preset threshold, the dam failure risk level is determined to be medium. The determination module determines that the dam failure risk level is normal when the dam failure risk value is less than or equal to the fifth preset threshold or the current dynamic threshold is less than or equal to the sixth preset threshold.
[0011] A second aspect of this invention provides a reservoir dam failure early warning system, comprising: The Apache Spark module is used to retrieve the current dataset after the furthest time from the source database based on the furthest time in the first temporary table; wherein the first temporary table includes a station identification number field and a timestamp field; the time in the timestamp field is the latest time of the collected station data; The Apache Spark module is also used to update the second temporary intermediate table based on the current dataset and generate update instructions for the target database; wherein the second temporary intermediate table is stored in the target database, the structure of the second temporary intermediate table is the same as the structure of the target table in the target database, and the first temporary table and the second temporary table are pre-created; The target database is used to update the target table according to the update instruction to obtain the input dataset; wherein, the target table includes an hourly rainfall table, an hourly reservoir water level table, and an hourly weir and sluice gate water level table; The Apache Spark module is also used to associate the training dataset with time and station identification number and then input it into the LSTM model for training until the loss function meets the convergence condition to obtain the target LSTM model. The Apache Spark module is also used to preprocess the input dataset by associating it with time and station identification number to obtain input features; The prediction module is used to input the input features into the target LSTM model and output the dam failure risk value; The calculation module is used to determine the target weight of the dynamic threshold based on the dam failure risk value, and to calculate the current dynamic threshold based on the target weight; The determination module is used to determine the dam failure risk level based on the current dynamic threshold or the dam failure risk value.
[0012] A third aspect of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement a reservoir dam failure early warning method provided in the first aspect of the present invention.
[0013] A fourth aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements a reservoir dam failure early warning method provided in the first aspect of the present invention.
[0014] The beneficial effects of this invention are: This invention optimizes data transfer through the collaboration of temporary tables and Spark stream processing. It eliminates the need for complex Change Data Capture (CDC) tools or direct monitoring of database logs (such as MySQL Binlog or Oracle Redo Log). Instead, it directly writes data changes to temporary tables via business logic or database triggers. This approach avoids the need for CDC tool deployment, reduces the system's dependence on the underlying database log structure, and enables low-latency and efficient synchronization from the source database to the target database. The first temporary table can be flexibly deployed in any database or file system, breaking through the limitations of traditional CDC tools on specific database types and adapting to diverse data storage environments.
[0015] Meanwhile, this invention achieves multimodal feature fusion for risk prediction by combining hourly rainfall data, hourly reservoir water level data, and hourly weir and sluice gate water level data. This enables a more comprehensive capture of the combined impact of flood evolution, reservoir capacity changes, and weir and sluice gate scheduling on dam safety, significantly improving the accuracy and reliability of risk prediction. The risk value prediction model assesses the dam break risk level under current conditions in real time and dynamically adjusts the sensitivity and judgment criteria of the threshold accordingly, significantly improving the robustness and anti-interference ability of risk assessment. By outputting quantified risk values through the risk prediction model and combining them with the dynamic threshold calculation results, a multi-level dam break risk assessment system is constructed. The synergistic analysis of risk values and dynamic thresholds significantly improves the scientific rigor and accuracy of risk early warning, helping downstream areas to formulate differentiated disaster prevention measures in advance.
[0016] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings.
[0017] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description
[0018] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings: Figure 1 A schematic flowchart of a reservoir dam failure early warning method provided in an embodiment of the present invention; Figure 2 This is a block diagram of a reservoir dam failure early warning system provided in an embodiment of the present invention. Detailed Implementation
[0019] The present invention will be further described in detail below with reference to specific embodiments, but the implementation of the present invention is not limited thereto.
[0020] like Figure 1 As shown, the first aspect of this invention provides a method for early warning of reservoir dam failure, comprising the following steps: Step 11: The Apache Spark module retrieves the current dataset from the source database based on the furthest time in the first temporary table.
[0021] The first temporary table includes a station identification number field and a timestamp field; the timestamp field shows the latest time of the collected station data.
[0022] Step 12: The Apache Spark module updates the second temporary intermediate table based on the current dataset and generates update instructions for the target database.
[0023] The second temporary intermediate table is stored in the target database, and its structure is the same as that of the target table in the target database. The first and second temporary tables are created in advance.
[0024] Step 13: The target database updates the target table according to the update instruction to obtain the input dataset.
[0025] The target tables include hourly rainfall tables, hourly reservoir water level tables, and hourly weir and sluice gate water level tables.
[0026] Step 14: The Apache Spark module associates the training dataset with time and station identification number and then inputs it into the LSTM model for training until the loss function meets the convergence condition, thus obtaining the target LSTM model.
[0027] Step 15: The Apache Spark module preprocesses the input dataset by associating it with the time and station identification number to obtain the input features.
[0028] Step 16: The prediction module inputs the input features into the target LSTM model and outputs the dam failure risk value.
[0029] Step 17: The calculation module determines the target weight of the dynamic threshold based on the dam failure risk value, and calculates the current dynamic threshold based on the target weight.
[0030] Step 18: The module determines the dam failure risk level based on the current dynamic threshold or dam failure risk value.
[0031] Apache Spark is an open-source, distributed, in-memory computing big data processing framework. This embodiment optimizes the interaction between temporary tables and Spark stream processing, eliminating the need for complex CDC (Change Data Capture) tools or direct monitoring of database logs (such as MySQL Binlog or Oracle Redo Log). Instead, data changes are directly written to temporary tables via business logic or database triggers. This approach avoids the need for CDC tool deployment, reduces the system's dependence on the underlying database log structure, and enables low-latency and efficient synchronization from the source database to the target database. The first temporary table can be flexibly deployed in any database or file system, breaking through the limitations of traditional CDC tools on specific database types and adapting to diverse data storage environments.
[0032] Meanwhile, this embodiment achieves multimodal feature fusion for risk prediction by combining hourly rainfall, hourly reservoir water level, and hourly weir and sluice gate water level tables. This enables a more comprehensive capture of the combined impact of flood evolution, reservoir capacity changes, and weir and sluice gate scheduling on dam safety, significantly improving the accuracy and reliability of risk prediction. The risk value prediction model assesses the dam break risk level under current conditions in real time and dynamically adjusts the sensitivity and judgment criteria of the threshold accordingly, significantly improving the robustness and anti-interference capability of risk assessment. By outputting quantified risk values from the risk prediction model and combining them with the dynamic threshold calculation results, a multi-level dam break risk assessment system is constructed. The synergistic analysis of risk values and dynamic thresholds significantly improves the scientific rigor and accuracy of risk early warning, helping downstream areas to formulate differentiated disaster prevention measures in advance.
[0033] Based on the first aspect of the present invention, the second aspect of the present invention provides a method for early warning of reservoir dam failure, comprising the following steps: Step 21: The Apache Spark module retrieves the current dataset from the source database based on the furthest time in the first temporary table.
[0034] The first temporary table includes a station identification number field and a timestamp field; the timestamp field shows the latest time of the collected station data. Each station identification number is unique.
[0035] In this step, the first temporary table is created in advance and stored in any kind of database or file system. The first temporary table records the latest time of data collected for each station in each batch.
[0036] Data for different operating conditions are stored in different first temporary tables. Hourly rainfall, hourly reservoir water level, and hourly weir and sluice gate water level are stored in three first temporary tables. When processing data for different operating conditions, the corresponding first temporary table is used.
[0037] Before step 21, it can be determined whether the first temporary table is empty. If it is empty, the station identifier number and the latest time of the corresponding collected data from the target table are written into the first temporary table. Then, the furthest time from the current time among all stations in the first temporary table is obtained. Next, the dataset of the stations in the first temporary table after the furthest time is obtained from the source database. The data fields in the current dataset include all fields from the source database.
[0038] Step 22: The Apache Spark module updates the second temporary intermediate table based on the current dataset and generates update instructions for the target database.
[0039] The second temporary intermediate table is stored in the target database, and its structure is the same as that of the target table in the target database. The first and second temporary tables are created in advance.
[0040] Step 22 includes steps 221-224: Step 221: The Apache Spark module performs linear interpolation on the missing data in the current dataset to obtain the complete data.
[0041] In this step, the Apache Spark module sorts the current dataset in chronological order, finds missing data, performs linear interpolation on the two nearest points with values to the missing data to obtain the interpolated value, writes the interpolated value y, and obtains the complete data.
[0042] The formula for linear interpolation is: y=(y2-y1)*(t-t1) / (t2-t1), where t1 and t2 are the times of two adjacent points of the missing data, t is the time of the missing data, and y2 and y1 are the data corresponding to the times t1 and t2. t is generally not missing, and the missing data y is calculated.
[0043] In step 222, the Apache Spark module deletes the data from the second temporary intermediate table and writes the complete data into the second temporary intermediate table.
[0044] Step 223: The Apache Spark module generates update instructions for the target database based on the second temporary intermediate table.
[0045] In step 224, the Apache Spark module writes the update instructions to the target database.
[0046] Step 23: The target database updates the target table according to the update instruction to obtain the input dataset.
[0047] The target tables include hourly rainfall tables, hourly reservoir water level tables, and hourly weir and sluice gate water level tables. Correspondingly, there are three second temporary intermediate tables, each corresponding to one of the three target tables. After updating the target tables, the data in the source database is synchronized to the target database, completing the data synchronization.
[0048] In one feasible implementation, after step 23 and before step 24, step A1 can also be executed: In step A1, the Apache Spark module updates the first temporary table with the latest time for each station of the complete data.
[0049] It's important to note that the Apache Spark module does not support update operations, only writing and deleting data. Therefore, the Apache Spark module requires CDC or binlog monitoring. Consequently, database log permissions need to be configured during data synchronization, involving sensitive permission configurations, and storage management may also impact database performance. There are also compatibility limitations: different databases (MySQL, Oracle, etc.) have significantly different log formats and interfaces, requiring customized development. Furthermore, CDC log parsing consumes substantial computing resources, easily becoming a bottleneck in high-concurrency scenarios; while full table polling results in high I / O pressure and significant latency (typically on the order of hours), leading to high latency and high I / O overhead.
[0050] In this embodiment, instead of relying on complex CDC (Change Data Capture) tools or directly monitoring database logs (such as MySQL Binlog or Oracle Redo Log), data changes are directly written to the first temporary table and the second temporary intermediate table through business logic or database triggers. This approach avoids the deployment of CDC tools, reduces the system's dependence on the underlying database log structure, lowers the coupling between the data acquisition module and the database, and improves the system's portability and deployment flexibility.
[0051] By leveraging Spark's structured streaming micro-batch processing mechanism, temporary log tables are scanned at configurable time intervals (e.g., seconds or minutes), and incremental metadata markers (e.g., timestamps, unique business identifiers, STCDs, etc.) are used to accurately identify newly added or changed data. Compared to traditional full data scanning or fixed-interval polling methods, this significantly reduces the overhead of reading and processing invalid data, achieving near real-time (or near real-time) data capture and processing. This enables faster response to changes in business data and meets the needs of high-timeliness scenarios.
[0052] The first temporary table can be flexibly deployed in any database (such as MySQL, PostgreSQL) or file system (such as HDFS, local storage), breaking through the limitations of traditional CDC tools on specific database types and adapting to diverse data storage environments. Meanwhile, the log table supports extended fields (such as previous values, operation types, etc.) to facilitate recording richer contextual information and meet complex business analysis needs. Furthermore, if it is necessary to re-collect historical data for a single field, only the range of the timestamp field (tm) in the log table needs to be adjusted to achieve targeted backtracking, without needing to reconstruct the entire data collection process, significantly improving the convenience and maintainability of data management.
[0053] The second temporary intermediate table automatically deletes synchronized data based on the data processing status to avoid storage bloat, while the first temporary table is automatically filled after being checked for emptiness, thus achieving automated lifecycle management.
[0054] The precise fetching mechanism based on incremental metadata tagging avoids redundant scanning and processing of the entire dataset, significantly reducing resource consumption (such as CPU, memory, and I / O overhead) in Spark stream computing and improving computational efficiency. Meanwhile, the temporary table, as a lightweight intermediate carrier, only needs to store the incrementally changed data, greatly reducing storage space usage and lowering long-term storage costs.
[0055] By separating data change capture, storage, and processing logic (temporary tables are independent of business tables and analysis modules), each module can be independently expanded and maintained, avoiding the system-level failure risks caused by CDC tools or log parsing anomalies in traditional solutions. Furthermore, it can easily adapt to multiple business scenarios (such as changes in different database types and multi-table relationships) without requiring customized development for specific scenarios, enhancing the system's versatility and scalability.
[0056] In summary, this embodiment achieves data change capture and processing with no CDC, low latency, and high flexibility through the collaborative optimization of temporary tables and Spark stream processing, which can effectively support large-scale data processing scenarios with high real-time requirements and complex data sources.
[0057] Step 24: The Apache Spark module associates the training dataset with time and station identification number and inputs it into the LSTM model for training until the loss function meets the convergence condition, thus obtaining the target LSTM model.
[0058] In this step, the training dataset includes hourly historical rainfall data, hourly historical reservoir water level data, and hourly historical weir and sluice gate water level data. When associating these three types of data, they are associated based on station identification numbers. Data from the same station are also associated according to timestamps, with data from the same hour at the same station grouped together. The hourly reservoir water level timestamp is used as the standard, allowing a deviation of 3600 seconds (1 hour). After data association is completed, the reservoir flow difference, upstream and downstream water level difference, reservoir capacity ratio, and reservoir upper water level ratio are calculated. Hourly rainfall, reservoir upper water level, and total sluice gate flow are also obtained as features. The Apache Spark module merges these features into column vectors, normalizes them, adds labels, and inputs them into the LSTM model for training until the loss function meets the convergence condition, resulting in the target LSTM model.
[0059] Here, the label creation process during training includes: Step B1: Based on engineering design specifications or historical experience, set a safety threshold (normal range), a warning threshold (risk starting point), and a danger threshold (high-risk critical point) for each feature. Here, the thresholds are continuous values between 0 and 1.
[0060] Step B2, Calculate the risk score for each individual feature: For each normalized feature, calculate the individual risk score based on its current value and its relative position to the threshold. Common methods include linear interpolation or piecewise functions. Let's take piecewise functions as an example: in, Represents any eigenvalue, Indicates the warning threshold. This indicates the danger threshold.
[0061] Step B3, Dynamic Weight Allocation and Comprehensive Risk Score: Different features contribute differently to the risk of dam failure (for example, water level usually has a greater impact than rainfall), so dynamic weights need to be assigned to each feature. w i The dam failure risk value y (0~1) is calculated by weighted summation and used as a label.
[0062] Step 25: The Apache Spark module preprocesses the input dataset by associating it with the time and station identification number to obtain the input features.
[0063] Step 25 includes steps 251-253: Step 251: The Apache Spark module associates the input dataset with the time and station identification number to obtain associated data.
[0064] The input dataset includes the latest hourly rainfall, hourly reservoir water level, and hourly weir and sluice gate water level data obtained when synchronization is completed. The association method is the same as the association method during model training in step 24. The data is associated according to the station identification number. Data from the same station is also associated according to the timestamp. Data from the same hour of the same station are associated as a group, with the timestamp of the hourly reservoir water level as the standard, allowing a deviation of 3600 seconds (1 hour).
[0065] Step 252: The Apache Spark module calculates the reservoir flow difference, upstream and downstream water level difference, reservoir capacity ratio, and reservoir water level ratio based on the associated data, and obtains the hourly cumulative rainfall, reservoir water level, and total flow through the gate as initial features.
[0066] The hourly rainfall table includes, but is not limited to, the following fields: rainfall monitoring point code (station identification number) - stcd, year - Yr, month - Mnth, ten-day period - Prdtp, day - Day, hour - Hour, rainfall time - Tm, cumulative rainfall - Accp, and update time - Moditime.
[0067] The hourly reservoir hydrological data table includes, but is not limited to, the following fields: reservoir hydrological monitoring point code (station identification number) - Stcd, monitoring time - Tm, reservoir water level - Rz, water storage - W, inflow - Inq, outflow - Otq, and update time - Update_time.
[0068] The hourly weir and sluice gate hydrological information table includes, but is not limited to, the following fields: river hydrological station code (station identification number) - Stcd, monitoring time - Tm, upstream water level - Upz, downstream water level - Dwz, total flow through the gate - Tgtq, and update time - Update_time.
[0069] Specifically, the reservoir flow difference = inflow - outflow, the upstream and downstream water level difference = upstream water level - downstream water level, the reservoir capacity ratio = water storage / design reservoir capacity, the reservoir surface water level ratio = reservoir surface water level / design water level, and the hourly cumulative rainfall, reservoir surface water level and total flow through the gate are obtained.
[0070] Step 253: The Apache Spark module normalizes the initial features to obtain the input features.
[0071] The code examples for steps 251-253 are as follows: import org.apache.spark.sql.{DataFrame, SparkSession} import org.apache.spark.sql.functions._ import org.apache.spark.sql.expressions.Window class DataProcessor(spark: SparkSession, designParams: Map[String,Double]) { / / Load and join three tables def loadAndJoin(rainPath: String, rsvrPath: String, wasPath: String):DataFrame = { val dfRain = spark.read.option("header","true").csv(rainPath) .select(col("stcd"), col("tm"), col("accp").cast("double")) val dfRsvr = spark.read.option("header","true").csv(rsvrPath) .select(col("stcd"), col("tm"), col("rz").cast("double"), col("inq").cast("double"), col("otq").cast("double"), col("w").cast("double")) val dfWas = spark.read.option("header","true").csv(wasPath) .select(col("stcd"), col("tm"), col("Upz").cast("double"), col("dwz").cast("double"), col("Tgtq").cast("double")) / / Window join val joined = dfRsvr.as("rsvr") .join(dfRain.as("rain"), expr("rsvr.stcd = rain.stcd AND abs(rsvr.tm - rain.tm)<= 3600"), "left") .join(dfWas.as("was"), expr("rsvr.stcd = was.stcd AND abs(rsvr.tm - was.tm)<= 3600"), "left") .selectExpr("rsvr.stcd", "rsvr.tm", "rz", "inq", "otq", "w", "accp", "Upz", "dwz", "Tgtq") joined } / / Feature engineering def createFeatures(df: DataFrame): DataFrame = { / / Sliding window definition val windowSpec = Window.partitionBy("stcd").orderBy("tm").rowsBetween(-5, 0) df.withColumn("net_inflow", col("inq") - col("otq")) .withColumn("gate_pressure", col("Upz") - col("dwz")) .withColumn("rolling_rain", sum(col("accp")).over(windowSpec)) .withColumn("storage_ratio", col("w") / lit(designParams("design_capacity"))) .withColumn("level_ratio", col("rz") / lit(designParams("safety_level"))) .na.fill(0) } / / Generate LSTM input sequence def createSequences(df: DataFrame, seqLength: Int): DataFrame = { val window = Window.partitionBy("stcd").orderBy("tm") val sequenceCols = Seq("rz", "net_inflow", "rolling_rain", "gate_pressure", "storage_ratio", "level_ratio", "Tgtq") sequenceCols.foldLeft(df)((df, colName) => df.withColumn(colName + "_seq", collect_list(col(colName)).over(window.rowsBetween(-seqLength+1, 0))) .filter(size(col("rz_seq")) === seqLength) } } Step 26: The prediction module inputs the input features into the target LSTM model and outputs the dam failure risk value.
[0072] Step 27: The calculation module determines the target weight of the dynamic threshold based on the dam failure risk value predRisk, and calculates the current dynamic threshold thd (threshold) based on the target weight.
[0073] Step 27 specifically includes steps 271-274: Step 271: The calculation module determines that when the dam failure risk value is greater than the first preset threshold, the first preset weight set is used as the target weight of the dynamic threshold.
[0074] For example, when the dam failure risk value is greater than the first preset threshold of 0.6, the first preset weight set is: , , .
[0075] Step 272: The calculation module determines that when the dam failure risk value is greater than the second preset threshold, the second preset weight set is used as the target weight of the dynamic threshold.
[0076] For example, when the dam failure risk value is greater than the second preset threshold of 0.3, the second preset weight set is: , , .
[0077] Step 273: The calculation module determines that when the dam failure risk value is less than or equal to the second preset threshold, the third preset weight set is used as the target weight of the dynamic threshold.
[0078] For example, when the dam failure risk value is less than or equal to the second preset threshold of 0.3, the third preset weight set is: , , .
[0079] The first preset threshold is greater than the second preset threshold.
[0080] Step 274: The calculation module calculates the current dynamic threshold based on the target weight.
[0081] The current dynamic threshold is calculated using the following formula: in, , , This indicates the target weight. The predicted rainfall for the next 3 hours is the weather forecast information issued by the meteorological department, and the historical maximum rainfall is the maximum rainfall in long-term historical records, such as the maximum rainfall in ten or twenty years.
[0082] Step 28: The module determines the dam failure risk level based on the current dynamic threshold or dam failure risk value.
[0083] Step 28 includes steps 281-283: Step 281: The module determines that when the dam failure risk value is greater than the third preset threshold or the current dynamic threshold is greater than the fourth preset threshold, the dam failure risk level is determined to be high.
[0084] For example, when the dam failure risk value is greater than the third preset threshold of 0.7 or the current dynamic threshold is greater than the fourth preset threshold of 0.85, the module outputs a dam failure risk level of "high", which is a red warning.
[0085] Step 282: The module determines that when the dam failure risk value is greater than the fifth preset threshold or the current dynamic threshold is greater than the sixth preset threshold, the dam failure risk level is determined to be medium.
[0086] For example, when the dam failure risk value is greater than the fifth preset threshold of 0.5 or the current dynamic threshold is greater than the sixth preset threshold of 0.75, the module outputs a dam failure risk level of medium, which is an orange warning.
[0087] Step 283: The module determines that the dam failure risk level is normal when the dam failure risk value is less than or equal to the fifth preset threshold or the current dynamic threshold is less than or equal to the sixth preset threshold.
[0088] For example, when the dam failure risk value is less than or equal to the fifth preset threshold of 0.5 or the current dynamic threshold is less than or equal to the sixth preset threshold of 0.75, the module outputs the dam failure risk level as normal.
[0089] For example, the complete code example for steps 24-28 is as follows: import org.apache.spark.sql.SparkSession import org.apache.spark.sql.functions._ import org.deeplearning4j.nn.conf.MultiLayerConfiguration import org.deeplearning4j.nn.conf.NeuralNetConfiguration import org.deeplearning4j.nn.conf.layers.LSTM import org.deeplearning4j.nn.conf.layers.RnnOutputLayer import org.deeplearning4j.nn.multilayer.MultiLayerNetwork import org.deeplearning4j.nn.weights.WeightInit import org.nd4j.linalg.activations.Activation import org.nd4j.linalg.api.ndarray.INDArray import org.nd4j.linalg.dataset.DataSet import org.nd4j.linalg.dataset.api.iterator.DataSetIterator import org.nd4j.linalg.factory.Nd4j import org.nd4j.linalg.learning.config.Adam import org.nd4j.linalg.lossfunctions.LossFunctions object ReservoirEarlyWarning { def main(args: Array[String]): Unit = { / / Initialize SparkSession val spark = SparkSession.builder() .appName("ReservoirEarlyWarning") .master("local[*]") .getOrCreate() / / Initialize parameters val designParams = Map( "capacity" ->1e8, "safetyLevel" ->185.0, "maxInflow" ->5000, "gateCapacity" ->3000 ) / / Data preparation val (X, y) = prepareDataset(spark, designParams) / / Split the dataset val splitRatio = Array(0.8, 0.2) val Array(X_train, X_val) = X.randomSplit(splitRatio) val Array(y_train, y_val) = y.randomSplit(splitRatio) / / Model Training val model = buildLSTMModel(6, 7) trainModel(model, X_train, y_train) / / Forecasting and Early Warning val sample = X_val.head() val (predLevel, predFlow, predRisk) = predict(model, sample) val thresholdCtrl = new DynamicThresholdController(designParams) thresholdCtrl.update_weights(predRisk) val currentState = Map( "rz" ->sample(1).asInstanceOf[Double], "Tgtq" ->sample(7).asInstanceOf[Double] ) val threshold = thresholdCtrl.calculate_threshold(currentState, Map("flow" ->predFlow)) / / Early warning decision val warningLevel = if (predRisk>0.7 || threshold>0.85) "red" else if (predRisk>0.5 || threshold>0.75) "orange" else "normal" println(s"Warning Level: $warningLevel, Predicted Risk Value: ${predRisk.formatted("%.2f")}, Dynamic Threshold: ${threshold.formatted("%.2f")}") spark.stop() } def prepareDataset(spark: SparkSession, designParams: Map[String,Double]): (Array[Array[Double]], Array[Array[Double]]) = { / / Load and join three original tables val df_rain = spark.read.csv("st_pptn_r_hi.csv").select("stcd", "tm","accp") val df_rsvr = spark.read.csv("st_rsvr_r_hi.csv").select("stcd", "tm","rz", "inq", "otq", "w") val df_was = spark.read.csv("st_was_r_hi.csv").select("stcd", "tm", "Upz", "dwz", "Tgtq") val merged = df_rsvr.as("r") .join(df_rain.as("p"), Seq("stcd", "tm"), "left_outer") .join(df_was.as("w"), Seq("stcd", "tm"), "left_outer") .na.drop() / / Feature engineering val featureDf = merged .withColumn("net_inflow", col("inq") - col("otq")) .withColumn("gate_pressure", col("Upz") - col("dwz")) .withColumn("rolling_rain", sum("accp").over(org.apache.spark.sql.expressions.Window.rowsBetween(-5, 0))) .withColumn("inflow_change", (col("inq") - lag("inq", 3).over(org.apache.spark.sql.expressions.Window.orderBy("tm"))) / lag("inq", 3).over(org.apache.spark.sql.expressions.Window.orderBy("tm"))) .withColumn("storage_ratio", col("w") / lit(designParams("capacity"))) .withColumn("level_ratio", col("rz") / lit(designParams("safetyLevel"))) .select("rz", "net_inflow", "rolling_rain", "gate_pressure", "storage_ratio", "level_ratio", "Tgtq") / / Normalization processing val scaler = new org.apache.spark.ml.feature.MinMaxScaler() .setInputCol("features") .setOutputCol("scaledFeatures") val assembler = new org.apache.spark.ml.feature.VectorAssembler() .setInputCols(Array("rz", "net_inflow", "rolling_rain", "gate_pressure", "storage_ratio", "level_ratio", "Tgtq")) .setOutputCol("features") val featureVector = assembler.transform(featureDf) val scaledData = scaler.fit(featureVector).transform(featureVector) / / Build time series samples val seqLength = 6 val predLength = 3 val data = scaledData.collect().map(_.getAs[org.apache.spark.ml.linalg.DenseVector]("scaledFeatures").toArray) var X = Array[Array[Double]]() var y = Array[Array[Double]]() for (i<- 0 until data.length - seqLength - predLength) { val seq_x = data.slice(i, i + seqLength).flatten val futureData = data.slice(i + seqLength, i + seqLength +predLength) val avgLevel = futureData.map(_(0)).sum / futureData.length val totalInflow = futureData.map(_(2)).sum val risk = if (futureData.map(_(4)).max>0.95) 1 else 0 y = y :+ Array(avgLevel, totalInflow, risk) X = X :+ seq_x } (X, y) } [[ID=3C]]def buildLSTMModel(seqLength: Int, numFeatures: Int):MultiLayerNetwork = { val conf: MultiLayerConfiguration = newNeuralNetConfiguration.Builder() .seed(12345) .weightInit(WeightInit.XAVIER) .updater(new Adam()) .list() .layer(0, new LSTM.Builder() .nIn(numFeatures) .nOut(64) .activation(Activation.TANH) .build()) .layer(1, new LSTM.Builder() .nIn(64) .nOut(32) .activation(Activation.TANH) .build()) .layer(2, new RnnOutputLayer.Builder(LossFunctions.LossFunction.MSE) .activation(Activation.IDENTITY) .nIn(32) .nOut(3) / / Output water level, flow rate, risk (risk_raw) .build()) .build() new MultiLayerNetwork(conf) } def trainModel(model: MultiLayerNetwork, X_train: Array[Array[Double]], y_train: Array[Array[Double]]): Unit = { val numEpochs = 50 val batchSize = 32 for (epoch<- 0 until numEpochs) { for (i<- 0 until X_train.length by batchSize) { val endIndex = Math.min(i + batchSize, X_train.length) val batchX = Nd4j.create(X_train.slice(i, endIndex)) val batchY = Nd4j.create(y_train.slice(i, endIndex)) val dataSet = new DataSet(batchX, batchY) model.fit(dataSet) } } } def predict(model: MultiLayerNetwork, sample: Array[Double]):(Double, Double, Double) = { val input = Nd4j.create(Array(sample)) val output = model.output(input) val predLevel = output.getDouble(0) val predFlow = output.getDouble(1) val predRisk = output.getDouble(2) (predLevel, predFlow, predRisk) } } class DynamicThresholdController(designParams: Map[String, Double]) { var weights = Map("alpha" ->0.4, "beta" ->0.3, "gamma" ->0.3) def update_weights(riskScore: Double): Unit = { if (riskScore>0.6) { weights = Map("alpha" ->0.5, "beta" ->0.4, "gamma" ->0.1) } else if (riskScore>0.3) { weights = Map("alpha" ->0.4, "beta" ->0.3, "gamma" ->0.3) } else { weights = Map("alpha" ->0.3, "beta" ->0.2, "gamma" ->0.5) } } def calculate_threshold(currentState: Map[String, Double], lstmPred:Map[String, Double]): Double = { val levelRatio = currentState("rz") / designParams("safetyLevel") val inflowRatio = lstmPred("rainfall") / designParams("maxrainfall") val gateRatio = currentState("Tgtq") / designParams("gateCapacity") weights("alpha") * levelRatio + weights("beta") * inflowRatio +weights("gamma") * gateRatio } } In this embodiment, an intelligent and high-precision method for predicting reservoir dam failure risk is constructed through multimodal feature fusion, dynamic threshold optimization, and joint risk level determination. Compared with existing technologies, it has the following significant advantages: I. Multimodal feature fusion enhances the comprehensiveness and accuracy of risk prediction. This embodiment combines three heterogeneous data tables—hourly rainfall tables, hourly reservoir hydrological tables, and hourly weir and sluice gate hydrological tables—for joint analysis. Multimodal feature fusion technology is used to fully explore the correlations and coupling effects of multiple hydrological elements such as rainfall, reservoir water level, inflow, and weir and sluice gate opening. Compared to traditional single-modal (single data source) prediction methods, this approach can more comprehensively capture the combined impact of flood evolution, reservoir capacity changes, and weir and sluice gate scheduling on dam safety, significantly improving the accuracy and reliability of risk prediction and effectively solving the problem of misjudgment caused by incomplete information from a single data source.
[0090] II. Dynamic threshold adaptive adjustment overcomes the failure risk of fixed thresholds under extreme operating conditions. This embodiment abandons the limitations of traditional fixed thresholds (such as single water level or rainfall thresholds) and dynamically calculates threshold weights based on real-time risk values. A risk value prediction model is used to assess the dam failure risk level under current conditions in real time, and the sensitivity and judgment criteria of the thresholds are dynamically adjusted accordingly. Compared to the problem of fixed thresholds failing under complex conditions such as extreme rainfall and sudden changes in reservoir capacity, the dynamic threshold mechanism can adaptively match current hydrological conditions and environmental changes, significantly improving the robustness and anti-interference ability of risk judgment, and avoiding missed or false alarms caused by unreasonable threshold settings.
[0091] III. Joint determination of risk value and dynamic threshold to achieve accurate classification of dam failure risk level. In this embodiment, a multi-level dam failure risk assessment system is constructed by outputting quantitative risk values through a risk prediction model and combining them with dynamic threshold calculation results. Through the synergistic analysis of risk values and dynamic thresholds, different levels such as "low risk," "medium risk," and "high risk" can be accurately distinguished, providing a clear tiered decision-making basis for emergency response. This significantly improves the scientific rigor and practicality of risk warning and helps downstream areas formulate differentiated disaster prevention measures in advance.
[0092] IV. Strong real-time performance and scalability, adaptable to complex hydrological environments and large-scale data scenarios. In this embodiment, based on an hourly high-frequency data update mechanism, combined with an efficient multimodal feature fusion algorithm and a lightweight dynamic threshold calculation model, risk prediction and threshold updates at the hourly or even minute level can be achieved, meeting the real-time early warning needs for emergencies such as floods and rainstorms. Simultaneously, the multimodal data fusion framework can be flexibly extended to more data sources (such as weather forecasts and dam structure monitoring data), and the dynamic threshold mechanism can adapt to the differentiated characteristics of different reservoirs (such as reservoir capacity curves and weir / sluice gate types), possessing strong environmental adaptability and engineering promotion value.
[0093] V. Reduce the rates of underreporting and false reporting to improve the effectiveness of reservoir safety management. By using multimodal feature fusion to compensate for the information blind spots of single data sources, by dynamically adjusting thresholds to avoid judgment failures under extreme conditions, and by jointly determining risk levels to achieve refined early warning classification, the probability of missed reports (failure to detect high risks in time) and false alarms (frequent false alarms interfering with decision-making) in dam failure risk prediction can be significantly reduced. This provides reservoir management departments with more reliable risk assessment tools, reducing resource waste caused by misjudgments or disaster losses caused by missed judgments, and improving the scientific and intelligent level of reservoir safety management.
[0094] In summary, this embodiment constructs an efficient, accurate, and reliable reservoir dam failure risk prediction system through the collaborative innovation of multimodal fusion, dynamic threshold optimization, and joint risk level determination technologies. This system can effectively support reservoir safety monitoring, disaster early warning, and emergency decision-making.
[0095] like Figure 2 As shown, a third aspect of the present invention provides a reservoir dam failure early warning system, comprising: Apache Spark module 31 is used to retrieve the current dataset after the furthest time from the source database based on the furthest time in the first temporary table; wherein, the first temporary table includes a station identification number field and a timestamp field; the time in the timestamp field is the latest time of the collected station data; Apache Spark module 31 is also used to update the second temporary intermediate table based on the current dataset and generate update instructions for the target database; wherein, the second temporary intermediate table is stored in the target database, and the structure of the second temporary intermediate table is the same as the structure of the target table in the target database, while the first temporary table and the second temporary table are pre-created; The target database 32 is used to update the target table according to the update instruction to obtain the input dataset; the target table includes hourly rainfall table, hourly reservoir water level table and hourly weir and sluice gate water level table; Apache Spark module 31 is also used to associate the training dataset with time and station identification number and then input it into the LSTM model for training until the loss function meets the convergence condition to obtain the target LSTM model. Apache Spark module 31 is also used to preprocess the input dataset by associating it with time and station identification number to obtain input features; Prediction module 33 is used to input the input features into the target LSTM model and output the dam failure risk value; The calculation module 34 is used to determine the target weight of the dynamic threshold based on the dam failure risk value, and to calculate the current dynamic threshold based on the target weight. Module 35 is used to determine the dam failure risk level based on the current dynamic threshold or dam failure risk value.
[0096] In one embodiment of the present invention, the Apache Spark module updates the second temporary intermediate table based on the current dataset and generates update instructions for the target database, including: The Apache Spark module performs linear interpolation on the missing data in the current dataset to obtain the complete data; The Apache Spark module deletes the data from the second temporary intermediate table and writes the complete data into the second temporary intermediate table; The Apache Spark module generates update instructions for the target database based on a second temporary intermediate table; The Apache Spark module writes update commands to the target database.
[0097] In one embodiment of the present invention, it further includes: The Apache Spark module updates the first temporary table with the latest time of the complete data.
[0098] In one embodiment of the present invention, the Apache Spark module preprocesses the input dataset by associating it with time and station identification number to obtain input features, including: The Apache Spark module associates the input dataset with time and station identification number to obtain associated data; The Apache Spark module calculates the reservoir flow difference, upstream and downstream water level difference, reservoir capacity ratio, and reservoir water level ratio based on the associated data, and obtains the hourly cumulative rainfall, reservoir water level, and total outflow as initial features. The Apache Spark module normalizes the initial features to obtain the input features.
[0099] In one embodiment of the present invention, the calculation module determines the target weight of the dynamic threshold based on the dam failure risk value, and calculates the current dynamic threshold based on the target weight, including: The calculation module determines that when the dam failure risk value is greater than the first preset threshold, the first preset weight set is used as the target weight of the dynamic threshold. The calculation module determines that when the dam failure risk value is greater than the second preset threshold, the second preset weight set is used as the target weight of the dynamic threshold. The calculation module determines that when the dam failure risk value is less than or equal to the second preset threshold, the third preset weight set is used as the target weight of the dynamic threshold; wherein, the first preset threshold is greater than the second preset threshold. The calculation module calculates the current dynamic threshold based on the target weight.
[0100] In one embodiment of the present invention, the formula for calculating the current dynamic threshold is: in, , , Indicates the target weight.
[0101] In one embodiment of the present invention, the determining module determines the dam failure risk level based on the current dynamic threshold or dam failure risk value, including: The module determines that when the dam failure risk value is greater than the third preset threshold or the current dynamic threshold is greater than the fourth preset threshold, the dam failure risk level is set to high. The module determines that the dam failure risk level is medium when the dam failure risk value is greater than the fifth preset threshold or the current dynamic threshold is greater than the sixth preset threshold. The module determines that the dam failure risk level is normal when the dam failure risk value is less than or equal to the fifth preset threshold or the current dynamic threshold is less than or equal to the sixth preset threshold.
[0102] A fourth aspect of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the reservoir dam failure early warning method provided by the present invention described above.
[0103] A fifth aspect of the present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the reservoir dam failure early warning method provided in the above-described embodiments of the present invention.
[0104] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0105] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware systems.
[0106] The method provided in this invention can be applied to electronic devices. Specifically, the electronic device can be a desktop computer, a portable computer, a smart mobile terminal, a server, etc. No limitation is made herein; any electronic device that can implement this invention falls within the protection scope of this invention.
[0107] For system / electronic device embodiments, since they are basically similar to method embodiments, the description is relatively simple, and relevant parts can be found in the description of the method embodiments.
[0108] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A system that specifies functions in one or more boxes.
[0109] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including an instruction set implemented in a process. Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0110] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0111] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A method for early warning of reservoir dam failure, characterized in that, Includes the following steps: The Apache Spark module retrieves the current dataset after the furthest time from the source database based on the furthest time in the first temporary table; wherein, the first temporary table includes a station identification number field and a timestamp field; the time in the timestamp field is the latest time of the collected station data; The Apache Spark module updates the second temporary intermediate table based on the current dataset and generates update instructions for the target database; wherein, the second temporary intermediate table is stored in the target database, and the structure of the second temporary intermediate table is the same as the structure of the target table in the target database; the first temporary table and the second temporary table are pre-created. The target database updates the target table according to the update instruction to obtain the input dataset; wherein, the target table includes an hourly rainfall table, an hourly reservoir water level table, and an hourly weir and sluice gate water level table; The Apache Spark module associates the training dataset with time and station identification number and then inputs it into the LSTM model for training until the loss function meets the convergence condition, thus obtaining the target LSTM model. The Apache Spark module preprocesses the input dataset by associating it with time and station identification number to obtain input features; The prediction module inputs the input features into the target LSTM model and outputs the dam failure risk value; The calculation module determines the target weight of the dynamic threshold based on the dam failure risk value, and calculates the current dynamic threshold based on the target weight; The determination module determines the dam failure risk level based on the current dynamic threshold or the dam failure risk value.
2. The method as described in claim 1, characterized in that, The Apache Spark module updates the second temporary intermediate table based on the current dataset and generates update instructions for the target database, including: The Apache Spark module performs linear interpolation on the missing data in the current dataset to obtain the complete data; The Apache Spark module deletes the data from the second temporary intermediate table and writes the complete data into the second temporary intermediate table; The Apache Spark module generates update instructions for the target database based on the second temporary intermediate table; The Apache Spark module writes the update command to the target database.
3. The method as described in claim 2, characterized in that, The method further includes: The Apache Spark module updates the first temporary table with the latest time of the complete data.
4. The method as described in claim 1, characterized in that, The Apache Spark module preprocesses the input dataset by associating it with time and station identification number to obtain input features, including: The Apache Spark module associates the input dataset with time and station identification number to obtain associated data; The Apache Spark module calculates the reservoir flow difference, upstream and downstream water level difference, reservoir capacity ratio, and reservoir water level ratio based on the associated data, and obtains the hourly cumulative rainfall, reservoir water level, and total gate flow as initial features. The Apache Spark module normalizes the initial features to obtain the input features.
5. The method as described in claim 1, characterized in that, The calculation module determines the target weight of the dynamic threshold based on the dam failure risk value, and calculates the current dynamic threshold based on the target weight, including: The calculation module determines that when the dam failure risk value is greater than the first preset threshold, the first preset weight set is used as the target weight of the dynamic threshold. The calculation module determines that when the dam failure risk value is greater than the second preset threshold, the second preset weight set is used as the target weight of the dynamic threshold. The calculation module determines that when the dam failure risk value is less than or equal to the second preset threshold, the third preset weight set is used as the target weight of the dynamic threshold; wherein, the first preset threshold is greater than the second preset threshold; The calculation module calculates the current dynamic threshold based on the target weight.
6. The method as described in claim 5, characterized in that, The formula for calculating the current dynamic threshold is: in, , , This represents the target weight.
7. The method as described in claim 1, characterized in that, The determining module determines the dam failure risk level based on the current dynamic threshold or the dam failure risk value, including: The determination module determines that when the dam failure risk value is greater than the third preset threshold or the current dynamic threshold is greater than the fourth preset threshold, the dam failure risk level is determined to be high. The determination module determines that when the dam failure risk value is greater than the fifth preset threshold or the current dynamic threshold is greater than the sixth preset threshold, the dam failure risk level is determined to be medium. The determination module determines that the dam failure risk level is normal when the dam failure risk value is less than or equal to the fifth preset threshold or the current dynamic threshold is less than or equal to the sixth preset threshold.
8. A reservoir dam failure early warning system, characterized in that, include: The Apache Spark module is used to retrieve the current dataset after the furthest time from the source database based on the furthest time in the first temporary table; wherein the first temporary table includes a station identification number field and a timestamp field; the time in the timestamp field is the latest time of the collected station data; The Apache Spark module is also used to update the second temporary intermediate table based on the current dataset and generate update instructions for the target database; wherein the second temporary intermediate table is stored in the target database, the structure of the second temporary intermediate table is the same as the structure of the target table in the target database, and the first temporary table and the second temporary table are pre-created; The target database is used to update the target table according to the update instruction to obtain the input dataset; wherein, the target table includes an hourly rainfall table, an hourly reservoir water level table, and an hourly weir and sluice gate water level table; The Apache Spark module is also used to associate the training dataset with time and station identification number and then input it into the LSTM model for training until the loss function meets the convergence condition to obtain the target LSTM model. The Apache Spark module is also used to preprocess the input dataset by associating it with time and station identification number to obtain input features; The prediction module is used to input the input features into the target LSTM model and output the dam failure risk value; The calculation module is used to determine the target weight of the dynamic threshold based on the dam failure risk value, and to calculate the current dynamic threshold based on the target weight; The determination module is used to determine the dam failure risk level based on the current dynamic threshold or the dam failure risk value.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the reservoir dam failure early warning method as described in any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the reservoir dam failure early warning method according to any one of claims 1 to 7.
