A real-time optimal power flow calculation method based on proximal strategy optimization algorithm

Through the Proximal Policy Optimization Algorithm (PPO), a simulation environment for the interaction between the agent and the environment is constructed in the power system, which solves the problem that the optimal power flow calculation in the power grid is difficult to respond quickly, and achieves efficient and accurate real-time optimal power flow solution, adaptable Grid uncertainty improves computational efficiency.

CN114566971BActive Publication Date: 2024-09-24NORTHEASTERN UNIV AT QINHUANGDAO

Patent Information

Application Number
CN202210196338.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-01
Publication Date
2024-09-24
Estimated Expiration
2042-03-01

AI Technical Summary

Technical Problem

Existing optimal power flow calculation methods are difficult to quickly respond to grid changes in large-scale power grids, especially when the uncertainty caused by renewable energy generation such as wind and solar increases, which affects the safe and stable operation of the grid, and the iterative method calculation time long, the optimal DC power flow ignores reactive power and network loss, and the calculation accuracy is not high.

Method used

A real-time optimal power flow calculation method based on the Proximal Policy Optimization Algorithm (PPO) is used to build a power system simulation environment and an interactive system between the agent and the environment. The DRL algorithm is used for offline training, optimizing agent parameters, and achieving rapid response to the power grid. Optimal power flow solution for state changes.

Benefits of technology

While ensuring calculation accuracy, it greatly improves calculation efficiency. It can quickly respond to the operating status of the power grid, provide optimal generator settings, adapt to grid uncertainty, and significantly improve calculation speed and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure BDA0003525948630000021
    Figure BDA0003525948630000021
  • Figure BDA0003525948630000022
    Figure BDA0003525948630000022
  • Figure BDA0003525948630000023
    Figure BDA0003525948630000023
Patent Text Reader

Abstract

The intermittent output of renewable energy and the randomness of loads have brought challenges to the safe operation of the power grid. The optimal power flow needs to be solved in real time to effectively help power grid operators make effective real-time decisions. The present invention proposes a real-time optimal power flow calculation method based on a proximal strategy optimization algorithm, which relates to the field of power system planning and control. First, a power system simulation environment is constructed based on the topological structure, historical information and power flow solver of the power system; then, an intelligent agent of the proximal strategy optimization algorithm is built to interact with the environment and optimize the parameters of the intelligent agent during offline training. After the offline training is completed, the intelligent agent provides the optimal action based on the real-time status of the power grid, obtains a near-optimal power flow solution, and realizes online application. The present invention is trained and verified in the IEEE14-node system, and compared with the optimal power flow standard solution of MATPOWER, verifying the effectiveness of this method in calculating the real-time optimal power flow.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of power system planning and control, and in particular to a real-time optimal power flow calculation method based on a proximal strategy optimization algorithm. Background Art

[0002] Optimal Power Flow (OPF) is to adjust the controllable devices of each dispatch interval t of the system from the perspective of optimizing the operation of the power system to change the distribution of the power grid flow, and achieve a certain optimal goal under the premise of stable and economic operation of the power system. Reactive power is taken into account in the optimal power flow, so it is also called AC Optimal Power Flow (ACOPF). The objective function is usually set as the total cost of power generation (active power flow optimization) and the network loss of the power grid (reactive power flow optimization).

[0003] Since the optimal power flow is an optimization problem based on the security, stability, and economy of the power grid, and can maintain good power supply quality in the power grid, it is widely used in the economic dispatch, unit combination, demand response, reliability analysis, and planning and design of the power system. From the perspective of mathematical model analysis, the node power balance equation introduced by Kirchhoff's law is a quadratic equality constraint with non-convexity, which leads to the optimal power flow being a typical nonlinear non-convex optimization problem, and it is difficult to find the global optimal solution. Therefore, the optimal power flow solution method needs to be guaranteed in terms of solution speed and quality.

[0004] At present, the solutions to the optimal power flow problem are mainly divided into three categories:

[0005] Seek the local optimal solution of the optimal power flow. For example, the ladder simplification method, Newton's method, interior point method, etc. are all gradient-based calculation methods, which rely on mathematical models and use penalty function method to deal with constraints to solve the local optimal solution of the optimal power flow. However, the optimization based on iteration takes a long time to calculate, especially in large-scale power grids, and cannot respond quickly to power grid changes. In today's power system, a high proportion of renewable energy generation such as wind and light and the connected flexible loads show strong volatility, intermittency and uncontrollability, which brings more uncertainties to the power system. If the optimal power flow solution cannot quickly follow the changes in the power grid state, it will seriously affect the safe and stable operation of the distribution network. Therefore, the rapid solution of the optimal power flow is very important.

