A microgrid real-time optimization method, system, device and medium based on piecewise linear Galerkin approximation

By constructing a real-time optimization model for microgrids using the piecewise linear Galerkin approximation method, the problem of insufficient fitting accuracy of value functions in microgrids by traditional methods is solved, enabling fast and accurate real-time optimization decisions and meeting the safe and economical operation requirements of microgrids.

CN122136994APending Publication Date: 2026-06-02GUIZHOU POWER GRID CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GUIZHOU POWER GRID CO LTD
Filing Date
2025-12-31
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Traditional Galerkin approximation methods based on polynomial basis functions are difficult to accurately fit the complex piecewise characteristics of the value function of microgrids, resulting in a decrease in approximation accuracy near the constraint boundary and failing to meet the stringent requirements of real-time optimization of microgrids.

Method used

The piecewise linear Galerkin approximation method is adopted. By constructing a piecewise linear basis function set, the value function is approximated by Galerkin. The Monte Carlo method is combined to generate multiple random scenarios, construct explicit mapping relationships, solve the optimization problem in real time, and output the optimal running decision.

Benefits of technology

It enables fast and deterministic real-time scheduling, supports the safe and economical operation of microgrids under multiple uncertainties, and improves the accuracy and efficiency of optimization strategies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122136994A_ABST
    Figure CN122136994A_ABST
Patent Text Reader

Abstract

This invention relates to the field of electrical engineering technology and discloses a real-time optimization method, system, device, and medium for microgrids based on piecewise linear Galerkin approximation. The method includes: first, establishing a real-time operation model of the microgrid and constructing a dynamic programming equation with energy storage state as the key variable; then, designing a piecewise linear basis function set and using Galerkin approximation to explicitly analyze the value function to obtain its mapping relationship with energy storage state; in the offline stage, generating multiple sets of stochastic scenarios based on prediction information, solving the approximate value function results under each scenario through parallel computing, and aggregating them to obtain the final model; in the real-time operation stage, combining the current system state with the model, solving the optimization problem containing the value function, and outputting the optimal operation decision at the current moment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of electrical engineering technology, and in particular to a method, system, device and medium for real-time optimization of microgrids based on piecewise linear Galerkin approximation. Background Technology

[0002] As an effective platform for integrating distributed renewable energy, the safe, economical, and efficient operation of microgrids is crucial. However, the multiple uncertainties in source, load, and price pose significant challenges to real-time optimization decisions in microgrids. Approximate dynamic programming (ADP) is considered an effective tool for solving such sequential decision-making problems due to its combination of forward-looking decision-making capabilities and real-time computation speed. The core of ADP lies in accurately constructing a value function to quantify the impact of current decisions on the future.

[0003] Existing ADP methods largely rely on data-driven iterative training strategies, such as those based on piecewise linear functions or table functions, which repeatedly update the strategy using a large amount of historical or simulated data to approximate the value function. While these methods can obtain near-optimal strategies, their training process is computationally burdensome, time-consuming, and highly dependent on the completeness of the training data, making it difficult to meet the stringent real-time decision-making requirements of microgrids. Furthermore, traditional Galerkin approximation ADP methods based on polynomial basis functions, although able to directly approximate the value function analytically to avoid iterative training, often exhibit complex piecewise linear characteristics or even truncation due to the power limits and energy storage constraints of various devices in the microgrid model. Smooth polynomial basis functions struggle to accurately fit these piecewise characteristics, leading to a significant decrease in approximation accuracy near the constraint boundaries, ultimately affecting the optimality of the optimization strategy. Summary of the Invention

[0004] In view of the aforementioned existing problems, the present invention is proposed.

[0005] Therefore, this invention provides a real-time optimization method, system, device, and medium for microgrids based on piecewise linear Galerkin approximation, which can solve the problems of traditional Galerkin approximation methods based on polynomial basis functions being unable to accurately fit the complex piecewise characteristics of the value function of microgrids and causing a decrease in approximation accuracy near the constraint boundary.

[0006] To solve the above-mentioned technical problems, the present invention provides the following technical solution: In a first aspect, the present invention provides a real-time optimization method for microgrids based on the piecewise linear Galerkin approximation, comprising: A real-time operation model for the microgrid is established, which is used to describe the relationship between system state, operation decisions and operation costs. Based on the real-time operation model, a dynamic programming equation is constructed with the energy storage state as the key variable. The dynamic programming equation includes a value function representing the future operating cost. By using a piecewise linear basis function set to perform the Galerkin approximation on the value function, an explicit mapping relationship between the value function and the energy storage state is obtained. In the offline phase, multiple random scenarios are generated based on the prediction information. The value function approximation results under each scenario are obtained through the Galerkin approximation process. The value function approximation results are then aggregated to obtain the final value function approximation model. During the real-time operation phase, the current system state is obtained, the current energy storage state is substituted into the final approximate value function model, the real-time optimization problem containing the value function is solved, and the optimal operation decision at the current moment is output.

