Learning method and system for linear model of power system

By constructing the first linear model in the power system and using the automatic differential function of the neural network for fitting, the problem that linear model learning in the prior art is limited by prior knowledge and data quality, and higher model accuracy and adaptability are achieved.

CN120010240APending Publication Date: 2025-05-16ELECTRIC POWER RES INST OF GUANGXI POWER GRID CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411814555.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-11
Publication Date
2025-05-16

AI Technical Summary

Technical Problem

The prior art is limited by prior knowledge and data quality when learning linear models in power systems, making it difficult to achieve effective linear model learning.

Method used

A linear model learning method of power system is proposed. By constructing the first linear model and presetting the first neural network, using the automatic differential function of the neural network to calculate the partial derivative of the output to the input, fit the first linear model, and obtain the second linear model.

Benefits of technology

This method effectively improves the accuracy and adaptability of the power system model, can better adapt to the nonlinear characteristics of the data, improves the generalization ability of the model, and can dynamically adjust the model parameters to reflect the latest status of the power system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120010240A_ABST
    Figure CN120010240A_ABST
Patent Text Reader

Abstract

The invention discloses an electric power system linear model learning method and system. The method comprises the following steps: constructing a first linear model about a target electric power system; a first neural network is preset, the input of the first neural network is an input variable obtained by a first state variable of the target power system, and the output is a derivative of the first state variable to time; and according to the first neural network and a first state variable of the target power system at the current moment, solving a partial derivative of the output of the first neural network for the input vector, and fitting the first linear model to obtain a second linear model. The electric power system linear model learning system can effectively improve the accuracy and adaptability of an electric power system model, especially in the face of a complex and changeable electric power system operation environment, the problem that the coefficient fitting effect of a linear differential equation is poor is solved, and then the accuracy of electric power system linearization is greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of power system control, and in particular to a power system linear model learning method and system. Background Art

[0002] The force system itself is a nonlinear complex system, and the model of the electrical equipment in the system is often a nonlinear model. The most direct way to understand such a model is to establish a dynamic equation. In fact, there have been many related studies on equation extraction of nonlinear systems in the last century. These studies have proposed some methods with parameters and without parameters, but these early studies lack methods with both certain accuracy and generalization ability.

[0003] With the continuous deepening of research and the improvement of computing power, many new methods and breakthroughs have been produced in recent years for data-driven identification of nonlinear system dynamics equations. In general, most of these methods are based on machine learning or deep learning. In terms of solution strategies, except for algorithms such as symbolic regression, most algorithms convert nonlinear equations into linear equations before solving them.

[0004] However, there are already many methods for data-driven nonlinear system dynamics equations, but the methods of converting them into linear equations for solution are often limited by prior knowledge and data quality, and therefore are limited in application scenarios.

[0005] Therefore, it is necessary to solve the problem that existing technologies are limited by prior knowledge and data quality and cannot effectively learn linear models of electrical systems. Summary of the invention

[0006] The purpose of this section is to summarize some aspects of embodiments of the present invention and briefly introduce some preferred embodiments. Some simplifications or omissions may be made in this section and the specification abstract and the invention title of this application to avoid blurring the purpose of this section, the specification abstract and the invention title, and such simplifications or omissions cannot be used to limit the scope of the present invention.

[0007] In view of the above existing problems, the present invention is proposed.

[0008] Therefore, the present invention provides a method and system for learning a linear model of an electric power system, which can solve the problems mentioned in the background technology.

[0009] In order to solve the above technical problems, the present invention provides the following technical solutions:

[0010] In a first aspect, the present invention provides a method for learning a linear model of a power system, comprising:

[0011] constructing a first linear model of the target power system;

[0012] Preset a first neural network, wherein the input of the first neural network is an input variable obtained by a first state variable of the target power system, and the output is a derivative of the first state variable with respect to time;

[0013] According to the first neural network and the first state variable of the target power system at the current moment, the partial derivative of the first neural network output with respect to the input vector is calculated, and the first linear model is fitted to obtain a second linear model.

[0014] As a preferred solution of the power system linear model learning method of the present invention, wherein: the preset first neural network, the input of the first neural network is the input variable obtained by the first state variable of the target power system, and the output is the derivative of the first state variable with respect to time, including:

[0015] The first neural network is any type of neural network whose input is an input variable obtained by a first state variable of a target power system and whose output is a partial derivative with respect to an input vector;

[0016] The first state variables of the target power system include at least a time midpoint state variable and an external input state variable.

[0017] As a preferred solution of the power system linear model learning method of the present invention, wherein: according to the first neural network and the first state variable of the target power system at the current moment, the partial derivative of the first neural network output with respect to the input vector is obtained, and the first linear model is fitted, including:

[0018] Obtaining the first state variable of the target power system at the current moment;

[0019] According to the first state variable of the target power system at the current moment, obtaining a time midpoint state variable within a first preset time period;

[0020] A real-time input vector is obtained according to the time midpoint state variable and the external input state variable.

[0021] As a preferred solution of the power system linear model learning method of the present invention, wherein: according to the first neural network and the first state variable of the target power system at the current moment, the partial derivative of the first neural network output with respect to the input vector is obtained, and fitting the first linear model also includes:

[0022] Obtaining a real-time input vector according to the time midpoint state variable and the external input state variable;

[0023] The real-time input vector is input into the first neural network to obtain partial derivatives with respect to the real-time input vector.