[0006] Approximate the node power balance equation. A representative method is to approximate the AC power flow constraint as a linear DC power flow constraint, and then solve the approximate DC Optimal Power Flow (DCOPF) problem. DC Optimal Power Flow is a linear optimization problem with fast calculation speed and can obtain the global optimal solution. However, DC Optimal Power Flow ignores the reactive power and network loss in the original AC Optimal Power Flow problem, and sets the node voltage to 1, resulting in the DC Optimal Power Flow solution being less accurate than the original problem; and the global optimal solution of the DC Optimal Power Flow is not necessarily a feasible solution to the original optimal power flow problem.

[0007] With the rapid development of artificial intelligence technology in recent years, a large number of deep reinforcement learning (DRL) algorithms have been applied to the optimal power flow problem. DRL can train models through a large amount of historical data in the offline process, and apply the trained models online in the power system, where the input is the predicted or measured known variables including load, network topology, etc., and the output is the real-time optimal power flow solution. DRL transfers the online computing burden to the offline training stage, improving the computing speed of real-time applications. Value-based DRL algorithms, such as Q-learning, are only applicable to discrete action spaces; since the variables in the power system are all continuous quantities, if the continuous states and actions are forcibly discretized, it cannot guarantee the optimal decision, and it will also bring about the dimensionality disaster. Summary of the invention

[0008] In view of the deficiencies in the prior art, the present invention provides a real-time optimal power flow calculation method based on the proximal policy optimization, namely, PPO algorithm.

[0009] A real-time optimal power flow calculation method based on a proximal strategy optimization algorithm specifically includes the following steps:

[0010] Step 1: Based on the DRL algorithm and the topological structure of the power system, historical data information and the built-in PF solver of MATPOWER, a power system simulation environment is constructed; wherein DRL includes the agent, environment, state, action and reward function;

[0011] Step 1.1: Construct the mathematical model of AC optimal power flow of power system; Assume that the power system consists of N b nodes, N g generators and N ltransmission lines; the objective function of the optimal power flow mathematical model is to minimize the total cost of generators in the power system, as shown in Formula 1; the equality constraints are the active power balance constraints and reactive power balance constraints of each node, as shown in Formula 2-3; the inequality constraints include the active power constraints and reactive power constraints of the generator, the node voltage amplitude constraints, the line transmission power constraints and the active power ramp constraints of the generator, as shown in Formula 4-8;

[0012]

[0013]

[0014]

[0015]

[0016]

[0017]

[0018]

[0019]

[0020] In the formula, is the active power output of the i-th generator at time t; c 2i 、c 1i and c 0i are the quadratic term coefficient, linear term coefficient and constant term coefficient of the cost of the i-th generator; are the active and reactive power outputs of the generator connected to node i in period t respectively; are respectively the active and reactive power of the load connected to node i in period t; V i t is the voltage amplitude of node i in period t; are the conductance and susceptance of the branch between nodes i and j in time period t respectively; is the phase angle difference between the branches connected between nodes i and j in period t; is the maximum and minimum value of the active output of generator i; is the maximum and minimum value of the reactive power output of generator i; V i max 、V i min are the maximum and minimum values ​​allowed for the voltage amplitude of node i; is the transmission power in the transmission line between nodes i and j; is the maximum transmission power allowed by the transmission line between nodes i and j; is the active output of generator i at the previous moment; are the instantaneous maximum decreasing and increasing active powers of generator i respectively;

[0021] Step 1.2: Construct the state space according to the topological structure of the power system; the state includes the active load, reactive load, system conductance matrix, susceptance matrix connected to each node at time t, and the active output and voltage amplitude of the generator at time t-1;

[0022]

[0023] In the formula, are the active and reactive loads of all nodes in period t respectively; G and B are the system conductance matrix and susceptance matrix respectively; is the active power output of the PV node generator in the period t-1; is the voltage amplitude of all generators in the period t-1;

[0024] Step 1.3: Construct an action space for the controllable device, i.e., the generator, of the AC optimal power flow mathematical model in step 1.1; the action is the optimal generator setting value under load at time t;

[0025]

[0026] In the formula, is the active power output of the PV node generator in period t; is the voltage amplitude of all generators in period t;

[0027] Step 1.4: Based on the optimal power flow mathematical model in step 1.1, construct the reward function of the power system simulation environment. t Take action a t The immediate reward after t Defined as:

[0028]

[0029] Where cost is the total cost of all generators in the power system; r pg 、r v 、r s 、r g The calculation formula is:

[0030]

[0031]

[0032]

[0033]