[0007] As a preferred embodiment of the microgrid real-time optimization method based on the piecewise linear Galerkin approximation described in this invention, the establishment of the real-time operation model of the microgrid includes: Define state variables, which include battery energy storage, wind turbine available power, solar panel available power, active load, reactive load, and real-time electricity price; Define decision variables, including battery charging power, battery discharging power, active power output of gas generator, active power exchanged with external power grid, active power output of wind turbine, active power output of solar panel, and reactive power allocation. Define exogenous information variables, which include wind power output forecast, solar power output forecast, active load forecast, reactive load forecast, real-time electricity price forecast, and their respective forecast residuals; Define a state transition function, which includes the battery energy storage state transition equation and other state variable transition equations; Define an operating cost function, which includes the operating cost of gas generators, the cost of wind power curtailment, and the cost of solar power curtailment.

[0008] As a preferred embodiment of the microgrid real-time optimization method based on piecewise linear Galerkin approximation described in this invention, wherein: the step of performing Galerkin approximation on the value function using a piecewise linear basis function set includes: The range of values ​​for the energy storage state is divided into multiple continuous intervals; Construct a piecewise linear basis function set based on the interval segment; The value function is represented as a linear combination of the piecewise linear basis function set; Substituting the linear combination into the first-order optimality condition equations derived from the real-time operation model, we obtain the residual equations. Set the weighted integral of the residual equation and each piecewise linear basis function over the energy storage energy state domain to zero; Solve the system of algebraic equations based on the condition that the weighted integral is zero to obtain the combination coefficients of the value function.

[0009] As a preferred embodiment of the microgrid real-time optimization method based on piecewise linear Galerkin approximation described in this invention, in which: when solving the algebraic equation system, a convexity constraint is applied to the value function, and the convexity constraint is achieved by applying a linear inequality constraint to the combination coefficients corresponding to the value function.

[0010] As a preferred embodiment of the microgrid real-time optimization method based on piecewise linear Galerkin approximation described in this invention, the following steps are included: In the offline phase, multiple stochastic scenarios are generated based on prediction information, and the approximate value function results for each scenario are obtained through the Galerkin approximation process. The approximate value function results are then aggregated, including: The Monte Carlo method is used to generate multiple sets of stochastic scenarios based on day-ahead forecast information. Each set of stochastic scenarios contains time-series forecast residual sequences of renewable energy output, load and electricity price. Perform parallel computation for each set of random scenarios; For each moment, iterate backward from the end of the cycle to the beginning. At each time step, the Galerkin approximation process described in claim 3 is executed to obtain the value function combination coefficients at that time step; After completing calculations for all scenarios, the arithmetic mean of the combined coefficients of the value functions of all scenarios at the same time is taken to obtain the final approximate model of the value function.

[0011] As a preferred embodiment of the microgrid real-time optimization method based on the piecewise linear Galerkin approximation described in this invention, the step of obtaining the current system state during the real-time operation phase, substituting the current energy storage state into the final value function approximation model, and solving the real-time optimization problem containing the value function includes: At each decision-making moment, the current system status of the microgrid is collected, including the current battery energy storage capacity, the available power of the wind turbine, the available power of the solar panel, the active load, the reactive load, and the real-time electricity price. Substitute the current battery energy storage capacity into the final approximate value function model; Solve the real-time optimization problem with the goal of summing the current operating cost and the value function at the next time step, and obtain the optimal operating decision at the current time step.

[0012] As a preferred embodiment of the microgrid real-time optimization method based on piecewise linear Galerkin approximation described in this invention, the dynamic programming equation is the Bellman equation.

[0013] Secondly, the present invention provides a real-time microgrid optimization system based on the piecewise linear Galerkin approximation, comprising: The model building module is used to build a real-time operation model of the microgrid, which describes the relationship between system state, operation decisions and operation costs. The equation construction module is used to construct a dynamic programming equation with the energy storage state as the key variable based on the real-time operation model. The dynamic programming equation includes a value function representing the future operating cost. The analytical approximation module is used to perform Galerkin approximation on the value function using a piecewise linear basis function set, so as to obtain an explicit mapping relationship of the value function with respect to the energy storage state. The offline fitting module is used to generate multiple random scenarios based on prediction information in the offline stage, obtain the approximate value function results under each scenario through the Galerkin approximation process, and aggregate the approximate value function results to obtain the final approximate value function model. The real-time decision-making module is used to obtain the current system state during the real-time operation phase, substitute the current energy storage state into the final value function approximation model, solve the real-time optimization problem containing the value function, and output the optimal operation decision at the current moment.

[0014] Thirdly, the present invention provides an electronic device including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the method described above.

[0015] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described above.

[0016] Compared with existing technologies, the beneficial effects of this invention are that it proposes a real-time optimization method for microgrids based on piecewise linear Galerkin approximation. This method first establishes a real-time operation model of the microgrid and constructs a dynamic programming equation with the energy storage state as the key variable. Then, it designs a piecewise linear basis function set and uses the Galerkin approximation to explicitly analyze the value function, obtaining its mapping relationship with the energy storage state. In the offline stage, multiple sets of stochastic scenarios are generated based on prediction information, and the approximate results of the value function under each scenario are solved through parallel computation and aggregated to obtain the final model. In the real-time operation stage, the current system state is substituted into the model to solve the optimization problem containing the value function, outputting the optimal operating decision at the current moment. This method avoids solving complex stochastic optimization problems online and supports fast, deterministic real-time scheduling. Attached Figure Description

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