[0024] As a preferred solution of the power system linear model learning method described in the present invention, wherein: the first neural network includes: the first neural network is obtained by training and optimization of the target loss function, and the target loss function includes the original loss function and the regularized loss function.

[0025] As a preferred solution of the power system linear model learning method of the present invention, wherein: according to the first neural network and the first state variable of the target power system at the current moment, the partial derivative of the first neural network output with respect to the input vector is obtained, and the first linear model is fitted to obtain the second linear model, which includes:

[0026] Inputting the real-time input vector into the first neural network to obtain a partial derivative with respect to the real-time input vector;

[0027] The first neural network is subjected to a first-order Taylor expansion using partial derivatives, and the coefficients of the first linear model are obtained by fitting, so as to obtain a second linear model with determined coefficients.

[0028] As a preferred solution of the power system linear model learning method described in the present invention, the partial derivative for the input vector includes: solving the partial derivative of the first state variable of the target power system at a future moment with respect to the input vector.

[0029] In a second aspect, the present invention provides a power system linear model learning system, comprising:

[0030] A model building module, used for building a first linear model about the target power system;

[0031] A neural network design module, used for presetting a first neural network, wherein the input of the first neural network is an input variable obtained by a first state variable of a target power system, and the output is a derivative of the first state variable with respect to time;

[0032] A fitting module is used to obtain the partial derivative of the first neural network output with respect to the input vector according to the first neural network and the first state variable of the target power system at the current moment, and to fit the first linear model to obtain a second linear model.

[0033] In a third aspect, the present invention provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned method when executing the computer program.

[0034] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the method described above when executed by a processor.

[0035] Compared with the prior art, the invention has the following beneficial effects: the invention proposes a method and system for learning a linear model of a power system, constructs a first linear model of a target power system; a first neural network is preset, the input of the first neural network is the input variable obtained by the first state variable of the target power system, and the output is the derivative of the first state variable with respect to time; according to the first neural network and the first state variable of the target power system at the current moment, the partial derivative of the output of the first neural network for the input vector is obtained, and the first linear model is fitted to obtain a second linear model. The linear model learning system of the power system can effectively improve the accuracy and adaptability of the power system model, especially when facing a complex and changeable power system operating environment. By using a neural network to predict and calculate partial derivatives, the system can better adapt to the nonlinear characteristics of the data, thereby improving the generalization ability of the model. In addition, the system can also dynamically adjust the model parameters according to real-time data to ensure that the model can timely reflect the latest state of the power system, and provide strong support for the stable operation and optimization control of the power system. Through the implementation of the invention, the limitations of traditional linear models in power system analysis and prediction can be effectively solved, and new technical means can be provided for the intelligent management of power systems. The problem of poor fitting of linear differential equation coefficients has been improved, thereby greatly improving the accuracy of power system linearization. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. Among them:

[0037] Figure 1 It is a flow chart of a method and system for learning a linear model of a power system provided by an embodiment of the present invention.

[0038] Figure 2 It is a schematic diagram of local linearization based on automatic differentiation provided by an embodiment of the present invention.

[0039] Figure 3 This is a diagram of the linearization effect of an ordinary differential neural network optimized using the MSE loss function provided by the existing technology.

[0040] Figure 4 This is a diagram showing the linearization effect of an ordinary differential neural network after regularization of all parameters provided by an embodiment of the present invention.

[0041] Figure 5 This is a diagram showing the linearization effect of an ordinary differential neural network after applying bias matrix regularization provided by an embodiment of the present invention.

[0042] Figure 6 This is a diagram showing the linearization effect of an ordinary differential neural network using a half-step integration method provided in an embodiment of the present invention.

[0043] Figure 7 It is a linearization effect diagram of an ordinary differential neural network using the fourth-order Runge-Kutta method provided by the prior art.

[0044] Figure 8 It is a diagram showing the linearization effect of an ordinary differential neural network using a prediction-correction half-step integration method provided in an embodiment of the present invention.

[0045] Fig. 9 It is a schematic diagram of the physical structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0046] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the drawings of the specification. Obviously, the described embodiments are part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary persons in the art without creative work should fall within the scope of protection of the present invention.

[0047] Example 1

[0048] Reference Figure 1-Figure 9 , which is the first embodiment of the present invention, provides a method and system for learning a linear model of a power system, including:

[0049] There are some problems and deficiencies in the existing related technologies. For example, in the process of establishing and optimizing the power system model, the traditional linear model often finds it difficult to accurately capture the dynamic changes of the system, especially when the system parameters fluctuate greatly. In addition, due to the complexity of the power system, when dealing with nonlinear problems, the linearization process of the traditional linear model often leads to a decrease in the accuracy of the model, which cannot meet the needs of high-precision prediction and control.

[0050] This application provides a method that can effectively solve the above-mentioned problems. Next, we will combine multiple embodiments to explain in detail how to implement the power system linear model learning method;

[0051] In recent years, many new methods and breakthroughs have been produced for data-driven identification of nonlinear system dynamics equations. Generally speaking, most of these methods are based on machine learning or deep learning. In terms of solution strategies, except for algorithms such as symbolic regression, most algorithms convert nonlinear equations into linear equations before solving them.

[0052] However, there are already many methods for data-driven nonlinear system dynamics equations, but the methods of converting them into linear equations for solution are often limited by prior knowledge and data quality, and therefore are limited in application scenarios.