[0034] In the formula, r pg 、rv 、r s 、r g Corresponding to formulas (4), (6), (7), and (8), when the constraints are met, the reward is 0; when the constraints are not met, the reward is the normalized value of the part exceeding the constraints; after normalization, the rewards of the generator active output, line flow, and node voltage constraints are all in the same order of magnitude, which is convenient for the intelligent agent to learn;

[0035] Step 2: Build an intelligent agent of the PPO algorithm and interact with the simulation environment built in step 1 to implement offline training and optimize the parameters of the intelligent agent; PPO is a DRL algorithm based on policy gradient;

[0036] Step 2.1: Build the agent including the target actor, online actor and critic network; Actor is used to fit the state s t Mapped to action a t The policy function, the input is the state s t , the output is mean μ, variance σ 2 The normal distribution of the selected action; Critic is used to fit s t Mapped to state value V(s t ) value function, with the input being the state s t , the output is the state value V π (s t );

[0037] Step 2.2: Initialize the online actor parameters θ in the agent μ 、critic parameter θ Q , target actor parameter θ μ′ ←θ μ ;

[0038] Step 2.3: Initialize PPO hyperparameters including η μ , η Q , maximum training round EP_Max, maximum step size within the round EP_Len, batch size batch_size, KL divergence threshold KL_target, clip rate ε, discount factor γ, NN update step update_step, the training round episode is initialized to 0;

[0039] Step 2.4: In the PPO algorithm, set an empty control sequence buffer;

[0040] Step 2.5: The PPO parameter training step is initialized to 0;

[0041] Step 2.6: Initialize the environmental state, including load data, power system conductance matrix and susceptance matrix, and generator initial setting values;

[0042] Step 2.7: The PPO algorithm agent takes corresponding actions based on the current state, step = step + 1;

[0043] Step 2.8: In the environment, according to the current action in step 2.7, i.e., the generator active power and voltage settings, the built-in PF solver of MATPOWER is used to calculate the power flow equation. The PF solver's PF_ALG is set to 1, 1 represents the Newton method, and ENFORCE_Q_LIMS is set to True. When any generator reactive power exceeds the limit during operation, the corresponding node is converted to a PQ node, and the reactive output is set to the limit value. The PF solver recalculates the power flow equation. In this process, formulas 2, 3, and 5 are satisfied. The reward function gives an immediate reward by judging whether the power flow calculation result meets the constraint conditions.

[0044] Step 2.9: The environment is transferred to the next state. Since the load change in the future scheduling interval t is not clear, the state transfer is random. It is also determined whether the power flow calculation results meet the constraints and feedback is given as an immediate reward.

[0045] Step 2.10: Store the current state, action, immediate reward and next state in the form of a vector into the PPO algorithm control sequence buffer;

[0046] Step 2.11: Determine whether step has reached EP_Len; if not, execute step 2.7; if reached, execute the next step;

[0047] Step 2.12: The agent uses the early stopping optimization KL-stop method and the gradient updates θ μ ,θ Q , and θ μ′ ←θ μ ;

[0048] Step 2.12.1: When updating actor parameters every fixed step update_step, the agent calculates the average KL divergence between the new and old strategies;

[0049] Step 2.12.2: If KL exceeds KL_target, then jump out and execute step 2.6; if KL does not exceed KL_target, then continue to the next step;

[0050] Step 2.12.3: Calculate the critic loss L(θ) using the data in the control sequence buffer Q ) and actor loss L clip (θ μ ).

[0051]

[0052]

[0053] A(s t ,a t )=r(s t ,a t )+γV π (s t+1 )-V π (s t ) (18)

[0054] Where V π (s t ) is s t The state value of r(s t ,a t ) is s t Take action a t Instant reward; V π (s t+1 ) is s t+1 The state value of A(s t ,a t ) is the advantage function, which is used to reduce the estimation variance; M is the amount of data in the control sequence buffer; ε is the cutoff rate, which limits the update range of the new strategy within the credible region; The parameter is θ μ In the actor network of s t Next select a t The probability of The parameter is θ μ′ In the actor network of s t Next select a t The probability of

[0055] Step 2.12.4: Adjust the critic and actor parameters θ Q ,θ μ Make updates;

[0056]

[0057]

[0058] In the formula, They are the critic and actor network parameters at time t+1 respectively; are the critic and actor network parameters at time t respectively; η Q , η μ are the learning rates of the critic and actor networks respectively; is the gradient function.

[0059] Step 2.13: episode = episode + 1; determine whether the episode reaches EP_Max; if it does not reach EP_Max, execute step 2.4; if it reaches, the agent training ends;

[0060] Step 3: After offline training, the agent can provide optimal actions based on the real-time status of the power grid, thereby obtaining a near-optimal power flow solution and realizing online applications in the power grid.