[0018] Figure 1 The present invention provides a flowchart of a real-time microgrid optimization method based on piecewise linear Galerkin approximation, which is an embodiment of the present invention.

[0019] Figure 2 The flowchart illustrates the phased operation of a real-time microgrid optimization method based on a piecewise linear Galerkin approximation, as provided in one embodiment of the present invention.

[0020] Figure 3 This is an internal structure diagram of an electronic device based on a piecewise linear Galerkin approximation-based real-time optimization method for microgrids, provided as an embodiment of the present invention. Detailed Implementation

[0021] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the protection scope of the present invention.

[0022] It should be noted in advance that the system mentioned in the embodiments as the subject of real-time operation refers to any system configured with this method.

[0023] Example 1, referring to Figure 1 This is the first embodiment of the present invention, which provides a real-time optimization method for microgrids based on the piecewise linear Galerkin approximation, comprising: This invention provides a method that can effectively solve the problems mentioned above. The following will describe in detail how to implement the microgrid real-time optimization method based on piecewise linear Galerkin approximation using multiple embodiments. Figure 1 A flowchart of a real-time microgrid optimization method based on the piecewise linear Galerkin approximation is shown, including: S101, Establish a real-time operation model for the microgrid. The real-time operation model is used to describe the relationship between system state, operation decisions and operating costs. In this embodiment of the invention, establishing a real-time operation model for a microgrid includes: Define state variables, which include battery energy storage, wind turbine available power, solar panel available power, active load, reactive load, and real-time electricity price; Define decision variables, which include battery charging power, battery discharging power, active power output of gas generator, active power exchanged with the external power grid, active power output of wind turbine, active power output of solar panel, and reactive power allocation. Exogenous information variables are defined, including wind power output forecast, solar power output forecast, active load forecast, reactive load forecast, real-time electricity price forecast, and their respective forecast residuals. Define a state transition function, which includes the battery energy storage state transition equation and other state variable transition equations; Define an operating cost function, which includes the operating cost of gas generators, the cost of wind power curtailment, and the cost of solar power curtailment.

[0024] It should be understood that when there are multiple uncertainties in the source-load price during the operation of a microgrid, relying solely on historical data or fixed rules to build an operating model will result in an inability to accurately depict the dynamic relationship between the current system state and future costs.

[0025] However, if the impact of the prediction residuals in exogenous information variables on state evolution is ignored, the energy storage dispatch may be inaccurate, the curtailment rate may increase, or the cost of purchasing electricity may surge due to insufficient consideration of the volatility of renewable energy and the randomness of load.

[0026] When establishing a real-time operation model of a microgrid, this invention initiates a complete modeling mechanism that includes state variables, decision variables, exogenous information variables, state transition functions, and operating cost functions.

[0027] Among them, the aforementioned state variables include battery energy storage, wind turbine available power, solar panel available power, active load, reactive load, and real-time electricity price, which are used to comprehensively characterize the internal operating conditions of the microgrid at any given time. The decision variables mentioned above include battery charging power, battery discharging power, active power output of gas generator, active power exchanged with the external power grid, active power output of wind turbine, active power output of solar panel, and reactive power allocation, which are used to describe the scheduling actions of all controllable resources at the current moment. The exogenous information variables mentioned above include wind power output forecast, solar power output forecast, active load forecast, reactive load forecast, real-time electricity price forecast, and their respective forecast residuals, which are used to quantify the impact of external environmental inputs and their uncertainties on system evolution. The aforementioned state transition functions include the battery energy storage state transition equation and other state variable transition equations, which are used to accurately describe the evolution path of each state variable from the current time to the next time. The aforementioned operating cost function includes the operating cost of gas generators, the curtailment penalty cost of wind power, and the curtailment penalty cost of solar power, used to reflect the economic costs incurred by different operating decisions.

[0028] The battery charging and discharging efficiency, power curtailment penalty coefficient, and gas generator cost coefficient mentioned in this section can be set according to the actual needs of relevant technical personnel and in combination with some existing technologies. This invention does not limit these parameters.

[0029] S102, based on the real-time operation model, constructs a dynamic programming equation with the energy storage state as the key variable. The dynamic programming equation includes a value function representing the future operating cost. In this embodiment of the invention, the dynamic programming equation is the Bellman equation.

[0030] It should be noted that when microgrids face fluctuations in renewable energy output and time-varying electricity prices during multi-timescale dispatch, directly adopting static optimization methods and ignoring the cost impact of future periods will lead to a lack of foresight in current dispatch decisions, resulting in suboptimal energy storage charging and discharging strategies, increased curtailment rates, or unnecessary increases in electricity purchase expenditures.

[0031] However, if energy storage scheduling is based solely on heuristic rules without introducing a quantitative assessment of future operating costs, it may lead to premature battery depletion, frequent start-ups and shutdowns of gas turbine units, or a decline in system voltage support capacity because the coupling relationship between state evolution and cost accumulation is not considered.

[0032] Therefore, based on the establishment of a real-time operation model, this invention initiates a state-space modeling mechanism with energy storage energy state as the core, and constructs a Bellman dynamic programming equation containing a value function to recursively express the comprehensive impact of the current decision on subsequent operating costs.

