Method, device and equipment for constructing power system model based on large language model
By constructing a power system model based on a large language model, the problem of poor model integration performance in existing technologies is solved, and higher completeness, accuracy and robustness are achieved, making it suitable for dynamic modeling of complex power systems.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- PEKING UNIV
- Filing Date
- 2025-12-30
- Publication Date
- 2026-06-02
Smart Images

Figure CN122132665A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of model building technology, and in particular to a method, apparatus, and equipment for building a power system model based on a large language model. Background Technology
[0002] With the increasing scale and complexity of power systems, establishing high-fidelity dynamic models is of great significance for power system security assessment and control. Currently, model validation compares simulated responses with synchronous phasor measurement unit (PMU) data under fault disturbances to identify discrepancies between the model and actual operation, allowing for model correction. For example, parameter identification and structural identification can be used to correct the model. However, parameter identification can only adjust parameters within a fixed model structure and cannot address structural errors caused by missing equations or variables. While structural identification attempts to directly reconstruct the differential-algebraic equation model and its parameters from the data, its symbol search space is enormous and it relies on pre-defined variable sets and function libraries, making it difficult to obtain a complete model for complex systems.
[0003] While symbolic regression methods, such as Sparse Identification of Nonlinear Dynamics (SINDy), narrow the search range by utilizing sparsity constraints, they still have many shortcomings. For example, they heavily rely on manually pre-defined function libraries, cannot automatically adapt to complex nonlinear mechanisms, and improper prior selection can lead to model bias or even unidentifiable results. The variable set needs to be manually specified in advance, lacking systematic identification of potential algebraic and input variables, resulting in incomplete modeling results. When both variables and functions are uncertain, the symbolic search space grows exponentially, leading to enormous computational costs and difficulty in achieving effective convergence in large-scale systems. Therefore, most existing methods only model the differential equation portion, lacking systematic identification of algebraic constraints, resulting in incomplete models that limit their application in system-level simulation and analysis. Consequently, the overall performance of current dynamic modeling methods for power systems is poor. Summary of the Invention
[0004] This invention provides a method, apparatus, and device for constructing a power system model based on a large language model, which solves the problem of poor overall performance of models obtained by dynamic modeling of power systems in the prior art, and realizes the construction of a model with better overall performance for power systems.
[0005] This invention provides a method for constructing a power system model based on a large language model, comprising the following steps.
[0006] Based on the operating data of the power system under disturbance conditions, construct the prompt information corresponding to the differential equation. The operating data includes at least one of the following: state variables, algebraic variables, and input variables. The prompt information includes at least one of the following: task contract, reference function, and function template. Multiple candidate models for differential equations are constructed based on the prompt information; Multiple candidate models of differential equations are iteratively trained, and the comprehensive evaluation parameters of each candidate model of differential equations are determined. If at least one of the candidate differential equation models satisfies the convergence condition, the target differential equation candidate model with the optimal comprehensive evaluation parameters is determined from at least one candidate differential equation model. Based on the target algebraic variables and target input variables corresponding to the candidate models of the target differential equation, multiple candidate models of algebraic equations are constructed. Multiple candidate algebraic equation models are iteratively trained to determine the target algebraic equation candidate model with the optimal comprehensive evaluation parameters from among the multiple candidate models; A power system model is constructed based on candidate models of objective differential equations and candidate models of objective algebraic equations.
[0007] According to the present invention, a method for constructing a power system model based on a large language model is provided, which constructs prompt information corresponding to the differential equations based on the operating data of the power system under disturbance conditions, including: Differentiate the state variables to obtain the state derivative data; Construct a sample set based on state variables, state derivative data, algebraic variables, and input variables; Based on the sample set, construct the task contract corresponding to the differential equation; A reference function is obtained from the experience pool, and a function template is determined based on the reference function. The experience pool stores a preset reference function and / or a candidate model obtained through iterative training. The task contract, reference function, and function template are defined as the prompt information corresponding to the differential equation.
[0008] According to the present invention, a method for constructing a power system model based on a large language model is provided, the method further includes: An experience pool is constructed, which includes multiple model storage areas. Each model storage area is used to store a preset reference function or a candidate model obtained through iterative training. Retrieve reference functions from the experience pool, including: Select the target model storage region from the multiple model storage regions included in the experience pool; If a preset reference function is stored in the target model storage area, the preset reference function is determined as the reference function. If candidate models obtained through iterative training are stored in the target model storage area, at least one candidate model is selected from the candidate models obtained through iterative training to be determined as the reference function.
[0009] According to the present invention, a method for constructing a power system model based on a large language model is provided, which iteratively trains multiple candidate differential equation models and determines the comprehensive evaluation parameters of each candidate differential equation model, including: Multiple candidate models for differential equations are screened for effectiveness, and a set of effective candidate models is constructed based on the screened candidate models. The effectiveness screening includes at least one of the following: syntax compilation check, dimensional consistency check, numerical stability check, anomaly handling check, and physical rationality check. Each differential equation candidate model included in the effective candidate model set is iteratively trained, and the comprehensive evaluation parameters of each differential equation candidate model in the effective candidate model set are determined.
[0010] According to a method for constructing a power system model based on a large language model provided by the present invention, the comprehensive evaluation parameters for each differential equation candidate model in the effective candidate model set are determined, including: Determine the optimal model parameters for each differential equation candidate model in the set of valid candidate models; Based on the optimal model parameters of each candidate differential equation model, an evaluation index is determined for each candidate differential equation model. The evaluation index includes at least one of the following: root mean square error, mean absolute percentage error, structural complexity, and average inference time. Based on the evaluation index of each candidate model of differential equation, the comprehensive evaluation parameters of each candidate model of differential equation are determined.
[0011] According to the present invention, a method for constructing a power system model based on a large language model is provided, the method further includes: During the iterative training of multiple candidate models of differential equations, if in any round of iterative training it is determined that the comprehensive evaluation parameter of the candidate model of differential equation is less than the preset evaluation parameter, and the gain of the comprehensive evaluation parameter is less than the preset gain, then the running data is expanded to obtain an expanded sample set. The gain of the comprehensive evaluation parameter is the difference between the comprehensive evaluation parameters of the candidate models of differential equations determined in two adjacent rounds of iterative training. Based on the expanded sample set, the task contract corresponding to the differential equation is reconstructed; Based on the hints, including the reconstructed task contract, multiple candidate models of differential equations are reconstructed; Iterative training is performed on multiple reconstructed candidate models of differential equations.
[0012] According to the present invention, a method for constructing a power system model based on a large language model is provided, which iteratively trains multiple candidate algebraic equation models and determines the target candidate algebraic equation model with optimal comprehensive evaluation parameters from the multiple candidate algebraic equation models, including: Iterative training is performed on multiple candidate models of algebraic equations, and the comprehensive evaluation parameters of each candidate model of algebraic equations are determined. If at least one of the multiple candidate algebraic equation models satisfies the convergence condition, the target candidate algebraic equation model with the optimal comprehensive evaluation parameters is determined from at least one candidate algebraic equation model.
[0013] The present invention also provides an apparatus for constructing a power system model based on a large language model, comprising the following modules: a processing module and a training module; The processing module is used to construct prompt information corresponding to the differential equation based on the operating data of the power system under disturbance conditions. The operating data includes at least one of the following: state variables, algebraic variables, and input variables. The prompt information includes at least one of the following: task contract, reference function, and function template. The processing module is also used to construct multiple candidate models of differential equations based on the prompt information; The training module is used to iteratively train multiple candidate models of differential equations and determine the comprehensive evaluation parameters of each candidate model of differential equations. The processing module is also used to determine the target differential equation candidate model with the optimal comprehensive evaluation parameters from at least one differential equation candidate model when at least one differential equation candidate model among multiple differential equation candidate models satisfies the convergence condition. The processing module is also used to construct multiple algebraic equation candidate models based on the target algebraic variables and target input variables corresponding to the target differential equation candidate models; The training module is also used to iteratively train multiple candidate algebraic equation models and determine the target candidate algebraic equation model with the optimal comprehensive evaluation parameters from multiple candidate algebraic equation models. The processing module is also used to construct power system models based on candidate models of objective differential equations and candidate models of objective algebraic equations.
[0014] According to the present invention, an apparatus for constructing a power system model based on a large language model, comprising a processing module, specifically used for: Differentiate the state variables to obtain the state derivative data; Construct a sample set based on state variables, state derivative data, algebraic variables, and input variables; Based on the sample set, construct the task contract corresponding to the differential equation; A reference function is obtained from the experience pool, and a function template is determined based on the reference function. The experience pool stores a preset reference function and / or a candidate model obtained through iterative training. The task contract, reference function, and function template are defined as the prompt information corresponding to the differential equation.
[0015] According to the present invention, an apparatus for constructing a power system model based on a large language model, the processing module is further used for: An experience pool is constructed, which includes multiple model storage areas. Each model storage area is used to store a preset reference function or a candidate model obtained through iterative training. The processing module is specifically used for: Select the target model storage region from the multiple model storage regions included in the experience pool; If a preset reference function is stored in the target model storage area, the preset reference function is determined as the reference function. If candidate models obtained through iterative training are stored in the target model storage area, at least one candidate model is selected from the candidate models obtained through iterative training to be determined as the reference function.
[0016] According to the present invention, an apparatus for constructing a power system model based on a large language model is provided, wherein the training module is specifically used for: Multiple candidate models for differential equations are screened for effectiveness, and a set of effective candidate models is constructed based on the screened candidate models. The effectiveness screening includes at least one of the following: syntax compilation check, dimensional consistency check, numerical stability check, anomaly handling check, and physical rationality check. Each differential equation candidate model included in the effective candidate model set is iteratively trained, and the comprehensive evaluation parameters of each differential equation candidate model in the effective candidate model set are determined.
[0017] According to the present invention, an apparatus for constructing a power system model based on a large language model is provided, wherein the training module is specifically used for: Determine the optimal model parameters for each differential equation candidate model in the set of valid candidate models; Based on the optimal model parameters of each candidate differential equation model, an evaluation index is determined for each candidate differential equation model. The evaluation index includes at least one of the following: root mean square error, mean absolute percentage error, structural complexity, and average inference time. Based on the evaluation index of each candidate model of differential equation, the comprehensive evaluation parameters of each candidate model of differential equation are determined.
[0018] According to the present invention, an apparatus for constructing a power system model based on a large language model, the training module is further used for: During the iterative training of multiple candidate models of differential equations, if in any round of iterative training it is determined that the comprehensive evaluation parameter of the candidate model of differential equation is less than the preset evaluation parameter, and the gain of the comprehensive evaluation parameter is less than the preset gain, then the running data is expanded to obtain an expanded sample set. The gain of the comprehensive evaluation parameter is the difference between the comprehensive evaluation parameters of the candidate models of differential equations determined in two adjacent rounds of iterative training. Based on the expanded sample set, the task contract corresponding to the differential equation is reconstructed; Based on the hints, including the reconstructed task contract, multiple candidate models of differential equations are reconstructed; Iterative training is performed on multiple reconstructed candidate models of differential equations.
[0019] According to the present invention, an apparatus for constructing a power system model based on a large language model is provided, wherein the training module is specifically used for: Iterative training is performed on multiple candidate models of algebraic equations, and the comprehensive evaluation parameters of each candidate model of algebraic equations are determined. If at least one of the multiple candidate algebraic equation models satisfies the convergence condition, the target candidate algebraic equation model with the optimal comprehensive evaluation parameters is determined from at least one candidate algebraic equation model.
[0020] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method for constructing a power system model based on a large language model as described above.
[0021] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for constructing a power system model based on a large language model as described above.
[0022] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the method for constructing a power system model based on a large language model as described above.
[0023] This invention provides a method, apparatus, and device for constructing a power system model based on a large language model. Using operating data of the power system under disturbance conditions, it first constructs prompt information corresponding to differential equations, and then constructs multiple candidate differential equation models based on this prompt information. The multiple candidate differential equation models are iteratively trained to determine the comprehensive evaluation parameters of each candidate model. Thus, if at least one candidate differential equation model satisfies the convergence condition, the target candidate differential equation model with the optimal comprehensive evaluation parameters can be determined from at least one candidate differential equation model. Further, based on the target algebraic variables and target input variables corresponding to the target candidate differential equation model, multiple candidate algebraic equation models are constructed. These candidate algebraic equation models are iteratively trained to determine the comprehensive evaluation parameters of each candidate algebraic equation model. When the candidate algebraic equation models satisfy the convergence condition, the target candidate algebraic equation model with the optimal comprehensive evaluation parameters is determined from the multiple candidate algebraic equation models. Finally, a power system model can be constructed based on the target candidate differential equation model and the target candidate algebraic equation model. Thus, by comprehensively evaluating parameters and selecting the optimal candidate models for the objective differential equation and objective algebraic equation, the overall performance of the constructed power system model can be improved. Furthermore, it can reduce the overhead of manual prior knowledge and search, enhance the model's completeness, accuracy, and robustness, and possess good scalability and engineering deployability. Attached Figure Description
[0024] To more clearly illustrate the technical solutions in this 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 some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0025] Figure 1 This is one of the flowcharts illustrating the method for constructing a power system model based on a large language model provided by the present invention.
[0026] Figure 2 This is the second flowchart illustrating the method for constructing a power system model based on a large language model provided by this invention.
[0027] Figure 3 This is the third flowchart of the method for constructing a power system model based on a large language model provided by the present invention.
[0028] Figure 4 This is the fourth flowchart of the method for constructing a power system model based on a large language model provided by the present invention.
[0029] Figure 5 This is the fifth flowchart illustrating the method for constructing a power system model based on a large language model provided by this invention.
[0030] Figure 6 This is the sixth flowchart illustrating the method for constructing a power system model based on a large language model provided by this invention.
[0031] Figure 7 This is the seventh flowchart illustrating the method for constructing a power system model based on a large language model provided by this invention.
[0032] Figure 8 This is a schematic diagram of the device for constructing a power system model based on a large language model provided by the present invention.
[0033] Figure 9 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0034] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0035] The following is combined with Figures 1-9 This invention describes the method, apparatus, and equipment for constructing power system models based on large language models.
[0036] The purpose of this application is to address the problems of existing power system dynamic model identification, such as strong dependence on fixed structures and function bases, difficulty in systematically discovering algebraic constraints, and excessively large symbolic search space, by proposing a power system dynamic modeling method based on a large language model.
[0037] The “large language model” here refers to a general sequence model with domain prior representation and program generation capabilities. Given a task contract and a small number of example functions (reference functions), it can automatically generate an executable candidate model skeleton and improve and converge the candidate model skeleton through an iterative process (i.e., generation-evaluation-feedback).
[0038] Furthermore, "dynamic modeling of power systems" refers to the joint identification and parameter estimation of differential-algebraic equations describing system behavior under the drive of disturbance data (i.e., the power system is under disturbance conditions). In other words, under the constraints of state variables, algebraic variables and input variables, the continuous-time dynamic equations and corresponding algebraic constraints are recovered to form a consistent dynamic model to support system-level simulation, evaluation and control applications.
[0039] Figure 1 This is one of the flowcharts illustrating the method for constructing a power system model based on a large language model provided by the present invention, such as... Figure 1 As shown, the method includes the following: Step 101: Based on the operating data of the power system under disturbance conditions, construct the prompt information corresponding to the differential equation.
[0040] The runtime data includes at least one of the following: state variables, algebraic variables, and input variables; the prompt information includes at least one of the following: task contract, reference function, and function template.
[0041] Step 102: Construct multiple candidate models of differential equations based on the prompt information.
[0042] Step 103: Iteratively train multiple candidate models of differential equations and determine the comprehensive evaluation parameters of each candidate model of differential equations.
[0043] Step 104: If at least one of the candidate differential equation models satisfies the convergence condition, determine the target differential equation candidate model with the optimal comprehensive evaluation parameters from at least one candidate differential equation model.
[0044] Step 105: Based on the target algebraic variables and target input variables corresponding to the candidate models of the target differential equation, construct multiple candidate models of algebraic equations.
[0045] Step 106: Iteratively train multiple candidate algebraic equation models to determine the target candidate algebraic equation model with the optimal comprehensive evaluation parameters from among the multiple candidate models.
[0046] Step 107: Construct a power system model based on the candidate models of the objective differential equation and the objective algebraic equation.
[0047] In one possible implementation, the operating data of the power system under disturbance conditions can be acquired through a synchronous phasor measurement unit (PMU), a supervisory control and data acquisition (SCADA) system, or a power system simulation platform. This allows for the acquisition of time-series data containing state variables, observational data containing algebraic variables, and available input variable data.
[0048] It should be noted that disturbance conditions refer to states in the power system such as grid faults, load switching, and line adjustments.
[0049] In one possible implementation, the operating data of the power system is used to characterize the dynamic behavior of the power system, as shown in Equation 1, which can be uniformly expressed as a system of differential algebraic equations.
[0050] Formula 1 in, , representing the state variables of the power system, mainly including the internal state variables of control links such as generator power angle, angular velocity deviation, excitation system (i.e., excitation current) and speed governor (i.e., rotor speed); , representing algebraic variables, mainly including instantaneous balance quantities such as voltage magnitude and phase angle of each node in the network, and branch power flow distribution; , represents the input variables, including system load, reference setpoints (such as generator setpoints, operating voltage, and output active power), and other external drive signals; p represents the model parameter vector to be identified, including physical parameters such as generator inertia constant, damping coefficient, excitation and speed control system gain, etc. Differential equations This describes the time evolution of various dynamic components in a power system, typically including the swing equation of a synchronous generator, the voltage regulation dynamics of an excitation system, and the frequency regulation dynamics of a speed governor. Algebraic equations These represent the instantaneous balance constraints that the power network must satisfy at every moment. They mainly include the active and reactive power balance equations of each node, Kirchhoff's laws constraints on branch power flow distribution, and consistency constraints on the exchange of electromagnetic power between generators and network power. By jointly identifying the functional forms and parameters of these two types of equations, a complete mathematical model describing the dynamic characteristics of the power system (i.e., the power system model) can be established.
[0051] Thus, after obtaining the operating data of the power system under disturbance conditions, it is possible to construct the corresponding prompt information of the differential equation, construct multiple candidate models of differential equations, and perform iterative training based on the operating data of the power system under disturbance conditions, thereby finally constructing the power system model.
[0052] It should be noted that the specific description of the above steps can be found in the following content, and will not be repeated here.
[0053] In this embodiment, using operating data of the power system under disturbance conditions, prompt information corresponding to the differential equations is first constructed. Then, multiple candidate models of differential equations are constructed based on the prompt information. The multiple candidate models are iteratively trained to determine the comprehensive evaluation parameters of each candidate model. Thus, if at least one candidate model among the multiple candidate models satisfies the convergence condition, the target candidate model with the optimal comprehensive evaluation parameters can be determined from at least one candidate model. Further, based on the target algebraic variables and target input variables corresponding to the target candidate model, multiple candidate algebraic equations are constructed. These candidate models are iteratively trained to determine the comprehensive evaluation parameters of each candidate model. When the candidate algebraic equations satisfy the convergence condition, the target candidate algebraic equation with the optimal comprehensive evaluation parameters is determined from the multiple candidate algebraic equations. Finally, based on the target candidate model of differential equations and the target candidate algebraic equations, a power system model can be constructed. Thus, by comprehensively evaluating parameters and selecting the optimal candidate models for the objective differential equation and objective algebraic equation, the overall performance of the constructed power system model can be improved. Furthermore, it can reduce the overhead of manual prior knowledge and search, enhance the model's completeness, accuracy, and robustness, and possess good scalability and engineering deployability.
[0054] Figure 2 This is the second flowchart illustrating the method for constructing a power system model based on a large language model provided by this invention. Figure 2 As shown, "Step 101, constructing the prompt information corresponding to the differential equation based on the operating data of the power system under disturbance conditions" specifically includes the following: Step 201: Differentiate the state variables to obtain the state derivative data.
[0055] Step 202: Construct a sample set based on state variables, state derivative data, algebraic variables, and input variables.
[0056] Step 203: Based on the sample set, construct the task contract corresponding to the differential equation.
[0057] Step 204: Obtain reference functions from the experience pool and determine function templates based on the reference functions.
[0058] The experience pool stores a preset reference function and / or candidate models obtained through iterative training.
[0059] Step 205: Determine the task contract, reference function, and function template as the prompt information corresponding to the differential equation.
[0060] In one possible implementation, after obtaining the running data including state variables (i.e., state variable time series data), algebraic variables, and input variables, numerical differentiation can be performed on the state variable time series data to construct state derivative data.
[0061] Furthermore, based on state variables, state derivative data, algebraic variables, and input variables, a sample set is constructed, and according to the fault point settings, the sample set is divided into a training fault set and a verification fault set.
[0062] Specifically, the sampling interval of the observation sequence can be set as follows: Discrete time points are The corresponding state observation is denoted as To obtain high-precision state derivative estimates, a fourth-order precision finite difference scheme is used to numerically differentiate the state sequence. For points within the sequence... Its derivative approximate value is calculated using the central difference formula, as shown in Formula 2.
[0063] Formula 2 For the endpoints of the sequence, forward or backward difference schemes can be used to maintain fourth-order precision. Left endpoint ( The derivative of is calculated using forward difference, as shown in Formula 3.
[0064] Formula 3 And the right endpoint ( The derivative of is calculated using backward difference, as shown in Formula 4.
[0065] Formula 4 Therefore, after completing the numerical differentiation process, a structure containing state variables is constructed. State derivative data Algebraic variables and input variables sample set .
[0066] Furthermore, to evaluate the generalization ability of the established model under different disturbance conditions, a dataset partitioning strategy based on fault location was adopted, dividing all fault locations according to a preset ratio. (Usually taken as 0.7-0.8) Randomly divided into training fault sets and verification fault set And make and .
[0067] Accordingly, training fault set Includes all disturbance response data from training fault locations (i.e., power system operating data under disturbance conditions), validating the fault set. It includes all disturbance response data from verified fault locations. This fault location-based approach effectively assesses the predictive accuracy and robustness of the identified model at unknown disturbance locations, better reflecting the application scenarios of unknown disturbances encountered in actual power system operation.
[0068] In one possible implementation, it is also necessary to construct structured prompts for differential equation recognition and call a modeling agent based on a large language model to generate an executable set of candidate differential equation models (i.e., multiple candidate differential equation models).
[0069] This is because large language models utilize large-scale pre-trained language models with powerful code generation and mathematical modeling capabilities, such as general-purpose language models based on a decoder-based Transformer architecture with hundreds of billions of parameters, which can support automatic code generation for scientific computing languages like Python. Modeling agents can be built based on large language models (e.g., deepseek-v3) and possess the ability to understand knowledge in the power system domain and generate executable mathematical models.
[0070] Specifically, the prompts for the differential equations It consists of three core components: task contract, reference function, and function template.
[0071] Among them, the Modeling Task Contract clearly defines the role of the modeling agent as a differential equation function generator, and specifies the input data format, including state variables. Given algebraic variables and input variables and parameter placeholders The output must meet the requirements. A Python function in the form of a variable expansion function. Furthermore, when the existing sample set is insufficient to build an effective model, the modeling agent needs to output the name, physical meaning, and dimensional information of the newly added variable in JSON format, triggering the variable expansion mechanism.
[0072] Reference functions, which can be understood as a small number of example functions (Few-shot Examples), provide multiple Python implementation examples of power system differential equations generated from feedback loops, covering classic models such as synchronous generator swing equations and excitation system dynamic equations, demonstrating standard programming paradigms and function interface specifications for tensor operations.
[0073] The Target Function Placeholder sets the function template to be filled below the reference function, explicitly requiring that the generated candidate functions (i.e., candidate models) must follow the same input / output interfaces and tensor operation formats.
[0074] Thus, based on the constructed prompt information The modeling agent controls temperature parameters Adjusting the diversity of generation and sampling to generate a set of candidate model skeletons ,in This represents the number of candidate models generated in a single round. Different temperature parameter settings can strike a balance between candidate quality and diversity; lower temperature parameters tend to generate conservative but reliable candidate models, while higher temperature parameters encourage the exploration of more innovative model structures.
[0075] For example, a task contract can look like this: ① Role and Task: You are a power system modeling expert. Please try to complete the following objective {differential or algebraic} equations.
[0076] ② Input dataset: State variable x, shape: [Ns, Nx], column names: …; Included variable library Shape: [Ns, Nv], Column names: …; Parameter placeholder p, Shape: [Np].
[0077] ③ Variable expansion mechanism: If you have determined the algebraic variables / input variables that need to be expanded, please specify the variable requirements in JSON format, as shown below: {"new_y": [{"name": "Pm", "physics": "mechanical power", "unit": "pu"},{"name": "Vfd", "physics": "field voltage", "unit": "pu"}]}.
[0078] In this embodiment, state derivative data is obtained by differentiating the state variables. A sample set is then constructed based on the state variables, state derivative data, algebraic variables, and input variables. Based on this sample set, a task contract corresponding to the differential equation can be constructed. A reference function is obtained from an experience pool, and a function template is determined based on the reference function. Finally, the task contract, reference function, and function template are used to determine the prompt information corresponding to the differential equation. Based on this, the prompt information corresponding to the differential equation can be accurately constructed based on the operating data of the power system under disturbance conditions.
[0079] Figure 3 This is the third flowchart illustrating the method for constructing a power system model based on a large language model provided by this invention. Figure 3 As shown, "Step 204, obtaining reference functions from the experience pool and determining function templates based on reference functions" specifically includes the following: Step 301: Construct an experience pool.
[0080] The experience pool includes multiple model storage areas, each of which stores a preset reference function or a candidate model obtained through iterative training.
[0081] Step 302: Select the target model storage region from the multiple model storage regions included in the experience pool.
[0082] Step 303: If a preset reference function is stored in the target model storage area, the preset reference function is determined as the reference function.
[0083] Step 304: If candidate models obtained through iterative training are stored in the target model storage area, select at least one candidate model from the candidate models obtained through iterative training to determine as a reference function, and determine the function template based on the reference function.
[0084] In one possible implementation, a hierarchical island-based experience pool management mechanism (i.e., building an experience pool) is established to enable the dynamic storage, organization, and utilization of candidate models.
[0085] It should be noted that the layered island-style experience pool adopts a model storage area partitioning strategy based on template source (that is, dividing the experience pool into multiple experience islands). This achieves the ordered organization of candidate models. Each candidate model is directly assigned to the corresponding model storage area (i.e., experience island) based on the source of the objective function template (i.e., reference function) used during its generation. In other words, candidate models with the same example template belong to the same model storage area, ensuring that candidate models with similar generation backgrounds are grouped together.
[0086] Furthermore, each experience island is further hierarchically divided based on the comprehensive evaluation parameters of the candidate models, and a scoring threshold is set. Candidate models within the experience island are divided into L hierarchical clusters. Candidate models with high comprehensive evaluation parameters are located in the upper cluster, while candidate models with low comprehensive evaluation parameters are located in the lower cluster, forming a quality gradient distribution within the empirical island.
[0087] In one possible implementation, the reference function selection mechanism employs a strategy combining equilibrium selection among empirical islands with optimal selection within empirical islands. First, it uses uniform probability... Selecting experience islands (i.e., selecting the target model storage area from multiple model storage areas included in the experience pool) ensures that examples from different template sources have a chance to be selected, maintaining the diversity of the generation process.
[0088] Furthermore, when determining the reference function from the target model storage area, it can be based on the average score of each hierarchical cluster within the selected empirical island. (i.e., the average value of the comprehensive evaluation parameters of the candidate models included in the hierarchical cluster) The hierarchical cluster is selected using a soft maximization distribution, and the probability of each hierarchical cluster being selected is shown in Formula 5.
[0089] Formula 5 in, This represents the temperature parameter.
[0090] In one possible implementation, when selecting hierarchical clusters, a bias may be placed towards selecting hierarchical clusters with higher scores.
[0091] Then, when determining the reference function from within the hierarchical cluster, the comprehensive evaluation parameters of each candidate model and the structural simplicity of each candidate model can be considered for selection. The probability of each candidate model being selected is shown in Formula 6.
[0092] Formula Six in, This represents the comprehensive evaluation parameters for each candidate model. This represents the length of each candidate model h. This represents the temperature parameter. The probability that a candidate model h is selected as the reference function is greater than or equal to the probability that the candidate model h is shorter and the candidate model has higher comprehensive evaluation parameters.
[0093] Thus, this application, through this hierarchical selection mechanism, not only ensures the balance of different reference function sources, but also prioritizes the selection of high-quality candidate models as reference models in each model storage area, thereby effectively guiding the model generation in subsequent rounds.
[0094] Figure 4 This is the fourth flowchart illustrating the method for constructing a power system model based on a large language model provided by this invention. Figure 4 As shown, "Step 103, iteratively training multiple candidate models of differential equations and determining the comprehensive evaluation parameters of each candidate model of differential equations" specifically includes the following: Step 401: Screen the effectiveness of multiple differential equation candidate models, and construct a set of effective candidate models based on the screened differential equation candidate models.
[0095] The validity screening includes at least one of the following: syntax compilation check, dimensional consistency check, numerical stability check, anomaly handling check, and physical rationality check.
[0096] Step 402: Iteratively train each differential equation candidate model included in the effective candidate model set, and determine the comprehensive evaluation parameters of each differential equation candidate model in the effective candidate model set.
[0097] In one possible implementation, multiple candidate models of differential equations can be subjected to multi-level compilation checks and validity screening to eliminate candidates with syntax errors and runtime exceptions, forming a valid candidate set that can be used for subsequent parameter estimation.
[0098] Specifically, compilation checking and validity screening can include three progressive levels of validation. First, a syntax compilation check is performed, filtering each candidate model... The Python interpreter performs syntax parsing to check for basic issues such as syntax errors, indentation errors, and variable name conflicts. Then, candidate models that pass the syntax check undergo a runtime verification phase. This phase uses constructed standard test input data (containing state variables, algebraic variables, and random parameter vectors) to filter candidate models. This verifies whether the candidate models can run correctly and return output results in the expected dimensions. The runtime verification phase specifically includes three aspects: dimensionality consistency checks, numerical stability checks, and anomaly handling checks. The dimensionality consistency check requires that the output dimension of the candidate model matches the dimension of the state variables, i.e., the output... Numerical stability checks require that candidate models do not produce abnormal results such as infinity or non-numerical values within a reasonable input range. Anomaly handling checks ensure that candidate models do not throw uncaught runtime anomalies under boundary conditions. Finally, physical rationality checks are performed to verify whether candidate models violate basic physical laws and engineering common sense. For example, checking for expressions that violate fundamental constraints such as energy conservation and power balance, and eliminating candidate models that clearly do not conform to the physical characteristics of power systems.
[0099] In one possible implementation, a comprehensive validity discriminant function can be defined. The validity discriminant function is valid if and only if the candidate model passes all validation levels. The value of ) is 1 otherwise 0. Finally, as shown in Formula 7, the selected differential equation candidate models are used to construct a set of effective candidate models. This lays a reliable foundation for subsequent parameter estimation and model evaluation.
[0100] Formula 7 In this embodiment, multiple candidate models for differential equations are screened for effectiveness, and a set of effective candidate models is constructed based on the screened candidate models. Therefore, during subsequent iterative training, only these effective candidate models can be trained, while ineffective candidate models are discarded. This reduces the amount of model training, improves model training efficiency, and avoids unnecessary iterative training on ineffective candidate models.
[0101] Figure 5 This is the fifth flowchart illustrating the method for constructing a power system model based on a large language model provided by this invention. Figure 5 As shown, the method includes the following: Step 501: Screen the effectiveness of multiple differential equation candidate models, and construct a set of effective candidate models based on the screened differential equation candidate models.
[0102] Step 502: Iteratively train each differential equation candidate model included in the effective candidate model set to determine the optimal model parameters for each differential equation candidate model in the effective candidate model set.
[0103] Step 503: Based on the optimal model parameters of each candidate differential equation model, determine the evaluation index for each candidate differential equation model.
[0104] The evaluation metrics include at least one of the following: root mean square error, mean absolute percentage error, structural complexity, and average inference time.
[0105] Step 504: Based on the evaluation index of each candidate model of differential equation, determine the comprehensive evaluation parameters of each candidate model of differential equation.
[0106] In the embodiments of this application, the above parameter estimation can be understood as: determining the optimal model parameters for each differential equation candidate model in the set of effective candidate models.
[0107] In one possible implementation, parameter estimation and comprehensive performance evaluation can be performed on each differential equation candidate model that passes the validity screening, thereby establishing a scoring system based on multi-index fusion.
[0108] Specifically, parameter estimation and model evaluation employ a staged optimization strategy. When performing parameter estimation and determining the optimal model parameters for each differential equation candidate model in the effective candidate model set, for each effective differential equation candidate model... First, in the training fault set The above describes a parameter optimization problem. A training loss function is defined. As shown in Formula 8.
[0109] Formula 8 Then, the optimal model parameters of the candidate model of the differential equation are solved using the Adam optimization algorithm with adaptive learning rate or the stochastic gradient descent method with momentum, as shown in Equation 9.
[0110] Formula Nine In one possible implementation, to avoid overfitting, an early stopping strategy is used during the optimization process, terminating training when the loss of the verification fault set no longer decreases for several consecutive rounds.
[0111] In one possible implementation, after obtaining the optimal model parameters of the candidate model for the differential equation, the verification fault set can be used. The above calculations include multiple evaluation indicators. The root mean square error (RMSE) is shown in Formula 10, and the mean absolute percentage error (MAPE) is shown in Formula 11.
[0112] Formula 10 Formula Eleven Furthermore, based on the evaluation index, taking the root mean square error as an example, as shown in Formula XII, a comprehensive scoring function can be constructed to determine the comprehensive evaluation parameters of each candidate model for the differential equation. .
[0113] Formula 12 in This indicates the structural complexity (such as the number of parameters, expression length, etc.) of a candidate model (e.g., a candidate model for differential equations or a candidate model for algebraic equations). This represents the average inference time of the candidate model. , , These are the weighting coefficients. This is the scaling parameter. Ultimately, each candidate model obtains a comprehensive evaluation parameter. The higher the comprehensive evaluation parameter, the better the overall performance of the candidate model.
[0114] Thus, this application determines the optimal model parameters for each differential equation candidate model in the effective candidate model set, and based on the optimal model parameters of each differential equation candidate model, determines the evaluation index for each differential equation candidate model. Therefore, based on the evaluation index of each differential equation candidate model, the comprehensive evaluation parameters for each differential equation candidate model are determined. In this way, by characterizing the comprehensive performance of the candidate models through comprehensive evaluation parameters, the candidate model with the best comprehensive performance can be accurately determined.
[0115] Figure 6 This is the sixth flowchart illustrating the method for constructing a power system model based on a large language model provided by this invention. Figure 6 As shown, the method includes the following: Step 601: During the iterative training of multiple candidate models of differential equations, if in any round of iterative training it is determined that the comprehensive evaluation parameter of the candidate model of the differential equation is less than the preset evaluation parameter, and the gain of the comprehensive evaluation parameter is less than the preset gain, then the running data is expanded to obtain an expanded sample set.
[0116] The gain of the comprehensive evaluation parameter is the difference between the comprehensive evaluation parameters of the candidate differential equation models determined by two adjacent rounds of iterative training.
[0117] Step 602: Based on the expanded sample set, reconstruct the task contract corresponding to the differential equation.
[0118] Step 603: Based on the prompts including the reconstructed task contract, reconstruct multiple candidate models of differential equations.
[0119] Step 604: Iteratively train the reconstructed candidate models of multiple differential equations.
[0120] In one possible implementation, an adaptive variable expansion mechanism based on iterative stall detection can be established, which automatically introduces new candidate variables to break through the modeling bottleneck when the model optimization gets stuck in a local optimum.
[0121] Specifically, the variable expansion mechanism can use a dual convergence criterion to ensure the reliability of the triggering conditions. That is, if the comprehensive evaluation parameter of the candidate model of the differential equation is less than the preset evaluation parameter, and the gain of the comprehensive evaluation parameter is less than the preset gain, then the running data is expanded to obtain an expanded sample set.
[0122] For example, suppose the globally optimal score (i.e., the comprehensive evaluation parameter of the candidate model of the differential equation) in the t-th iteration is: And define the score gain sequence for consecutive R iterations as Then, when the convergence stagnation condition is met... (That is, the gain of the comprehensive evaluation parameters is less than the preset gain), and the current optimal score is still lower than the expected threshold. When the comprehensive evaluation parameters of the candidate model for the differential equation are less than the preset evaluation parameters, the optimization process is deemed to have stalled and the model accuracy has not met the standard, at which point the variable expansion mechanism is triggered. and It is a small positive integer, and .
[0123] In one possible implementation, the variable requirements in the extended runtime data can be extracted by considering the ranking of the top K high-quality candidate models from the comprehensive evaluation parameters. These high-quality candidate models output variable extension requirements in a predefined JSON format during the generation process. Specifically, this includes the fields "variable_name" (variable symbol), "physical_meaning" (physical meaning), "unit" (unit of measurement), "variable_type" (variable type, such as "algebraic" or "input"), and "expected_role" (expected role description). The system parses this structured information, filters candidate variables that appear frequently and have clear physical meaning, forming a set of samples to be extended. .
[0124] Furthermore, updating the variable library (i.e., the sample set) involves two steps: expanding the sample set and reconstructing the prompt information. First, the sample set to be expanded is added to the sample set. Then, it assigns appropriate data placeholders and initialization strategies to the sample set to be expanded. Then it updates the prompt information. In the task contract section, variable declarations were modified to include the expanded sample set, and typical function examples involving the new variables were added to the Few-shot examples. The refactored prompts guide the modeling agent to generate more complex candidate models that include the new variables, effectively expanding the search space for modeling.
[0125] Therefore, if the convergence condition is not met during model iteration, the sample set can be expanded by extending the running data. Then, based on the expanded sample set, the task contract corresponding to the differential equation is reconstructed. This results in the reconstruction of multiple candidate models for the differential equation, which are then iteratively trained. In this way, by expanding the data during model iteration, the model can achieve sufficient convergence, thereby obtaining the optimal candidate model.
[0126] Figure 7 This is the seventh flowchart illustrating the method for constructing a power system model based on a large language model provided by this invention. Figure 7As shown, "Step 106, iteratively training multiple candidate algebraic equation models to determine the target algebraic equation candidate model with the optimal comprehensive evaluation parameters from multiple candidate algebraic equation models," specifically includes the following: Step 701: Iteratively train multiple candidate algebraic equation models and determine the comprehensive evaluation parameters for each candidate algebraic equation model.
[0127] Step 702: If at least one of the multiple candidate algebraic equation models satisfies the convergence condition, determine the target candidate algebraic equation model with the optimal comprehensive evaluation parameters from at least one candidate algebraic equation model.
[0128] In one possible implementation, once the differential equation identification process (i.e., iterative training of the candidate differential equation model) reaches the convergence condition, the set of algebraic variables and the configuration of input variables determined in this stage can be fixed, and then the algebraic equation identification stage (i.e., iterative training of the candidate algebraic equation model) can be started to construct a complete differential-algebraic equation system model.
[0129] In one possible implementation, the algebraic equation identification stage redirects the task based on the results of differential equation identification. The fixed set of variables includes all algebraic variables discovered during the differential equation identification process through a variable expansion mechanism. and input variables These variables constitute the complete input space for modeling algebraic equations. The target of the algebraic equations is the derivative of the predicted state. The process transforms into establishing constraints between algebraic variables, i.e., finding a function g(⋅) that satisfies the form 0=g(x,y,u,p).
[0130] Furthermore, the adjustments to the prompts cover the reconstruction of three key components. The task contract section explicitly requires the modeling agent to generate algebraic constraint functions, prohibits the appearance of time derivative terms in the function expressions, and emphasizes that the output must be a zero vector to conform to the mathematical definition of algebraic constraints.
[0131] In the example below, the Few-shot example function has been replaced from the differential equation paradigm to the algebraic constraint paradigm, including typical power system algebraic relationships such as nodal power balance equations, branch power flow constraints, and generator port power consistency constraints. The function template has been modified to return the algebraic constraint residuals, requiring that the output dimension of the candidate function be consistent with the algebraic variable dimension.
[0132] For example, the differential equation case and objective function are shown below: def example(x, v, p): dx1 = p[0]*x[:,1]+p[1]*x[:,0] dx² = p[2]*x[:,0]+p[3]*v[:,0] ... return torch.stack([dx1, dx2, ...]) # Supplement the following system of differential equations def target_DE(x:torch.Tensor,v: torch.Tensor, p:torch.Tensor): For example, the algebraic equation case and objective function are shown below: def example(x, v, p): y1 = p[0]*x[:,1]+p[1]*x[:,0] y2 = p[2]*x[:,0]+p[3]*v[:,0] ... return torch.stack([y1, y2, ...]) # Supplement the following system of algebraic equations def target_AE(x:torch.Tensor,v: torch.Tensor, p:torch.Tensor): In one possible implementation, the parameter estimation and model evaluation strategies are adapted to the characteristics of algebraic equations, and the training loss function is adjusted as shown in Equation 13.
[0133] Formula Thirteen Specifically, the optimization objective is to make the residuals of the algebraic constraints as close to zero as possible across all data points. Because algebraic equations typically exhibit greater nonlinearity and numerical sensitivity, a more conservative learning rate setting and more stringent numerical stability checks are employed during parameter optimization. The scoring system, while maintaining prediction accuracy, also includes a check on the physical rationality of the algebraic constraints to ensure that the identified algebraic relationships conform to the fundamental laws of power systems.
[0134] The experience pool management and variable expansion mechanism also play a crucial role in algebraic equation identification. Candidate models with algebraic constraints are also divided into islands based on their template sources, with each island grouped hierarchically according to its score. When the algebraic equation identification process stalls due to convergence, the variable expansion mechanism can introduce new auxiliary or intermediate variables to help establish a more complete algebraic constraint system. The entire algebraic equation identification process is organically unified with the differential equation identification process, ultimately outputting a DAE model containing the complete differential equation f(⋅) and algebraic equation g(⋅), providing a high-fidelity mathematical foundation for power system dynamic analysis and control design.
[0135] It should be noted that the iterative training process for multiple candidate models of algebraic equations can be referred to the iterative training process for multiple candidate models of differential equations, which will not be elaborated here.
[0136] Thus, in this embodiment, the Dynamic Model Discovery Framework (LLM-DMD) based on a large language model iterates through "candidate model generation—parameter estimation—feedback-driven suggestion optimization," and triggers dynamic variable expansion when scoring stagnates, achieving automatic identification of the complete DAE of a power system. This framework is the first to utilize the prior knowledge and code generation capabilities of a large language model, breaking through the bottleneck of traditional symbolic search. It then generates an executable skeleton through a modeling agent based on task contracts and feedback examples, without needing to pre-define the function base. An adaptive expansion mechanism using JSON-based variable requirement parsing compensates for unmodeled variable dependencies. Finally, a two-stage decoupled identification process—"differential equation (DE)—algebraic equation (AE)"—ensures structured and convergent model reconstruction. This significantly reduces the overhead of manual prior knowledge and search, improves the completeness, accuracy, and robustness of the model, and possesses good scalability and engineering deployability.
[0137] The apparatus for constructing a power system model based on a large language model provided by the present invention will be described below. The apparatus for constructing a power system model based on a large language model described below can be referred to in correspondence with the method for constructing a power system model based on a large language model described above.
[0138] Figure 8 This is a schematic diagram of the device for constructing a power system model based on a large language model provided by the present invention, as shown below. Figure 8 As shown, the device for constructing a power system model based on a large language model includes the following modules: a processing module 801 and a training module 802. Processing module 801 is used to construct prompt information corresponding to differential equations based on the operating data of the power system under disturbance conditions. The operating data includes at least one of the following: state variables, algebraic variables and input variables. The prompt information includes at least one of the following: task contract, reference function and function template. The processing module 801 is also used to construct multiple candidate models of differential equations based on the prompt information; Training module 802 is used to iteratively train multiple candidate models of differential equations and determine the comprehensive evaluation parameters of each candidate model of differential equations among the multiple candidate models of differential equations. The processing module 801 is also used to determine the target differential equation candidate model with the optimal comprehensive evaluation parameters from at least one differential equation candidate model when at least one differential equation candidate model among multiple differential equation candidate models satisfies the convergence condition. The processing module 801 is also used to construct multiple algebraic equation candidate models based on the target algebraic variables and target input variables corresponding to the target differential equation candidate models; Training module 802 is also used to iteratively train multiple candidate algebraic equation models and determine the target candidate algebraic equation model with the optimal comprehensive evaluation parameters from multiple candidate algebraic equation models. The processing module 801 is also used to construct a power system model based on the candidate models of the target differential equation and the candidate models of the target algebraic equation.
[0139] According to the present invention, an apparatus for constructing a power system model based on a large language model is provided, wherein the processing module 801 is specifically used for: Differentiate the state variables to obtain the state derivative data; Construct a sample set based on state variables, state derivative data, algebraic variables, and input variables; Based on the sample set, construct the task contract corresponding to the differential equation; A reference function is obtained from the experience pool, and a function template is determined based on the reference function. The experience pool stores a preset reference function and / or a candidate model obtained through iterative training. The task contract, reference function, and function template are defined as the prompt information corresponding to the differential equation.
[0140] According to the apparatus for constructing a power system model based on a large language model provided by the present invention, the processing module 801 is further used for: An experience pool is constructed, which includes multiple model storage areas. Each model storage area is used to store a preset reference function or a candidate model obtained through iterative training. Processing module 801 is specifically used for: Select the target model storage region from the multiple model storage regions included in the experience pool; If a preset reference function is stored in the target model storage area, the preset reference function is determined as the reference function. If candidate models obtained through iterative training are stored in the target model storage area, at least one candidate model is selected from the candidate models obtained through iterative training to be determined as the reference function.
[0141] According to the present invention, an apparatus for constructing a power system model based on a large language model is provided, wherein the training module 802 is specifically used for: Multiple candidate models for differential equations are screened for effectiveness, and a set of effective candidate models is constructed based on the screened candidate models. The effectiveness screening includes at least one of the following: syntax compilation check, dimensional consistency check, numerical stability check, anomaly handling check, and physical rationality check. Each differential equation candidate model included in the effective candidate model set is iteratively trained, and the comprehensive evaluation parameters of each differential equation candidate model in the effective candidate model set are determined.
[0142] According to the present invention, an apparatus for constructing a power system model based on a large language model is provided, wherein the training module 802 is specifically used for: Determine the optimal model parameters for each differential equation candidate model in the set of valid candidate models; Based on the optimal model parameters of each candidate differential equation model, an evaluation index is determined for each candidate differential equation model. The evaluation index includes at least one of the following: root mean square error, mean absolute percentage error, structural complexity, and average inference time. Based on the evaluation index of each candidate model of differential equation, the comprehensive evaluation parameters of each candidate model of differential equation are determined.
[0143] According to the apparatus for constructing a power system model based on a large language model provided by the present invention, the training module 802 is further used for: During the iterative training of multiple candidate models of differential equations, if in any round of iterative training it is determined that the comprehensive evaluation parameter of the candidate model of differential equation is less than the preset evaluation parameter, and the gain of the comprehensive evaluation parameter is less than the preset gain, then the running data is expanded to obtain an expanded sample set. The gain of the comprehensive evaluation parameter is the difference between the comprehensive evaluation parameters of the candidate models of differential equations determined in two adjacent rounds of iterative training. Based on the expanded sample set, the task contract corresponding to the differential equation is reconstructed; Based on the hints, including the reconstructed task contract, multiple candidate models of differential equations are reconstructed; Iterative training is performed on multiple reconstructed candidate models of differential equations.
[0144] According to the present invention, an apparatus for constructing a power system model based on a large language model is provided, wherein the training module 802 is specifically used for: Iterative training is performed on multiple candidate models of algebraic equations, and the comprehensive evaluation parameters of each candidate model of algebraic equations are determined. If at least one of the multiple candidate algebraic equation models satisfies the convergence condition, the target candidate algebraic equation model with the optimal comprehensive evaluation parameters is determined from at least one candidate algebraic equation model.
[0145] Figure 9 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 9 As shown, the electronic device may include: a processor 910, a communications interface 920, a memory 930, and a communications bus 940, wherein the processor 910, the communications interface 920, and the memory 930 communicate with each other through the communications bus 940. The processor 910 can call logic instructions in the memory 930 to execute a method for constructing a power system model based on a large language model. This method includes: constructing prompt information corresponding to differential equations based on the operating data of the power system under disturbance conditions; the operating data including at least one of the following: state variables, algebraic variables, and input variables; and the prompt information including at least one of the following: task contract, reference function, and function template; constructing multiple candidate models of differential equations based on the prompt information; iteratively training the multiple candidate models of differential equations and determining the comprehensive evaluation parameters of each candidate model; determining the target candidate model of differential equations with the optimal comprehensive evaluation parameters from at least one candidate model of differential equations, provided that at least one candidate model of differential equations satisfies the convergence condition; constructing multiple candidate models of algebraic equations based on the target algebraic variables and target input variables corresponding to the target candidate model of differential equations; iteratively training the multiple candidate models of algebraic equations and determining the target candidate model of algebraic equations with the optimal comprehensive evaluation parameters from the multiple candidate models of algebraic equations; and constructing a power system model based on the target candidate model of differential equations and the target candidate model of algebraic equations.
[0146] Furthermore, the logical instructions in the aforementioned memory 930 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a 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 a computer 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.
[0147] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the method for constructing a power system model based on a large language model provided by the above methods. This method includes: constructing prompt information corresponding to differential equations based on the operating data of the power system under disturbance conditions. The operating data includes at least one of the following: state variables, algebraic variables, and input variables. The prompt information includes at least one of the following: task contract, reference function, and function template; constructing multiple candidate models of differential equations based on the prompt information; and performing processing on the multiple candidate models of differential equations. Iterative training is performed to determine the comprehensive evaluation parameters of each candidate differential equation model among multiple candidate differential equation models. If at least one candidate differential equation model among the multiple candidate models satisfies the convergence condition, the target candidate differential equation model with the optimal comprehensive evaluation parameters is determined from at least one candidate differential equation model. Based on the target algebraic variables and target input variables corresponding to the target candidate differential equation model, multiple candidate algebraic equation models are constructed. Iterative training is performed on the multiple candidate algebraic equation models to determine the target candidate algebraic equation model with the optimal comprehensive evaluation parameters from among the multiple candidate algebraic equation models. Based on the target candidate differential equation model and the target candidate algebraic equation model, a power system model is constructed.
[0148] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the method for constructing a power system model based on a large language model provided by the methods described above. This method includes: constructing prompt information corresponding to differential equations based on operating data of the power system under disturbance conditions; the operating data including at least one of the following: state variables, algebraic variables, and input variables; and the prompt information including at least one of the following: task contract, reference function, and function template; constructing multiple candidate models of differential equations based on the prompt information; iteratively training the multiple candidate models of differential equations, and determining the multiple candidate differential equations... The process involves selecting comprehensive evaluation parameters for each candidate differential equation model in the model selection process; determining the target differential equation candidate model with optimal comprehensive evaluation parameters from at least one candidate differential equation model if at least one candidate differential equation model satisfies the convergence condition; constructing multiple algebraic equation candidate models based on the target algebraic variables and target input variables corresponding to the target differential equation candidate model; iteratively training the multiple algebraic equation candidate models to determine the target algebraic equation candidate model with optimal comprehensive evaluation parameters from the multiple algebraic equation candidate models; and constructing a power system model based on the target differential equation candidate model and the target algebraic equation candidate model.
[0149] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0150] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0151] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; 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; and these 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 constructing a power system model based on a large language model, characterized in that, include: Based on the operating data of the power system under disturbance conditions, the prompt information corresponding to the differential equation is constructed. The operating data includes at least one of the following: state variables, algebraic variables, and input variables. The prompt information includes at least one of the following: task contract, reference function, and function template. Based on the aforementioned prompts, multiple candidate models for differential equations are constructed. The multiple candidate models of differential equations are iteratively trained, and the comprehensive evaluation parameters of each candidate model of differential equations are determined. If at least one of the candidate differential equation models satisfies the convergence condition, the target candidate differential equation model with the optimal comprehensive evaluation parameters is determined from the at least one candidate differential equation model. Based on the target algebraic variables and target input variables corresponding to the target differential equation candidate models, multiple algebraic equation candidate models are constructed. The multiple candidate algebraic equation models are iteratively trained to determine the target candidate algebraic equation model with the optimal comprehensive evaluation parameters from the multiple candidate algebraic equation models. A power system model is constructed based on the candidate models of the target differential equation and the target algebraic equation.
2. The method for constructing a power system model based on a large language model according to claim 1, characterized in that, The prompt information corresponding to the differential equation constructed based on the power system operating data under disturbance conditions includes: The state variables are differentiated to obtain state derivative data; Based on the state variables, the state derivative data, the algebraic variables, and the input variables, a sample set is constructed; Based on the sample set, construct the task contract corresponding to the differential equation; The reference function is obtained from the experience pool, and the function template is determined based on the reference function. The experience pool stores a preset reference function and / or a candidate model obtained through iterative training. The task contract, the reference function, and the function template are determined as the prompt information corresponding to the differential equation.
3. The method for constructing a power system model based on a large language model according to claim 2, characterized in that, The method further includes: The experience pool is constructed, which includes multiple model storage areas. Each model storage area in the multiple model storage areas is used to store the preset reference function or the candidate model obtained by iterative training. Obtaining the reference function from the experience pool includes: Select a target model storage region from the multiple model storage regions included in the experience pool; If the preset reference function is stored in the target model storage area, the preset reference function is determined as the reference function; If the target model storage area stores candidate models obtained through iterative training, at least one candidate model is selected from the candidate models obtained through iterative training and determined as the reference function.
4. The method for constructing a power system model based on a large language model according to claim 1, characterized in that, The iterative training of the plurality of candidate differential equation models and the determination of the comprehensive evaluation parameters for each candidate differential equation model include: The validity screening of the multiple differential equation candidate models is performed, and a set of valid candidate models is constructed based on the screened differential equation candidate models. The validity screening includes at least one of the following: syntax compilation check, dimensional consistency check, numerical stability check, anomaly handling check, and physical rationality check. Each differential equation candidate model included in the effective candidate model set is iteratively trained, and the comprehensive evaluation parameters of each differential equation candidate model in the effective candidate model set are determined.
5. The method for constructing a power system model based on a large language model according to claim 4, characterized in that, The determination of the comprehensive evaluation parameters for each differential equation candidate model in the set of effective candidate models includes: Determine the optimal model parameters for each differential equation candidate model in the set of valid candidate models; Based on the optimal model parameters of each candidate differential equation model, an evaluation index is determined for each candidate differential equation model. The evaluation index includes at least one of the following: root mean square error, mean absolute percentage error, structural complexity, and average inference time. Based on the evaluation index of each candidate model of differential equation, the comprehensive evaluation parameter of each candidate model of differential equation is determined.
6. The method for constructing a power system model based on a large language model according to claim 1, characterized in that, The method further includes: During the iterative training of the multiple differential equation candidate models, if in any round of iterative training it is determined that the comprehensive evaluation parameter of the differential equation candidate model is less than the preset evaluation parameter, and the gain of the comprehensive evaluation parameter is less than the preset gain, then the running data is expanded to obtain an expanded sample set, and the gain of the comprehensive evaluation parameter is the difference between the comprehensive evaluation parameters of the differential equation candidate models determined in two adjacent rounds of iterative training. Based on the expanded sample set, the task contract corresponding to the differential equation is reconstructed. Based on the prompts including the reconstructed task contract, multiple candidate models of differential equations are reconstructed; The reconstructed candidate models of multiple differential equations are iteratively trained.
7. The method for constructing a power system model based on a large language model according to claim 1, characterized in that, The step of iteratively training the plurality of candidate algebraic equation models to determine the target algebraic equation candidate model with the optimal comprehensive evaluation parameters from the plurality of candidate algebraic equation models includes: The multiple candidate algebraic equation models are iteratively trained, and the comprehensive evaluation parameters of each candidate algebraic equation model are determined. If at least one of the multiple candidate algebraic equation models satisfies the convergence condition, the target candidate algebraic equation model with the optimal comprehensive evaluation parameters is determined from the at least one candidate algebraic equation model.
8. A device for constructing a power system model based on a large language model, characterized in that, include: Processing module and training module; The processing module is used to construct prompt information corresponding to the differential equation based on the operating data of the power system under disturbance conditions. The operating data includes at least one of the following: state variables, algebraic variables, and input variables. The prompt information includes at least one of the following: task contract, reference function, and function template. The processing module is also used to construct multiple candidate models of differential equations based on the prompt information; The training module is used to iteratively train the plurality of differential equation candidate models and determine the comprehensive evaluation parameters of each differential equation candidate model among the plurality of differential equation candidate models. The processing module is further configured to determine the target differential equation candidate model with the optimal comprehensive evaluation parameters from the at least one differential equation candidate model, provided that at least one differential equation candidate model among the plurality of differential equation candidate models satisfies the convergence condition. The processing module is also used to construct multiple algebraic equation candidate models based on the target algebraic variables and target input variables corresponding to the target differential equation candidate models; The training module is also used to iteratively train the plurality of algebraic equation candidate models and determine the target algebraic equation candidate model with the optimal comprehensive evaluation parameters from the plurality of algebraic equation candidate models. The processing module is also used to construct a power system model based on the candidate model of the target differential equation and the candidate model of the target algebraic equation.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the method for constructing a power system model based on a large language model as described in any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the method for constructing a power system model based on a large language model as described in any one of claims 1 to 7.
11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the method for constructing a power system model based on a large language model as described in any one of claims 1 to 7.