Hydrological measurement and control method and device based on DSL rule engine and electronic equipment

By constructing an intermediate rule tree using a DSL rule engine and optimizing thresholds by combining large models and historical information, the problems of false alarms and missed alarms in hydrological monitoring and control systems have been solved, achieving highly accurate and adaptive hydrological monitoring and control.

CN121920549BActive Publication Date: 2026-06-23NORTHWEST ENGINEERING CORPORATION LIMITED

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NORTHWEST ENGINEERING CORPORATION LIMITED
Filing Date
2026-03-26
Publication Date
2026-06-23

AI Technical Summary

Technical Problem

In existing hydrological monitoring and control systems, the triggering conditions for rules are based on static threshold settings, resulting in high false alarm and missed alarm rates and insufficient accuracy.

Method used

A DSL-based rule engine approach is adopted, which generates a DSL syntax tree by parsing user input rules through a large model, constructs an intermediate rule tree, performs node-by-node matching, generates hydrological monitoring and control strategies, and optimizes threshold requirements by combining historical system information.

Benefits of technology

It has improved the accuracy of hydrological monitoring and control, lowered the threshold for rule writing, increased response speed and emergency response efficiency, and enabled the rules to learn and optimize themselves.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121920549B_ABST
    Figure CN121920549B_ABST
Patent Text Reader

Abstract

The application provides a hydrological measurement and control method and device based on a DSL rule engine and electronic equipment, relates to the technical field of hydrological measurement and control, and comprises the following steps: obtaining user input rules, wherein the user input rules comprise natural language and DSL input rules; performing natural language analysis on the user input rules based on a large model analysis function to obtain a DSL syntax tree; obtaining an intermediate rule tree according to the DSL syntax tree, wherein the intermediate rule tree is used for representing a directed tree or a directed acyclic graph with a hierarchical structure; and performing node-by-node matching on real-time monitored hydrological data according to the intermediate rule tree to obtain a hydrological measurement and control control strategy. The application realizes the improvement of the accuracy of hydrological measurement and control.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of hydrological measurement and control technology, and more specifically, to a hydrological measurement and control method, device, and electronic equipment based on a DSL rule engine. Background Technology

[0002] Hydrological monitoring and control is a crucial technological link in ensuring flood control safety, water resource allocation, and water ecological protection in river basins. With the development of big data technology, existing hydrological monitoring and control systems have gradually achieved real-time acquisition and remote transmission of multi-source hydrological elements such as water level, flow rate, rainfall, and water quality. Currently, mainstream hydrological monitoring and control systems generally adopt rule configuration methods based on hard coding or fixed scripts to realize alarm judgment and control decisions. The triggering conditions of the rules are often based on static threshold settings, resulting in high false alarm and missed alarm rates. Summary of the Invention

[0003] The problem addressed by this invention is how to improve the accuracy of hydrological monitoring and control.

[0004] To address the aforementioned problems, this invention provides a hydrological monitoring and control method, apparatus, and electronic device based on a DSL rule engine.

[0005] In a first aspect, the present invention provides a hydrological monitoring and control method based on a DSL rule engine, comprising:

[0006] Obtain user input rules, wherein the user input rules include natural language and DSL input rules;

[0007] Based on the large model parsing function, the user input rules are parsed using natural language to obtain a DSL syntax tree;

[0008] An intermediate rule tree is obtained from the DSL syntax tree, wherein the intermediate rule tree is used to represent a directed tree or a directed acyclic graph with a hierarchical structure;

[0009] Based on the intermediate rule tree, the real-time hydrological monitoring data is matched node by node to obtain the hydrological monitoring and control strategy.

[0010] Optionally, the intermediate rule tree includes action nodes, and the step of matching real-time monitored hydrological data node by node according to the intermediate rule tree to obtain a hydrological monitoring and control strategy includes:

[0011] The real-time hydrological data is input into the intermediate rule tree to obtain the rule triggering result;

[0012] The hydrological monitoring and control strategy is obtained from the action node corresponding to the trigger result of the rule, wherein the hydrological monitoring and control strategy includes alarm release operation, equipment control operation and business processing operation.

[0013] Optionally, the intermediate rule tree further includes condition nodes and logical nodes, and the step of inputting the real-time monitored hydrological data into the intermediate rule tree to obtain the rule triggering result includes:

[0014] When the real-time monitored hydrological data meets the threshold requirement of the condition node, the condition node is triggered, and the triggering result of the condition node is obtained by traversing all the condition nodes.

[0015] The rule triggering result is obtained by performing logical operations on the triggering result of the condition node based on the logical node.

[0016] Optionally, before triggering the condition node when the real-time monitored hydrological data meets the threshold requirement of the condition node, and before traversing all the condition nodes to obtain the condition node triggering result, the method further includes:

[0017] Collect historical system information, which includes historical hydrological monitoring data, rule execution and alarm logs, and manual intervention records;

[0018] The threshold requirements of the condition nodes are adjusted based on the historical system information to obtain the adjusted threshold requirements;

[0019] The adjusted threshold requirements include:

[0020] ,