[0033] Preferably, the specific steps for constructing dynamic programming equations with energy storage state as the key variable may include the following: First, based on the set of state variables at the current moment, the battery energy storage energy is extracted as the core state of dynamic programming, and the available power of wind turbine, available power of solar panel, active load, reactive load and real-time electricity price are used as auxiliary state dimensions to jointly form a complete state vector in the state space. Furthermore, for each feasible combination of decision variables, the immediate operating cost is calculated, which includes the operating cost of the gas generator, the wind power curtailment penalty cost, and the solar power curtailment penalty cost. The prediction residuals in the exogenous information variables are then combined to perform probabilistic transition modeling of the state at the next time step. Furthermore, the Bellman equation is used to express the total cost at the current moment as a weighted sum of the immediate operating cost and the expected value of the value function at the next moment. The value function is solved by backward recursion or approximate dynamic programming methods to ensure that the operating cost is minimized within a finite scheduling period. Finally, the control command for the current moment in the optimal decision variable sequence obtained by solving is sent to each controllable unit of the microgrid to complete the closed-loop scheduling execution.

[0034] The aforementioned energy storage state can be understood as the level of available energy stored in the battery energy storage system at any scheduling time in this invention, and is a key bridge connecting current decisions and future costs. The aforementioned value function can be understood in this invention as a mathematical expression used to quantify the cumulative operating cost over all future periods under the optimal strategy, starting from the current state. The Bellman equation mentioned above can be understood as the core dynamic programming tool used in this invention to establish the recursive relationship between current decisions, state transitions, and future costs.

[0035] The weighting of curtailment penalty costs, fuel cost coefficients for gas generators, and value function discount factors mentioned in this section can be set according to the actual needs of relevant technical personnel and in combination with some existing technologies; this invention does not limit these settings.

[0036] S103, using a piecewise linear basis function set to perform Galerkin approximation on the value function, obtains the explicit mapping relationship of the value function with respect to the energy storage state; In this embodiment of the invention, the Galerkin approximation of the value function is performed using a piecewise linear basis function set, including: The range of values ​​for the energy storage state is divided into multiple continuous intervals; Constructing a piecewise linear basis function set based on interval segments; The value function is represented as a linear combination of a set of piecewise linear basis functions; Substituting the linear combination into the first-order optimality condition equations derived from the real-time running model, we obtain the residual equations; Set the weighted integral of the residual equation and each piecewise linear basis function over the energy storage energy state domain to zero; Solve the system of algebraic equations based on the condition that the weighted integral is zero to obtain the combination coefficients of the value function.

[0037] In this embodiment of the invention, when solving a system of algebraic equations, a convexity constraint is applied to the value function. The convexity constraint is achieved by applying a linear inequality constraint to the combination coefficients corresponding to the value function.

[0038] It should be noted that in practice, the value function of a microgrid typically exhibits nonlinearity and convexity in the dimension of energy storage state. This convexity directly reflects the marginal increase in operating costs as energy storage changes. If the convexity of the value function is ignored in the approximation process, the solved scheduling strategy may exhibit physically infeasible charging and discharging behaviors, such as over-discharging in a low energy storage state or refusing to charge in a high energy storage state, thereby causing the system safety boundary to be exceeded or the economic performance to deteriorate.

[0039] Optionally, performing a Galerkin approximation of the value function using a piecewise linear basis function set may include the following operations performed in sequence: First, the range of values ​​for the battery energy storage state is divided into multiple continuous and non-overlapping intervals based on the upper and lower limits of its physical capacity. The endpoints of each interval correspond to nodes in the energy storage state space. Furthermore, a set of piecewise linear basis functions is constructed based on interval segments, where each basis function takes the value of one at the corresponding node, exhibits linear variation between adjacent nodes, and remains zero in the remaining intervals, thus forming a family of locally supported hat functions. Furthermore, the value function is represented as a linear combination of a set of piecewise linear basis functions, and the combination coefficients are the function values ​​of the value function at each node, forming the vector of unknown parameters to be solved. Furthermore, by substituting the linear combination into the first-order optimality condition equations derived from the real-time running model, the residual equations characterizing the approximation error are obtained. Furthermore, the weighted integral of the residual equation and each piecewise linear basis function over the energy storage state domain is set to zero, forming the Galerkin projection condition. In conjunction with the convexity constraint, linear inequality constraints are applied to the combination coefficients to ensure that the overall value function is convex. Finally, by solving the system of constrained algebraic equations consisting of the weighted integral being zero and the convexity constraint, the value function combination coefficients that satisfy the consistency between physical laws and mathematical structure are obtained.

[0040] It should be noted that the convexity constraints mentioned above include, but are not limited to, imposing nonnegative constraints on the second-order differences of the combination coefficients at adjacent nodes to ensure the discrete convexity of the value function.

[0041] It should also be noted that the piecewise linear basis function set mentioned above can be understood as a family of structured functions used in this invention to approximate high-dimensional value functions in a finite-dimensional space; The Galerkin approximation mentioned above can be understood as a numerical method in this invention that transforms the continuous optimal control problem into a finite-dimensional algebraic system by using the principle of weighted residual minimization. The aforementioned combination coefficients can be understood as key parameters in this invention that characterize the value function at discrete nodes of energy storage energy state. Their convexity directly determines the economic rationality and physical feasibility of the scheduling strategy.

