A method, apparatus, device and medium for structure optimization of a hydrological model

By generating controlled module description information and watershed diagnostic feature information through a large language model, the hydrological model structure is optimized, solving the problems of low efficiency caused by reliance on human experience and trial-and-error search in existing technologies, and achieving more efficient model adaptability and accuracy.

CN123179750APending Publication Date: 2026-11-27SUN YAT SEN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611675238.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-28
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

The existing hydrological model structure adjustment relies on human experience or simple trial and error search, which makes it difficult to efficiently explore structural errors in multi-module combinations and a large number of watersheds, resulting in insufficient model adaptability and simulation accuracy in different watersheds.

Method used

By acquiring watershed data, using a large language model to generate controlled module description information, combining watershed diagnostic feature information, constructing candidate structures, and performing safety checks and parameter calibration, the hydrological model structure is optimized.

Benefits of technology

It improves the automation and efficiency of hydrological model structure search, generates more adaptive candidate structures, improves the simulation accuracy and applicability of the model in different watersheds, and reduces unreliable illusion output.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123179750A_ABST
    Figure CN123179750A_ABST
Patent Text Reader

Abstract

The application discloses a hydrological model structure optimization method, device, equipment and medium, the method comprises the following steps: obtaining the basin related data of the target basin, and extracting the training period data and the development period data from the basin related data according to the time sequence; according to the training period data and the development period data, the parameter calibration of the benchmark hydrological model of the target basin is carried out, the benchmark model information is obtained, and the basin diagnosis characteristic information is generated; according to the benchmark model information and the basin diagnosis characteristic information, the prompt word is constructed and the module description information is generated; after the module candidate code is compiled from each module description information, the safety check is carried out, and the candidate structure is obtained; according to the training period data and the development period data, the parameter calibration of each candidate structure is carried out, and the target optimization structure of the benchmark hydrological model is selected. Therefore, the structure level optimization of the hydrological model module is carried out, the simulation precision and the generalization ability of the model are effectively improved under the premise of retaining the rationality of the basin physical mechanism.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of model structure optimization technology, and in particular to a method, apparatus, equipment and medium for optimizing the structure of a hydrological model. Background Technology

[0002] Rainfall-runoff simulation is fundamental to flood forecasting, water resource allocation, drought assessment, and climate change impact analysis. Hydrological models abstract processes such as precipitation, snow cover, snowmelt, evapotranspiration, soil water, groundwater response, and river runoff into several reservoirs and flux calculation formulas, and use parameter calibration to make simulated runoff approximate observed runoff. Such models typically employ a fixed structure, and the same set of process formulas and state machines cannot simultaneously adapt to the runoff generation and confluence mechanisms of different watersheds, such as snow-dominated, semi-arid, and significantly groundwater-recharged basins.

[0003] To improve the adaptability of fixed structures to watershed differences, existing technologies typically start with a benchmark hydrological model, with experts or programs proposing several structural modification schemes. The parameters of each scheme are recalibrated, and the simulation effects are compared using hydrological indicators to select a relatively better model structure.

[0004] However, in the above schemes, model structure adjustment mainly relies on human experience or simple trial and error search. When faced with multi-module combinations and a large number of watersheds, the structure search efficiency is low, and it is difficult to systematically explore the errors caused by model structure in different watersheds. Summary of the Invention

[0005] This invention provides a method, apparatus, equipment, and medium for optimizing the structure of a hydrological model. It solves the technical problem that existing schemes mainly rely on manual experience or simple trial-and-error search for model structure adjustment, resulting in low structure search efficiency when facing multi-module combinations and a large number of watersheds, and making it difficult to systematically explore the errors caused by model structure in different watersheds.

[0006] The first aspect of this invention provides a method for optimizing the structure of a hydrological model, comprising: Acquire watershed-related data for the target watershed, and extract training and development data from the watershed-related data in chronological order; Based on the training period data and the development period data, the parameters of the benchmark hydrological model for the target watershed are calibrated to obtain benchmark model information and generate watershed diagnostic feature information. Based on the baseline model information and the watershed diagnostic feature information, prompt words are constructed, and module description information of at least one candidate structure is generated based on the prompt words; The module description information is compiled into executable module candidate code, and a security check is performed on each module candidate code to obtain the corresponding candidate structure; Based on the training period data and the development period data, after parameter calibration of each candidate structure, the target optimization structure of the benchmark hydrological model is selected.

[0007] Optionally, the step of calibrating the parameters of the benchmark hydrological model for the target watershed based on the training period data and the development period data to obtain benchmark model information and generate watershed diagnostic feature information includes: Based on the training period data, the parameters of the benchmark hydrological model for the target watershed are calibrated to obtain benchmark model information; Based on the training period data and the development period data, watershed diagnostic feature information of the target watershed is generated.

[0008] Optionally, before performing the step of calibrating the parameters of the benchmark hydrological model of the target watershed based on the training period data to obtain benchmark model information, the step further includes: Obtain the preheating period data corresponding to the watershed-related data; The preheating period data is used to initialize the state of the baseline hydrological model.

[0009] Optionally, the step of generating watershed diagnostic feature information of the target watershed based on the training period data and the development period data includes: The baseline hydrological model is invoked to perform hydrological simulations on the target watershed based on the training period data and the development period data, respectively, to determine the first simulated runoff sequence and the second simulated runoff sequence; Based on the first simulated runoff sequence, the second simulated runoff sequence, and the observed runoff in the watershed-related data, simulation deviation information is calculated from multiple preset feature dimensions. Using the simulated deviation information, watershed diagnostic feature information of the target watershed is generated.

[0010] Optionally, the step of constructing prompt words based on the baseline model information and the watershed diagnostic feature information, and generating module description information for at least one candidate structure based on the prompt words, includes: If no historical candidate information corresponding to the historical candidate structure exists, then the baseline model information and the watershed diagnostic feature information are used, combined with the preset first structure generation rule, to construct prompt words; If there is historical candidate information corresponding to a historical candidate structure, then the current round is determined based on the historical candidate information, and the second structure generation rule corresponding to the current round is matched. Using the baseline model information, the watershed diagnostic feature information, the historical candidate information, and the second structure generation rule, prompt words are constructed; The prompt words are input into a preset large language model, and the large language model generates module description information of at least one candidate structure according to the prompt words.

[0011] Optionally, the baseline model information includes baseline model module code and module interface constraints; the step of generating module description information of at least one candidate structure according to the prompt words using the large language model includes: If no historical candidate structure exists, the module description information of at least one candidate structure is generated by adjusting the parameters of the baseline model module code in accordance with the first structure generation rule through the large language model and the module interface constraints. If the historical candidate structure exists, the diagnostic text corresponding to the historical candidate structure is determined by the large language model according to the historical candidate information and the watershed diagnostic feature information. The prompt word and the diagnostic text are combined to obtain the updated prompt word; The large language model is invoked to adjust the parameters of the baseline model module code in accordance with the second structure generation rule under the constraints of the module interface, according to the updated prompt words, to generate module description information of at least one candidate structure.

[0012] Optionally, the step of compiling each module description information into executable module candidate code and performing security checks on each module candidate code to obtain the corresponding candidate structure includes: The compiler is invoked to compile the module description information into executable module candidate code; A security check is performed on the candidate code of each module to determine whether each candidate code of the module meets multiple preset check conditions; the check conditions include static abstract syntax tree check conditions and candidate runtime check conditions; If any of the module candidate codes satisfies all of the above check conditions, then a candidate structure corresponding to the module candidate code is created; If any of the module candidate codes does not meet all the check conditions, then the module candidate code is removed.

[0013] Optionally, the step of calling the compiler to compile each of the module description information into executable module candidate code includes: The compiler is invoked to read all the model code of the benchmark hydrological model. Identify the target module code specified by the module description information for each of the entire model code; Determine whether the target module code belongs to the adjustable code set; If so, determine whether the interface of the target module code satisfies the module interface constraints; If the conditions are met, the target module code is replaced according to the module description information, and the replaced target module code is merged with the unreplaced model code in the baseline hydrological model to obtain executable module candidate code.

[0014] Optionally, the benchmark model information further includes benchmark model indicators; the step of selecting the target optimization structure of the benchmark hydrological model after calibrating the parameters of each candidate structure based on the training period data and the development period data includes: Based on the training data and a preset parameter calibration algorithm, the parameters of each candidate structure are calibrated to obtain the calibrated candidate structure. The benchmark hydrological models under each of the calibration candidate structures are used to perform hydrological simulations on the development period data to obtain the hydrological simulation results corresponding to each of the calibration candidate structures. Based on the hydrological simulation results, calculate the model evaluation index corresponding to each of the calibration candidate structures. The comprehensive development score of each calibration candidate structure is determined based on the evaluation index of each model and the benchmark model index. The calibration candidate structure that meets the preset selection conditions in the comprehensive score of the development period is selected as the target optimization structure of the benchmark hydrological model.

[0015] Optionally, the method further includes: Extract test period data from the watershed-related data; The baseline hydrological model under the aforementioned target optimization structure is used to perform hydrological simulation on the test period data to obtain the test hydrological simulation results. Based on the test hydrological simulation results, the test period evaluation index corresponding to the target optimized structure is calculated, and a test report is generated.

[0016] Optionally, the method further includes: When watershed migration request data is received, the similarity between the watershed to be migrated and the target watershed is calculated based on the watershed migration request data and the watershed-related data. When the similarity meets the preset similarity conditions, the benchmark hydrological model of the target optimized structure is determined as the first hydrological model of the watershed to be migrated. Based on the watershed migration demand data, the parameters of the first hydrological model are calibrated to obtain the target hydrological model for the watershed to be migrated.

[0017] Optionally, the method further includes: When a parallel optimization instruction is received, the set of target watersheds to be processed in parallel is determined according to the parallel optimization instruction; The candidate structure generation and parameter calibration processes for each undetermined watershed in the target watershed set are processed in parallel to obtain the optimized model structure corresponding to each undetermined watershed.

[0018] Optionally, the method further includes: When any candidate structure generation or parameter calibration process for a pending watershed is abnormal, the pending watershed is marked as an abnormal watershed, and the candidate structure generation and parameter calibration processes for other pending watersheds in the target watershed set continue to be executed. Once the candidate structure generation or parameter calibration process for the anomalous watershed has resumed, the candidate structures and calibration parameters of the anomalous watershed that have passed the checks are reused based on the processing results of other undetermined watersheds until the target optimized structure of the anomalous watershed is determined.