[0021] in, The adjusted threshold requirement for the i-th condition node. The threshold requirement for the i-th condition node is... For learning rate, For the actual benefits of implementing the rules, For the rule-based returns predicted by the model, The sensitivity of the rule-triggered result to the threshold.

[0022] Optionally, the DSL syntax tree includes:

[0023] ,

[0024] in, For the DSL syntax tree, For large models of semantic understanding and mapping, The user inputs the i-th rule of the rules. This includes site information, historical data statistics, and watershed characteristics.

[0025] Optionally, obtaining the intermediate rule tree based on the DSL syntax tree includes:

[0026] The intermediate rule tree is obtained by matching the DSL syntax tree with the pre-built hydrological business rule graph. The pre-built hydrological business rule graph includes basic site attribute information, hydrological business parameter information, equipment and control capability information, and business rule constraint information.

[0027] Optionally, matching the DSL syntax tree with the pre-built hydrological business rule graph to obtain the intermediate rule tree includes:

[0028] Abstract service metrics are obtained by abstracting the elements of the DSL syntax tree;

[0029] The abstract business indicators are replaced with the business parameters of the pre-constructed hydrological business rule map to obtain the parameter-replaced abstract business indicators.

[0030] The abstract business metrics after parameter replacement are validated by rule constraints to obtain the intermediate rule tree.

[0031] Secondly, the present invention provides a hydrological monitoring and control device based on a DSL rule engine, comprising:

[0032] The user interaction module is used to acquire user input rules, wherein the user input rules include natural language and DSL input rules;

[0033] The large model rule parsing module is used to perform natural language parsing on the user input rules based on the large model parsing function to obtain a DSL syntax tree;

[0034] The DSL rule engine module is used to obtain an intermediate rule tree based on the DSL syntax tree, wherein the intermediate rule tree is used to represent a directed tree or a directed acyclic graph with a hierarchical structure.

[0035] The hydrological monitoring and control strategy acquisition module is used to perform node-by-node matching of real-time monitoring hydrological data according to the intermediate rule tree to obtain the hydrological monitoring and control strategy.

[0036] Thirdly, the present invention provides an electronic device, including a memory and a processor;

[0037] The memory is used to store computer programs;

[0038] The processor is configured to implement the hydrological monitoring and control method based on the DSL rule engine as described in the first aspect when executing the computer program.

[0039] Fourthly, the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the hydrological monitoring and control method based on a DSL rule engine as described in the first aspect.

[0040] The beneficial effects of the hydrological monitoring and control method, device, and electronic equipment based on the DSL rule engine of this invention are as follows: It utilizes a large model to perform deep semantic understanding of user input rules, mapping these rules into a DSL syntax tree that conforms to the semantics of the hydrological domain, avoiding ambiguity or omissions caused by traditional keyword matching and filling methods. User input rules include both natural language and DSL input rules, significantly reducing the barrier to rule writing. An intermediate rule tree is obtained from the DSL syntax tree, preserving the hierarchical logic of the rules, facilitating the optimization of traversal strategies, and improving the response speed to real-time hydrological data. Based on the intermediate rule tree, node-by-node matching of real-time hydrological data is performed to generate a hydrological monitoring and control strategy that better reflects the actual hydrological process, thereby improving the accuracy of hydrological monitoring and control. Attached Figure Description

[0041] Figure 1 This is a flowchart illustrating a hydrological monitoring and control method based on a DSL rule engine according to an embodiment of the present invention.

[0042] Figure 2 This is a schematic diagram of the structure of a hydrological monitoring and control device based on a DSL rule engine according to an embodiment of the present invention;

[0043] Figure 3 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention. Detailed Implementation

[0044] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Although some embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present invention. It should be understood that the accompanying drawings and embodiments of the present invention are for illustrative purposes only and are not intended to limit the scope of protection of the present invention.

[0045] It should be understood that the various steps described in the method embodiments of the present invention may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present invention is not limited in this respect.

[0046] The term "comprising" and its variations as used herein are open-ended, meaning "including but not limited to"; the term "based on" means "at least partially based on"; the term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments"; and the term "optionally" means "optional embodiments". Definitions of other terms will be given in the following description. It should be noted that the concepts of "first," "second," etc., mentioned in this invention are used only to distinguish different devices, modules, or units, and are not intended to limit the order of functions performed by these devices, modules, or units or their interdependencies.

[0047] It should be noted that the terms "a" and "a plurality of" used in this invention are illustrative rather than restrictive. Those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".

[0048] The names of the messages or information exchanged between the multiple devices in the embodiments of the present invention are for illustrative purposes only and are not intended to limit the scope of these messages or information.

[0049] like Figure 1 As shown in the figure, an embodiment of the present invention provides a hydrological monitoring and control method based on a DSL rule engine, comprising:

[0050] Step 110: Obtain user input rules, wherein the user input rules include natural language and DSL input rules.

[0051] Specifically, users define rules directly using natural language or DSL, supporting semantic fuzzy matching and multi-condition combinations. Natural language and DSL input rules are two rule expression methods targeting different user groups but with the same goal: to transform the warning or control intentions of business personnel into executable machine logic. Natural language refers to users using everyday colloquial or semi-structured Chinese sentences to describe hydrological alarms or control logic. DSL input rules refer to rules written in a structured, formal language specifically designed for the hydrological field, with concise syntax and clear semantics, while still retaining business readability.