[0053] Considering this, the present invention proposes a power system linear model learning method based on ordinary differential neural network. Specifically, Figure 1 A flow chart of a method and system for learning a linear model of a power system provided by an embodiment of the present invention is shown.

[0054] Figure 1 A flow chart of a power system linear model learning method and system is shown, including:

[0055] S101, constructing a first linear model of a target power system;

[0056] In an optional embodiment, there may be many methods for establishing the first linear model of the target power system, including but not limited to using historical data for regression analysis, or using an expert system to design model parameters according to the operating characteristics of the power system.

[0057] In the embodiment of the present application, the first linear model is related to the subsequent first neural network, so the first linear model of the target power system can be designed as (f NN (x,z)=Ax+Bz+C), thus, the first linear model of the target power system can be obtained, that is, the linear model of the power system, which is a local linearization process.

[0058] For example, an actual equation of the power system can be given according to the actual situation of the power system, as shown in the following formula.

[0059]

[0060] Among them, i L represents the current, i R Represents resistance, u c Represents capacitance.

[0061] In an optional embodiment, because the first linear model is solved by the first neural network, the first linear model is not limited here, and the first linear models designed by relevant technical personnel should be related to the preset first neural network.

[0062] It should be noted that the benefit of constructing the first linear model of the target power system is that it can provide a basic framework for subsequent model learning, thereby simplifying the learning process and improving learning efficiency.

[0063] S102, preset a first neural network, the input of the first neural network is the input variable obtained by the first state variable of the target power system, the output is the derivative of the first state variable with respect to time, and the automatic differentiation function of the neural network is used to calculate the partial derivative of the output with respect to the input.

[0064] In an embodiment of the present application, a first neural network is preset, the input of the first neural network is the input variable obtained by the first state variable of the target power system, and the output is the derivative of the first state variable with respect to time, including:

[0065] The first neural network is any type of neural network whose input is an input variable obtained by a first state variable of a target power system and whose output is a partial derivative with respect to the input vector;

[0066] The first state variables of the target power system include at least a time midpoint state variable and an external input state variable.

[0067] In an optional embodiment, the first neural network can be constructed based on a deep learning framework, such as a convolutional neural network (CNN), a recurrent neural network (RNN), or a long short-term memory network (LSTM), etc. These neural networks can process sequence data and can capture complex patterns of dynamic changes in the power system.

[0068] In an optional embodiment, the first neural network can also be a neural network based on a fully connected layer. Since the dynamic changes of the power system may involve multiple time scales, the first neural network can be designed as a deep network with multiple hidden layers to enhance its modeling ability for complex dynamic patterns.

[0069] In an optional embodiment, the first neural network can also be a simple ordinary differential neural network (CDNN), which has a simple structure, is easy to implement, and can effectively model the dynamic changes of the power system. By learning the state variables of the target power system and their changing laws, the CDNN can output the partial derivatives of the corresponding state variables, providing data support for further learning and optimization of the linear model.

[0070] In the embodiment of the present application, the first neural network is designed by selecting an ordinary differential neural network. For an ordinary differential neural network, its automatic differentiation function will be affected by the numerical integration method. When the input of the ordinary differential neural network is the state variable at the current time t i When the value of the ordinary differential neural network is t i ~t i+1 A linear combination of the means of the state variables over time, not t i The linear combination of state variables at each moment. In this case, the obtained target linear differential equation is seriously inconsistent with the actual equation of the system.

[0071] It should be noted that this embodiment makes improvements to the input of the ordinary differential neural network. The state variables at the current moment are no longer directly used as the model input, but the state variables at the midpoint of time are used as the input.

[0072] In an optional embodiment, there are many ways to obtain the first neural network input vector, for example, half-step integration method, prediction-correction half-step integration method, fourth-order Runge-Kutta method, etc. These methods have their own advantages and disadvantages, and relevant technicians can choose the appropriate method according to the actual application scenario and needs. For example, the half-step integration method has higher accuracy when dealing with certain types of nonlinear problems, while the prediction-correction half-step integration rule can effectively reduce the amount of calculation while ensuring accuracy. The fourth-order Runge-Kutta rule is widely used in many engineering applications because it strikes a good balance between stability and accuracy.

[0073] In an optional embodiment, the half-step integration method, also known as the semi-implicit Euler method or the improved Euler method, is a numerical integration method for solving ordinary differential equations. The half-step integration method combines the features of the explicit Euler method and the implicit Euler method to provide higher accuracy than the simple explicit Euler method. This method predicts the intermediate state by taking a "half step" between the current time point and the next time point, and then uses this predicted value to calculate the final state update.

[0074] In an embodiment of the present application, a half-step integration method is used to obtain an input vector of the ordinary differential neural network at the current moment; wherein the input vector includes a time midpoint state variable and an external input variable.

[0075] In an optional embodiment, the state variables describing the behavior of the electrical equipment are first determined. These state variables may include voltage, current, etc. At the same time, it is also necessary to consider external factors affecting the power system, namely external input variables, such as load changes, power injection, etc. Then, a suitable time step is selected, and the time midpoint state variable corresponding to the state variable at the current moment is calculated using the half-step integration method. Finally, the time midpoint state variable and the external input variable are concatenated to obtain the input vector.

[0076] In an optional embodiment, the state variables refer to key physical quantities that can describe the dynamic behavior of the system, including but not limited to the angle, frequency, speed, etc. of the generator. For a specific power network, the state variables may also include the voltage phase angle and voltage amplitude at both ends of the line and transformer.