[0019] A second aspect of the present invention provides a structure optimization device for a hydrological model, comprising: The data acquisition unit is used to acquire watershed-related data of the target watershed, and extract training period data and development period data from the watershed-related data in chronological order; The model information extraction unit is used to calibrate the parameters of the benchmark hydrological model of the target watershed based on the training period data and the development period data, obtain the benchmark model information, and generate watershed diagnostic feature information. The module description information generation unit is used to construct prompt words based on the baseline model information and the watershed diagnostic feature information, and generate module description information of at least one candidate structure based on the prompt words; The candidate structure generation unit is used to compile the module description information into executable module candidate code, and perform security checks on the module candidate code to obtain the corresponding candidate structure. The target optimization structure selection unit is used to select the target optimization structure of the benchmark hydrological model after calibrating the parameters of each candidate structure based on the training period data and the development period data.

[0020] A third aspect of the present invention provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of the hydrological model structure optimization method as described in any one of the first aspects of the present invention.

[0021] A fourth aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed, implements the method for structural optimization of a hydrological model as described in any of the first aspects of the present invention.

[0022] As can be seen from the above technical solutions, the present invention has the following advantages: This invention acquires watershed-related data for a target watershed and extracts training and development period data from this data in chronological order. Based on the training and development period data, it calibrates the parameters of a baseline hydrological model for the target watershed to obtain baseline model information and generate watershed diagnostic feature information. Based on the baseline model information and watershed diagnostic feature information, it constructs prompt words and generates module description information for at least one candidate structure. It compiles each module description information into executable candidate module code and performs security checks on each candidate module code to obtain the corresponding candidate structure. Based on the training and development period data, it calibrates the parameters of each candidate structure and selects the target optimized structure of the baseline hydrological model. By combining the structure generation capabilities of a large language model with watershed diagnostic information, it systematically explores the candidate structure space, reduces reliance on human experience, and improves the automation and efficiency of structure search. This allows for the generation of more adaptive candidate structures tailored to the runoff generation characteristics of different watersheds, effectively improving the simulation accuracy and applicability of fixed-structure models in different watersheds. Meanwhile, by fixing the hydrological module interface, using the DSL compiler, and physical checks, the candidates are limited to interpretable, executable, and auditable hydrological processes, reducing the unreliability caused by illusionary output and plain text interpretation. Attached Figure Description

[0023] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0024] Figure 1 A flowchart illustrating the steps of a method for structural optimization of a hydrological model, as provided in an embodiment of the present invention; Figure 2 A module interface constraint diagram of a hydrological model provided in an embodiment of the present invention; Figure 3 This is a flowchart illustrating the two-stage invocation process of the large language model within an embodiment of the present invention. Figure 4 A detailed implementation diagram of a structural optimization method for a hydrological model provided in an embodiment of the present invention; Figure 5 A structural block diagram of a hydrological model optimization device provided in an embodiment of the present invention; Figure 6 This is an architectural block diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0025] Rainfall-runoff simulation is a fundamental technique in hydrology, water resources management, flood forecasting, drought assessment, and climate change impact analysis. Conceptual hydrological models typically abstract complex watershed processes into several reservoirs and flux calculation formulas. For example, precipitation entering the watershed is first divided into rain and snow. Snowmelt occurs as temperatures rise, forming liquid inflow. This liquid water enters the soil layer and is then distributed as soil water storage, evapotranspiration, and recharge to groundwater or response reservoirs. Finally, through fast and slow responses and confluence calculations, it forms the outlet runoff. A significant problem with this type of model is that its fixed structure is difficult to adapt to different climate zones, topographic regions, and watershed response mechanisms. For instance, snow-dominated watersheds may require more refined snowmelt or refreezing processes, semi-arid watersheds may need more reasonable evapotranspiration limits, and watersheds with significant groundwater recharge may require different infiltration and response formulas.

[0026] Currently, hydrological model improvement typically falls into three categories. The first is expert-driven artificial structure improvement, where researchers modify a process formula based on hydrological knowledge, such as changing the snowmelt formula, adding seasonal evapotranspiration corrections, or modifying groundwater reservoir responses. This method offers strong physical interpretation but relies heavily on expert experience, resulting in lower efficiency and difficulty in systematically exploring large watersheds. The second is parameter optimization, which fixes the model structure and improves the fit solely through parameter calibration. This method is easy to implement but cannot address structural errors. The third is machine learning or automated program search methods, such as genetic programming, symbolic regression, or neural network runoff models. These methods have strong search capabilities but may lack modular hydrological interpretation and water conservation constraints. In recent years, large language models have demonstrated strong code generation and formula combination capabilities, theoretically allowing for the development of new hydrological process formulas. However, directly generating a complete hydrological model using LLM carries several technical risks: First, the complete code has too much freedom and is prone to breaking the model's input and output interfaces; second, LLM may generate unusable or insecure code; third, LLM may only pursue index improvement while ignoring the physical meaning; and fourth, candidate formulas need to be recalibrated and independently verified, and their merits cannot be judged solely based on the LLM textual interpretation.

[0027] However, in the above-mentioned schemes, modifications to the traditional hydrological model structure rely on formulas proposed by experts, which are then implemented, calibrated, and verified one by one. When the candidate process involves combinations of multiple modules, the cost of manual exploration is even higher. There is a lack of hydrological process constraints on the LLM-generated content. Directly generating complete code can lead to problems such as inconsistent interfaces, inconsistent variable naming, incorrect state updates, non-executability, or the introduction of irrelevant files / network operations. There is a lack of hard constraints on physical consistency. Some automatically generated structures may improve indicators in the short term, but they can destroy the hydrological meanings of storage, flux, threshold, delay, feedback, and mass conservation, making them difficult to use for reliable hydrological simulations. There is a lack of a fair comparison mechanism for candidate structures. If different structures do not have their parameters recalibrated, it is impossible to distinguish between structural superiority and inferiority, or differences caused by insufficient parameter optimization; if the final test set is used in candidate selection, the actual generalization ability is easily overestimated. Large-scale watershed experiments have low computational efficiency. The computational load for multiple watersheds, multiple rounds of LLM, multiple candidates, and recalibration of each candidate is large; single-threaded or serial processes will significantly increase runtime.

[0028] To address this, embodiments of the present invention provide a method, apparatus, device, and medium for optimizing the structure of a hydrological model. This addresses the technical problem that existing schemes rely primarily on manual experience or simple trial-and-error searches for model structure adjustments. These methods suffer from low structure search efficiency when dealing with multi-module combinations and numerous watersheds, making it difficult to systematically explore errors caused by model structure in different watersheds. The present invention provides an automated, constrained, executable, calibrable, verifiable, and reproducible hydrological model structure optimization scheme. This allows the LLM (Liquid Model Builder) to propose candidate structures within a controlled hydrological process interface and to complete safety checks, physical checks, calibration, evaluation, and selection through external programs rather than the LLM itself.

[0029] To make the objectives, features, and advantages of this invention more apparent and understandable, the technical solutions of the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described below are only some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.

[0030] Please see Figure 1 , Figure 1 A flowchart illustrating the steps of a hydrological model structure optimization method provided in an embodiment of the present invention.

[0031] The present invention provides a method for structural optimization of a hydrological model, comprising the following steps 101-105: Step 101: Obtain watershed-related data for the target watershed, and extract training and development data from the watershed-related data according to time sequence; A hydrological model is a computational model that uses mathematical equations to describe hydrological processes such as precipitation, snow accumulation, snowmelt, evapotranspiration, soil infiltration, groundwater runoff, and river runoff, and outputs runoff simulation results. For example, the HBV model (Hydrologiska Byråns Vattenbalansavdelning) is a conceptual precipitation-runoff hydrological model, typically including modules for precipitation and snowfall distribution, snow accumulation and snowmelt, soil moisture content, evapotranspiration, upper / lower groundwater response, and runoff calculation. Besides its application in structural optimization of the HBV model, it can also be applied to SAC-SMA, GR4J, VIC, PRMS, or other conceptual, semi-distributed, and distributed hydrological models, requiring only the definition of the corresponding process module interfaces and state variables. This embodiment of the invention does not impose specific limitations on this.

[0032] Watershed-related data refers to data describing the input meteorological drivers, observed runoff response, and static attributes of a target watershed, which may include precipitation, air temperature, potential evapotranspiration, observed runoff, watershed area, topographic indicators, and climate indicators. A watershed refers to the surface area enclosed by a watershed and converging at the same outlet section. In this invention, one watershed corresponds to one hydrological station and its meteorological, runoff, and attribute data.

[0033] In this embodiment, by acquiring watershed-related data of the target watershed, data such as precipitation, temperature, potential evapotranspiration, observed runoff, and static attributes are time-aligned, unit-standardized, and marked as missing. The watershed-related data is then divided into training data and development data according to a preset chronological order. Training data is used for model parameter calibration and structural diagnosis, while development data is used to verify the effectiveness of structural optimization. The two are sequential and non-overlapping, ensuring that development data does not participate in any parameter calibration or structural selection during the model structure search process, thus avoiding information leakage. Simultaneously, parameter optimization and structural selection each have independent data basis, reducing the risk of overly optimistic structural evaluations due to development-period information influencing parameter adjustments.

[0034] The ratio of training period to development period can be set according to the length of watershed data. For example, the first 70% of the time period can be divided into training period and the last 30% into development period. If the watershed data is short, the proportion of training period can be appropriately increased to ensure the stability of parameter calibration.

[0035] Step 102: Based on the training period data and the development period data, calibrate the parameters of the benchmark hydrological model for the target watershed to obtain the benchmark model information and generate watershed diagnostic feature information. A baseline hydrological model refers to an initial conceptual hydrological model that has not undergone candidate structure replacement or large model combination optimization, such as an initial model based on the HBV model, which includes process modules such as precipitation and snow distribution, snow accumulation, snowmelt, soil, evapotranspiration, infiltration, response, and runoff.

[0036] Benchmark model information refers to the collection of information such as model parameter values, objective function values, and simulated runoff sequences obtained after parameter calibration of a benchmark hydrological model under the condition of a fixed model structure. The parameters used for calibration mainly include the following: tt, cfmax, cfr, cwh, fc, beta, lp, k0, k1, k2, uzl, perc, and maxbas.

[0037] Watershed diagnostic feature information refers to a set of quantitative indicators used to describe the simulation performance and structural defects of the benchmark model on training and development data, including water volume deviation, low flow deviation, high flow deviation, drainage error, seasonality error, peak timing error, snow season / non-snow season difference, and flow continuity curve error, etc.