[0052] Step 120: Based on the large model parsing function, perform natural language parsing on the user input rules to obtain the DSL syntax tree.

[0053] Specifically, based on the large model parsing function, natural language parsing is performed on the user input rules to obtain a Domain-Specific Language (DSL) syntax tree. The large model parsing function is the AI ​​model (large model) parsing function, used to understand the semantic structure, recognition conditions, actions, and logical relationships of natural language, and generate an executable rule structure. The DSL syntax tree is used to represent the output Domain-Specific Language (DSL) syntax tree, which structurally represents the conditions, actions, and priorities of the rules for direct execution by the rule engine.

[0054] Step 130: Obtain an intermediate rule tree based on the DSL syntax tree, wherein the intermediate rule tree is used to represent a directed tree or a directed acyclic graph with a hierarchical structure.

[0055] Specifically, the generated DSL syntax tree is parsed into an intermediate rule tree for subsequent rule matching, priority decision-making, and action execution. The intermediate rule tree represents a directed tree or a directed acyclic graph (DAG) with a hierarchical structure. A directed tree is a special type of DAG, consisting of a set of nodes and directed edges, with a unique root node from which all other nodes in the tree can be reached. A DAG is also a graph structure consisting of nodes and directed edges, but it is more general than a directed tree, allowing multiple source nodes without direct predecessors and multiple sink nodes without direct successors.

[0056] Step 140: Perform node-by-node matching of real-time monitoring hydrological data according to the intermediate rule tree to obtain the hydrological monitoring and control strategy.

[0057] Specifically, hydrological monitoring and control strategies include alarm issuance, equipment control, and operational processing. When real-time monitoring of hydrological data triggers corresponding rules, alarm issuance, equipment control, or operational processing operations are triggered according to those rules. Alarm issuance operations are used to represent different levels and types of early warning information. Equipment control operations are used to represent the automated control of physical equipment, such as automatically opening or closing gates, pumping stations, and valves. Operational processing operations are used to represent triggering background business processes or management actions related to hydrological events, such as automatically generating dispatch work orders.

[0058] In this embodiment, a large model is used to perform deep semantic understanding of user input rules, mapping them into a DSL syntax tree that conforms to the semantics of the hydrological domain. This avoids ambiguity or omissions caused by traditional keyword matching and filling methods. User input rules include natural language and DSL input rules, significantly reducing the barrier to rule writing. An intermediate rule tree is obtained from the DSL syntax tree, preserving the hierarchical logic of the rules, facilitating the optimization of traversal strategies, and improving the response speed to real-time hydrological data. Based on the intermediate rule tree, node-by-node matching of real-time hydrological data is performed to generate hydrological monitoring and control strategies that better fit the actual hydrological process, thereby improving the accuracy of hydrological monitoring and control.

[0059] Optionally, the intermediate rule tree includes action nodes, and the step of matching real-time monitored hydrological data node by node according to the intermediate rule tree to obtain a hydrological monitoring and control strategy includes:

[0060] The real-time hydrological data is input into the intermediate rule tree to obtain the rule triggering result;

[0061] The hydrological monitoring and control strategy is obtained from the action node corresponding to the trigger result of the rule, wherein the hydrological monitoring and control strategy includes alarm release operation, equipment control operation and business processing operation.

[0062] In some more specific embodiments, the intermediate rule tree further includes priority nodes. When the number of action nodes corresponding to the rule triggering result is greater than one, the action node with the highest priority is executed according to the priority nodes. The process of executing the action node with the highest priority includes:

[0063] ,

[0064] in, The highest priority action node is the one that will be executed last, such as triggering an alarm or controlling a gate. A represents the set of all action nodes that can be executed. argmax is the priority of the action node rule a corresponding to the rule triggering result R_i, and argmax is the input variable corresponding to the maximum value of the objective function.

[0065] In this optional embodiment, real-time monitoring hydrological data is input into an intermediate rule tree to obtain rule triggering results. Based on the action nodes corresponding to the rule triggering results, hydrological monitoring and control strategies are obtained. This allows the system to directly output clear alarms, equipment control, or business processing instructions after completing rule matching, without the need for additional mapping or manual intervention. This forms an end-to-end automated closed loop from data input to control output, significantly improving the efficiency of hydrological emergency response.

[0066] Optionally, the intermediate rule tree further includes condition nodes and logical nodes, and the step of inputting the real-time monitored hydrological data into the intermediate rule tree to obtain the rule triggering result includes:

[0067] When the real-time monitored hydrological data meets the threshold requirement of the condition node, the condition node is triggered, and the triggering result of the condition node is obtained by traversing all the condition nodes.

[0068] The rule triggering result is obtained by performing logical operations on the triggering result of the condition node based on the logical node.