[0061] Beneficial technical effects of the present invention: The present invention uses an intelligent agent to interact with the environment and performs complex training calculations in an offline process. The trained intelligent agent can quickly respond to the current grid operation status while ensuring accuracy and provide appropriate generator settings, greatly improving computing efficiency.

[0062] 1. The present invention is used to calculate the optimal power flow in real time AC, and can quickly respond to the optimal generator settings when the power grid has obvious uncertainty. This is because a large amount of historical data is simulated during the training of the intelligent agent and interacts with the power grid simulation environment, and the nonlinear mapping relationship between the power grid state and the optimal solution is learned. In the offline process, heavy learning tasks are undertaken, and the training time is long. However, in the process of online application, the predicted or monitored operating state can be directly used as the input of the intelligent agent to map the optimal solution.

[0063] 2. The principle of KL-stop technology is to calculate the average KL divergence between the new and old strategies when updating actor parameters at fixed step lengths. If KL is greater than a preset threshold, the current batch update will be stopped and a new batch will continue to be generated for update; if KL does not reach the threshold, the gradient update can continue to be performed to ensure that KL does not become larger. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] Figure 1 This is a system framework diagram of the PPO algorithm for solving AC optimal power flow in an embodiment of the present invention;

[0065] Figure 2 This is a flow chart of the PPO algorithm for solving the AC optimal power flow problem according to an embodiment of the present invention;

[0066] Figure 3 When the actor update step number K is 20 in the embodiment of the present invention, the set of KL divergence change curves with the update number that changes the most in multiple training rounds of the original PPO algorithm;

[0067] Figure 4This is a comparison curve of the average KL divergence of PPO and PPO-KLstop changing with the number of updates in multiple training rounds when the actor update step number K is 20 in an embodiment of the present invention;

[0068] Figure 5 is a load data curve for one day in an embodiment of the present invention;

[0069] Figure 6 This is a topology diagram of the IEEE 14-node system according to an embodiment of the present invention;

[0070] Figure 7 This is a curve showing the change of instant reward with the number of training times according to an embodiment of the present invention;

[0071] Figure 8 The cumulative reward curve of the embodiment of the present invention varies with the training rounds;

[0072] Fig. 9 It is a comparison curve of the total cost of the optimal power flow between DRL and MATPOWER in the embodiment of the present invention. DETAILED DESCRIPTION

[0073] The present invention will be further described below in conjunction with the accompanying drawings and embodiments;

[0074] The present invention provides a real-time optimal power flow calculation method based on the proximal strategy optimization (PPO) algorithm. The system framework diagram of the PPO algorithm to solve the AC optimal power flow is shown in the attached figure. Figure 1 PPO is a DRL algorithm based on policy gradient, which can find the optimal control strategy in the continuous action space, solve the dimensionality disaster problem in the optimal power flow problem, and speed up the training.

[0075] A real-time optimal power flow calculation method based on proximal strategy optimization algorithm, the flow chart is as follows Figure 2 As shown, the specific steps include:

[0076] Step 1: Based on the DRL algorithm and the topological structure of the power system, historical data information and the built-in PF solver of MATPOWER, a power system simulation environment is constructed; wherein DRL includes the agent, environment, state, action and reward function;

[0077] Step 1.1: Construct the mathematical model of AC optimal power flow of power system; Assume that the power system consists of N b nodes, N g generators and N ltransmission lines; the objective function of the optimal power flow mathematical model is to minimize the total cost of generators in the power system, as shown in Formula 1; the equality constraints are the active power balance constraints and reactive power balance constraints of each node, as shown in Formula 2-3; the inequality constraints include the active power constraints and reactive power constraints of the generator, the node voltage amplitude constraints, the line transmission power constraints and the active power ramp constraints of the generator, as shown in Formula 4-8;

[0078]

[0079]

[0080]

[0081]

[0082]

[0083]

[0084]

[0085]

[0086] In the formula, is the active power output of the i-th generator at time t; c 2i 、c 1i and c 0i are the quadratic term coefficient, linear term coefficient and constant term coefficient of the cost of the i-th generator; are the active and reactive power outputs of the generator connected to node i in period t respectively; are respectively the active and reactive power of the load connected to node i in period t; V i t is the voltage amplitude of node i in period t; are the conductance and susceptance of the branch between nodes i and j in time period t respectively; is the phase angle difference between the branches connected between nodes i and j in period t; is the maximum and minimum value of the active output of generator i; is the maximum and minimum value of the reactive power output of generator i; V i max 、V i min are the maximum and minimum values ​​allowed for the voltage amplitude of node i; is the transmission power in the transmission line between nodes i and j; is the maximum transmission power allowed by the transmission line between nodes i and j; is the active output of generator i at the previous moment; are the instantaneous maximum decreasing and increasing active powers of generator i respectively;