[0038] In this embodiment, training data drives a baseline hydrological model for runoff simulation. Optimization algorithms such as SCE-UA (Shuffled Complex Evolution - University of Arizona) are used to search for parameter combinations within the parameter boundaries that approximate the observed runoff. Development data is used to calculate the baseline simulation error, forming baseline model information and watershed diagnostic characteristics. Parameter calibration employs a multi-objective weighted approach, using the Nash efficiency coefficient as the primary objective, supplemented by water balance error and low-flow error as constraints, to ensure overall simulation accuracy across high, medium, and low flow processes. During calibration, each parameter is searched within its physically reasonable range, and insensitive parameters are fixed to reduce parameter dimensionality and improve calibration efficiency. Diagnostic characteristics correlate errors with potential hydrological processes; for example, low-flow deviations may indicate recession or lower-level response processes, while high-flow deviations may indicate confluence or soil recharge processes. This allows subsequent candidate generation to propose modifications based on specific process defects, rather than arbitrarily altering formulas.

[0039] In one example of this application, step 102 may include the following sub-steps S11-S12: S11. Based on the training period data, calibrate the parameters of the benchmark hydrological model for the target watershed to obtain benchmark model information; S12. Generate watershed diagnostic feature information for the target watershed based on training and development data.

[0040] In this step, the parameters of the benchmark hydrological model for the target watershed are calibrated based on the training period data. After the state variables are initialized during the warm-up period, optimization algorithms such as SCE-UA are used to search for parameter combinations within the parameter boundaries that reduce the difference between the simulated runoff sequence and the observed runoff sequence, thereby obtaining benchmark model information that includes calibration parameters, simulation results and evaluation indicators.

[0041] Simultaneously, training and development data were used to drive the baseline hydrological model for hydrological simulations to determine different simulated runoff sequences. Deviations were calculated between each simulated runoff sequence and observed runoff within the relevant watershed information. These deviations were then organized into watershed diagnostic features based on dimensions such as water volume, low flow, high flow, receding flow, seasonality, and flow duration curves. Since the training period handles parameter searching and the development period handles error characterization, the diagnostic features reflect the structure's performance during periods when it did not participate in parameter adjustments. Therefore, errors can be located to potential hydrological process modules, providing a directional basis for subsequent candidate structure generation and reducing ineffective searches caused by blindly modifying formulas.

[0042] It should be noted that the calibration algorithm used for parameter calibration can also be differential evolution, genetic algorithm, particle swarm optimization, Bayesian optimization, CMA-ES, random search, gradient optimization or hybrid optimization algorithm, and this embodiment does not limit this.

[0043] Optionally, before performing step S11, step 102 may also include the following sub-steps: Obtain the preheating period data corresponding to the relevant watershed data; The baseline hydrological model was initialized using data from the warm-up period.

[0044] The warm-up period data refers to a segment of data extracted chronologically from watershed-related data, located before the training period and maintaining temporal continuity with the training period.

[0045] In this embodiment, the preheating period data is not used for parameter calibration and error calculation. It is only used to eliminate the uncertainty of the model's initial state (such as soil moisture content, snow storage, etc.), so that the model is already in a state adapted to the actual conditions of the watershed when it enters the training period, thereby avoiding the interference of initial state deviation on the calibration process and simulation results. Specifically, by acquiring the preheating period data from the watershed-related data that is located before the training period, the preheating period data is continuously input into the benchmark hydrological model in chronological order. The model is run before parameter calibration, so that state variables such as snow storage, soil water, upper layer response pool, lower layer response pool, and runoff storage gradually evolve from the initial state assignment and tend to stabilize. Then, the state variables at the end of the preheating period are used as the starting state of the training period simulation and passed to step S11. This reduces the impact of the arbitrariness of the initial state on the simulated runoff, so that the benchmark model information and subsequent watershed diagnostic features reflect more the model structure and parameter errors, rather than the false errors caused by the instability of the initial values, thereby improving the reliability of subsequent candidate structure comparison and selection.

[0046] The data for the warm-up period can be obtained by continuously extracting data immediately before the training period, repeatedly extracting data according to hydrological years, cyclical warm-up, or segmented warm-up.

[0047] Optionally, S12 may include the following sub-steps: The baseline hydrological model was invoked to perform hydrological simulations on the target watershed using training period data and development period data, respectively, to determine the first and second simulated runoff sequences; Based on the first simulated runoff sequence, the second simulated runoff sequence, and observed runoff in watershed-related data, simulation deviation information is calculated from multiple preset feature dimensions. By using the simulation deviation information, watershed diagnostic feature information of the target watershed is generated.

[0048] A simulated runoff sequence refers to the runoff process output by a baseline hydrological model in time intervals, driven by data after parameter calibration, with its time range corresponding to the input data. This embodiment includes a first simulated runoff sequence driven by training period data and a second simulated runoff sequence driven by development period data. The first simulated runoff sequence characterizes the model's fitting ability during the parameter calibration period, while the second simulated runoff sequence characterizes the model's generalization performance during the development period. Observed runoff is obtained from measured flow records in watershed-related data, serving as a reference benchmark for calculating simulation bias.

[0049] Feature dimensions refer to different angles for quantitatively assessing the differences between simulated and observed runoff. In this embodiment, at least the categories of total volume deviation, temporal dynamic deviation, distribution deviation, and process morphology deviation are included. Specifically, total volume deviation characterizes the degree of deviation between simulated and observed runoff in terms of overall magnitude; temporal dynamic deviation characterizes the ability of simulated runoff to fit the temporal fluctuation characteristics of observed runoff; distribution deviation characterizes the degree of difference between simulated and observed runoff in terms of the numerical distribution of flow; and process morphology deviation characterizes the ability of simulated runoff to reproduce the morphological characteristics of specific hydrological processes (such as the recession phase or peak flow phase). Each feature dimension reflects the degree of matching between the model structure and the watershed hydrological processes from different perspectives, providing multi-dimensional quantitative basis for the subsequent construction of watershed diagnostic features.

[0050] In this embodiment, a baseline hydrological model is invoked to perform hydrological simulations on the target watershed using training and development data, respectively. After obtaining the first and second simulated runoff sequences, they are aligned with the corresponding observed runoff sequences in terms of time step. The difference between the simulated and observed values ​​is calculated for each time period, and statistical summaries are performed according to preset feature dimensions to obtain simulation deviation information for each dimension. Specifically, feature dimensions may include water volume deviation, low-flow deviation, high-flow deviation, recession error, seasonal error, peak time series error, snow season / non-snow season difference, and flow continuity curve error, etc. Finally, the simulation deviation information is merged according to its category to generate structured watershed diagnostic feature information. This diagnostic feature information is organized in vector or key-value pair form, with each dimension corresponding to a quantitative index used to characterize the degree of simulation deviation of the baseline hydrological model in that dimension, thereby providing targeted diagnostic basis for subsequent candidate generation units. Since the first simulated runoff sequence reflects the fitting performance after parameter calibration, and the second simulated runoff sequence reflects the performance during the development period without calibration, the deviations of the two on the same characteristic dimension can be compared with each other, thereby distinguishing the surface improvement caused by parameter compensation from the continuous deviation caused by structural defects. This makes the watershed diagnostic characteristic information more likely to point to the hydrological processes that need to be modified, providing a basis for the subsequent generation and selection of candidate structures.

[0051] Step 103: Based on the baseline model information and watershed diagnostic feature information, construct prompt words, and generate module description information for at least one candidate structure based on the prompt words; Cue words refer to the text or structured instructions input into the large language model, which are used to constrain the direction, scope and format of the candidate structures output by the large language model.

[0052] A candidate structure refers to an executable model structure formed by replacing, adjusting, or combining one or more hydrological process modules based on a baseline hydrological model. A hydrological process module refers to a process module with fixed inputs, fixed outputs, and physical meanings, such as rain and snow distribution, snowmelt, evapotranspiration adjustment, soil recharge, actual evapotranspiration, seepage, response, and runoff modules.

[0053] Module description information refers to Domain Specific Language (DSL), a restricted, domain-specific description method used to describe the formulas, parameters, return values, and interface constraints within a hydrological process module in text or structured form. Alternatively, it can be implemented using JSON, YAML, restricted subsets of Python, symbolic expression trees, computational graphs, or other structured representations, as long as it can be compiled into an executable model and pass interface checks.

[0054] In this embodiment, the construction of prompts must balance structural integrity and clarity of expression to ensure that the large language model can accurately understand the structural defects and optimization goals of the benchmark model. After obtaining the benchmark model information and watershed diagnostic feature information, prompts are constructed based on this. These prompts include at least the benchmark model module code, benchmark module interface constraints, candidate generation rules, and watershed diagnostic feature information. They may also include the current best candidate summary and the selection results of historical candidate structures. These prompts are sent to the large language model. Upon receiving the prompts, the large language model generates module description information for the candidate structures based on the constraints and diagnostic information in the prompts. This module description information is expressed in DSL form to ensure that the candidate structures output by the large language model have clear physical meaning and executability. The DSL should include the module name, input / output interface definitions, parameter definitions, formula expressions, and physical constraints to support subsequent compilation and execution processes. During this process, complete free code is not output; instead, constrained candidate module DSLs are output, thereby reducing the uncontrollability of the generated content and improving the pass rate of the candidate structures in subsequent compilation and calibration stages. By limiting the formula combination capability of LLM to fixed hydrological process interfaces, the risks of interface damage, non-executability, and physical inconsistencies are reduced, while retaining the ability to automatically explore hydrological process formulas.

[0055] In one example of this application, step 103 may include the following sub-steps S21-S24: S21. If there is no historical candidate information corresponding to the historical candidate structure, then the baseline model information and watershed diagnostic feature information are used in combination with the preset first structure generation rules to construct prompt words. S22. If there is historical candidate information corresponding to the historical candidate structure, then determine the current round based on the historical candidate information and match the second structure generation rule corresponding to the current round. S23. Construct prompt words using baseline model information, watershed diagnostic feature information, historical candidate information, and second structure generation rules; S24. Input the prompt words into the preset large language model, and generate module description information of at least one candidate structure according to the prompt words through the large language model.

[0056] Historical candidate information refers to the module description information and evaluation results corresponding to the best historical candidate structure in the historical rounds, including the DSL description, compilation status, calibration error, physical feasibility verification results, and the criteria for rejection or adoption of the historical candidate.

[0057] The first structure generation rule refers to the candidate generation constraints used when there is no historical candidate information. It is used to limit the modification scope, interface boundaries, output fields, and physical specification requirements of the initial candidates.