[0077] In an optional embodiment, external input variables refer to influencing factors from outside the system, including but not limited to weather conditions (temperature, wind speed, etc.), changes in market demand, fault events, etc., which may affect the operating status of the power system.

[0078] In an optional embodiment, the state variables and external input variables may use various sensors and measuring devices (such as current transformers, voltage transformers, digital meters, etc.) to collect real-time data, which is not specifically limited here.

[0079] In an embodiment of the present application, the first neural network includes: the first neural network is obtained by training and optimizing the target loss function, and the target loss function includes the original loss function and the regularized loss function.

[0080] In an embodiment of the present application, the first neural network is an ordinary differential neural network, which is a machine learning model that combines traditional neural networks and ordinary differential equations. It can use neural networks to define the dynamics of ordinary differential equations and predict the evolution of power systems. Compared with traditional deep neural networks, ordinary differential neural networks need to store fewer states and require less memory space during training. Ordinary differential neural networks can adaptively evaluate strategies based on inputs, and can clearly balance numerical accuracy with speed, and can dynamically adjust the required computing resources according to actual application scenarios. For some systems, ordinary differential equations are more suitable for describing the system's dynamic equations than other equations.

[0081] In an optional embodiment, the input vector obtained in step S101 is input into a pre-trained ordinary differential neural network to obtain the differential of the state variable at the current moment, and then the differential of the state variable at the current moment is numerically integrated to obtain the state variable at the future moment. Then, the automatic differentiation function of the ordinary differential neural network (or other automatic differentiation tools, such as the autograd function in PyTorch) can be used to solve the partial derivative of the state variable at the future moment with respect to the input vector.

[0082] In an optional embodiment, the state variable at the future time represents the electrical characteristics of the electrical equipment in the power system, such as the angle, frequency, and voltage of the generator.

[0083] In the embodiment of the present application, the ordinary differential neural network in this embodiment is pre-trained, and the integration method based on half-step integration is also used during training (the input and output during training are consistent with the input and output of the ordinary differential neural network in this step during application). In particular, when training and optimizing the ordinary differential neural network, the target loss function is used, and the target loss function here includes the original loss function and the regularized loss function.

[0084] In an optional embodiment, the original loss function can be a mean square error loss function, or other loss functions with the same function (such as a cross entropy loss function), and the regularized loss function can be L1 regularization or L2 regularization, or other regularization methods (other more complex structured regularization terms), which are not specifically limited here.

[0085] In an embodiment of the present application, the mean square error loss function is used to measure the difference between the predicted value and the true value, and the regularization loss function is used to make unnecessary network parameters tend to be exactly zero or maintain a small value, thereby making the ordinary differential neural network tend to be sparse, thereby improving the accuracy of the linearization of the power system.

[0086] In an embodiment of the present application, the partial derivative for the input vector includes: solving the partial derivative of the first state variable of the target power system at a future time with respect to the input vector.

[0087] It should be noted that the benefit of presetting the first neural network is that it can significantly reduce the time and computing resource consumption of model training. In addition, through the preset neural network, different power system models can be adapted more quickly and the generalization ability of the model can be improved. In practical applications, this preset neural network can be used as a powerful tool for power system analysis and prediction, helping engineers and researchers to better understand and control the dynamic behavior of the power system. In this way, the stability and reliability of the power system are improved, and new possibilities are also provided for the optimization and dispatching of the power system.

[0088] S103, according to the first neural network and the first state variable of the target power system at the current moment, the partial derivative of the first neural network output with respect to the input vector is obtained, and the first linear model is fitted to obtain a second linear model.

[0089] In an embodiment of the present application, according to the first neural network and the first state variable of the target power system at the current moment, the partial derivative of the first neural network output with respect to the input vector is obtained, and fitting the first linear model includes:

[0090] Obtaining the first state variable of the target power system at the current moment;

[0091] According to the first state variable of the target power system at the current moment, obtaining a time midpoint state variable within a first preset time period;

[0092] According to the time midpoint state variables and the external input state variables, the real-time input vector is obtained.

[0093] In the embodiment of the present application, according to the first state variable of the target power system at the current moment, the midpoint state variable in the first preset time period is obtained by adopting the half-step integration method. It can be understood that for ordinary differential neural networks, its automatic differentiation function will be affected by the numerical integration method. Taking the forward Euler integration shown in the first formula below as an example, it is assumed that the original power system equation is the second formula below.

[0094] x(t+Δt)=x(t)+Δt*f NN (x(t),z(t))

[0095]

[0096] Among them, x(t+Δt) represents the state variable at time t+Δt, x(t) represents the state variable at time t, Δt represents the time step, and f NN represents an ordinary differential neural network, z(t) represents the external input variable at time t, represents the original power system equation, A and B represent the coefficients of the original power system equation, x represents the state variable, and z represents the external input variable.

[0097] In an optional embodiment, after a specified number of rounds, assuming that the learning effect of the ordinary differential neural network is very ideal, and the value calculated at each moment through numerical integration is very close to the actual value, then any two adjacent data points in the time domain sequence and the ordinary differential neural network satisfy the relationship shown below.

[0098] x(t i+1 )=x(t i )+f NN (x(t i ),z(t i ))*Δt

[0099]

[0100] in, Respectively represent x and z at t i ~t i+1 The mean value over time.