[0087] Step 1.2: Construct the state space according to the topological structure of the power system; the state includes the active load, reactive load, system conductance matrix, susceptance matrix connected to each node at time t, and the active output and voltage amplitude of the generator at time t-1;

[0088]

[0089] In the formula, are the active and reactive loads of all nodes in period t respectively; G and B are the system conductance matrix and susceptance matrix respectively; is the active power output of the PV node generator in the period t-1; is the voltage amplitude of all generators in the period t-1;

[0090] Step 1.3: Construct an action space for the controllable device, i.e., the generator, of the AC optimal power flow mathematical model in step 1.1; the action is the optimal generator setting value under load at time t;

[0091]

[0092] In the formula, is the active power output of the PV node generator in period t; is the voltage amplitude of all generators in period t;

[0093] Step 1.4: Based on the optimal power flow mathematical model in step 1.1, construct the reward function of the power system simulation environment. t Take action a t The immediate reward after t Defined as:

[0094]

[0095] Where cost is the total cost of all generators in the power system; r pg 、r v 、r s 、r g The calculation formula is:

[0096]

[0097]

[0098]

[0099]

[0100] In the formula, r pg 、rv 、r s 、r g Corresponding to formulas (4), (6), (7), and (8), when the constraints are met, the reward is 0; when the constraints are not met, the reward is the normalized value of the part exceeding the constraints; after normalization, the rewards of the generator active output, line flow, and node voltage constraints are all in the same order of magnitude, which is convenient for the intelligent agent to learn;

[0101] Step 2: Build an intelligent agent of the PPO algorithm and interact with the simulation environment built in step 1 to implement offline training and optimize the parameters of the intelligent agent; PPO is a DRL algorithm based on policy gradient;

[0102] Step 2.1: Build the agent including the target actor, online actor and critic network; Actor is used to fit the state s t Mapped to action a t The policy function, the input is the state s t , the output is mean μ, variance σ 2 The normal distribution of the selected action; Critic is used to fit s t Mapped to state value V(s t ) value function, with the input being the state s t , the output is the state value V π (s t );

[0103] Step 2.2: Initialize the online actor parameters θ in the agent μ 、critic parameter θ Q , target actor parameter θ μ′ ←θ μ ;

[0104] Step 2.3: Initialize PPO hyperparameters including η μ , η Q , maximum training round EP_Max, maximum step size within the round EP_Len, batch size batch_size, KL divergence threshold KL_target, clip rate ε, discount factor γ, NN update step update_step, the training round episode is initialized to 0;

[0105] Step 2.4: In the PPO algorithm, set an empty control sequence buffer;

[0106] Step 2.5: The PPO parameter training step is initialized to 0;

[0107] Step 2.6: Initialize the environmental state, including load data, power system conductance matrix and susceptance matrix, and generator initial setting values;

[0108] Step 2.7: The PPO algorithm agent takes corresponding actions based on the current state, step = step + 1;

[0109] Step 2.8: In the environment, according to the current action in step 2.7, i.e., the generator active power and voltage settings, the built-in PF solver of MATPOWER is used to calculate the power flow equation. The PF solver's PF_ALG is set to 1 Newton method, and ENFORCE_Q_LIMS is set to True. When any generator reactive power exceeds the limit during operation, the corresponding node is converted to a PQ node, and the reactive power is set to the limit value. The PF solver recalculates the power flow equation. In this process, formulas 2, 3, and 5 are satisfied. The reward function gives an immediate reward by judging whether the power flow calculation result meets the constraints.

[0110] Step 2.9: The environment is transferred to the next state. Since the load change in the future scheduling interval t is not clear, the state transfer is random. It is also determined whether the power flow calculation results meet the constraints and feedback is given as an immediate reward.

[0111] Step 2.10: Store the current state, action, immediate reward and next state in the form of a vector into the PPO algorithm control sequence buffer;

[0112] Step 2.11: Determine whether step has reached EP_Len; if not, execute step 2.7; if reached, execute the next step;

[0113] Step 2.12: The agent uses the early stopping optimization KL-stop method and the gradient updates θ μ ,θ Q , and θ μ′ ←θ μ ;

[0114] Step 2.12.1: When updating actor parameters every fixed step update_step, the agent calculates the average KL divergence between the new and old strategies;

[0115] Step 2.12.2: If KL exceeds KL_target, then jump out and execute step 2.6; if KL does not exceed KL_target, then continue to the next step;