[0058] The second structure generation rule refers to the candidate generation constraints obtained from the current round of matching when historical candidate information exists. These constraints are used to adjust the number of modifiable modules, the module combination method, and the utilization of historical information. In this embodiment, the second structure generation rule is related to the current round, with different rounds corresponding to different candidate structure complexity constraints. For example, the first round requires all candidates to modify only one module; the second round requires at least two candidates to modify only one module and at least one candidate to modify two modules; the third round requires at least one candidate to modify one module, at least one candidate to modify two modules, and at least one candidate to modify three modules; the fourth round and thereafter require at least one candidate to modify one module, at least one candidate to modify two or more modules, and at least one candidate to modify three or more modules. These round constraints serve two purposes: first, to conduct controlled experiments on a single hydrological process to identify which process modifications are effective; and second, to allow the LLM to combine multiple modules based on the effects of historical candidates in subsequent rounds, forming a joint structure improvement. Even if a historical candidate is not ultimately selected, it can still serve as evidence for subsequent candidates; however, new candidates are still compiled based on the baseline model, rather than directly copying a complete historical code file.

[0059] In this embodiment, when constructing the prompt word, it is determined whether there are historical candidate structures and corresponding historical candidate information. If not, the prompt word is constructed using baseline model information, watershed diagnostic feature information, and a preset first structure generation rule. Specifically, the prompt word explicitly requires the large language model to output only the module description information of the candidate structure, without directly outputting the complete code file; the baseline model information also includes baseline model module code and module structure constraints.

[0060] If historical candidate structures and corresponding historical candidate information exist, a prompt word is constructed using baseline model information, watershed diagnostic feature information, historical candidate information, and the second structure generation rule. This prompt word explicitly requires the large language model to generate new candidate structure module description information within the modification range defined by the second structure generation rule, based on the evaluation results of historical candidates. It also explicitly requires that the new candidate differ from the historical candidate in the module modification location to avoid repeatedly trying modification directions that have been proven ineffective. Simultaneously, the prompt word includes the DSL description and evaluation results of the historical candidates to assist the large language model in understanding the modification location, effect evaluation, and reasons for failure of historical candidates, thereby avoiding invalid directions in subsequent generation. Furthermore, the prompt word also includes the candidate quantity requirement and module modification constraints for the current round to ensure that the generated results meet the controlled experimental objectives of this round. Through the above methods, this embodiment can gradually converge to an effective combination of hydrological process modules in multiple iterations, while avoiding wasting computational resources due to repeatedly trying invalid modifications, thus improving overall search efficiency.

[0061] Finally, the prompt words are input into a pre-defined large language model, which generates module description information for at least one candidate structure based on the prompt words. Thus, the initial rounds explore single-point modifications under controlled rules, while subsequent rounds adjust the complexity and combination direction of modifications based on historical candidate effects and failure records. This avoids repeated ineffective attempts and gradually transitions candidate generation from isolated formula replacements to evidence-supported multi-module combinations, improving the targeting and reproducibility of structure search.

[0062] The large language model generates at least one candidate structure, each associated with its corresponding module description information, which includes at least the following: candidate identifier, modified module, module DSL, modification summary, hydrological mechanism explanation, expected improvement indicators, potential risks, added or deleted parameters, parameter boundaries, target module, and complexity changes. The system requires each candidate to explain the altered water or energy pathway and the physical meaning of how the modification maintains storage, flux, distribution, delay, threshold, or feedback mechanisms.

[0063] It's important to note that the large language model cannot directly generate a complete hydrological model. Instead, it breaks down the hydrological model into fixed interface modules. The large language model then generates module description information for candidate structures based on prompt words, rather than directly outputting a complete code file. Furthermore, the large language model cannot modify each fixed interface module; however, it allows modification of modules including, but not limited to, those specified below. Figure 2 The following modules in: (1) The precipitation partitioning module `precip_partition_step(p, temp, state, par)` is used to divide precipitation into rain and snow, and requires the return of non-negative `rainfall`, `snowfall`, and corresponding flux. (2) The snow accumulation module `snow_accumulation_step(snowfall, state, par)` is used to update the solid snow storage and the liquid water storage in snow, and requires the preservation of snow water equivalent. (3) The snow melting module `snow_melt_step(rainfall, temp, state, par)` is used to calculate snow melting, refreezing, liquid water retention in snow, and liquid input entering the soil. (4) The potential evapotranspiration adjustment module `pet_adjustment_step(potential_et, temp, day_index, state, par)` is used to adjust the potential evapotranspiration according to temperature, season, or state, but does not directly change the water storage. (5) The soil recharge module `soil_recharge_step(liquid_input, state, par)` is used to allocate liquid input as soil storage changes and recharge into the response pool. (6) The actual evapotranspiration module `actual_et_step(adjusted_pet, state, par)` is used to subtract non-negative actual evapotranspiration from soil water. (7) The percolation module `percolation_step(recharge, state, par)` is used to transfer water entering the upper response pool to the lower response pool. (8) The response module `response_step(state, par)` is used to release runoff from the upper and lower reservoirs, and water must not be created out of thin air. (9) The routing_transform module `routing_transform(runoff, par)` is used to delay and broaden uncombined runoff and output a simulated runoff sequence. Each module has a fixed function name, fixed input variables, a key that must be returned, accessible state variables, and a physical contract. The LLM can only modify formulas and parameters within these interfaces and cannot change the overall system state machine. Please refer to [link to relevant documentation]. Figure 2 The module interface constraint diagram is as follows: the water flux output by the upstream module is sequentially passed to the downstream module. The state variables include snow storage, liquid water in snow, soil water, upper response pool, lower response pool and runoff storage. The input and output of each module are defined by the interface contract.

[0064] like Figure 2As shown, among the modules described above, state variables include snow storage, liquid water in snow, soil water, upper response reservoir, lower response reservoir, and runoff storage. Water flux is transferred in the following order: precipitation, rain and snow distribution, snow accumulation, snowmelt, soil recharge, actual evapotranspiration, infiltration, response, and runoff. In the legend, water process modules represent modules that affect water storage and generate fluxes, evaporation-related modules represent modules that do not directly change water storage, state variables represent variables that can be accessed or updated by modules, water flux transfer is indicated by arrows, modular system boundaries are indicated by dashed lines, and state variable read / write operations are indicated by corresponding arrows.

[0065] Interface constraints and the editable boundaries of the large language model include: fixed function names, fixed input variables, mandatory return keys, restricted access to state variables, mandatory fulfillment of physical contracts, the large language model allowing only formulas and parameters to be modified, and prohibiting changes to the overall state machine. Therefore, the candidate structures generated by the large language model are confined to the authorized modules. During compilation, only the target module is replaced, while unmodified modules are retained. This ensures that the candidate structures exhibit auditable structural differences relative to the baseline model, facilitating subsequent security checks, physical consistency checks, parameter calibration, and development-phase evaluation.

[0066] Optionally, the baseline model information includes baseline model module code and module interface constraints; S24 may include the following sub-steps: If no historical candidate structure exists, the module description information of at least one candidate structure is generated by adjusting the parameters of the baseline model module code in accordance with the first structure generation rule through the large language model according to the module interface constraints. If historical candidate structures exist, the diagnostic text corresponding to the historical candidate structures is determined by using a large language model based on the historical candidate information and the watershed diagnostic feature information. Merge the prompt words and diagnostic text to obtain the updated prompt words; The large language model is invoked to adjust the parameters of the baseline model module code in accordance with the second structure generation rules under the constraints of the module interface, based on the update prompt words, and to generate module description information of at least one candidate structure.

[0067] The baseline model module code refers to the set of executable code for each hydrological process module in the baseline hydrological model, which includes fixed function names, input variables, return fields, access methods for state variables, and module calling order.

[0068] Module interface constraints refer to the restrictions on the functions, inputs, outputs, return fields, state reads and writes, and physical contracts that allow modification of a module.

[0069] Diagnostic text refers to text generated by a large language model based on historical candidate information and watershed diagnostic feature information, which describes the possible sources of error in historical candidate structures and the direction of subsequent modifications.

[0070] Updated prompt words refer to the final prompt words obtained after merging prompt words and diagnostic text, which are used to guide the large language model to generate new candidate structures.

[0071] In this embodiment, if no historical candidate structure exists, the large language model adjusts the parameters of the baseline model module code according to the module interface constraints, conforming to the first structure generation rule, to generate module description information for at least one candidate structure. In this case, the first structure generation rule constrains the candidate to modify only one module, allowing for controlled single-point modification based on the baseline model's code. This facilitates isolating the impact of a single module change on the overall simulation effect in the initial stage and avoids the confusion caused by combined adjustments of multiple modules.

[0072] If historical candidate structures exist, the diagnostic text corresponding to the historical candidate structure is determined by the large language model according to the historical candidate information and the watershed diagnostic feature information; the prompt words and diagnostic text are merged to obtain the updated prompt words; the large language model is called to adjust the parameters of the baseline model module code in accordance with the second structure generation rules under the module interface constraints according to the updated prompt words, and at least one candidate structure module description information is generated.

[0073] It should be noted that, in the presence of historical candidate structures, module description information is generated through a two-stage large language model invocation. For example... Figure 3 As shown, in the first stage, historical candidate information and watershed diagnostic features are input into the large language model. The large language model is required to output only diagnostic summaries and modification directions, without outputting candidate codes or module descriptions. The diagnostic content may include, but is not limited to, the hydrological process that the current error might correspond to, supporting indicators, possible competing interpretations, preferred modification directions, and historically failed directions that need to be avoided. Then, in the second stage, diagnostic text is added to the original prompts to obtain updated prompts, and the large language model is called to output formal module descriptions of the candidate structures. The diagnostic text output in the first stage is only for reference and does not replace the original watershed data, indicators, historical candidates, and physical constraints. Its role is to guide the candidate generation process to focus on potential error sources, while avoiding repeated exploration of modification paths that have been verified as invalid by historical candidates, thereby improving the targeting and convergence efficiency of candidate generation.

[0074] In the specific implementation, Figure 3 The process can include adding a diagnostic stage before the original candidate generation process, so that the large language model first analyzes the sources of watershed errors and the direction of modification, and then generates formal candidate structures under the controlled module interface, thereby reducing the problems of illusion, repeated trial and error and lack of physical meaning that may occur when directly generating complete code or module description information.