[0069] Specifically, the generated DSL syntax tree is parsed into an intermediate rule tree R_tree, which is used for subsequent rule matching, priority decision-making, and action execution. The intermediate rule tree R_tree represents a hierarchical directed tree or directed acyclic graph, whose nodes include at least condition nodes, logical nodes, and action nodes. Condition nodes represent hydrological monitoring condition judgments, including monitoring indicator type, time window, threshold, and logical operation relationships, such as water level. Warning water level, 3-hour cumulative rainfall 50mm, water level rise rate Set thresholds. Logical nodes represent logical relationships between conditions, including AND, OR, and NOT, and are used to combine multiple condition nodes. Action nodes represent the operations to be performed when the corresponding condition node or logical node is satisfied, including alarm triggering, device control, and record generation. Priority nodes or attributes identify the execution priority of rules or actions, serving as the basis for decision-making when multiple rules simultaneously meet the conditions. Each DSL rule corresponds to at least one rule subtree of an intermediate rule tree. The rule tree serves as the unified intermediate representation structure of the rule execution engine and is used for condition matching, execution decisions, and traceable record generation in subsequent steps.

[0070] In some more specific embodiments, an intermediate rule tree R_tree is used as the execution carrier to perform node-by-node matching on the real-time hydrological data D_t. First, starting from the root node of the rule tree, each condition node and logical node is traversed sequentially according to a preset execution order or priority. Then, condition node matching is performed; for each condition node, the corresponding condition judgment result is calculated based on the current real-time data D_t to determine whether the node threshold requirement is met. Logical nodes are calculated; when a logical node exists in the rule tree, the overall result of the logical expression is calculated based on the matching results of its child nodes. Rule triggering is determined; when both the condition node and logical node corresponding to a certain rule subtree are satisfied, the rule is determined to be triggered. The matching process includes:

[0071] ,

[0072] in, Let represent the i-th condition node, i.e., whether the i-th rule is triggered under real-time monitoring of hydrological data D_t (1 = triggered, 0 = not triggered). Let $i$ be the conditional value calculated for the current data $D_t$ under the $i$-th rule, such as water level, cumulative rainfall, or flow surge rate. This is the threshold for the i-th rule, such as a warning water level or rainfall threshold. If the condition value reaches or exceeds the threshold, the rule is triggered; otherwise, it is not triggered.

[0073] In this optional embodiment, the intermediate rule tree transforms user-input natural language or DSL rules into a directed tree or directed acyclic graph with a clear semantic hierarchy. Condition nodes precisely encapsulate hydrological monitoring elements, logic nodes explicitly express complex combinations, and action nodes directly associate control behaviors. This transforms hydrological rules from fuzzy text or script code into a parsable, executable, standardized intermediate representation, significantly improving the rules' standardization and reusability.

[0074] Optionally, before triggering the condition node when the real-time monitored hydrological data meets the threshold requirement of the condition node, and before traversing all the condition nodes to obtain the condition node triggering result, the method further includes:

[0075] Collect historical system information, which includes historical hydrological monitoring data, rule execution and alarm logs, and manual intervention records;

[0076] The threshold requirements of the condition nodes are adjusted based on the historical system information to obtain the adjusted threshold requirements;

[0077] The adjusted threshold requirements include:

[0078] ,

[0079] in, The adjusted threshold requirement for the i-th condition node. The threshold requirement for the i-th condition node is... For learning rate, For the actual benefits of implementing the rules, For the rule-based returns predicted by the model, The sensitivity of the rule-triggered result to the threshold.

[0080] Specifically, historical hydrological monitoring data H_t includes multi-source time-series data such as water level, rainfall, flow rate, and soil moisture, as well as spatial attributes such as corresponding stations, watersheds, and upstream-downstream relationships. Rule execution and alarm logs L_t include the number of rule triggers, trigger time, trigger conditions, alarm level, actual handling results, and whether there are false alarms or missed alarms. Manual intervention records M_t include operations such as manual confirmation, manual alarm cancellation, and manual adjustment of gates or thresholds, used to reflect the deviation between rule decisions and actual operational judgments. Based on the above historical hydrological monitoring data, the system intelligently optimizes the condition nodes in the rule tree that involve threshold judgments.

[0081] In some more specific embodiments, multiple rules may be correlated in hydrological monitoring and control scenarios. For example, there may be a causal relationship between rainfall rules and water level rules; a time-delay response relationship between upstream and downstream station rules; and a complementary relationship between short-duration heavy rainfall rules and long-term cumulative rainfall rules. Based on historical hydrological process data, the system performs joint analysis on multiple condition nodes and rule subtrees in the rule tree, automatically identifying trigger correlations and redundancies between rules, and optimizing and recommending rule combinations, triggering sequences, and priorities to reduce duplicate alarms and conflict control. Through continuous accumulation of historical data and feedback from human intervention, the system can develop rule optimization experience for different watersheds and station types, achieving progressive self-learning and evolution of the rule system. The system does not directly and automatically modify rule thresholds, but instead adopts a recommendation-based optimization mechanism: for thresholds with a clear tendency to generate false alarms, the system suggests appropriately increasing the original threshold or adjusting the time window length to reduce the frequency of invalid alarms; for thresholds with a risk of missed alarms, the system suggests appropriately decreasing the threshold or adding multi-condition joint triggering rules to improve alarm sensitivity; for cases where different sites have the same rule semantics, the system can recommend differentiated threshold settings based on historical performance differences to achieve "one rule for multiple sites adaptive".