[0042] The number of interval segments, node distribution density, and linear inequality form of convexity constraints mentioned in this section can be set according to the actual needs of relevant technical personnel and in combination with some existing technologies. This invention does not limit these settings.

[0043] S104. In the offline stage, multiple random scenarios are generated based on the prediction information. The value function approximation results under each scenario are obtained through the Galerkin approximation process. The value function approximation results are then aggregated to obtain the final value function approximation model. In this embodiment of the invention, during the offline phase, multiple random scenarios are generated based on prediction information. The value function approximation results for each scenario are obtained through the Galerkin approximation process, and the value function approximation results are aggregated, including: The Monte Carlo method is used to generate multiple sets of stochastic scenarios based on day-ahead forecast information. Each set of stochastic scenarios contains time-series forecast residual sequences of renewable energy output, load and electricity price. Perform parallel computation for each set of random scenarios; For each moment, iterate backward from the end of the cycle to the beginning. The Galerkin approximation process executed at each time step yields the value function combination coefficients at that time step. After completing calculations for all scenarios, the arithmetic mean of the combined coefficients of the value functions of all scenarios at the same time is taken to obtain the final approximate model of the value function.

[0044] It should be noted that in actual operation, the renewable energy output, load demand and real-time electricity price on which microgrid operation depends all have significant randomness and time-varying characteristics. These uncertainties directly determine the robustness and economy of energy storage dispatch strategies. If the value function is constructed based solely on a single deterministic prediction scenario, it cannot reflect the extreme fluctuations that may occur in the real operating environment.

[0045] For example, if solar power output suddenly drops by 40% at noon on a certain day due to cloud cover, while active load surges by 25% due to high temperatures, and the value function does not take into account such combined disturbance scenarios, then in real-time dispatch, insufficient energy storage reserves may force the purchase of electricity at high prices or the start of high-cost gas turbine units, or even cause local voltage exceedances.

[0046] For example, if wind power output far exceeds forecasts at night and electricity prices are low, but the value function underestimates the benefits of energy storage charging due to overly optimistic training scenarios, then low-cost energy storage opportunities will be missed, leading to limited power supply capacity during peak hours the following day. If only point predictions are used to construct the value function without introducing multi-scenario stochastic modeling, the scheduling strategy's adaptability to future uncertainties will be severely weakened, resulting in increased operating costs or decreased power supply reliability.

[0047] Therefore, it is necessary to generate multiple stochastic scenarios based on the day-ahead forecast information in the offline stage, obtain approximate value function results for each scenario through the Galerkin approximation process, and aggregate the approximate value function results to construct a unified value function model with statistical robustness.

[0048] Optionally, generating multiple stochastic scenarios based on prediction information and aggregating the value function using the Galerkin approximation during the offline phase may include the following operations performed in sequence: First, the Monte Carlo method is used to generate multiple sets of stochastic scenarios based on the predicted values ​​of wind power output, solar power output, active load, reactive load and real-time electricity price in the day-ahead forecast information, combined with their respective historical forecast residual distributions. Each set of stochastic scenarios contains the time-series forecast residual sequence of renewable energy output, load and electricity price within the complete scheduling cycle. Furthermore, an independent computing thread is allocated to each set of random scenarios to perform parallel computing in order to improve offline training efficiency; Furthermore, for each stochastic scenario, we iterate backward from the last scheduling moment of the runtime cycle to the first scheduling moment, recursively constructing a dynamic programming problem moment by moment; Furthermore, at each scheduling moment, the aforementioned Galerkin approximation process is invoked, and the value function at the current moment is projected under convexity constraints using a piecewise linear basis function set to obtain the value function combination coefficients corresponding to that moment. Finally, after completing the full-cycle calculation for all stochastic scenarios, the arithmetic mean of the combined coefficients of the value functions obtained for all scenarios at the same scheduling time is taken to form the aggregated value function parameters at that time, thereby constructing the final approximate value function model covering the entire scheduling cycle.

[0049] It should be noted that the Monte Carlo methods mentioned above include, but are not limited to, Latin hypercube sampling, importance sampling, or conditional random field generation techniques. The number of scenarios can be set according to the actual needs of relevant technical personnel and in combination with some existing technologies. This invention does not limit the number of scenarios.

[0050] It should also be noted that the aforementioned randomness scenario can be understood as a set of representative time series samples used in this invention to characterize the joint uncertainty of renewable energy, load, and electricity price.

[0051] S105, during the real-time operation phase, obtains the current system state, substitutes the current energy storage state into the final approximate value function model, solves the real-time optimization problem containing the value function, and outputs the optimal operating decision at the current moment.

[0052] In this embodiment of the invention, during the real-time operation phase, the current system state is acquired, and the current energy storage state is substituted into the final approximate value function model to solve a real-time optimization problem involving the value function, including: At each decision-making moment, the current system status of the microgrid is collected, including the current battery energy storage capacity, the available power of the wind turbine, the available power of the solar panel, the active load, the reactive load, and the real-time electricity price. Substitute the current battery energy storage capacity into the final approximate value function model; Solve the real-time optimization problem with the goal of summing the current operating cost and the value function at the next time step, and obtain the optimal operating decision at the current time step.