[0075] On the input side, the system acquires diagnostic data and historical candidate information. Diagnostic data includes watershed diagnostic information, specifically including water volume deviation, low-flow deviation, high-flow deviation, recession error, seasonality error, peak timing error, differences between snowy and non-snowy seasons, and flow continuity curve error. Historical candidate information includes historical candidate performance, the current best candidate summary, and historical failure directions. This information is used to generate initial candidate generation suggestions, which also include the baseline model module code, module interface constraints, candidate generation rules, and the current best candidate summary.

[0076] The first phase involves calling the diagnostic large language model. This phase sends the original candidate generation prompts to the large language model, but requires the model to only output a diagnostic summary and modification directions, without outputting candidate code or module domain-specific language (DSL) descriptions. The output of the first phase is diagnostic text, which includes the hydrological process that the current error may correspond to, supporting indicative evidence, possible competing interpretations, preferred modification directions, and historically failed directions that should be avoided. This diagnostic text is for reference only and cannot replace the original watershed data, evaluation indicators, historical candidate records, and physical constraints.

[0077] After obtaining the first-stage diagnostic text, the system performs prompt merging. Prompt merging combines the original candidate generation prompts with the first-stage diagnostic results to obtain updated prompt terms. The updated prompt terms retain the baseline model module code, watershed diagnostic information, historical candidate effects, current best candidate summary, candidate generation rules, and module interface constraints from the original candidate generation prompts, while incorporating the diagnostic text output from the first stage. This ensures that the second-stage generation retains both original data evidence and incorporates explicit error diagnoses.

[0078] The second phase involves calling the large language model to generate candidates. Based on updated prompts, this phase requires the large language model to output formal candidate modules (DSLs). The candidate module DSL describes the target module's formulas, parameters, return fields, and physical specifications within a fixed interface. The large language model can only modify the internal formulas and parameters of the modules, without altering the overall model state machine. Therefore, the first phase is responsible for diagnostic direction, while the second phase is responsible for forming compilable candidate structures within a controlled interface. This clear division of labor reduces the randomness of directly generating candidates.

[0079] After candidate modules (DSLs) are generated, they enter the downstream execution flow. The DSL compilation unit compiles the candidate modules into complete and executable candidate HBV code, retaining modules not covered by the baseline model during compilation and replacing only the specified candidate modules. The security and physical inspection unit performs static security checks, interface checks, parameter boundary checks, and physical scenario checks on the compiled candidate code, rejecting candidates containing unauthorized operations, interface errors, out-of-bounds parameters, or physical inconsistencies. Candidates that pass the checks enter the candidate parameter calibration unit, where the parameters are independently recalibrated for each candidate structure. The candidate evaluation and selection unit uses development-phase data for structure selection. Final testing-phase information is not included in the prompting, diagnosis, candidate generation, parameter calibration, and structure selection processes; it is only used to report the generalization effect after final determination.

[0080] Through the aforementioned two-stage invocation model, the candidate generation process first establishes interpretable diagnostic directions, and then generates formal candidate structures under module interface constraints. This allows the formula combination capabilities of the large language model to complement the external program's security checks, physical checks, parameter calibration, and development-phase evaluation. This model improves the relevance and reproducibility of candidate generation, reduces invalid candidates and repeated failed directions, and provides an auditable source of candidates for subsequent structure selection, cross-basin migration, and batch parallel optimization.

[0081] Step 104: Compile the description information of each module into executable candidate module code, and perform a security check on each candidate module code to obtain the corresponding candidate structure; Candidate module code refers to candidate hydrological model code that can be executed by a unified calling interface, formed by compiling and merging the description information of the unmodified baseline hydrological model module and the candidate module.

[0082] In this embodiment, by reading all module codes within the precise hydrological model, the target module specified in the module description information is identified. The target module is verified to belong to the allowed modification set. The function name, input variables, return fields, state access, and parameter boundaries are checked to ensure they conform to the interface contract. Candidate modules are replaced with their corresponding positions in the baseline model, while unmodified modules are retained. Module candidate code is generated and a unified calling interface is exposed. Static AST checks and runtime checks are performed on the module candidate code. Static checks reject imported external packages, file read / write operations, network access, system calls, dynamic execution, and unauthorized names. Runtime checks verify whether anomalies, negative runoff, negative storage, numerical divergence, or violation of mass conservation occur under scenarios such as drought, heavy rain, continuous wet conditions, and snowmelt after cold snow accumulation. Candidates that fail are rejected or marked as failed candidate structures. This ensures that candidate structures entering parameter calibration are both executable and conform to water conservation and the physical meaning of the process.

[0083] In one example of this application, step 104 may include the following sub-steps S31-S34: S31. Call the compiler to compile the module description information into executable module candidate code; S32. Perform security checks on the candidate code of each module to determine whether the candidate code of each module meets multiple preset check conditions; the check conditions include static abstract syntax tree check conditions and candidate runtime check conditions; S33. If any candidate code of a module satisfies all the check conditions, then create the candidate structure corresponding to the candidate code of the module. S34. If any candidate code for a module does not meet all the check conditions, then the candidate code for that module is removed.

[0084] A compiler is a tool that converts module description information into executable code. Its input is candidate module description information, and its output is complete candidate module code. It performs replacement and merging according to the module interfaces and calling order of the baseline hydrological model.

[0085] The check criteria refer to the set of rules used to determine whether the candidate module code is safe, executable, and conforms to physical constraints. Static abstract syntax tree check criteria refer to the verification rules that parse the code and generate an AST (Abstract Syntax Tree) without running the code, traversing nodes to identify unauthorized operations, interface violations, or dangerous statements. Examples include rejecting the import of external packages, file reading and writing, network access, system calls, dynamic execution, and unauthorized names. Candidate execution check criteria refer to the verification rules that actually execute the candidate module code under preset input scenarios to observe whether runtime anomalies, negative values, numerical divergence, or violations of mass conservation occur. For example, running the candidate model under extreme input scenarios such as drought, torrential rain, continuous wet conditions, or snowmelt after cold snowfall to check for anomalies, negative runoff, negative storage, numerical divergence, or significant violations of mass conservation.

[0086] In this step, a compiler can be invoked to compile the module description information into executable candidate module code. During compilation, unmodified modules from the baseline hydrological model are retained, and only the specified candidate modules are replaced. Subsequently, a security check is performed on each candidate module code to determine whether it meets multiple preset check conditions. If all check conditions are met, the corresponding candidate structure is created; if any check condition is not met, the candidate module code is eliminated. This process ensures that candidates undergo interface, security, and physical screening before entering parameter calibration. Static checks can intercept unauthorized operations, and runtime checks can expose negative runoff, negative storage, numerical divergence, and violations of mass conservation. Only those that pass the checks proceed to subsequent independent calibration and development phase evaluation, thereby reducing invalid calculations, isolating failed candidates, and ensuring that the candidate structure is executable, auditable, and physically reliable.

[0087] Optionally, S31 may include the following sub-steps: The compiler is invoked to read the complete model code of the benchmark hydrological model; Identify the target module code specified by the module description information from all model codes; Determine whether the target module code belongs to the adjustable code set; If so, then determine whether the interface of the target module code satisfies the module interface constraints; If the conditions are met, the target module code is replaced according to the module description information, and the replaced target module code is merged with the unreplaced model code in the baseline hydrological model to obtain executable module candidate code.

[0088] Model code refers to the complete code contained in the baseline hydrological model before compilation and replacement, covering various hydrological process modules and their calling relationships, state variable transmission, and unified simulation entry point.

[0089] The adjustable code set refers to the pre-authorized set of module codes that the baseline hydrological model allows to be replaced by candidate module descriptions. Modules outside this set are considered read-only modules. In this embodiment, it refers to modules that are allowed to be modified by the LLM.

[0090] In this embodiment, the compiler first reads all the model code of the baseline hydrological model and establishes an index relationship between module names, function signatures, and call locations. For each module description, it locates the specified target module code from all the model code and determines whether the target module code belongs to the adjustable code set. If it does not belong, the module description is rejected or marked as a failure candidate. If it does belong, the compiler further checks whether the interface of the target module code satisfies the module interface constraints, including function names, input variables, return fields, state variable access, and call order. If the interface satisfies the constraints, the target module code is replaced according to the module description information, and the replaced target module code is merged with the unreplaced model code in the baseline hydrological model to obtain executable module candidate code, which exposes a unified calling interface, such as simulate_hbv(precipitation, temperature, pet, params), default parameters, parameter boundaries, and a list of calibrable parameters. This process restricts candidate modifications to authorized modules, preventing unauthorized changes to state machines and interfaces. Each candidate is represented only as an auditable structural difference relative to the baseline model, thereby reducing the risk of compilation failures, variable misalignment, and physical process breakage. It also provides executable objects for subsequent security checks, parameter calibration, and fair comparisons.

[0091] Step 105: Based on the training and development data, after calibrating the parameters of each candidate structure, select the target optimization structure of the benchmark hydrological model.

[0092] The target optimization structure refers to the hydrological model structure selected from all candidate structures that performs best during the validation period and satisfies the physical consistency constraint.

[0093] In this embodiment, for each candidate structure that passes the safety check, parameter calibration is performed on each candidate structure based on training period data. This ensures that each candidate structure reaches its optimal parameter state under unified conditions, rather than using the parameters of the baseline hydrological model. Then, based on development period data, the deviation and overall performance between each candidate structure and the observed runoff are calculated. Each candidate structure is compared with the baseline hydrological model, and the candidate structure that performs better than the baseline hydrological model and meets the physical consistency constraint is selected as the target optimization structure. Since the training period is used for parameter calibration and the development period is used for structure selection, the quality of the structure is no longer affected by insufficient parameter optimization, thereby improving the generalization ability of the selected target optimization structure for subsequent runoff simulation.

[0094] It should be noted that, in addition to extreme input scenario checks, this physical consistency constraint can also include long-term water balance checks, energy constraint checks, parameter sensitivity checks, monotonicity checks, state variable boundary checks, or unit consistency checks.

[0095] In one example of this application, the benchmark model information also includes benchmark model metrics; step 105 may include the following sub-steps: Based on the training data and the preset parameter calibration algorithm, the parameters of each candidate structure are calibrated to obtain the calibrated candidate structure. The baseline hydrological models under each calibration candidate structure were used to perform hydrological simulations on the development period data, and the hydrological simulation results corresponding to each calibration candidate structure were obtained. Calculate the model evaluation index corresponding to each calibration candidate structure based on the hydrological simulation results. The comprehensive development score of each calibration candidate structure is determined based on the evaluation indicators of each model and the benchmark model indicators. Candidate structures that meet the preset selection criteria in the comprehensive score during the development period are selected as the target optimization structure for the benchmark hydrological model.