[0101] According to the above three formulas, when the input of the ordinary differential neural network is a variable at t i When the value of time is t, the output of the ordinary differential neural network calculation is i ~t i+1 A linear combination of the means of the input variables over time, not t i The linear combination of variables at each moment. When the ordinary differential neural network is back-propagating, the derivative calculated is the output of the ordinary differential neural network with respect to t iThe derivative of the variable at each moment gives the following linear equation. Obviously, the linear equation obtained at this time does not match the actual equation of the power system.

[0102]

[0103] In an optional embodiment, in order to make the linearization result more accurate, it is necessary to make the ordinary differential neural network integral calculation t i ~t i+1 During the process, the input variable value is as close as possible to the variable at t i ~t i+1 The average value in the time period, so this embodiment adopts the half-step integration method, that is, the state variable value input to the ordinary differential neural network during the integration process is replaced by its value at t i ~t i+1 The state variable value at the midpoint of time. Since this value is closer to the state variable at t i ~t i+1 The average value within the time period, the result of linearization of the ordinary differential neural network will be more accurate.

[0104] Specifically, obtain the state variable x(t i ), and then use the ordinary differential neural network f NN Calculate the midpoint state variable based on the current state variable Please refer to the following formula for details.

[0105]

[0106] in, represents the midpoint state variable, x(t i ) represents the state variable at the current time i, f NN represents an ordinary differential neural network, z0(t i )、z1(t i ) represents the external input variable, and Δt represents the time difference / time step.

[0107] In the embodiment of the present application, the calculated time midpoint state variable is concatenated with the acquired external input variable to obtain an input vector.

[0108] In the embodiment of the present application, according to the first neural network and the first state variable of the target power system at the current moment, the partial derivative of the first neural network output with respect to the input vector is obtained, and fitting the first linear model further includes:

[0109] According to the time midpoint state variable and the external input state variable, a real-time input vector is obtained;

[0110] The real-time input vector is input into the first neural network to obtain the partial derivative with respect to the real-time input vector.

[0111] Specifically, the obtained time midpoint state variable and the external input variable are input into the ordinary differential neural network as input vectors, and the output results of the ordinary differential neural network are numerically integrated to obtain the state variable at the future moment, as shown in the following formula.

[0112]

[0113] Then, using the automatic differentiation function of the ordinary differential neural network, the partial derivatives of the state variables at future moments with respect to the input vector can be solved.

[0114] In the embodiment of the present application, the state variable of the ordinary differential neural network at the current moment is obtained, and the midpoint state variable in the preset time period is obtained according to the state variable at the current moment to obtain the input vector, and then the input vector is input into the pre-trained ordinary differential neural network, and numerical integration is performed to obtain the state variable at the future moment, and then the automatic differentiation function of the ordinary differential neural network is used to solve the partial derivative of the state variable at the future moment to the input vector, thereby using the partial derivative to perform a first-order Taylor expansion on the ordinary differential neural network, and fitting the coefficients of the target linear differential equation to obtain the linear model of the power system. This method optimizes the ordinary differential neural network by training the target loss function including the regularization loss function, and uses the half-step integration method to obtain one of the inputs of the ordinary differential neural network (the midpoint state variable in time), thereby improving the problem of poor fitting effect of the linear differential equation coefficients, and thus greatly improving the accuracy of the linearization of the power system.

[0115] In the embodiment of the present application, the correction process after obtaining the state variables at the future time will be described in detail below.

[0116] The state variable at a future moment is obtained, and then the following steps are included: calculating the change value of the state variable for a simulation step; iterating the change value of the state variable according to a first preset formula, terminating when the iteration reaches a specified round or the difference between the change values ​​of the state variable between the previous and next rounds is within a specified range, and obtaining the target state variable change value; and according to the target state variable change value, correcting the state variable at the future moment through a second preset formula.

[0117] It is understandable that the linearization effect of the ordinary differential neural network is improved by using the half-step integration method to replace the state variable values ​​input into the ordinary differential neural network during the integration process with the state variable values ​​at the midpoint of the time step, but there will still be large errors in the coefficient fitting near the power system jump point. The reason for this phenomenon is that the power system will gradually return to a steady state after the jump, and the data near the jump point accounts for a small proportion of the total data and is sparse, so it is difficult for the ordinary differential neural network to effectively learn this part of the data.

[0118] To improve this phenomenon and strengthen the learning of sparse data by ordinary differential neural networks, this embodiment further introduces a prediction-correction integration method. Taking the first-order differential equation as an example, the prediction-correction algorithm itself should contain two formulas: a prediction formula (the first formula below) for the current data point (x i ,y i )Calculate the data point (y) at the future time i+1 ); a correction formula such as (the second formula below) is used to correct the predicted value based on the current data point and the result calculated by the prediction formula. When the two parts of the prediction-correction algorithm have the same accuracy, the calculation will be simpler and more efficient.

[0119] y i+1 =y i +hf(x i ,y i )

[0120]

[0121] The prediction-correction method used in this embodiment can use the same neural network for the correction formula and the prediction formula. When performing numerical integration, firstly, the state variable change value of a simulation step is explicitly calculated according to the formula (the first formula below) as the initial value of Δx, and then the state variable change value Δx is implicitly iterated according to the first preset formula (the second formula below), and the iteration is terminated after a specified round or when the difference between Δx before and after the iteration is within a specified range, and finally the second preset formula (the third formula below) is used to correct the integral result, that is, the state variable at the future moment.