[0116] When the actor update step number K is 20, the KL divergence curve of the original PPO algorithm that changes the most in multiple training rounds with the number of updates is shown in the attached figure. Figure 3As shown in the figure, we can see that the KL divergence of the original PPO algorithm will be very large in the later stage of training. When the actor update step number K is 20, the average KL divergence of PPO and PPO-KLstop in multiple training rounds changes with the number of updates. Figure 4 As shown in this figure, it can be seen that adding the KL-stop method to PPO can effectively prevent the KL divergence from being too large.

[0117] Step 2.12.3: Calculate the critic loss L(θ) using the data in the control sequence buffer Q ) and actor loss L clip (θ μ ).

[0118]

[0119]

[0120] A(s t ,a t )=r(s t ,a t )+γV π (s t+1 )-V π (s t ) (18)

[0121] Where V π (s t ) is s t The state value of r(s t ,a t ) is s t Take action a t Instant reward; V π (s t+1 ) is s t+1 The state value of A(s t ,a t ) is the advantage function, which is used to reduce the estimation variance; M is the amount of data in the control sequence buffer; ε is the cutoff rate, which limits the update range of the new strategy within the credible region; The parameter is θ μ In the actor network of s t Next select a t The probability of The parameter is θ μ′ In the actor network of s t Next select a t The probability of

[0122] Step 2.12.4: Adjust the critic and actor parameters θ Q ,θμ Make updates;

[0123]

[0124]

[0125] In the formula, They are the critic and actor network parameters at time t+1 respectively; are the critic and actor network parameters at time t respectively; η Q , η μ are the learning rates of the critic and actor networks respectively; is the gradient function.

[0126] Step 2.13: episode = episode + 1; determine whether the episode reaches EP_Max; if it does not reach EP_Max, execute step 2.4; if it reaches, the agent training ends;

[0127] Step 3: After offline training, the agent can provide the best action according to the real-time status of the power grid, thereby obtaining a near-optimal power flow solution and realizing online application in the power grid. The online application test is as follows:

[0128] The example is run using Python 3.7 software on a computer with an Intel(R) Core(TM) i3-8100 CPU, a main frequency of 3.60 GHz, 8 GB memory, and an operating system of Windows 10. The PPO algorithm is implemented using tensoflow 1.14, and the hyperparameters are shown in Table 1. The PF solver is provided by the toolkit MATPOWER 7.0.

[0129] Table 1. PPO algorithm hyperparameter settings

[0130]

[0131] The load data used is 45 days of data from November 20, 2018 to January 3, 2019 in the New York area, with a power factor of 0.9. A group of data was taken every five minutes, and a total of 12,960 groups of data were taken. The first 11,960 groups of data were used as training data, and the remaining 1,000 groups of data were used as test data. 20% of random noise was added to the data to represent the uncertainty of the load. The constantly changing load data can prove that the model has good robustness. The original load data of one day and the uncertainty load curve after adding noise are shown in the attached figure. Figure 5 shown.

[0132] The proposed method is tested on the IEEE 14-node system. The IEEE 14-node system contains 14 nodes, 20 branches, 5 generators, and 11 loads. The topology diagram is shown in the attached figure. Figure 6 As shown in the figure, node 1 is selected as the balancing node. The agent performs 50,000 offline trainings, the maximum training round EP_Max is set to 1000, and the maximum step length EP_Len within a round is set to 50.

[0133] At the beginning of training, the agent cannot make good decisions, and the rewards for exploring actions in each state are mostly penalties. Through continuous interaction with the environment, the agent gradually explores better action directions and eventually learns a good strategy that can obtain high cumulative rewards. The curve of the change of immediate rewards with the number of training times is shown in the attached figure. Figure 7 The cumulative reward curve with the training round is shown in the attached Figure 8 As shown in the figure, it can be seen that the cumulative reward converges quickly in the first 300 training rounds and then tends to be stable. The fluctuation of the curve is that the intelligent agent follows the state, that is, the uncertainty load data to perform the corresponding optimal action.

[0134] DRL is compared with the standard solution obtained by the optimal power flow solver built into MATPOWER. The system total cost comparison curve of 1000 test data is shown in the attached figure. Fig. 9 As shown in the figure, the accuracy of the test data reaches 98.7%. The calculation time of MATPOWER to solve a set of data is 0.09 seconds, and the calculation time of the intelligent agent to solve a set of data online is 0.00937 seconds, which greatly improves the calculation efficiency of the AC optimal power flow.