[0082] In this optional embodiment, the system dynamically adjusts the threshold based on historical data and actual execution results, making the rules more accurate and achieving self-learning optimization. The system is no longer a static engine that remains unchanged after a one-time configuration, but rather an intelligent agent with online learning and self-optimization capabilities. As runtime increases and event samples accumulate, the rules' understanding of local hydrological patterns deepens, and the threshold parameters gradually converge to the optimal range.

[0083] Optionally, the DSL syntax tree includes:

[0084] ,

[0085] in, For the DSL syntax tree, For large models of semantic understanding and mapping, The user inputs the i-th rule of the rules. This includes site information, historical data statistics, and watershed characteristics.

[0086] Specifically, the DSL (Domain-Specific Language) syntax tree structure typically refers to the abstract syntax tree generated after parsing the DSL source code. It's a tree-like representation of the source code's syntactic structure, ignoring specific syntactic details such as parentheses and semicolons, retaining only the program's logical structure. Large-scale model semantic understanding of user input rules includes:

[0087] ,

[0088] Here, N_L is the natural language rule description of the user-input rule, which is a "condition-threshold-action" rule expression that conforms to the daily usage habits of hydrological operators. f_AI(N_L) is the AI ​​model (large model) parsing function, used to understand the semantic structure of natural language, identify conditions, actions and logical relationships, and generate an executable rule structure. DSL_tree is the domain-specific language (DSL) syntax tree, which structurally represents the conditions, actions and priorities of the rule for direct execution by the rule engine. When one or more types of hydrological monitoring indicators meet or exceed preset threshold conditions, corresponding alarms or control operations are triggered, such as: single indicator threshold triggering rules, for example: "When the water level exceeds the warning level, trigger a level one alarm"; "When the instantaneous flow is greater than the design flow limit, send an over-limit alarm message". Multi-indicator combination triggering rules, for example: "When the water level exceeds the warning level and the cumulative rainfall in the past hour exceeds 50mm, trigger an alarm and start the drainage pump"; "When the water level at the upstream station continues to rise and the downstream water level approaches the safe water level, issue an early warning". Rules triggered by time windows or statistical conditions, such as: "When the cumulative rainfall in 3 hours exceeds 80mm, a rainstorm warning is triggered"; "When the water level rises by more than 0.5 meters within 30 minutes, a sudden rise alarm is triggered." Rules combining thresholds with control actions, such as: "When the water level exceeds the warning level, an alarm is triggered and the drainage gate is opened"; "When the soil moisture remains below the lower threshold, the irrigation valve is automatically opened."

[0089] Optionally, obtaining the intermediate rule tree based on the DSL syntax tree includes:

[0090] The intermediate rule tree is obtained by matching the DSL syntax tree with the pre-built hydrological business rule graph. The pre-built hydrological business rule graph includes basic site attribute information, hydrological business parameter information, equipment and control capability information, and business rule constraint information.

[0091] Specifically, after the DSL syntax tree is generated, the system parses the hydrological business abstract elements involved in the syntax tree and matches them with a pre-built hydrological business rule map to achieve automatic adaptation of rules under different watersheds and different types of stations. Hydrological business abstract elements include: physical entities such as watersheds and stations; observational data such as rainfall, water level, and flow; events and states such as flood warnings and dry seasons; and operations and commands such as triggering alarms and adjusting thresholds. Due to differences in the watershed, the same amount of rainfall may cause flash floods in mountainous watersheds but only slow water level rises in plain watersheds. By matching watersheds, the generated intermediate rule tree can adapt to different watersheds. Different types of stations measure different data; rain gauges only measure precipitation, while water level stations measure water depth. The generated intermediate rule tree can adapt to multiple types of stations. The rule map includes the following information: basic station attribute information, including station type (rain gauge, water level station, hydrological station, etc.), watershed location, and upstream and downstream relationships. Hydrological operational parameters include warning water levels, guaranteed water levels, design flow rates, and historical rainfall statistical thresholds for each station. Equipment and control capability information includes whether controllable equipment such as gates and pumping stations are available and their control constraints. Operational rule constraint information is used to limit the applicability of rules at specific stations or in specific scenarios.

[0092] Optionally, matching the DSL syntax tree with the pre-built hydrological business rule graph to obtain the intermediate rule tree includes:

[0093] Abstract service metrics are obtained by abstracting the elements of the DSL syntax tree;

[0094] The abstract business indicators are replaced with the business parameters of the pre-constructed hydrological business rule map to obtain the parameter-replaced abstract business indicators.

[0095] The abstract business metrics after parameter replacement are validated by rule constraints to obtain the intermediate rule tree.

[0096] Specifically, the system identifies abstract business indicator references from the DSL syntax tree, such as "warning water level," "safe water level," and "cumulative rainfall threshold." Based on the station or watershed information to which the current rule applies, the system queries the corresponding specific business parameters in the rule graph and replaces the abstract indicators in the DSL syntax tree with the specific parameter values ​​for that station. For example, for an upstream small river station, "warning water level" matches 3.0 meters; for a downstream main stream station, "warning water level" matches 5.0 meters. After parameter replacement, the system performs rule constraint verification, such as checking whether the rule contains control actions that the current station does not possess. If a mismatch exists, the rule is marked as unexecutable or only retains the alarm action. After matching and verification, the system only updates the parameter values ​​of the corresponding condition nodes in the rule tree, without changing the logical structure and semantic expression of the rule, ensuring rule consistency and traceability.