[0122] Δx 0 =f NN (x(t i ),z0(t i ),z1t i ))*Δt

[0123] Δx k+1 =f NN (x(t i )+0.5*Δx k,z0(t i ),z1(t i ))*Δt x(t i+1 )=x(t i )+Δx N

[0124] Where Δx 0 Represents the change in state variables for a simulation step, Δx k+1 represents the change value of the state variable in iteration round k+1, f NN represents an ordinary differential neural network, x(t i ) represents the current time t i The state variable, Δx k represents the change value of the state variable in iteration round k, z0(t i )、z1(t i ) represents the external input variable, Δt represents the time difference, x(t i+1 ) represents the future time t i+1 The state variable, Δx N Represents the target state variable change value, and N represents the specified round.

[0125] In this embodiment, after obtaining the state variables at the future moment, the state variable change value of a simulation step is calculated, and the state variable change value is iterated according to the first preset formula. The iteration is terminated when the specified round or the difference between the state variable change values ​​of the previous and next rounds is within the specified range, and the target state variable change value is obtained. Then, based on the target state variable change value, the state variables at the future moment are corrected by the second preset formula, thereby further improving the accuracy of the linearization of the power system.

[0126] In the embodiment of the present application, according to the first neural network and the first state variable of the target power system at the current moment, the partial derivative of the first neural network output with respect to the input vector is obtained, and the first linear model is fitted to obtain the second linear model including:

[0127] Inputting the real-time input vector into the first neural network to obtain a partial derivative with respect to the real-time input vector;

[0128] The first neural network is subjected to first-order Taylor expansion using partial derivatives, and the coefficients of the first linear model are obtained by fitting, so as to obtain a second linear model with determined coefficients.

[0129] In an optional embodiment, the first-order Taylor expansion is an approximation method for expressing a function near a certain point using a linear function.

[0130] It can be understood that the partial derivative of the state variable at the future moment with respect to the input vector is used to calculate the ordinary differential neural network fNN By performing a first-order Taylor expansion, the target linear differential equation (f NN (x,z)=Ax+Bz+C), thus, we can get the target linear differential equation, that is, the linear model of the power system. This is a local linearization process.

[0131] The target linear differential equation is a linear representation of the ordinary differential neural network, and the ordinary differential neural network is used to represent the dynamic equations of the power system. NN In (x,z)=Ax+Bz+C), x represents the state variable and z represents the external input variable.

[0132] In an optional embodiment, detailed operation steps for training and optimizing the loss function of an ordinary differential neural network are also provided, as follows:

[0133] It can be understood that for a system whose dynamic equation is a linear differential equation, after obtaining its ordinary differential neural network through training, the equation (f NN (x,z)=Ax+Bz+C) should correspond to the actual equation of the power system, but in reality it is often not the case. The reason is that the equation (f NN The residual C obtained by linearizing the ordinary differential neural network in (x,z)=Ax+Bz+C) is not a fixed value. The value of the residual is a value that changes with the input, and contains some information of the original system. Due to the influence of the residual, the parameters of the ordinary differential neural network will stay near a local optimal point rather than the global optimal point during the iteration process. The result of the linearization of the ordinary differential neural network at the local optimal point is often different from the actual equation of the power system.

[0134] In this embodiment, in order to reduce the influence of the residual and improve the accuracy of the linearization of the power system, this embodiment modifies the loss function of the training optimization ordinary differential loss function. The residual term actually comes from the bias of the linear layer. In order to reduce the influence of the bias, regularization is applied to the ordinary differential neural network. Regularization introduces the parameters of the ordinary differential neural network into the loss function, which is generally used to solve the problem of overfitting of data.

[0135] In this embodiment, regularization is applied only to the bias matrix, and the calculation result of L1 regularization or L2 regularization is added to the original loss function as a new loss function, namely, the target loss function.

[0136] That is to say, the ordinary differential neural network is obtained by training and optimizing the target loss function. The target loss function includes the original loss function and the regularized loss function, which are specifically defined as follows.

[0137] L(xtrue ,x pred )=αL 原始 (x true ,x pred )+βL 正则 (x true ,x pred )

[0138] L 原始 (x true ,x pred )=MSE(x true ,x pred )

[0139]

[0140] or,

[0141] Among them, L(x true ,x pred ) represents the target loss function, x true represents the measured value, x pred represents the predicted value, L 原始 represents the original loss function, L 正则 represents the regularized loss function, α and β represent the weight coefficients of the original loss function and the regularized loss function respectively, MSE represents the mean square error loss function, γ represents the regularization strength, and w i represents the regularized network parameter, i represents the network parameter number, and N represents the total number of network parameters. The third formula above is L1 regularization, and the fourth formula above is L2 regularization.

[0142] In this embodiment, by combining the regularized loss function and the original loss function as the target loss function for training and optimizing the ordinary differential neural network, the influence of the residual error can be effectively reduced, thereby improving the accuracy of the linearization of the power system.

[0143] For ordinary differentiable neural networks, we first need to generate the data sets used for training, including training sets and test sets. The data structures of the training sets and test sets are the same, and the systems used for generation are also the same, but they have different initial settings.

[0144] Taking the training set as an example, in the training set used in this embodiment, each sample in the training set includes information related to electrical characteristics, such as t, x, z, z_jump, and event_t. Among them, t represents the time series; x is the state variable described above, and z is the external input variable described above; z_jump represents the moment when the system jumps, and event_t represents the time when the jump occurs. When the time recorded by event_t is calculated, the input of the network will switch from z to z_jump. When it is specifically input into the network, after specifying the training rounds, the model will extract the specified N samples from the training set in each round of training, and divide them into several batches according to the batch_size samples contained in each batch, and use batches for training.