[0053] It should be noted that in order to address the decision-making bias caused by state uncertainty in the real-time dispatch of microgrids, it is necessary to clarify the actual state of the current system operation. That is, the precise values ​​of the current battery energy storage capacity, the available power of the wind turbine, the available power of the solar panel, the active load, the reactive load, and the real-time electricity price should be determined first.

[0054] Once the current system state is confirmed, real-time optimization can be performed based on the approximate model of the final value function. This helps to reasonably address issues such as uncontrollable operating costs or imbalanced resource allocation, and reduces scheduling strategy failures caused by reliance on outdated or simplified state information.

[0055] In some embodiments, a joint mechanism of embedded state acquisition and online optimization can be used to achieve rapid mapping from the current system state to the optimal decision. For example, a convex optimization solver can be used, which takes the current energy storage energy as input, the aggregated value function approximation model as the evaluation core, and includes the output of the gas generator and the power interaction with the grid as control variables. This approach can output the optimal scheduling command that satisfies the operational constraints within milliseconds, while ensuring physical feasibility.

[0056] In practice, it is possible to first implement the synchronous collection of all key state quantities within the microgrid at each scheduling moment. For example, at 10:00 AM on a typical summer workday, the microgrid monitoring system reads that the current battery energy storage capacity is 320 kWh, the available power of the wind turbine is 45 kW, the available power of the solar panel is 180 kW, the active load is 210 kW, the reactive load is 65 kV, and the real-time electricity price is 0.65 yuan per kWh.

[0057] Based on this, the current battery energy storage capacity is further substituted into the final value function approximation model generated in the offline stage. This model is composed of the combination coefficients of piecewise linear basis functions aggregated from each time period, which can accurately reflect the expected operating cost in the future scheduling cycle based on the current energy storage level.

[0058] Building upon this foundation, a real-time optimization problem is further constructed with the sum of the current operating cost and the next time value function as the optimization objective. The current operating cost includes the fuel cost of the gas generator, the cost of wind power curtailment penalty, and the cost of solar power curtailment penalty. The next time value function is obtained by predicting the current energy storage energy through the state transition equation and then querying the approximate model. The optimization variables include battery charging power, battery discharging power, gas generator active power output, active power exchanged with the external power grid, wind generator active power output, solar panel active power output, and reactive power allocation, while strictly satisfying power balance, equipment capacity, and energy storage dynamic constraints.

[0059] Finally, by calling the interior point method or a sequential quadratic programming solver to solve the above real-time optimization problem, the optimal operating decision for the current moment can be determined.

[0060] The aforementioned final value function approximation model can be understood as a robust function expression for online evaluation of future operating costs, formed by combining multi-scenario Galerkin approximation and convexity constraints in this invention. The real-time optimization problem mentioned above can be understood as a two-stage decision-making framework that integrates immediate cost and future cost expectations in this invention, used to generate control instructions that balance economy and security at each scheduling moment.

[0061] The weighting of the curtailment penalty cost, the minimum technical output of the gas generator, and the battery charging and discharging efficiency mentioned in this section can be set according to the actual needs of relevant technical personnel and in combination with some existing technologies. This invention does not limit these settings.

[0062] Example 2, refer to Figure 2 Based on the above embodiments, a specific implementation of a microgrid real-time optimization method based on piecewise linear Galerkin approximation can be designed as follows: First, a real-time operation model of the microgrid is established, with the objective function of minimizing the total expected operating cost: in, Total expected operating cost, For a moment Operating costs For a moment The system status, For the operational decision at time t; Furthermore, based on the real-time operation model, a Bellman equation with the energy storage state as the key variable is constructed: in, Let be the value function, representing the state . The initial minimum residual cost, It is an approximation of the value function. For a moment The state of energy stored in the battery; Furthermore, design a piecewise linear basis function set. ; Furthermore, based on Galerkin theory, a direct analytical approximation of the value function in the Bellman equation is obtained by using a piecewise linear basis function set, thus obtaining an explicit value function mapping relationship. It should be noted that in actual operation, the system state and the approximate mapping relationship of the explicit value function are first obtained through offline fitting, and then the optimization problem is solved in real time to obtain the optimal operation strategy.

[0063] Furthermore, the state variables are represented as: in, To store energy for batteries This refers to the available power of the wind turbine. The available power of the solar panel. For active load, For reactive load, For real-time electricity prices; Furthermore, the decision variables are represented as follows: Among them, subscript and These represent the battery's charging and discharging power, respectively. Indicates a gas generator. Indicates the power exchanged with the external power grid. Indicates wind turbine generator, Indicates solar panels, and These represent active power and reactive power, respectively. Furthermore, the exogenous information variables are: Among them, superscript Indicates the predicted value. and These are the predicted values ​​for wind power and solar power output, respectively. and These are the predicted values ​​for active and reactive loads, respectively. The variable represents the predicted electricity price; variables marked with a triangle represent the residuals corresponding to the predicted values. Exogenous information variables. It characterizes the uncertainty of external inputs to the system.