[0097] In this optional embodiment, an intermediate rule tree is generated by matching the DSL syntax tree with a pre-built hydrological business rule graph and then performing a three-step process of abstract element identification, parameter replacement, and constraint verification. By introducing the pre-built hydrological business rule graph, the system can automatically identify and map abstract business indicators in the DSL into standardized concepts with clear hydrological meanings. This effectively avoids semantic ambiguity and ensures that the rules are accurate in a professional context.

[0098] In some more specific embodiments, once a rule trigger condition is met, the rule engine executes the corresponding operation based on the action node in the rule tree, including alarm issuance, device control, or business processing. Simultaneously, the system generates a complete traceable record of rule execution based on the matching path of the rule tree nodes, for subsequent interpretation, auditing, and playback. This traceable record of rule execution includes:

[0099] ,

[0100] Where Trace represents the traceable record of rule execution, R_i represents the rule triggering result, and D_t represents the real-time hydrological data at the time the rule was triggered. The highest priority action node is defined by the `Time` parameter, which represents the rule trigger time. The entire execution process of each rule is recorded for easy backtracking, auditing, and accountability. A trace record is generated for each rule execution, including: rule ID, execution conditions and corresponding data values, execution action, execution timestamp, and relevant site information. The rule trigger path is also recorded; the system can record the execution order and dependencies of multiple rules under the same event, facilitating backtracking analysis. Cross-site and multi-dimensional data conditions for rule execution tracing are supported. The system provides interpretable execution; for each alarm, it generates a visual report showing which rule triggered the alarm and the specific values ​​of the trigger conditions. Users and regulatory authorities can view the rule execution logic, not just the result. The system can replay rule execution records for any time period; analyze the causes of false alarms and missed alarms; and support rule optimization and system improvement. The system analyzes the rule execution effect by combining historical hydrological data, early warning logs, and manual intervention records. Based on indicators such as the accuracy, false alarm rate, and missed alarm rate of rule triggering, it automatically recommends more reasonable thresholds or condition combinations. Supports "rule self-learning": During execution, rules are dynamically adjusted based on data characteristics and historical performance, accumulating experience. Rule recommendations can be directly presented to users, who can choose to accept them or make further fine-tuning.

[0101] Cloud-edge collaborative scheduling dynamically migrates execution based on terminal load, communication status, and latency, ensuring alarm timeliness and execution efficiency. The system supports dynamically compiled rules; before execution, optimized execution logic is generated based on site data. Depending on terminal load, communication latency, and data timeliness, rules can be executed either in the cloud or at the edge. High-frequency, low-latency rules can be executed at the edge, while complex calculations or cross-site rules can be executed in the cloud. The system's decision on whether to execute a rule at the terminal (edge) or in the cloud includes:

[0102] ,

[0103] Among them, NodeLoad represents the current computing load of the terminal, NetworkLatency represents the communication latency between the terminal and the cloud, DataFreshness represents data freshness (real-time requirements), and ExecutionLocation represents the rules determined by the system. The system selects the optimal location to execute rules, ensuring that high-priority rules are triggered in a timely manner. When the terminal load is too high or communication is abnormal, rules can be automatically migrated to the cloud for execution; conversely, rules suitable for low latency and low computational load can be deployed to the edge. Dynamic updates of the rule tree and parameters are supported without manual intervention. Different rules can be executed simultaneously at the edge and in the cloud, achieving parallel processing. The system dynamically schedules tasks based on rule priority and resource status, ensuring that critical alarms are handled first. This module directly solves the technical problem of "low efficiency in rule deployment under cloud-edge collaboration" by achieving efficient, reliable, and low-latency execution of the system through dynamic decision-making, load scheduling, and rule migration.

[0104] like Figure 2 As shown in the figure, an embodiment of the present invention provides a hydrological monitoring and control device based on a DSL rule engine, comprising:

[0105] User interaction module 10 is used to acquire user input rules, wherein the user input rules include natural language and DSL input rules;

[0106] The large model rule parsing module 20 is used to perform natural language parsing on the user input rules based on the large model parsing function to obtain a DSL syntax tree;

[0107] DSL rule engine module 30 is used to obtain an intermediate rule tree based on the DSL syntax tree, wherein the intermediate rule tree is used to represent a directed tree or a directed acyclic graph with a hierarchical structure;

[0108] The hydrological monitoring and control strategy acquisition module 40 is used to perform node-by-node matching of real-time monitoring hydrological data according to the intermediate rule tree to obtain the hydrological monitoring and control strategy.

[0109] The hydrological monitoring and control device based on the DSL rule engine in this embodiment is used to implement the hydrological monitoring and control method based on the DSL rule engine as described above. Its advantages over the prior art are the same as the advantages of the hydrological monitoring and control method based on the DSL rule engine compared to the prior art, and will not be repeated here.