[0145] When training an ordinary differential neural network, starting from the initial value, the neural network receives the current value of x(t) and z(t) and calculates the current value. Then, according to x(t) and The value of x(t+Δt) can be obtained by numerical integration. When calculating the next moment, the calculated x(t+Δt) and z(t+Δt) are used as inputs, and the x values ​​corresponding to different times can be obtained by cyclic calculation. In different scenarios, the settings of the neural network module used are different, and different numbers of hidden layers and neurons can be set. After calculating the x value corresponding to the entire time series, the loss function is calculated, and back propagation and parameter update are performed.

[0146] Among them, x(t) represents the state variable at the current moment, z(t) represents the external input variable at the current moment, represents the derivative function of the state variable at the current moment, and x(t+Δt) represents the predicted state variable at the future moment.

[0147] After obtaining the trained ordinary differential neural network, the first-order Taylor expansion equation of the ordinary differential neural network at each data point can be obtained by using the automatic differentiation function. The coefficients corresponding to each variable should be consistent with the formula Be consistent.

[0148] In an alternative embodiment, Figure 2 FIG. 2 shows a schematic diagram of local linearization based on automatic differentiation provided by an embodiment of the present invention. Figure 2 As shown, the given data is input into the forward propagation of the ordinary differential neural network, and the automatic differentiation function of the ordinary differential neural network is used to obtain the partial derivative of the ordinary differential neural network output to the input, and the partial derivative is used to perform a first-order Taylor expansion of the neural network. In order to ensure the accuracy of the partial derivatives obtained by automatic differentiation and to avoid the local optimal problem as much as possible, this embodiment makes improvements in terms of loss function and integration method (this part is described in detail in the above embodiment, in Figure 2 (not shown in the figure), so that the characteristics of the ordinary differential neural network are more in line with the requirements.

[0149] In an alternative embodiment, Figure 3 The figure shows the linearization effect of the ordinary differential neural network optimized using the MSE loss function provided by the prior art. Figure 4 The figure shows the linearization effect of the ordinary differential neural network after regularization is applied to all parameters provided by the embodiment of the present invention.

[0150] like Figure 3 As shown in the figure, the MSE loss function is used to optimize the ordinary differential neural network. At this time, the learning effect of the ordinary differential neural network is as follows: Figure 3 The error is within the acceptable range. However, after back propagating the derivative function of the ordinary differential neural network, the linearization effect is as follows Figure 3 In the right figure, the coefficients of the fitted equations deviate greatly from the expected values. Correspondingly, the corresponding values ​​of the red dotted line and the red solid line should always be 10, and the corresponding value of the blue line should always be -5.

[0151] like Figure 4 As shown in Figure 1, after applying L1 regularization to all parameters of the ordinary differential neural network including weights and biases, the equation coefficients obtained are obviously distorted to a greater extent, and have changed from being too large to being too small, which indicates that part of the information is fitted to the bias matrix.

[0152] In the ordinary differential neural network used in this embodiment, each linear layer contains 64 neurons, the corresponding weight matrix is ​​a matrix of size 64*64, and the bias matrix is ​​a matrix of size 64 multiplied by the input data dimension. The amount of data in the weight matrix is ​​much larger than that in the bias matrix, so the loss caused by the weight matrix during regularization is much greater than that of the bias matrix. After regularizing all parameters, the ordinary differential neural network will actually use the bias matrix more to fit the data, which reduces the derivative calculated by back propagation.

[0153] Considering this, this embodiment modifies the loss function and only applies regularization to the bias matrix. L1 regularization and L2 regularization are used respectively, and the regularization strength is 10. The results are as follows: Figure 5 , Figure 5 A diagram showing the linearization effect of an ordinary differential neural network after applying bias matrix regularization provided by an embodiment of the present invention is shown.

[0154] like Figure 5 As shown, L1 regularization ( Figure 5 ) and L2 regularization ( Figure 5 The right figure of ) will improve the learning effect of the equation coefficients. The result obtained by L1 regularization is slightly better than that of L2 regularization, but the difference is not large.

[0155] In an alternative embodiment, Figure 6 The figure shows the linearization effect of the ordinary differential neural network using the half-step integration method provided by the embodiment of the present invention. Figure 7 The figure shows the linearization effect of the ordinary differential neural network using the fourth-order Runge-Kutta method provided by the prior art. Figure 6 and Figure 7 It can be seen that the fitting effect of the equation coefficients when the half-step integration method is used is better than the fitting effect of the equation coefficients when the fourth-order Runge-Kutta method is used. Figure 6 Except for the jump point, the maximum error is basically controlled within 3%.

[0156] Figure 8 The figure shows the linearization effect of the ordinary differential neural network using the prediction-correction half-step integration method provided by the embodiment of the present invention. Figure 8 As shown, compared to Figure 6 , the deviation of the equation coefficients decreases near the jump point, which shows that the robustness of the ordinary differential neural network is improved.

[0157] This embodiment also provides a power system linear model learning system, including:

[0158] A model building module, used for building a first linear model about the target power system;

[0159] A neural network design module is used to preset a first neural network, wherein the input of the first neural network is an input variable obtained by a first state variable of a target power system, and the output is a derivative of the first state variable with respect to time;

[0160] The fitting module is used to obtain the partial derivative of the first neural network output with respect to the input vector according to the first neural network and the first state variable of the target power system at the current moment, fit the first linear model, and obtain the second linear model.

[0161] The above-mentioned unit modules may be embedded in or independent of a processor in a computer device in the form of hardware, or may be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to the above-mentioned modules.

[0162] Fig. 9 An example of a physical structure diagram of an electronic device is shown in FIG. Fig. 9As shown, the electronic device may include: a processor 1010, a communication interface 1020, a memory 1030 and a communication bus 1040, wherein the processor 1010, the communication interface 1020 and the memory 1030 communicate with each other through the communication bus 1040. The processor 1010 may call the logic instructions in the memory 1030 to execute the power system linear model learning method based on the ordinary differential neural network, the method comprising: constructing a first linear model of the target power system; presetting a first neural network, the input of the first neural network is the input variable obtained by the first state variable of the target power system, and the output is the derivative of the first state variable with respect to time; according to the first neural network and the first state variable of the target power system at the current moment, the partial derivative of the output of the first neural network with respect to the input vector is obtained, and the first linear model is fitted to obtain a second linear model.

[0163] In addition, the logic instructions in the above-mentioned memory 1030 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of various embodiments of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk.

[0164] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it is implemented to execute the power system linear model learning method based on ordinary differential neural network provided by the above-mentioned methods, the method comprising: constructing a first linear model of the target power system; presetting a first neural network, the input of the first neural network is the input variable obtained by the first state variable of the target power system, and the output is the derivative of the first state variable with respect to time; according to the first neural network and the first state variable of the target power system at the current moment, the partial derivative of the first neural network output with respect to the input vector is obtained, and the first linear model is fitted to obtain a second linear model.

[0165] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, i.e., they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative effort.

[0166] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.

[0167] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

[0168] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.

[0169] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of complete hardware embodiments, complete software embodiments, or embodiments in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code. The scheme in the embodiments of the present application can be implemented in various computer languages, for example, object-oriented programming language Java and literal scripting language JavaScript, etc.

[0170] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0171] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0172] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0173] Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0174] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A method for learning a linear model of a power system, characterized in that: include: constructing a first linear model of the target power system; Preset a first neural network, wherein the input of the first neural network is an input variable obtained by a first state variable of the target power system, and the output is a derivative of the first state variable with respect to time; According to the first neural network and the first state variable of the target power system at the current moment, the partial derivative of the first neural network output with respect to the input vector is calculated, and the first linear model is fitted to obtain a second linear model.