[0135] Affected by the volatility of renewable energy and the uncertainty of load, in order to ensure the safe and stable operation of the power system, the real-time solution of AC optimal power flow has received widespread attention. AC optimal power flow is a non-convex nonlinear optimization problem, which is difficult to solve and takes a long time to calculate. The calculation method based on mathematical models improves the solution speed while abandoning the calculation accuracy. The present invention enables the intelligent agent to interact with the environment based on model-free DRL, and performs complex training calculations in the offline process. The trained intelligent agent can quickly respond to the current power grid operation status while ensuring accuracy, and provide appropriate generator settings, which greatly improves the calculation efficiency.

[0136] The similarity of the probability distribution of actions can be calculated using KL divergence. The greater the difference in distribution, the greater the KL. PPO uses the clip function to clip the target to ensure that the new strategy can have the greatest improvement over the old strategy without being too far away from the old strategy. However, clip does not strictly require KL to update the target within a certain threshold. According to experience, the KL divergence generated by PPO will increase exponentially with the number of actor network updates. Advantages of KL-stop: 1) It can ensure that the agent's policy update is within the trust region, that is, the agent's policy changes remain within the KL divergence threshold; 2) Since KL-stop may terminate the policy parameter update of this batch in advance and generate a new batch immediately, it can slightly shorten the entire training time.

Claims

1. A real-time optimal power flow calculation method based on a proximal strategy optimization algorithm, characterized in that: The specific steps include: Step 1: Based on the DRL algorithm and the topological structure of the power system, historical data information and the built-in PF solver of MATPOWER, a power system simulation environment is constructed; wherein DRL includes the agent, environment, state, action and reward function; Step 1.1: Construct the mathematical model of AC optimal power flow of power system; Assume that the power system consists of N b nodes, N g generators and N l transmission lines; the objective function of the optimal power flow mathematical model is to minimize the total cost of generators in the power system, as shown in Formula 1; the equality constraints are the active power balance constraints and reactive power balance constraints of each node, as shown in Formula 2-3; the inequality constraints include the active power constraints and reactive power constraints of the generator, the node voltage amplitude constraints, the line transmission power constraints and the active power ramp constraints of the generator, as shown in Formula 4-8; In the formula, is the active power output of the ith generator at time t; c2i, c1i and c0i are the quadratic coefficient, linear coefficient and constant coefficient of the cost of the ith generator; are the active and reactive power outputs of the generator connected to node i in period t respectively; are respectively the active and reactive power of the load connected to node i in period t; V i t is the voltage amplitude of node i in period t; are the conductance and susceptance of the branch between nodes i and j in time period t respectively; is the phase angle difference between the branches connected between nodes i and j in period t; is the maximum and minimum value of the active output of generator i; is the maximum and minimum value of the reactive power output of generator i; V i max 、V i min are the maximum and minimum values ​​allowed for the voltage amplitude of node i; is the transmission power in the transmission line between nodes i and j; is the maximum transmission power allowed by the transmission line between nodes i and j; is the active output of generator i at the previous moment; are the instantaneous maximum decreasing and increasing active powers of generator i respectively; Step 1.2: Construct the state space according to the topological structure of the power system; the state includes the active load, reactive load, system conductance matrix, susceptance matrix connected to each node at time t, and the active output and voltage amplitude of the generator at time t-1; In the formula, are the active and reactive loads of all nodes in period t respectively; G and B are the system conductance matrix and susceptance matrix respectively; is the active power output of the PV node generator in the period t-1; is the voltage amplitude of all generators in the period t-1; Step 1.3: Construct an action space for the controllable device, i.e., the generator, of the AC optimal power flow mathematical model in step 1.1; the action is the optimal generator setting value under load at time t; In the formula, is the active power output of the PV node generator in period t; is the voltage amplitude of all generators in period t; Step 1.4: Based on the optimal power flow mathematical model in step 1.1, construct the reward function of the power system simulation environment. t Take action a t The immediate reward after t Defined as: Where cost is the total cost of all generators in the power system; r pg 、r v 、r s 、r g The calculation formula is: In the formula, r pg 、r v 、r s 、r g Corresponding to formulas (4), (6), (7), and (8), when the constraints are met, the reward is 0; when the constraints are not met, the reward is the normalized value of the part exceeding the constraints; After standardization, the rewards for generator active output, line flow, and node voltage constraints are all in the same order of magnitude, which is convenient for the agent to learn; Step 2: Build an intelligent agent of the PPO algorithm and interact with the simulation environment built in step 1 to implement offline training and optimize the parameters of the intelligent agent; PPO is a DRL algorithm based on policy gradient; Step 3: After offline training, the agent can provide optimal actions based on the real-time status of the power grid, thereby obtaining a near-optimal power flow solution and realizing online applications in the power grid.