[0096] Benchmark model indices refer to the set of evaluation indices obtained after calibration or simulation of the benchmark hydrological model, used as a reference for comparing candidate structures. These indices include, but are not limited to, KGE (Kling-Gupta Efficiency), NSE (Nash-Sutcliffe Efficiency), logNSE (logarithmicNash-Sutcliffe Efficiency), PBIAS (Percent Bias), low flow bias, high flow bias, and relative error of the recession slope. Among them, KGE comprehensively measures the overall goodness of fit between simulated and observed runoff in terms of correlation, variance ratio, and bias ratio. The closer its value is to 1, the better the simulation effect. NSE is used to measure the overall goodness of fit between simulated and observed runoff. The closer its value is to 1, the better the simulation effect. When it is less than 0, it means that the simulated value is worse than the observed mean. logNSE is calculated by transforming the runoff series with log1p. It can more sensitively reflect the fitting accuracy during low flow periods. The closer its value is to 1, the better the simulation effect in low flow periods. PBIAS is used to measure the average deviation of the simulated total runoff from the observed total runoff. When its value is 0, it means there is no systematic bias. A positive value means that the simulated runoff is too large, and a negative value means that the simulated runoff is too small. The low-flow deviation and the average flow deviation calculated based on the low quantile sample of observed runoff are used to characterize the simulation error of the model during the dry season; the high-flow deviation is calculated based on the average flow deviation calculated based on the high quantile sample of observed runoff, and is used to characterize the simulation error of the model during the flood season; the relative error of the recession slope is calculated based on the logarithmic recession slope of the observed runoff decline segment, and is used to characterize the model's ability to depict the watershed storage and discharge process and recession dynamics.

[0097] Model evaluation indexes refer to the index values ​​of each candidate structure on the corresponding evaluation dimension, calculated using the same calculation method as the benchmark model indexes, based on the hydrological simulation results corresponding to each calibration candidate structure.

[0098] In this embodiment, using the benchmark model indicators in the benchmark model information as a reference, each candidate structure that passes the safety check has its parameters independently calibrated using training data combined with a preset parameter calibration algorithm, and its model evaluation indicators are calculated during the development phase. The model evaluation indicators of each candidate structure are compared with the benchmark model indicators, and the candidate structures are ranked according to the comparison results. Calibration candidate structures that outperform the benchmark hydrological model during the development phase are selected and included in the candidate set. If the model evaluation indicators of a candidate structure do not exceed the benchmark model in multiple dimensions, the candidate structure is marked as a failed candidate, and the reasons for failure are recorded, including but not limited to parameter calibration non-convergence, structural redundancy, insufficient simulation accuracy, or numerical instability. This process ensures that structural comparisons are based on independent parameter optimization and independent verification during the development phase, reducing misjudgments caused by insufficient parameter calibration and providing verifiable improvement evidence for the finally selected structures relative to the benchmark model.

[0099] In the comparison phase between the model evaluation indicators and the benchmark model indicators, this can be achieved through the calculation of the comprehensive development score. For the comprehensive development score of any calibrated candidate structure, a weighted summation method is used to map the differences in indicators across each evaluation dimension into dimensionless scores. : ; ; in, This represents the relative error between the observed and simulated median daily logarithmic recession slopes. The recession slope is calculated based on consecutive recession day pairs identified in the observed flow processline, requiring the observed flow of the previous day to be above its 35th percentile. The simulated recession slope is calculated using the same date pairs.

[0100] The above scoring is not the only limitation; the weights of each indicator can be adjusted or additional indicators such as peak flow error, peak time error, water balance, seasonality error, drought index, flood index, ecological flow index, or uncertainty index can be added according to the application scenario. Candidate selection units choose the best-performing candidate during the development phase and report its generalization effect during the final testing phase. For the selection rules of the objective optimization structure, in addition to selecting the candidate with the highest score during the development phase, Pareto front, multi-objective constraints, stability penalty, complexity penalty, parameter number penalty, cross-basin average effect, or physical rationality score can also be used for selection.

[0101] In another example of this application, the method further includes the following steps: Extract test period data from watershed-related data; A baseline hydrological model under the target optimization structure was used to perform hydrological simulation on the test period data to obtain the test hydrological simulation results; Based on the test hydrological simulation results, the evaluation indicators for the test period corresponding to the target optimized structure are calculated, and a test report is generated.

[0102] Test period data refers to the time period data extracted from watershed-related data in chronological order, which is located after the training and development periods and does not participate in parameter calibration, candidate generation, and structure selection.

[0103] In this embodiment, test period data is extracted from relevant watershed data and is excluded from training period calibration, development period structure selection, candidate generation, and diagnostic text generation. A baseline hydrological model under the target optimized structure is used to perform hydrological simulation on the test period data, yielding test hydrological simulation results. Then, based on the test hydrological simulation results, the test period evaluation index corresponding to the target optimized structure is calculated, and a test report is generated. Since the test period data is only used after the target optimized structure is determined, the test period evaluation index reflects the structure's performance on data that was not involved in its generation and selection. Therefore, it can be used to verify whether the structure improvement has generalization ability, reducing information leakage and overly optimistic evaluation problems caused by repeated comparisons during the development period. Simultaneously, the test report provides a basis for subsequent auditing, reproduction, and cross-watershed comparisons.

[0104] In another example of this application, the method further includes the following steps: When watershed migration request data is received, the similarity between the watershed to be migrated and the target watershed is calculated based on the watershed migration request data and watershed-related data. When the similarity meets the preset similarity conditions, the benchmark hydrological model of the target optimized structure is determined as the first hydrological model of the watershed to be migrated. Based on the watershed migration demand data, the parameters of the first hydrological model were calibrated to obtain the target hydrological model for the watershed to be migrated.

[0105] Watershed migration demand data refers to the relevant data of the watershed to be migrated specified by the user, including the meteorological driving data, observed runoff data and static attribute data of the watershed.

[0106] Similarity refers to the degree of comprehensive similarity between two watersheds in terms of meteorology, runoff, and static properties.

[0107] In this embodiment, upon receiving watershed migration demand data, the comprehensive similarity between the watershed to be migrated and the target watershed in terms of meteorological drivers, runoff response, and static attributes is calculated based on the watershed migration demand data and the watershed-related data of the current watershed. Specifically, the similarity of each feature dimension can be calculated separately, and then weighted and summed according to preset weights to obtain a comprehensive similarity value. When the similarity meets a preset similarity condition, such as being greater than a preset similarity threshold, the baseline hydrological model under the target optimized structure is determined as the first hydrological model of the watershed to be migrated. At this time, only the model structure is migrated, and the source watershed calibration parameters are not migrated. Subsequently, based on the meteorological drivers and observed runoff of the watershed to be migrated in the watershed migration demand data, the parameters of the first hydrological model are calibrated to obtain the target hydrological model of the watershed to be migrated. Thus, the source watershed optimized structure can be reused in similar watersheds to be migrated, while the parameter recalibration adapts the model to the watershed to be migrated, avoiding the mismatch of hydrological response caused by directly applying the source parameters, and providing a basis for judging whether the structural improvement has cross-watershed portability.

[0108] Furthermore, similarity can be calculated based on climate, topography, soil, land use, hydrological signature, baseline model error pattern, or learned embedding vectors. Distance metrics can be Euclidean distance, Mahalanobis distance, cosine distance, or weighted distance, and this embodiment does not impose any restrictions on these metrics.

[0109] In another example of this application, the method further includes the following steps: When a parallel optimization instruction is received, the set of target watersheds to be processed in parallel is determined according to the parallel optimization instruction; The candidate structure generation and parameter calibration processes for each undetermined watershed in the target watershed set are processed in parallel to obtain the optimized model structure for each undetermined watershed.

[0110] Parallel optimization instructions refer to control information used to trigger the simultaneous or batch execution of hydrological model structure optimization in multiple watersheds. They may include the target watershed set, task priority, parallelism constraints, or result summarization requirements.

[0111] An undetermined watershed refers to a single watershed in the target watershed set that has not yet completed candidate structure generation, parameter calibration, and structure selection, or has not yet determined the final model optimization structure.

[0112] In this embodiment, upon receiving a parallel optimization instruction, the set of target watersheds to be processed in parallel is determined according to the instruction. Subsequently, the candidate structure generation and parameter calibration processes for each watershed are processed in parallel. Specifically, based on the parallelism constraints in the parallel optimization instruction, the target watershed set is divided into several batches. Within each batch, each watershed simultaneously performs candidate structure generation, safety checks, and parameter calibration tasks. After each batch is completed, the candidate evaluation results for each watershed are summarized, and structure selection is performed independently to obtain the optimized model structure for each watershed. Therefore, multi-watershed parallel optimization can significantly shorten the overall structure search and calibration time, improve experimental efficiency in large-scale hydrological modeling scenarios, and reduce the time cost caused by serial processes, enabling multi-watershed, multi-round candidate structure exploration to be completed within an acceptable timeframe. Simultaneously, the parallel tasks of each watershed are independent and do not interfere with each other. The failure of candidate structure generation or calibration in one watershed will not affect the normal progress of other watersheds, thereby improving the robustness and fault tolerance of the overall optimization process.

[0113] It should be noted that parallel optimization instructions can trigger any of the following types of parallelism: first, parallel calibration of baseline models across multiple watersheds; second, parallel LLM structure optimization experiments across multiple watersheds; and third, parallel calibration of multiple candidate parameters within the same LLM round. Parallel worker processes can limit the number of BLAS / OpenMP threads, avoiding excessive resource contention on multi-core servers. Parallel execution can be implemented using local multi-processing, distributed task queues, cluster scheduling systems, cloud functions, or containerized batch processing.

[0114] In another example of this application, the method further includes the following steps: When an anomaly occurs in the candidate structure generation or parameter calibration process of any undetermined watershed, the undetermined watershed is marked as an abnormal watershed, and the candidate structure generation and parameter calibration processes of other undetermined watersheds in the target watershed set continue to be executed. Once the candidate structure generation or parameter calibration process for the anomalous watershed has resumed, the candidate structures and calibration parameters of the anomalous watershed that have passed the checks are reused based on the processing results of other undetermined watersheds until the target optimization structure of the anomalous watershed is determined.