2. The power system linear model learning method according to claim 1, characterized in that: The preset first neural network, wherein the input of the first neural network is the input variable obtained by the first state variable of the target power system, and the output is the derivative of the first state variable with respect to time, includes: The first neural network is any type of neural network whose input is an input variable obtained by a first state variable of a target power system and whose output is a partial derivative with respect to an input vector; The first state variables of the target power system include at least a time midpoint state variable and an external input state variable.

3. The power system linear model learning method according to claim 2, characterized in that: The step of obtaining the partial derivative of the first neural network output with respect to the input vector according to the first neural network and the first state variable of the target power system at the current moment, and fitting the first linear model comprises: Obtaining the first state variable of the target power system at the current moment; According to the first state variable of the target power system at the current moment, obtaining a time midpoint state variable within a first preset time period; A real-time input vector is obtained according to the time midpoint state variable and the external input state variable.

4. The power system linear model learning method according to claim 3, characterized in that: The step of obtaining a partial derivative of the first neural network output with respect to an input vector based on the first neural network and the first state variable of the target power system at the current moment, and fitting the first linear model further comprises: Obtaining a real-time input vector according to the time midpoint state variable and the external input state variable; The real-time input vector is input into the first neural network to obtain partial derivatives with respect to the real-time input vector.

5. The power system linear model learning method according to claim 4, characterized in that: The first neural network includes: the first neural network is obtained by training and optimizing a target loss function, and the target loss function includes an original loss function and a regularized loss function.

6. The power system linear model learning method according to claim 5, characterized in that: The method of obtaining the partial derivative of the first neural network output with respect to the input vector according to the first neural network and the first state variable of the target power system at the current moment, fitting the first linear model, and obtaining the second linear model includes: Inputting the real-time input vector into the first neural network to obtain a partial derivative with respect to the real-time input vector; The first neural network is subjected to a first-order Taylor expansion using partial derivatives, and the coefficients of the first linear model are obtained by fitting, so as to obtain a second linear model with determined coefficients.

7. The power system linear model learning method according to claim 6, characterized in that: The partial derivative for the input vector includes: solving the partial derivative of the first state variable of the target power system at a future moment with respect to the input vector.

8. A power system linear model learning system, characterized in that: include: A model building module, used for building a first linear model about the target power system; A neural network design module, used for presetting a first neural network, wherein the input of the first neural network is an input variable obtained by a first state variable of a target power system, and the output is a derivative of the first state variable with respect to time; A fitting module is used to obtain the partial derivative of the first neural network output with respect to the input vector according to the first neural network and the first state variable of the target power system at the current moment, and to fit the first linear model to obtain a second linear model. A computer device comprises a memory and a processor, wherein the memory stores a computer program, and wherein the processor implements the steps of the method according to any one of claims 1 to 7 when executing the computer program.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.