[0064] Furthermore, the state transition function Describe state variables from Time's up The evolution of time includes, in detail: Battery energy storage state transition: in, Corresponding state variables , and Corresponding decision variables and , and These are the charging and discharging efficiencies of the battery, respectively. Furthermore, other state variable transitions: in, Corresponding state variables [ ], For the predicted value of the corresponding variable, This represents the prediction error for the corresponding variable; Furthermore, the operating cost function Specifically, it is expressed as follows: .

[0065] in, This represents the cost coefficient of the gas generator. These are the curtailment penalty coefficients for wind power and solar power, respectively.

[0066] It should be noted that the energy state range of a battery is divided into... A series of consecutive intervals satisfying: Construct a piecewise linear basis function set based on interval segments. .

[0067] Furthermore, define augmented decision variables. Construct a parameterized set of KKT condition equations , It includes an explicit approximate expression for the value function and KKT conditional constraints; Furthermore, the value function and the optimal decision variables are represented as a linear combination of a set of piecewise linear basis functions: ,in Let be the coefficient to be determined; Furthermore, the linear combination is substituted into the parameterized KKT condition equations derived from the real-time running model. The residual equation is obtained. ; Furthermore, according to Galerkin theory, let the inner product of the residual equation and each piecewise linear basis function be zero: Furthermore, by solving the system of algebraic equations constituting the condition that the inner product is zero, the true coefficients can be obtained. .

[0068] Furthermore, we introduce the convexity constraint of the value function: This is to improve the accuracy of the approximation.

[0069] It should be noted that the offline fitting process (code type) includes: Multiple sets of random scenarios are generated using the Monte Carlo method based on recent forecast information. Furthermore, for each stochastic scenario (which can be computed in parallel); Furthermore, For ; Furthermore, solve for the coefficients of the value function. ; Furthermore, End for; Furthermore, End for; Furthermore, the coefficients from all scenarios are averaged to obtain the final coefficients; It should be noted that the real-time operation process includes: At each decision point during the operating day, obtain the current state of the microgrid. ; Furthermore, the battery energy in the current state Substitute the explicit value function mapping relationship at the corresponding time point ; Furthermore, let's solve the real-time optimization problem: To obtain the optimal operating decision at the current moment. .

[0070] Furthermore, the constraints that real-time optimization problems must satisfy include: Battery energy state transition constraints: ; Battery charge / discharge mutual exclusion constraint: ; Battery energy and power upper and lower limits constraints: ; Generator and renewable energy output constraints: .

[0071] Example 3, referring to Figure 3 This embodiment also provides a microgrid real-time optimization system based on the piecewise linear Galerkin approximation, including: The model building module is used to build a real-time operation model of the microgrid. The real-time operation model is used to describe the relationship between system state, operation decisions and operation costs. The equation building module is used to construct dynamic programming equations with energy storage energy state as the key variable based on the real-time operation model. The dynamic programming equations include a value function representing the future operating costs. The analytical approximation module is used to perform Galerkin approximation on the value function using a piecewise linear basis function set, thereby obtaining an explicit mapping relationship between the value function and the energy storage state. The offline fitting module is used to generate multiple random scenarios based on prediction information in the offline stage, obtain approximate value function results for each scenario through the Galerkin approximation process, and aggregate the approximate value function results to obtain the final approximate value function model. The real-time decision-making module is used to obtain the current system state during the real-time operation phase, substitute the current energy storage state into the final approximate value function model, solve the real-time optimization problem containing the value function, and output the optimal operation decision at the current moment.

[0072] The above-mentioned unit modules can be embedded in the processor of the electronic device in hardware form or independent of it, or they can be stored in the memory of the electronic device in software form, so that the processor can call and execute the corresponding operations of the above modules.

[0073] This embodiment also provides an electronic device, which can be a terminal, and its internal structure diagram can be as follows: Figure 3As shown, the electronic device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage medium. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, carrier networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a real-time microgrid optimization method based on a piecewise linear Galerkin approximation. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad on the device's casing, or an external keyboard, touchpad, or mouse.

[0074] This embodiment also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, it performs the following steps: Establish a real-time operation model for the microgrid. The real-time operation model is used to describe the relationship between system state, operation decisions and operating costs. Based on the real-time operation model, a dynamic programming equation is constructed with the energy storage state as the key variable. The dynamic programming equation includes a value function representing the future operating cost. By using a piecewise linear basis function set to perform the Galerkin approximation on the value function, an explicit mapping relationship between the value function and the energy storage state is obtained. In the offline phase, multiple random scenarios are generated based on the prediction information. The value function approximation results under each scenario are obtained through the Galerkin approximation process. The value function approximation results are then aggregated to obtain the final value function approximation model. During the real-time operation phase, the current system state is obtained, the current energy storage state is substituted into the final approximate value function model, the real-time optimization problem containing the value function is solved, and the optimal operation decision at the current moment is output.

[0075] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

[0076] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.

[0077] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.

Claims