2. The real-time optimal power flow calculation method based on the proximal strategy optimization algorithm according to claim 1 is characterized in that: Step 2 is as follows: Step 2: Build an intelligent agent of the PPO algorithm and interact with the simulation environment built in step 1 to implement offline training and optimize the parameters of the intelligent agent; PPO is a DRL algorithm based on policy gradient; Step 2.1: Build the agent including the target actor, online actor and critic network; Actor is used to fit the state s t Mapped to action a t The policy function, the input is the state s t , the output is mean μ, variance σ 2 The normal distribution of the selected action; Critic is used to fit s t Mapped to state value V(s t ) value function, with the input being the state s t , the output is the state value V π (s t ); Step 2.2: Initialize the onlineactor parameters θ in the agent μ 、critic parameter θ Q , targetactor parameter θ μ′ ←θ μ ; Step 2.3: Initialize PPO hyperparameters including η μ , η Q , maximum training round EP_Max, maximum step size within the round EP_Len, batch size batch_size, KL divergence threshold KL_target, clip rate ε, discount factor γ, NN update step update_step, the training round episode is initialized to 0; Step 2.4: In the PPO algorithm, set an empty control sequence buffer; Step 2.5: The PPO parameter training step is initialized to 0; Step 2.6: Initialize the environmental state, including load data, power system conductance matrix and susceptance matrix, and generator initial setting values; Step 2.7: The PPO algorithm agent takes corresponding actions based on the current state, step = step + 1; Step 2.8: In the environment, according to the current action in step 2.7, i.e., the generator active power and voltage settings, the built-in PF solver of MATPOWER is used to calculate the power flow equation. The PF solver's PF_ALG is set to 1, which represents the Newton method, and ENFORCE_Q_LIMS is set to True. When any generator exceeds the reactive power limit during operation, the corresponding node is converted to a PQ node, and the reactive output is set to the limit value. The PF solver recalculates the power flow equation. In this process, formulas 2, 3, and 5 are satisfied. The reward function gives an immediate reward by judging whether the power flow calculation result meets the constraint conditions. Step 2.9: The environment is transferred to the next state. Since the load change in the future scheduling interval t is not clear, the state transfer is random. It is also determined whether the power flow calculation results meet the constraints and feedback is given as an immediate reward. Step 2.10: Store the current state, action, immediate reward and next state in the form of a vector into the PPO algorithm control sequence buffer; Step 2.11: Determine whether step has reached EP_Len; if not, execute step 2.7; if reached, execute the next step; Step 2.12: The agent uses the early stopping optimization KL-stop method and the gradient updates θ μ ,θ Q , and θ μ′ ←θ μ ; Step 2.13: episode = episode + 1; determine whether episode reaches EP_Max; if not, execute step 2.4; if reached, the agent training ends.

3. The real-time optimal power flow calculation method based on the proximal strategy optimization algorithm according to claim 2 is characterized in that: Step 2.12 is as follows: Step 2.12.1: When updating actor parameters every fixed step update_step, the agent calculates the average KL divergence between the new and old strategies; Step 2.12.2: If KL exceeds KL_target, then jump out and execute step 2.6; if KL does not exceed KL_target, then continue to the next step; Step 2.12.3: Calculate the critic loss L(θ) using the data in the control sequence buffer Q ) and actor loss L clip (θ μ ); A(s t ,a t )=r(s t ,a t )+γV π (s t+1 )-V π (s t ) (18) Where V π (s t ) is s t The state value of r(s t ,a t ) is s t Take action a t Instant reward; V π (s t+1 ) is s t+1 The state value of A(s t ,a t ) is the advantage function, which is used to reduce the estimation variance; M is the amount of data in the control sequence buffer; ε is the cutoff rate, which limits the update range of the new strategy within the credible region; The parameter is θ μ In the actor network of s t Next select a t The probability of The parameter is θ μ′ In the actor network of s t Next select a t The probability of Step 2.12.4: Adjust the critic and actor parameters θ Q ,θ μ Make updates; In the formula, They are the critic and actor network parameters at time t+1 respectively; are the critic and actor network parameters at time t respectively; η Q , η μ are the learning rates of the critic and actor networks respectively; is the gradient function.

Citation Information

Patent Citations

  • Linearized power flow calculation method for radial distribution network

    CN108599167A

  • Reactive voltage control method based on multi-time-scale multi-agent deep reinforcement learning

    CN113363997A

  • Multi-Objective Real-time Power Flow Control Method Using Soft Actor-Critic

    US20210367424A1

Cited By

  • A transient stability constrained optimal power flow solution method considering wind and solar power output uncertainty

    CN123162874A