[0110] Optionally, the hydrological monitoring and control strategy acquisition module 40 is specifically used to: input the real-time monitoring hydrological data into the intermediate rule tree to obtain the rule triggering result;

[0111] The hydrological monitoring and control strategy is obtained from the action node corresponding to the trigger result of the rule, wherein the hydrological monitoring and control strategy includes alarm release operation, equipment control operation and business processing operation.

[0112] Optionally, the hydrological monitoring and control strategy acquisition module 40 is specifically used to: trigger the condition node when the real-time monitoring hydrological data meets the threshold requirements of the condition node, and traverse all the condition nodes to obtain the condition node triggering result;

[0113] The rule triggering result is obtained by performing logical operations on the triggering result of the condition node based on the logical node.

[0114] Optionally, the hydrological monitoring and control device based on the DSL rule engine further includes a threshold requirement adjustment module, which is used to: collect historical system information, wherein the historical system information includes historical hydrological monitoring data, rule execution and alarm logs, and manual intervention records;

[0115] The threshold requirements of the condition nodes are adjusted based on the historical system information to obtain the adjusted threshold requirements;

[0116] The adjusted threshold requirements include:

[0117] ,

[0118] in, The adjusted threshold requirement for the i-th condition node. The threshold requirement for the i-th condition node is... For learning rate, For the actual benefits of implementing the rules, For the rule-based returns predicted by the model, The sensitivity of the rule-triggered result to the threshold.

[0119] Optionally, the large model rule parsing module 20 is specifically used to: perform natural language parsing on the user input rules to obtain the DSL syntax tree;

[0120] The DSL syntax tree includes:

[0121] ,

[0122] in, For the DSL syntax tree, For large models of semantic understanding and mapping, The user inputs the i-th rule of the rules. This includes site information, historical data statistics, and watershed characteristics.

[0123] Optionally, the DSL rule engine module 30 is specifically used to: match the DSL syntax tree with the pre-built hydrological business rule graph to obtain the intermediate rule tree, wherein the pre-built hydrological business rule graph includes site basic attribute information, hydrological business parameter information, equipment and control capability information, and business rule constraint information.

[0124] Optionally, the DSL rule engine module 30 is specifically used to: obtain abstract business indicators by performing abstract element identification on the DSL syntax tree;

[0125] The abstract business indicators are replaced with the business parameters of the pre-constructed hydrological business rule map to obtain the parameter-replaced abstract business indicators.

[0126] The abstract business metrics after parameter replacement are validated by rule constraints to obtain the intermediate rule tree.

[0127] like Figure 3 As shown, an electronic device 300 provided in this embodiment of the invention includes a memory 310 and a processor 320; the memory 310 is used to store a computer program; the processor 320 is used to implement the hydrological monitoring and control method based on the DSL rule engine as described above when the computer program is executed.

[0128] Alternatively, an electronic device 300 includes a memory 310 and a processor 320 coupled to the memory 310; the memory 310 is configured to store a computer program; and the processor 320 is configured to perform the following operations when the computer program is executed:

[0129] Obtain user input rules, wherein the user input rules include natural language and DSL input rules;

[0130] Based on the large model parsing function, the user input rules are parsed using natural language to obtain a DSL syntax tree;

[0131] An intermediate rule tree is obtained from the DSL syntax tree, wherein the intermediate rule tree is used to represent a directed tree or a directed acyclic graph with a hierarchical structure;

[0132] Based on the intermediate rule tree, the real-time hydrological monitoring data is matched node by node to obtain the hydrological monitoring and control strategy.

[0133] This invention provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the hydrological monitoring and control method based on a DSL rule engine as described above.

[0134] Alternatively, a non-volatile computer-readable storage medium storing a computer program that, when executed by a processor, causes the processor to perform the following operations:

[0135] Obtain user input rules, wherein the user input rules include natural language and DSL input rules;

[0136] Based on the large model parsing function, the user input rules are parsed using natural language to obtain a DSL syntax tree;

[0137] An intermediate rule tree is obtained from the DSL syntax tree, wherein the intermediate rule tree is used to represent a directed tree or a directed acyclic graph with a hierarchical structure;

[0138] Based on the intermediate rule tree, the real-time hydrological monitoring data is matched node by node to obtain the hydrological monitoring and control strategy.

[0139] The present invention will now be described an electronic device 300 that can serve as a server or client of the present invention, which is an example of a hardware device that can be applied to various aspects of the present invention. Electronic device 300 is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. Electronic device 300 can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.

[0140] Electronic device 300 includes a computing unit that can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) or a computer program loaded from a storage unit into random access memory (RAM). The RAM may also store various programs and data required for device operation. The computing unit, ROM, and RAM are interconnected via a bus. Input / output (I / O) interfaces are also connected to the bus.

[0141] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc. In this application, the units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of the embodiments of the present invention according to actual needs. Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated units can be implemented in hardware or as software functional units.

[0142] While the present invention has been disclosed above, its scope of protection is not limited thereto. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention, and all such changes and modifications will fall within the scope of protection of the present invention.

Claims