[0115] In this embodiment, when an anomaly is detected in the candidate structure generation or parameter calibration process of any undetermined watershed, the undetermined watershed is first marked as an abnormal watershed, and its current task is paused, but no blocking or rollback operation is performed. The parallel processing flow of other undetermined watersheds in the target watershed set is unaffected and continues to proceed. After the abnormal watershed is marked, its incomplete task status and generated intermediate results are persistently recorded for seamless connection after anomaly recovery. When the candidate structure generation or parameter calibration process of the abnormal watershed is restored, the system prioritizes reusing its candidate structures that have passed security checks and its calibrated parameters, avoiding repeated execution of completed generation and calibration steps, thereby reducing computational resource waste and shortening retry time after anomaly recovery. At the same time, the recovery process of the abnormal watershed is independent of the parallel flow of other watersheds and will not interfere with the parallel execution progress of other undetermined watersheds. Thus, the anomaly handling mechanism and the parallel execution mechanism work together to ensure the continuity and stability of the overall optimization process, and improve the fault tolerance and resource utilization efficiency in multi-watershed parallel optimization scenarios.

[0116] Please see Figure 4 , Figure 4 The present invention illustrates the system implementation process of a hydrological model structure optimization method provided by an embodiment of the present invention.

[0117] In this embodiment, the system can be deployed on a computer server, workstation, or cloud computing environment, and is divided into units such as data reading, benchmark model calibration, diagnostic feature generation, large language model candidate generation, module compilation, security and physical checks, parameter calibration, evaluation and selection, parallel execution and recovery, and result output.

[0118] During the data input phase, the data reading unit reads the meteorological drivers, observed runoff, and static attributes of the target watershed. Meteorological drivers include precipitation, air temperature, and potential evapotranspiration; static attributes include watershed area, climate indicators, topographic indicators, and hydrological response characteristics. The read data is divided chronologically, and information from the final testing period is strictly isolated and not included in subsequent large-scale language model prompts, parameter calibration, and structure selection processes.

[0119] The baseline model calibration unit calibrates the parameters of the initial HBV model, outputting baseline parameters and baseline evaluation indicators. This initial HBV model includes modules for precipitation and snowfall distribution, snow accumulation, snowmelt, potential evapotranspiration adjustment, soil recharge, actual evapotranspiration, leakage, response, and runoff. Simultaneously, the diagnostic feature generation unit generates watershed diagnostic information based on training and development period data, specifically including water volume deviation, low-flow deviation, high-flow deviation, recession error, seasonality error, peak flow timing error, snow season versus non-snow season difference, and flow persistence curve error. This diagnostic information is used to indicate structural defects in the baseline model during specific hydrological processes.

[0120] During the candidate generation phase, the large language model candidate generation unit receives prompts consisting of the baseline model module code, the current best candidate summary, historical candidate effects, watershed diagnostic information, candidate generation rules, and module interface constraints. Based on the prompts, the large language model generates a module domain-specific language description for one or more candidate structures. This description is a restricted, structured expression, rather than a free-form complete code. Subsequently, the module DSL compilation unit compiles the module DSL output by the large language model into complete, executable candidate HBV code. The compilation process preserves modules not covered in the baseline model and only replaces the specified candidate modules, thus creating a structural difference relative to the baseline model.

[0121] After compilation, the candidate security and physics checking unit performs static security checks, interface checks, parameter boundary checks, return value checks, and physical scenario checks on the candidate code. If the checks find issues such as importing external packages, file operations, network access, dynamic execution, incorrect module names, incorrect function signatures, missing return keys, negative reserves, or obvious water conservation problems, the candidate is rejected or marked as a failed candidate and recorded in the failed candidate record. Candidates that pass the checks enter the candidate parameter calibration unit, which independently recalibrates the parameters of each candidate structure using training data. The implementation example uses the SCE-UA algorithm. The candidate evaluation and selection unit uses development data for structure selection. It is not used for prompting or structure selection during the final testing phase, but only for reporting the generalization effect after the candidate is finally determined.

[0122] During the overall execution process, the parallel execution and recovery unit supports parallel processing across different watersheds, parallel processing of different candidates within the same round, and batch parallel processing of the baseline model. The system supports the reuse of completed results and the recording of failed candidates; when an anomaly occurs in a single watershed or a single candidate, it does not affect the continued execution of batch processing. Finally, the results output unit outputs candidate DSLs, complete candidate codes, calibration parameters, indicators for each stage, diagnostic results, selection rationale, simulation time series, and summary tables for auditing, reproduction, and subsequent analysis.

[0123] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0124] The following describes the structure optimization device for the hydrological model provided in the embodiments of this application. The structure optimization device for the hydrological model described below can be referred to in correspondence with the structure optimization method for the hydrological model described above.

[0125] Please see Figure 5 The present invention illustrates a structure optimization device for a hydrological model, comprising: The data acquisition unit 201 is used to acquire watershed-related data of the target watershed, and extract training period data and development period data from the watershed-related data in chronological order; The model information extraction unit 202 is used to calibrate the parameters of the benchmark hydrological model of the target watershed based on the training period data and the development period data, obtain the benchmark model information, and generate watershed diagnostic feature information. The module description information generation unit 203 is used to construct prompt words based on the baseline model information and watershed diagnostic feature information, and generate module description information of at least one candidate structure based on the prompt words; The candidate structure generation unit 204 is used to compile the description information of each module into executable candidate module code, and to perform a security check on each candidate module code to obtain the corresponding candidate structure. The target optimization structure selection unit 205 is used to select the target optimization structure of the benchmark hydrological model after calibrating the parameters of each candidate structure based on the training period data and the development period data.

[0126] Optionally, the model information extraction unit 202 includes: The benchmark model information generation subunit is used to calibrate the parameters of the benchmark hydrological model of the target watershed based on the training period data, and obtain the benchmark model information. The watershed diagnostic feature information generation subunit is used to generate watershed diagnostic feature information for the target watershed based on training and development data.

[0127] Optionally, the model information extraction unit 202 further includes a preheating subunit, used for: Obtain the preheating period data corresponding to the relevant watershed data; The baseline hydrological model was initialized using data from the warm-up period.

[0128] Optionally, the watershed diagnostic feature information generation subunit is specifically used for: The baseline hydrological model was invoked to perform hydrological simulations on the target watershed using training period data and development period data, respectively, to determine the first and second simulated runoff sequences; Based on the first simulated runoff sequence, the second simulated runoff sequence, and observed runoff in watershed-related data, simulation deviation information is calculated from multiple preset feature dimensions. By using the simulation deviation information, watershed diagnostic feature information of the target watershed is generated.

[0129] Optionally, the module description information generation unit 203 includes: The first prompt word construction subunit is used to construct prompt words by combining the baseline model information and watershed diagnostic feature information with the preset first structure generation rules if no historical candidate information corresponding to the historical candidate structure exists. The structure generation rule matching sub-unit is used to determine the current round based on the historical candidate information if there is historical candidate information corresponding to the historical candidate structure, and to match the second structure generation rule corresponding to the current round. The second prompt word construction subunit is used to construct prompt words by using baseline model information, watershed diagnostic feature information, historical candidate information, and second structure generation rules. The large model reasoning subunit is used to input prompt words into a preset large language model, and generate module description information of at least one candidate structure according to the prompt words.

[0130] Optionally, the baseline model information includes the baseline model module code and module interface constraints; the large model inference subunit is specifically used for: If no historical candidate structure exists, the module description information of at least one candidate structure is generated by adjusting the parameters of the baseline model module code in accordance with the first structure generation rule through the large language model according to the module interface constraints. If historical candidate structures exist, the diagnostic text corresponding to the historical candidate structures is determined by using a large language model based on the historical candidate information and the watershed diagnostic feature information. Merge the prompt words and diagnostic text to obtain the updated prompt words; The large language model is invoked to adjust the parameters of the baseline model module code in accordance with the second structure generation rules under the constraints of the module interface, based on the update prompt words, and to generate module description information of at least one candidate structure.

[0131] Optionally, the candidate structure generation unit 204 includes: The code compilation subunit is used to call the compiler to compile the module description information into executable module candidate code; The condition judgment subunit is used to perform security checks on the candidate code of each module and determine whether the candidate code of each module meets multiple preset check conditions; the check conditions include static abstract syntax tree check conditions and candidate runtime check conditions; The candidate structure creation sub-unit is used to create the candidate structure corresponding to the candidate code of the module if any candidate code of the module meets all the check conditions. The candidate structure elimination subunit is used to eliminate candidate code for a module if any candidate code fails to meet all the check conditions.

[0132] Optionally, the code compilation subunit is specifically used for: The compiler is invoked to read the complete model code of the benchmark hydrological model; Identify the target module code specified by the module description information from all model codes; Determine whether the target module code belongs to the adjustable code set; If so, then determine whether the interface of the target module code satisfies the module interface constraints; If the conditions are met, the target module code is replaced according to the module description information, and the replaced target module code is merged with the unreplaced model code in the baseline hydrological model to obtain executable module candidate code.

[0133] Optionally, the benchmark model information also includes benchmark model metrics; the target optimization structure selection unit 205 is specifically used for: Based on the training data and the preset parameter calibration algorithm, the parameters of each candidate structure are calibrated to obtain the calibrated candidate structure. The baseline hydrological models under each calibration candidate structure were used to perform hydrological simulations on the development period data, and the hydrological simulation results corresponding to each calibration candidate structure were obtained. Calculate the model evaluation index corresponding to each calibration candidate structure based on the hydrological simulation results. The comprehensive development score of each calibration candidate structure is determined based on the evaluation indicators of each model and the benchmark model indicators. Candidate structures that meet the preset selection criteria in the comprehensive score during the development period are selected as the target optimization structure for the benchmark hydrological model.

[0134] Optionally, the apparatus also includes a test report generation unit, specifically used for: Extract test period data from watershed-related data; A baseline hydrological model under the target optimization structure was used to perform hydrological simulation on the test period data to obtain the test hydrological simulation results; Based on the test hydrological simulation results, the evaluation indicators for the test period corresponding to the target optimized structure are calculated, and a test report is generated.

[0135] Optionally, the apparatus further includes a watershed migration unit, specifically used for: When watershed migration request data is received, the similarity between the watershed to be migrated and the target watershed is calculated based on the watershed migration request data and watershed-related data. When the similarity meets the preset similarity conditions, the benchmark hydrological model of the target optimized structure is determined as the first hydrological model of the watershed to be migrated. Based on the watershed migration demand data, the parameters of the first hydrological model were calibrated to obtain the target hydrological model for the watershed to be migrated.

[0136] Optionally, the device further includes a parallel optimization unit, specifically used for: When a parallel optimization instruction is received, the set of target watersheds to be processed in parallel is determined according to the parallel optimization instruction; The candidate structure generation and parameter calibration processes for each undetermined watershed in the target watershed set are processed in parallel to obtain the optimized model structure for each undetermined watershed.