1. A real-time optimization method for microgrids based on the piecewise linear Galerkin approximation, characterized in that, include: A real-time operation model for the microgrid is established, which is used to describe the relationship between system state, operation decisions and operation costs. Based on the real-time operation model, a dynamic programming equation is constructed with the energy storage state as the key variable. The dynamic programming equation includes a value function representing the future operating cost. By using a piecewise linear basis function set to perform the Galerkin approximation on the value function, an explicit mapping relationship between the value function and the energy storage state is obtained. In the offline phase, multiple random scenarios are generated based on the prediction information. The value function approximation results under each scenario are obtained through the Galerkin approximation process. The value function approximation results are then aggregated to obtain the final value function approximation model. During the real-time operation phase, the current system state is obtained, the current energy storage state is substituted into the final approximate value function model, the real-time optimization problem containing the value function is solved, and the optimal operation decision at the current moment is output.

2. The microgrid real-time optimization method based on piecewise linear Galerkin approximation as described in claim 1, characterized in that, The real-time operation model for establishing the microgrid includes: Define state variables, which include battery energy storage, wind turbine available power, solar panel available power, active load, reactive load, and real-time electricity price; Define decision variables, including battery charging power, battery discharging power, active power output of gas generator, active power exchanged with external power grid, active power output of wind turbine, active power output of solar panel, and reactive power allocation. Define exogenous information variables, which include wind power output forecast, solar power output forecast, active load forecast, reactive load forecast, real-time electricity price forecast, and their respective forecast residuals; Define a state transition function, which includes the battery energy storage state transition equation and other state variable transition equations; Define an operating cost function, which includes the operating cost of gas generators, the cost of wind power curtailment, and the cost of solar power curtailment.

3. The microgrid real-time optimization method based on piecewise linear Galerkin approximation as described in claim 2, characterized in that, The Galerkin approximation of the value function using a piecewise linear basis function set includes: The range of values ​​for the energy storage state is divided into multiple continuous intervals; Construct a piecewise linear basis function set based on the interval segment; The value function is represented as a linear combination of the piecewise linear basis function set; Substituting the linear combination into the first-order optimality condition equations derived from the real-time operation model, we obtain the residual equations. Set the weighted integral of the residual equation and each piecewise linear basis function over the energy storage energy state domain to zero; Solve the system of algebraic equations based on the condition that the weighted integral is zero to obtain the combination coefficients of the value function.

4. The microgrid real-time optimization method based on piecewise linear Galerkin approximation as described in claim 3, characterized in that, When solving the system of algebraic equations, a convexity constraint is imposed on the value function. This convexity constraint is achieved by imposing a linear inequality constraint on the combination coefficients corresponding to the value function.

5. The microgrid real-time optimization method based on piecewise linear Galerkin approximation as described in claim 4, characterized in that, In the offline phase, multiple random scenarios are generated based on prediction information. The Galerkin approximation process is used to obtain approximate value function results for each scenario, and these approximation results are aggregated, including: The Monte Carlo method is used to generate multiple sets of stochastic scenarios based on day-ahead forecast information. Each set of stochastic scenarios contains time-series forecast residual sequences of renewable energy output, load and electricity price. Perform parallel computation for each set of random scenarios; For each moment, iterate backward from the end of the cycle to the beginning. At each time step, the Galerkin approximation process is executed to obtain the value function combination coefficients at that time step. After completing calculations for all scenarios, the arithmetic mean of the combined coefficients of the value functions of all scenarios at the same time is taken to obtain the final approximate model of the value function.

6. The microgrid real-time optimization method based on piecewise linear Galerkin approximation as described in claim 5, characterized in that, During the real-time operation phase, the current system state is obtained, and the current energy storage state is substituted into the final approximate value function model to solve a real-time optimization problem containing the value function, including: At each decision-making moment, the current system status of the microgrid is collected, including the current battery energy storage capacity, the available power of the wind turbine, the available power of the solar panel, the active load, the reactive load, and the real-time electricity price. Substitute the current battery energy storage capacity into the final approximate value function model; Solve the real-time optimization problem with the goal of summing the current operating cost and the value function at the next time step, and obtain the optimal operating decision at the current time step.

7. The microgrid real-time optimization method based on piecewise linear Galerkin approximation as described in claim 6, characterized in that, The dynamic programming equations are Bellman equations.

8. A real-time optimization system for microgrids based on the piecewise linear Galerkin approximation, employing the method described in any one of claims 1 to 7, characterized in that, include: The model building module is used to build a real-time operation model of the microgrid, which describes the relationship between system state, operation decisions and operation costs. The equation construction module is used to construct a dynamic programming equation with the energy storage state as the key variable based on the real-time operation model. The dynamic programming equation includes a value function representing the future operating cost. The analytical approximation module is used to perform Galerkin approximation on the value function using a piecewise linear basis function set, so as to obtain an explicit mapping relationship of the value function with respect to the energy storage state. The offline fitting module is used to generate multiple random scenarios based on prediction information in the offline stage, obtain the approximate value function results under each scenario through the Galerkin approximation process, and aggregate the approximate value function results to obtain the final approximate value function model. The real-time decision-making module is used to obtain the current system state during the real-time operation phase, substitute the current energy storage state into the final value function approximation model, solve the real-time optimization problem containing the value function, and output the optimal operation decision at the current moment.

9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the real-time optimization method for microgrids based on the piecewise linear Galerkin approximation according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the real-time optimization method for microgrids based on the piecewise linear Galerkin approximation according to any one of claims 1 to 7.