1. A hydrological monitoring and control method based on a DSL rule engine, characterized in that, include: Obtain user input rules, wherein the user input rules include natural language and DSL input rules; Based on the large model parsing function, the user input rules are parsed using natural language to obtain a DSL syntax tree; An intermediate rule tree is obtained from the DSL syntax tree, wherein the intermediate rule tree is used to represent a directed tree or a directed acyclic graph with a hierarchical structure; The DSL syntax tree includes: , in, For the DSL syntax tree, For large models of semantic understanding and mapping, The user inputs the i-th rule of the rules. This includes site information, historical data statistics, and watershed characteristics; Based on the intermediate rule tree, the real-time monitoring hydrological data is matched node by node to obtain the hydrological measurement and control strategy. The intermediate rule tree includes action nodes. The step of matching real-time monitored hydrological data node by node according to the intermediate rule tree to obtain a hydrological monitoring and control strategy includes: The real-time hydrological data is input into the intermediate rule tree to obtain the rule triggering result; The hydrological monitoring and control strategy is obtained based on the action node corresponding to the trigger result of the rule, wherein the hydrological monitoring and control strategy includes alarm release operation, equipment control operation and business processing operation; The intermediate rule tree also includes condition nodes and logical nodes. The step of inputting the real-time monitored hydrological data into the intermediate rule tree to obtain the rule triggering result includes: When the real-time monitored hydrological data meets the threshold requirement of the condition node, the condition node is triggered, and the triggering result of the condition node is obtained by traversing all the condition nodes. The rule triggering result is obtained by performing logical operations on the triggering result of the condition node based on the logical node.

2. The hydrological monitoring and control method based on a DSL rule engine according to claim 1, characterized in that, Before triggering the condition node by traversing all condition nodes to obtain the condition node triggering result when the real-time monitored hydrological data meets the threshold requirement of the condition node, the method further includes: Collect historical system information, which includes historical hydrological monitoring data, rule execution and alarm logs, and manual intervention records; The threshold requirements of the condition nodes are adjusted based on the historical system information to obtain the adjusted threshold requirements; The adjusted threshold requirements include: , in, The adjusted threshold requirement for the i-th condition node. The threshold requirement for the i-th condition node is... For learning rate, For the actual benefits of implementing the rules, For the rule-based returns predicted by the model, The sensitivity of the rule-triggered result to the threshold.

3. The hydrological monitoring and control method based on a DSL rule engine according to claim 1, characterized in that, The process of obtaining the intermediate rule tree based on the DSL syntax tree includes: The intermediate rule tree is obtained by matching the DSL syntax tree with the pre-built hydrological business rule graph. The pre-built hydrological business rule graph includes basic site attribute information, hydrological business parameter information, equipment and control capability information, and business rule constraint information.

4. The hydrological monitoring and control method based on a DSL rule engine according to claim 3, characterized in that, The step of matching the DSL syntax tree with the pre-built hydrological business rule graph to obtain the intermediate rule tree includes: Abstract service metrics are obtained by abstracting the elements of the DSL syntax tree; The abstract business indicators are replaced with the business parameters of the pre-constructed hydrological business rule map to obtain the parameter-replaced abstract business indicators. The abstract business metrics after parameter replacement are validated by rule constraints to obtain the intermediate rule tree.

5. A hydrological monitoring and control device based on a DSL rule engine, characterized in that, include: The user interaction module is used to acquire user input rules, wherein the user input rules include natural language and DSL input rules; The large model rule parsing module is used to perform natural language parsing on the user input rules based on the large model parsing function to obtain a DSL syntax tree; The DSL rule engine module is used to obtain an intermediate rule tree based on the DSL syntax tree, wherein the intermediate rule tree is used to represent a directed tree or a directed acyclic graph with a hierarchical structure. The DSL syntax tree includes: , in, For the DSL syntax tree, For large models of semantic understanding and mapping, The user inputs the i-th rule of the rules. This includes site information, historical data statistics, and watershed characteristics; The hydrological monitoring and control strategy acquisition module is used to perform node-by-node matching of real-time monitoring hydrological data according to the intermediate rule tree to obtain the hydrological monitoring and control strategy. The intermediate rule tree includes action nodes. The step of matching real-time monitored hydrological data node by node according to the intermediate rule tree to obtain a hydrological monitoring and control strategy includes: The real-time hydrological data is input into the intermediate rule tree to obtain the rule triggering result; The hydrological monitoring and control strategy is obtained based on the action node corresponding to the trigger result of the rule, wherein the hydrological monitoring and control strategy includes alarm release operation, equipment control operation and business processing operation; The intermediate rule tree also includes condition nodes and logical nodes. The step of inputting the real-time monitored hydrological data into the intermediate rule tree to obtain the rule triggering result includes: When the real-time monitored hydrological data meets the threshold requirement of the condition node, the condition node is triggered, and the triggering result of the condition node is obtained by traversing all the condition nodes. The rule triggering result is obtained by performing logical operations on the triggering result of the condition node based on the logical node.

6. An electronic device, characterized in that, Including memory and processor; The memory is used to store computer programs; The processor is configured to implement the hydrological monitoring and control method based on the DSL rule engine as described in any one of claims 1 to 4 when executing the computer program.

7. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the hydrological monitoring and control method based on a DSL rule engine as described in any one of claims 1 to 4.