[0137] Optionally, the device further includes an exception handling and multiplexing unit, specifically used for: When an anomaly occurs in the candidate structure generation or parameter calibration process of any undetermined watershed, the undetermined watershed is marked as an abnormal watershed, and the candidate structure generation and parameter calibration processes of other undetermined watersheds in the target watershed set continue to be executed. Once the candidate structure generation or parameter calibration process for the anomalous watershed has resumed, the candidate structures and calibration parameters of the anomalous watershed that have passed the checks are reused based on the processing results of other undetermined watersheds until the target optimization structure of the anomalous watershed is determined.

[0138] This invention provides an electronic device, including a memory and a processor. The memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of the hydrological model structure optimization method as described in any embodiment of this invention.

[0139] This invention provides a computer-readable storage medium storing a computer program thereon, which, when executed, implements the hydrological model structure optimization method as described in any embodiment of this invention.

[0140] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the above-described device and module can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0141] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.

[0142] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0143] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or as software functional modules.

[0144] If the integrated module is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0145] Indicatively, such as Figure 6 As shown, Figure 6 This is a schematic diagram of the internal structure of a computer device 300 provided in an embodiment of this application. The computer device 300 can be provided as a server. (Refer to...) Figure 6The computer device 300 includes a processing component 302, which further includes one or more processors, and memory resources represented by memory 301 for storing instructions, such as application programs, that can be executed by the processing component 302. The application programs stored in memory 301 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component 302 is configured to execute instructions to perform the text recognition method of any of the above embodiments.

[0146] The computer device 300 may also include a power supply component 303 configured to perform power management of the computer device 300, a wired or wireless network interface 304 configured to connect the computer device 300 to a network, and an input / output (I / O) interface 305. The computer device 300 may operate based on storage.

[0147] In the description of the embodiments of the present invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in the present invention based on the specific circumstances.

[0148] In the description of the embodiments of the present invention, the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing the present invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the present invention. In addition, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0149] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for structural optimization of a hydrological model, characterized in that, include: Acquire watershed-related data for the target watershed, and extract training and development data from the watershed-related data in chronological order; Based on the training period data and the development period data, the parameters of the benchmark hydrological model for the target watershed are calibrated to obtain benchmark model information and generate watershed diagnostic feature information. Based on the baseline model information and the watershed diagnostic feature information, prompt words are constructed, and module description information of at least one candidate structure is generated based on the prompt words; The module description information is compiled into executable module candidate code, and a security check is performed on each module candidate code to obtain the corresponding candidate structure; Based on the training period data and the development period data, after parameter calibration of each candidate structure, the target optimization structure of the benchmark hydrological model is selected.

2. The method for structural optimization of a hydrological model according to claim 1, characterized in that, The step of calibrating the parameters of the benchmark hydrological model for the target watershed based on the training period data and the development period data, obtaining benchmark model information, and generating watershed diagnostic feature information includes: Based on the training period data, the parameters of the benchmark hydrological model for the target watershed are calibrated to obtain benchmark model information; Based on the training period data and the development period data, watershed diagnostic feature information of the target watershed is generated.

3. The method for structural optimization of a hydrological model according to claim 2, characterized in that, Before performing the step of calibrating the parameters of the benchmark hydrological model for the target watershed based on the training period data to obtain benchmark model information, the step further includes: Obtain the preheating period data corresponding to the watershed-related data; The preheating period data is used to initialize the state of the baseline hydrological model.

4. The method for structural optimization of a hydrological model according to claim 2, characterized in that, The step of generating watershed diagnostic feature information of the target watershed based on the training period data and the development period data includes: The baseline hydrological model is invoked to perform hydrological simulations on the target watershed based on the training period data and the development period data, respectively, to determine the first simulated runoff sequence and the second simulated runoff sequence; Based on the first simulated runoff sequence, the second simulated runoff sequence, and the observed runoff in the watershed-related data, simulation deviation information is calculated from multiple preset feature dimensions. Using the simulated deviation information, watershed diagnostic feature information of the target watershed is generated.

5. The method for structural optimization of a hydrological model according to claim 1, characterized in that, The step of constructing prompt words based on the baseline model information and the watershed diagnostic feature information, and generating module description information for at least one candidate structure based on the prompt words, includes: If no historical candidate information corresponding to the historical candidate structure exists, then the baseline model information and the watershed diagnostic feature information are used, combined with the preset first structure generation rule, to construct prompt words; If there is historical candidate information corresponding to a historical candidate structure, then the current round is determined based on the historical candidate information, and the second structure generation rule corresponding to the current round is matched. Using the baseline model information, the watershed diagnostic feature information, the historical candidate information, and the second structure generation rule, prompt words are constructed; The prompt words are input into a preset large language model, and the large language model generates module description information of at least one candidate structure according to the prompt words.

6. The method for structural optimization of a hydrological model according to claim 5, characterized in that, The baseline model information includes the baseline model module code and module interface constraints; The step of generating module description information of at least one candidate structure according to the prompt words using the large language model includes: If no historical candidate structure exists, the module description information of at least one candidate structure is generated by adjusting the parameters of the baseline model module code in accordance with the first structure generation rule through the large language model and the module interface constraints. If the historical candidate structure exists, the diagnostic text corresponding to the historical candidate structure is determined by the large language model according to the historical candidate information and the watershed diagnostic feature information. The prompt word and the diagnostic text are combined to obtain the updated prompt word; The large language model is invoked to adjust the parameters of the baseline model module code in accordance with the second structure generation rule under the constraints of the module interface, according to the updated prompt words, to generate module description information of at least one candidate structure.

7. The method for structural optimization of a hydrological model according to claim 1, characterized in that, The steps of compiling the module description information into executable module candidate code and performing security checks on each module candidate code to obtain the corresponding candidate structure include: The compiler is invoked to compile the module description information into executable module candidate code; A security check is performed on the candidate code of each module to determine whether each candidate code of the module meets multiple preset check conditions; the check conditions include static abstract syntax tree check conditions and candidate runtime check conditions; If any of the module candidate codes satisfies all of the above check conditions, then a candidate structure corresponding to the module candidate code is created; If any of the module candidate codes does not meet all the check conditions, then the module candidate code is removed.

8. The method for structural optimization of a hydrological model according to claim 7, characterized in that, The step of calling the compiler to compile each of the module description information into executable module candidate code includes: The compiler is invoked to read all the model code of the benchmark hydrological model. Identify the target module code specified by the module description information for each of the entire model code; Determine whether the target module code belongs to the adjustable code set; If so, determine whether the interface of the target module code satisfies the module interface constraints; If the conditions are met, the target module code is replaced according to the module description information, and the replaced target module code is merged with the unreplaced model code in the baseline hydrological model to obtain executable module candidate code.

9. The method for structural optimization of a hydrological model according to claim 1, characterized in that, The benchmark model information also includes benchmark model indicators; the step of selecting the target optimization structure of the benchmark hydrological model after calibrating the parameters of each candidate structure based on the training period data and the development period data includes: Based on the training data and a preset parameter calibration algorithm, the parameters of each candidate structure are calibrated to obtain the calibrated candidate structure. The benchmark hydrological models under each of the calibration candidate structures are used to perform hydrological simulations on the development period data to obtain the hydrological simulation results corresponding to each of the calibration candidate structures. Based on the hydrological simulation results, calculate the model evaluation index corresponding to each of the calibration candidate structures. The comprehensive development score of each calibration candidate structure is determined based on the evaluation index of each model and the benchmark model index. The calibration candidate structure that meets the preset selection conditions in the comprehensive score of the development period is selected as the target optimization structure of the benchmark hydrological model.

10. The method for structural optimization of a hydrological model according to claim 1, characterized in that, The method further includes: Extract test period data from the watershed-related data; The baseline hydrological model under the aforementioned target optimization structure is used to perform hydrological simulation on the test period data to obtain the test hydrological simulation results. Based on the test hydrological simulation results, the test period evaluation index corresponding to the target optimized structure is calculated, and a test report is generated.

11. The method for structural optimization of a hydrological model according to claim 1, characterized in that, The method further includes: When watershed migration request data is received, the similarity between the watershed to be migrated and the target watershed is calculated based on the watershed migration request data and the watershed-related data. When the similarity meets the preset similarity conditions, the benchmark hydrological model of the target optimized structure is determined as the first hydrological model of the watershed to be migrated. Based on the watershed migration demand data, the parameters of the first hydrological model are calibrated to obtain the target hydrological model for the watershed to be migrated.

12. The method for structural optimization of a hydrological model according to claim 1, characterized in that, The method further includes: When a parallel optimization instruction is received, the set of target watersheds to be processed in parallel is determined according to the parallel optimization instruction; The candidate structure generation and parameter calibration processes for each undetermined watershed in the target watershed set are processed in parallel to obtain the optimized model structure corresponding to each undetermined watershed.

13. The method for structural optimization of a hydrological model according to claim 12, characterized in that, The method further includes: When any candidate structure generation or parameter calibration process for a pending watershed is abnormal, the pending watershed is marked as an abnormal watershed, and the candidate structure generation and parameter calibration processes for other pending watersheds in the target watershed set continue to be executed. Once the candidate structure generation or parameter calibration process for the anomalous watershed has resumed, the candidate structures and calibration parameters of the anomalous watershed that have passed the checks are reused based on the processing results of other undetermined watersheds until the target optimized structure of the anomalous watershed is determined.

14. A structural optimization device for a hydrological model, characterized in that, include: The data acquisition unit is used to acquire watershed-related data of the target watershed, and extract training period data and development period data from the watershed-related data in chronological order; The model information extraction unit is used to calibrate the parameters of the benchmark hydrological model of the target watershed based on the training period data and the development period data, obtain the benchmark model information, and generate watershed diagnostic feature information. The module description information generation unit is used to construct prompt words based on the baseline model information and the watershed diagnostic feature information, and generate module description information of at least one candidate structure based on the prompt words; The candidate structure generation unit is used to compile the module description information into executable module candidate code, and perform security checks on the module candidate code to obtain the corresponding candidate structure. The target optimization structure selection unit is used to select the target optimization structure of the benchmark hydrological model after calibrating the parameters of each candidate structure based on the training period data and the development period data.

15. An electronic device, characterized in that, The system includes a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor causes the processor to perform the steps of the structural optimization method for the hydrological model as described in any one of claims 1-13.

16. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed, it implements the structural optimization method for the hydrological model as described in any one of claims 1-13.