Method, system, device and medium for double-layer stochastic optimization operation of electric-hydrogen coupling system

By constructing a two-layer stochastic optimization operation method for the electro-hydrogen coupling system, and utilizing an improved particle swarm optimization algorithm and mixed integer linear programming, the optimization scheduling problem of the electro-hydrogen coupling system under multiple uncertainties is solved, achieving synergistic optimization of economy and stability, and improving the system's operating efficiency and reliability.

CN121965581BActive Publication Date: 2026-07-21STATE GRID JIANGSU ELECTRIC POWER CO LTD RESEARCH INSTITUTE +2
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
STATE GRID JIANGSU ELECTRIC POWER CO LTD RESEARCH INSTITUTE
Filing Date
2026-04-02
Publication Date
2026-07-21

AI Technical Summary

Technical Problem

Existing electric-hydrogen coupling systems struggle to achieve optimal scheduling that balances economic efficiency and stability when faced with multiple uncertainties such as the randomness of renewable energy output, electricity price fluctuations, and load changes. Traditional optimization algorithms are prone to getting trapped in local optima and fail to effectively coordinate global strategies.

Method used

A two-layer stochastic optimization operation method for an electro-hydrogen coupling system is constructed. By acquiring multi-source historical operation data, a linear model and a flexible load response model are established. An improved particle swarm optimization algorithm and mixed integer linear programming are adopted to form an iterative optimization framework between the upper and lower layers, realizing global strategy search and multi-scenario scheduling.

Benefits of technology

Under conditions of uncertain renewable energy output and load demand, the system achieves dual optimization of economic efficiency and stability, reducing operating costs and improving dispatch efficiency and system reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121965581B_ABST
    Figure CN121965581B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of power system automation, and more particularly to a method, system, device and medium for double-layer stochastic optimization operation of an electricity-hydrogen coupling system, the method comprising: obtaining and processing multi-source historical operation data to construct an input data set of the electricity-hydrogen coupling system; establishing a linear operation model to form a mathematical model of the electricity-hydrogen coupling system; establishing a flexible load response model based on a power price signal, defining user-side power adjustment and response coefficients, and constructing a power price-load linear mapping relationship to depict demand response behavior; constructing a double-layer stochastic optimization framework for the target, the upper layer being responsible for global power and response strategy optimization, and the lower layer being responsible for multi-scenario operation scheduling and feedback to form a closed loop; the upper layer uses an improved particle swarm algorithm to introduce a dynamic inertia weight to realize global strategy search, the lower layer converts the scheduling problem into a mixed integer linear programming (MILP) model and solves it in parallel, and the upper and lower layers are iteratively optimized through expected cost and energy deviation feedback to obtain an optimal operation strategy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of power system automation technology, and in particular to a two-layer stochastic optimization operation method, system, equipment and medium for an electro-hydrogen coupling system. Background Technology

[0002] With the large-scale integration of renewable energy, the volatility and uncertainty of power systems have increased significantly. Traditional single-energy systems are struggling to meet the demands of high-proportion energy consumption in terms of regulation capacity and spatiotemporal energy coordination. Hydrogen energy, as a high-density energy storage carrier of renewable energy, can achieve flexible conversion between electrical and chemical energy, providing the power system with cross-period energy buffering and backup capabilities. Electro-hydrogen coupling systems, by combining hydrogen electrolysis, hydrogen storage, and fuel cell power generation, form a closed-loop "electricity-hydrogen-electricity" structure, which can play an important role in peak shaving, valley filling, energy storage frequency regulation, and multi-energy complementarity. However, the operation of electro-hydrogen systems is affected by multiple uncertainties such as the randomness of renewable energy output, electricity price fluctuations, and load changes, making the optimal scheduling problem between economic efficiency and stability increasingly complex.

[0003] On the other hand, user-side demand response (DR) provides a new and flexible adjustment tool for system operation optimization. By guiding users to adjust their electricity consumption behavior through price signals, load reduction and energy transfer can be achieved during high load or peak electricity price periods, improving the system's flexibility and economy. However, the effectiveness of demand response is greatly affected by user response characteristics, electricity pricing mechanisms, and time dynamics, and needs to be optimized in conjunction with the operating strategy of the hydrogen-electric system to fully realize its potential.

[0004] Existing research often employs single-layer or deterministic optimization methods, making operational decisions only under fixed electricity prices or known load conditions, failing to effectively consider the coupling relationships under the randomness of multiple scenarios. Traditional optimization algorithms are prone to getting trapped in local optima when dealing with complex, nonlinear, and multi-constraint electric-hydrogen systems, making it difficult to achieve global coordination.

[0005] The information disclosed in this background section is intended only to enhance the understanding of the general background of the invention and should not be construed as an admission or in any way implying that the information constitutes prior art known to those skilled in the art. Summary of the Invention

[0006] This invention provides a two-layer stochastic optimization operation method, system, equipment, and medium for an electro-hydrogen coupling system, thereby effectively solving the problems in the background art.

[0007] To achieve the above objectives, the technical solution adopted by this invention is: a two-layer stochastic optimization operation method for an electro-hydrogen coupling system, comprising the following steps: Acquire and preprocess multi-source historical operating data from the power side, hydrogen energy side, and external environment to construct the input dataset for the electric-hydrogen coupling system; Establish a linearized operation model for the electrolyzer, fuel cell, energy storage system, hydrogen storage device and load, and form a mathematical model of the electro-hydrogen coupling system that satisfies energy conservation and equipment constraints; A flexible load response model is established based on electricity price signals. User-side power adjustment and response coefficient are defined, and a linear mapping relationship between electricity price and load is constructed to characterize demand response behavior. A two-layer stochastic optimization framework is constructed with the goal of minimizing the expected operating cost of the system. The upper layer is responsible for global power and response strategy optimization, while the lower layer is responsible for multi-scenario operation scheduling and feedback of results to form a closed loop. The two-layer stochastic optimization framework employs an improved particle swarm optimization algorithm to introduce dynamic inertia weights in the upper layer to achieve global policy search, while the lower layer transforms the scheduling problem into a mixed integer linear programming (MILP) model for parallel solution. Iterative optimization between the upper and lower layers is achieved through feedback of expected cost and energy deviation to obtain the optimal operating strategy of the system.

[0008] Furthermore, the acquisition and preprocessing of multi-source historical operating data from the power side, hydrogen energy side, and external environment are used to construct the input data centralization of the electric-hydrogen coupling system. The data on the power side includes the load power curve P of the distribution network. L (t), real-time electricity price λ(t), renewable energy output photovoltaic P V (t), and the operating status parameter S of the energy storage device ES (t); The data from the hydrogen energy side includes the electrolyzer power P. el (t) and efficiency characteristics Rated capacity of hydrogen storage device (w) H Fuel cell rated power P fc_max and conversion efficiency ; The data from the external environment includes user-side response participation data P. dr (t); Historical data is selected from continuous operation data of the past year as the sample basis, covering typical seasons and operation modes. The optimization calculation uses a one-week rolling window to periodically update the system, and the time resolution is uniformly set to a 1-hour step. In the data preprocessing stage, the raw data is time-aligned, outliers are removed, and units are standardized. Statistical sampling and clustering methods are used to analyze photovoltaic output, electricity price fluctuations, and load changes to generate representative operating samples for subsequent random optimization input.

[0009] Furthermore, the establishment of a linearized operation model for the electrolyzer, fuel cell, energy storage system, hydrogen storage device, and load, forming a mathematical model of the electro-hydrogen coupling system that satisfies energy conservation and equipment constraints, includes: The operating status of a hydrogen storage device is described by the hydrogen mass balance equation: ; In the formula, the mass of hydrogen in the hydrogen storage tank Based on the hydrogen storage at the previous moment Hydrogen mass flow rate input to the hydrogen production process Hydrogen mass flow rate consumed by fuel cells Joint decision; To improve hydrogen storage and charging efficiency, For hydrogen storage and dehydrogenation efficiency; Hydrogen storage processes are limited by capacity and power constraints: ; ;; ; ; In the formula, , Let represent the hydrogen charging and discharging state variables of the hydrogen storage device during time period t, respectively. These are 0-1 variables, and the charging and discharging processes occur mutually exclusively within the same time period. This indicates the mass of hydrogen in the hydrogen storage tank of the hydrogen storage system; To reflect the long-term energy migration characteristics of seasonal hydrogen storage, the hydrogen storage system needs to adopt an annual closed-loop configuration: ; In the formula, and The hydrogen storage quality of the hydrogen storage equipment at the end of the year and the beginning of the year are respectively; The relationship between power consumption and hydrogen production in a proton exchange membrane electrolyzer (PEM) is shown below: ; in The quality of hydrogen produced by the electrolyzer; Input electrical power to the electrolytic cell; The proportionality coefficient for converting power into hydrogen production; The operating power constraint of the electrolytic cell is: ; in, This is a binary variable representing the state of the electrolytic cell. It is 1 when the electrolytic cell is in the active state, and its operating power must be between the minimum starting power and the rated power. It is 0 when the electrolytic cell is closed, and the power is forced to zero. Indicates the minimum operating ratio coefficient of the electrolytic cell; Indicates the hydrogen production of the electrolyzer; This indicates the actual operating power of the electrolytic cell during time period t; The power constraint of the fuel cell is: ; in, This refers to the output power of the fuel cell; Fuel cell rated power; Indicates the length of each scheduling period; Hydrogen consumption - power relationship: ; In the formula, The mass of hydrogen consumed by the fuel cell; For fuel cell efficiency; Battery energy storage devices are used in power distribution systems to achieve energy timing balance and demand response auxiliary regulation. Their operating characteristics are jointly determined by energy balance, power constraints, state of charge constraints, and initial and final state conditions. ; This formula describes the energy change of an energy storage battery over time period t, based on the energy stored at the previous time step. The current charging and discharging power together determine the total power; among which and These represent charging and discharging efficiencies, respectively. and These are the charging and discharging powers, respectively. Energy and power constraints limit energy storage The rated capacity shall not be exceeded. And ensure that the charging and discharging processes are mutually exclusive within the same time period; ; ; ; ; in, and These are the charging and discharging powers, respectively. and These are two variables representing the battery's charge / discharge state; This indicates the maximum charging power of the energy storage battery; This indicates the maximum discharge power of the energy storage battery; State of Charge (SOC) Constraints: By normalizing the energy, the SOC is defined. s,t And set upper and lower limits to ensure that the battery operates within a safe operating range: ; ; In the formula, , These are the minimum and maximum values ​​of the state of charge, respectively; This represents the current stored energy of the energy storage battery in time period t under scenario s; Indicates the rated maximum capacity of the energy storage battery; Photovoltaic power generation capacity is: ; In the formula, the photovoltaic power generation is The rated power of photovoltaic power generation is .

[0010] Furthermore, the establishment of a flexible load response model based on electricity price signals, defining user-side power adjustment and response coefficients, and constructing a linear mapping relationship between electricity price and load to characterize demand response behavior includes: By combining price incentive signals with system operational deviation information, a comprehensive demand response signal is generated: ; In the formula, Basic electricity price, This indicates the power imbalance in the system. The rate of change of system operating costs. , This is the signal conditioning coefficient, which comprehensively reflects the system load level, electricity price fluctuations and economic operating constraints, and serves as a trigger variable for user-side and equipment-side responses; Based on the integrated signal on the load side It autonomously adjusts power demand to form a linear response relationship: ; in, This is the baseline load power when not participating in the response. The load response coefficient reflects the user's sensitivity to price changes; The response power is expressed as: ; When electricity prices rise or system load is high, users automatically reduce their electricity demand; when electricity prices fall, the load rebounds, thus achieving peak shaving and valley filling and load balancing. At the system level, the total response power Allocation is based on equipment flexibility and response time: ; in, The proportion of response power undertaken by the battery energy storage device; This is the response component achieved by adjusting the hydrogen charging power of the electrolyzer; Adjustable load power; The demand response constraints are as follows: ; in, Maximum responsive load in the current period Interruptible load; The allocation rule is solved under equipment constraints and system power balance conditions to minimize the total system operating cost and response deviation. ; in, Operating costs; Weights for response accuracy; and These are the target response power and the actual response power, respectively.

[0011] Furthermore, the construction of a two-layer stochastic optimization framework aimed at minimizing the expected operating cost of the system, with the upper layer responsible for global power and response strategy optimization and the lower layer responsible for multi-scenario operation scheduling and feedback of results to form a closed loop, includes: The upper-level model aims to minimize the overall system operating cost. Under the constraints of electricity price fluctuations, uncertainties in renewable energy output, and demand response behavior, it optimizes the power allocation and operation strategies of each adjustable unit. ; in, Cost of purchasing or selling electricity; Cost of energy storage charging and discharging; Energy consumption cost for hydrogen production via electrolysis; Costs of load adjustment caused by demand response; This indicates the current energy storage capacity or hydrogen storage amount of a hydrogen storage device or energy storage equipment at a certain time period. Upper-level decision variables include: ; in, Adjustable load power; The constraints of the upper-level model include: system energy conservation constraints, equipment operating limit constraints, energy balance constraints between energy storage and hydrogen storage, electricity price and operating cost range constraints, demand response constraints, equipment operating limit constraints, including the operating range restrictions of electrolyzers, fuel cells, hydrogen storage, energy storage and photovoltaic equipment, energy balance constraints between energy storage and hydrogen storage, and demand response constraints. The system's energy conservation constraint ensures that the system's power supply and demand are balanced across different time periods. ; In the formula, This represents the output power of the fuel cell during time period t; The constraints between electricity prices and operating costs are: ; ; In the formula, , These represent the minimum and maximum electricity prices, respectively. By setting upper and lower limits on electricity prices and constraining electricity purchase costs, we can ensure that strategy optimization is feasible within the market price range. The lower-level model, under the power strategy and response parameters given by the upper level, considers uncertainties such as renewable energy output fluctuations and random load disturbances to solve the actual operation and scheduling of the system. The objective is to minimize the expected energy deviation and operational losses. ; in, Let s be the probability of scenario s occurring. This is a penalty for system energy loss or power curtailment; , These are weighting coefficients used to balance economic efficiency and stability; The lower-level constraints include: hydrogen energy balance, energy storage SOC and power constraints, operating limits of electrolyzers and fuel cells, feasible demand response domain within the scenario, hydrogen energy balance, SOC and power constraints, operating limits of electrolyzers and fuel cells, and demand response constraints. The power balance is: ; in, In order to purchase electricity for grid connection, This refers to the power output for electricity sales. Electricity price ranges and grid transactions are mutually exclusive, ensuring that buying and selling will not occur simultaneously in the same time period; M is a sufficiently large constant. ; ; ; ; ; in, , The two variables are mutually exclusive: grid-connected power purchase and power sales. The upper and lower layer models achieve iterative optimization through a two-way feedback mechanism between the expected cost function and the scenario operation results. This interaction process aims to dynamically coordinate the global strategy and local operation of the electro-hydrogen coupling system under uncertain conditions in multiple scenarios, forming an optimization closed loop with adaptive learning capabilities. The decision variables passed from the upper layer to the lower layer are the results calculated by the upper layer, including electrolyzer power, energy storage power allocation, grid trading strategy, demand response weight coefficient, electricity price signal sequence and flexible load adjustment ratio. These variables constitute the strategy constraint boundary and guiding parameters of the lower layer stochastic optimization, which determine the search space and economic priority of scenario scheduling. The lower layer feeds back the operational results to the upper layer: Based on data from various scenarios, including renewable energy output, load demand, and electricity price fluctuations, the lower layer optimizes scheduling and returns a set of scenario operational results. ,in This indicates the mass of hydrogen in the hydrogen storage tank.

[0012] Furthermore, the upper layer employs an improved particle swarm optimization algorithm to introduce dynamic inertia weights for global policy search, while the lower layer transforms the scheduling problem into a mixed-integer linear programming (MILP) model for parallel solution. Iterative optimization between the upper and lower layers is achieved through feedback of expected cost and energy deviation to obtain the optimal system operation strategy, including: The upper layer uses the improved particle swarm optimization algorithm IPSO for global search. The algorithm represents candidate running strategies in the form of individual particles and evaluates the economy and energy balance characteristics of the current strategy through the fitness function. The objective function to be optimized is: ; in, Let be the probability of scenario s occurring. The operating cost of the lower layer in scenario s, , These are energy and power deviations, respectively. , For penalty weighting; To balance the algorithm's global search capability with local convergence accuracy, a strategy of adjusting linearly decreasing inertia weights and nonlinear learning factors is adopted. The particle velocity and position update formulas are as follows: ; in, As the number of iterations decreases, The inertia weight represents the current iteration algebra. This represents the initial maximum inertia weight. This represents the minimum inertia weight. Indicates the current iteration number. Indicates the maximum number of iterations; , These represent the velocities of particle i in the kth and k+1th generations, respectively. and Represents a random number between 0 and 1; This represents the historical best position of particle i; , These represent the positions of particle i in the kth and (k+1)th generations, respectively. Indicates the globally optimal position; Learning factor , Dynamically adjust based on error trend: ; In the formula, and Let c1 represent the minimum and maximum values ​​of the individual cognitive factor c1, respectively. and Let c and d represent the minimum and maximum values ​​of the social learning factor c2, respectively. This represents the learning factor adjustment speed coefficient. and It represents the global optimal fitness of the previous generation and the current generation; the balance between exploration and utilization is dynamically adjusted through error feedback. Algorithm iterates until satisfied Terminates upon reaching the optimal policy parameter. ; in, This represents the expected change in cost during the current iteration. Indicates the cost convergence threshold. Indicates energy deviation. Indicates the energy convergence threshold; This indicates the optimized electrolytic cell power. This indicates the optimized energy storage charging and discharging power. This represents the optimized demand response electricity price signal. This represents the optimized load response weighting coefficient; it serves as input for lower-level operation scheduling and system execution. Under the constraints of power allocation and electricity pricing strategies passed from the upper layer, the lower-level model solves each typical scenario independently to obtain the optimal operating state and expected operating cost of the hydrogen-electric system. The lower-level model is transformed into a mixed integer linear programming (MILP) problem for solution. To eliminate nonlinearity and logically mutually exclusive relationships in the model, linearization and discretization are employed: Introducing 0 / 1 state variables , , , These represent the mutually exclusive states of energy storage charging / discharging and power purchase / sale, respectively. A piecewise linear approximation is used for the partial load efficiency of the electrolyzer and fuel cell; The slack variable linearization method is used for absolute value and complementary constraints; Preserve the linear form of all energy and power balance constraints; After linearization, the original problem can be uniformly expressed as: ; ; ; Where x represents continuous power and energy variables, and z represents equipment operating state variables; The lower layer receives reference values ​​passed from the upper layer as boundary conditions for model constraints, and generates multi-scenario constraint matrices based on scenario-specific input data. And independently build MILP sub-models for each scenario; Each scene sub-model was solved in parallel using the commercial Gurobi solver to obtain the optimal solution set. And calculate the expected operating cost. The results are then fed back to the upper-level model for policy correction.

[0013] The present invention also includes a two-layer stochastic optimization operating system for an electro-hydrogen coupling system, using the method described above, wherein the system comprises: The acquisition unit is used to acquire and preprocess multi-source historical operating data from the power side, hydrogen energy side, and external environment to construct the input dataset of the electric-hydrogen coupling system. The modeling unit is used to establish a linearized operation model of the electrolyzer, fuel cell, energy storage system, hydrogen storage device and load, forming a mathematical model of the electro-hydrogen coupling system that satisfies energy conservation and equipment constraints; The response characterization unit is used to establish a flexible load response model based on electricity price signals, define the user-side power adjustment amount and response coefficient, and construct a linear mapping relationship between electricity price and load to characterize demand response behavior. The two-layer optimization unit is used to construct a two-layer stochastic optimization framework with the goal of minimizing the expected operating cost of the system. The upper layer is responsible for global power and response strategy optimization, while the lower layer is responsible for multi-scenario operation scheduling and feedback of results to form a closed loop. The solution unit is used in the two-layer stochastic optimization framework. The upper layer adopts an improved particle swarm optimization algorithm to introduce dynamic inertia weights to realize global policy search, while the lower layer transforms the scheduling problem into a mixed integer linear programming (MILP) model for parallel solution. Iterative optimization between the upper and lower layers is achieved through feedback of expected cost and energy deviation to obtain the optimal operating strategy of the system.

[0014] The present invention also includes a computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the method as described above.

[0015] The present invention also includes a storage medium having a computer program stored thereon, which, when executed by a processor, implements the method as described above.

[0016] The beneficial effects of this invention are as follows: By introducing a demand response mechanism and an improved particle swarm optimization algorithm, a two-layer stochastic optimization framework for the electric-hydrogen coupled system is constructed, achieving a synergistic unity between global strategy optimization and precise scheduling across multiple scenarios. The improved particle swarm optimization algorithm in the upper layer adopts dynamic inertial weights, improving global search capability and convergence accuracy; the lower layer transforms the operational problem into a mixed-integer linear programming model, achieving precise solutions to equipment operating constraints. Through feedback iteration of expected cost and energy deviation between the upper and lower layers, the system can achieve dual optimization of economy and stability under uncertain conditions of renewable energy output and load demand. Compared with traditional methods, this invention has significant advantages in reducing operating costs, improving scheduling efficiency, and enhancing system reliability, and is suitable for real-time optimization and engineering deployment of electric-hydrogen combined energy systems. Attached Figure Description

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

[0018] Figure 1 This is a flowchart of the method of the present invention; Figure 2 This is a schematic diagram of the system structure of the present invention; Figure 3 This is a schematic diagram of the structure of the computer device of the present invention. Detailed Implementation

[0019] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.

[0020] like Figure 1 As shown: A two-layer stochastic optimization method for an electro-hydrogen coupling system includes the following steps: Acquire and preprocess multi-source historical operating data from the power side, hydrogen energy side, and external environment to construct the input dataset for the electric-hydrogen coupling system; Establish a linearized operation model for the electrolyzer, fuel cell, energy storage system, hydrogen storage device and load, and form a mathematical model of the electro-hydrogen coupling system that satisfies energy conservation and equipment constraints; A flexible load response model is established based on electricity price signals. User-side power adjustment and response coefficient are defined, and a linear mapping relationship between electricity price and load is constructed to characterize demand response behavior. A two-layer stochastic optimization framework is constructed with the goal of minimizing the expected operating cost of the system. The upper layer is responsible for global power and response strategy optimization, while the lower layer is responsible for multi-scenario operation scheduling and feedback of results to form a closed loop. The two-layer stochastic optimization framework employs an improved particle swarm optimization algorithm to introduce dynamic inertia weights in the upper layer to achieve global policy search, while the lower layer transforms the scheduling problem into a mixed integer linear programming (MILP) model for parallel solution. Iterative optimization between the upper and lower layers is achieved through feedback of expected cost and energy deviation to obtain the optimal operating strategy of the system.

[0021] In this embodiment, multi-source historical operating data from the power supply side, hydrogen energy side, and external environment are acquired and preprocessed to construct the input data centralization of the electric-hydrogen coupling system. The data on the power side includes the load power curve P of the distribution network. L (t), real-time electricity price λ(t), renewable energy output photovoltaic P V (t), and the operating status parameter S of the energy storage device ES (t); Data from the hydrogen energy side includes electrolyzer power P. el (t) and efficiency characteristics Rated capacity of hydrogen storage device (w) H Fuel cell rated power P fc_max and conversion efficiency ; External environment data includes user-side response participation data P dr (t); To ensure the sufficiency of statistical analysis and the real-time nature of optimization decisions, historical data is selected from continuous operation data of the past year as the sample basis, covering typical seasons and operation modes. The optimization calculation uses a one-week rolling window to periodically update the system, and the time resolution is uniformly set to a 1-hour step to balance operation accuracy and computational efficiency. In the data preprocessing stage, the raw data undergoes time alignment, outlier removal, and unit standardization. Statistical sampling and clustering methods are used to analyze photovoltaic output, electricity price fluctuations, and load changes, generating representative operating samples for subsequent random optimization input. Through these steps, the constructed input dataset comprehensively characterizes the system's long-term trends and short-term fluctuations, providing reliable data support for subsequent electric-hydrogen system modeling and demand response optimization.

[0022] This step provides the data foundation for the operation of the electro-hydrogen coupling system and is the starting point of the entire operation method. By collecting, processing, and organizing multi-source operational data from the power supply side, the hydrogen energy side, and the external environment, the system's operating status and requirements are assessed.

[0023] This includes establishing a linearized operation model for the electrolyzer, fuel cell, energy storage system, hydrogen storage device, and load, forming a mathematical model of the electro-hydrogen coupling system that satisfies energy conservation and equipment constraints, including: The system includes components such as an electrolyzer, hydrogen storage device, fuel cell, energy storage device, adjustable load, and photovoltaic power generation, forming a two-way coupling structure of electrical energy and hydrogen energy.

[0024] Hydrogen storage devices, as key energy buffer units in electro-hydrogen coupling systems, are used to achieve temporal energy balance between hydrogen production in electrolyzers and hydrogen release in fuel cells. The operating state of hydrogen storage devices is described by the hydrogen mass balance equation: ; In the formula, the mass of hydrogen in the hydrogen storage tank Based on the hydrogen storage at the previous moment Hydrogen mass flow rate input to the hydrogen production process Hydrogen mass flow rate consumed by fuel cells Joint decision; To improve hydrogen storage and charging efficiency, For hydrogen storage and dehydrogenation efficiency; Hydrogen storage processes are limited by capacity and power constraints: ; ;; ; ; In the formula, , Let represent the hydrogen charging and discharging state variables of the hydrogen storage device during time period t, respectively. These are 0-1 variables, and the charging and discharging processes occur mutually exclusively within the same time period. This indicates the mass of hydrogen in the hydrogen storage tank of the hydrogen storage system; To reflect the long-term energy migration characteristics of seasonal hydrogen storage, the hydrogen storage system needs to adopt an annual closed-loop configuration: ; In the formula, and The hydrogen storage quality of the hydrogen storage equipment at the end of the year and the beginning of the year are respectively; The system ensures real-time operational feasibility of the hydrogen storage system at the hourly scheduling level and guarantees system energy closed-loop at the annual or quarterly scale. This hierarchical modeling approach reflects both the dynamic response characteristics of the hydrogen storage device and the long-term energy migration characteristics of seasonal hydrogen storage, serving as the foundational model for multi-timescale operational optimization and demand response control of the electro-hydrogen coupling system.

[0025] The relationship between power consumption and hydrogen production in a proton exchange membrane electrolyzer (PEM) is shown below: ; in The quality of hydrogen produced by the electrolyzer; Input electrical power to the electrolytic cell; The proportionality coefficient for converting power into hydrogen production; The operating power constraint of the electrolytic cell is: ; in, This is a binary variable representing the state of the electrolytic cell. It is 1 when the electrolytic cell is in the active state, and its operating power must be between the minimum starting power and the rated power. It is 0 when the electrolytic cell is closed, and the power is forced to zero. Indicates the minimum operating ratio coefficient of the electrolytic cell; Indicates the hydrogen production of the electrolyzer; This indicates the actual operating power of the electrolytic cell during time period t; The power constraint of the fuel cell is: ; in, This refers to the output power of the fuel cell; Fuel cell rated power; Hydrogen consumption - power relationship: ; In the formula, The mass of hydrogen consumed by the fuel cell; For fuel cell efficiency; Battery energy storage devices are used in power distribution systems to achieve energy timing balance and demand response auxiliary regulation. Their operating characteristics are jointly determined by energy balance, power constraints, state of charge constraints, and initial and final state conditions. ; This formula describes the energy change of an energy storage battery over time period t, based on the energy stored at the previous time step. The current charging and discharging power together determine the total power; among which and These represent charging and discharging efficiencies, respectively. and These are the charging and discharging powers, respectively. Energy and power constraints limit energy storage The rated capacity shall not be exceeded. And ensure that the charging and discharging processes are mutually exclusive within the same time period; ; ; ; ; in, and These are the charging and discharging powers, and These are two variables representing the battery's charge / discharge state; This indicates the maximum charging power of the energy storage battery; This indicates the maximum discharge power of the energy storage battery; State of Charge (SOC) Constraints: By normalizing the energy, the SOC is defined. s,t And set upper and lower limits to ensure that the battery operates within a safe operating range: ; ; In the formula, , These are the minimum and maximum values ​​of the state of charge, respectively; This represents the current stored energy of the energy storage battery in time period t under scenario s; Indicates the rated maximum capacity of the energy storage battery; Photovoltaic power generation capacity is: ; In the formula, the photovoltaic power generation is The rated power of photovoltaic power generation is .

[0026] This step is used to establish the electro-hydrogen energy conversion relationship and clarify the interaction mode between the internal adjustable unit and external signals.

[0027] As a preferred embodiment of the above, a flexible load response model is established based on the electricity price signal, defining the user-side power adjustment amount and response coefficient, and constructing a linear mapping relationship between electricity price and load to characterize demand response behavior, including: The price incentive signal output by the upper-level strategy optimization module and the system operation deviation information are combined to form a comprehensive demand response signal: ; In the formula, Basic electricity price, This indicates the power imbalance in the system. The rate of change of system operating costs. , This is the signal conditioning coefficient, which comprehensively reflects the system load level, electricity price fluctuations and economic operating constraints, and serves as a trigger variable for user-side and equipment-side responses; Based on the integrated signal on the load side It autonomously adjusts power demand to form a linear response relationship: ; in, This is the baseline load power when not participating in the response. The load response coefficient reflects the user's sensitivity to price changes; The response power is expressed as: ; When electricity prices rise or system load is high, users automatically reduce their electricity demand; when electricity prices fall, the load rebounds, thus achieving peak shaving and valley filling and load balancing. At the system level, the total response power Allocation is based on equipment flexibility and response time: ; in, The proportion of response power undertaken by the battery energy storage device; This is the response component achieved by adjusting the hydrogen charging power of the electrolyzer; Adjustable load power; The demand response constraints are as follows: ; in, Maximum responsive load in the current period Interruptible load; The allocation rule is solved under equipment constraints and system power balance conditions to minimize the total system operating cost and response deviation. ; in, Operating costs; Weights for response accuracy; and These are the target response power and the actual response power, respectively.

[0028] This step establishes a multi-level demand response mechanism in the electro-hydrogen coupling system, enabling the load side to adaptively adjust to electricity price signals and system operating status, thereby balancing power supply and demand and improving the system's economy and flexibility. By establishing this demand response mechanism, coordinated regulation among the load side, energy storage side, and electrolyzer can be achieved, providing adjustable power space and operational feedback data for optimizing upper-level operating strategies. Subsequent steps will construct a two-level stochastic optimization operating model based on this response characteristic, achieving dynamic coupling between strategy optimization and operational scheduling.

[0029] In this embodiment, a two-layer stochastic optimization framework is constructed with the goal of minimizing the expected operating cost of the system. The upper layer is responsible for global power and response strategy optimization, while the lower layer is responsible for multi-scenario operation scheduling and feedback of results to form a closed loop, including: The upper-level model aims to minimize the overall system operating cost. Under the constraints of electricity price fluctuations, uncertainties in renewable energy output, and demand response behavior, it optimizes the power allocation and operation strategies of each adjustable unit. ; in, Cost of purchasing or selling electricity; Cost of energy storage charging and discharging; Energy consumption cost for hydrogen production via electrolysis; Costs of load adjustment caused by demand response; This indicates the current energy storage capacity or hydrogen storage amount of a hydrogen storage device or energy storage equipment at a certain time period. Upper-level decision variables include: ; in, Adjustable load power; The constraints of the upper-level model include: system energy conservation constraints, equipment operating limit constraints, energy balance constraints between energy storage and hydrogen storage, electricity price and operating cost range constraints, demand response constraints, equipment operating limit constraints, including the operating range restrictions of electrolyzers, fuel cells, hydrogen storage, energy storage and photovoltaic equipment, energy balance constraints between energy storage and hydrogen storage, and demand response constraints. The system's energy conservation constraint ensures that the system's power supply and demand are balanced across different time periods. ; In the formula, This represents the output power of the fuel cell during time period t; The constraints between electricity prices and operating costs are: ; ; In the formula, , These represent the minimum and maximum electricity prices, respectively. By setting upper and lower limits on electricity prices and constraining electricity purchase costs, we can ensure that strategy optimization is feasible within the market price range. The lower-level model, under the power strategy and response parameters given by the upper level, considers uncertainties such as renewable energy output fluctuations and random load disturbances to solve the actual operation and scheduling of the system. The objective is to minimize the expected energy deviation and operational losses. ; in, Let s be the probability of scenario s occurring. This is a penalty for system energy loss or power curtailment; , These are weighting coefficients used to balance economic efficiency and stability; The lower-level constraints include: hydrogen energy balance, energy storage SOC and power constraints, operating limits of electrolyzers and fuel cells, feasible demand response domain within the scenario, hydrogen energy balance, SOC and power constraints, operating limits of electrolyzers and fuel cells, and demand response constraints. The power balance is: ; in, In order to purchase electricity for grid connection, This refers to the power output for electricity sales. Electricity price ranges and grid transactions are mutually exclusive, ensuring that buying and selling will not occur simultaneously in the same time period; M is a sufficiently large constant. ; ; ; ; ; in, , The two variables are mutually exclusive: grid-connected power purchase and power sales. The upper and lower layer models achieve iterative optimization through a two-way feedback mechanism between the expected cost function and the scenario operation results. This interaction process aims to dynamically coordinate the global strategy and local operation of the electro-hydrogen coupling system under uncertain conditions in multiple scenarios, forming an optimization closed loop with adaptive learning capabilities. The decision variables passed from the upper layer to the lower layer are the results calculated by the upper layer, including electrolyzer power, energy storage power allocation, grid trading strategy, demand response weight coefficient, electricity price signal sequence and flexible load adjustment ratio. These variables constitute the strategy constraint boundary and guiding parameters of the lower layer stochastic optimization, which determine the search space and economic priority of scenario scheduling. The lower layer feeds back the operational results to the upper layer: Based on data from various scenarios, including renewable energy output, load demand, and electricity price fluctuations, the lower layer optimizes scheduling and returns a set of scenario operational results. ,in This indicates the mass of hydrogen in the hydrogen storage tank.

[0030] This step involves constructing a two-layer stochastic optimization operation model based on the established electro-hydrogen coupling system model and demand response mechanism, achieving a balance between system operation economy and flexibility. The model consists of two parts: an upper-layer strategy optimization and a lower-layer stochastic operation scheduling. The gradual convergence of the operation strategy is achieved through parameter feedback and iterative solution.

[0031] The iterative solution includes the following steps: (1) Upper-layer expectation assessment: The upper layer calculates the expected operating cost of the system based on the scenario operation results returned by the lower layer. And assess the energy balance deviation. .

[0032] (2) Strategy correction: If the expected operating cost or energy deviation exceeds the set threshold, the upper layer corrects the power allocation parameters and response weights, such as adjusting the electrolytic cell power, demand response weight coefficient or electricity price signal sequence, and updates the iteration step size.

[0033] (3) Lower layer rescheduling: The lower layer re-solves the multi-scenario optimization problem under the updated policy constraints to obtain new device power allocation and operating status.

[0034] (4) Iteration and convergence determination: Repeat steps (1)-(3) until the expected operating cost and energy deviation of the system meet the convergence conditions and the global optimal operating strategy is obtained.

[0035] As a preferred embodiment of the above, the upper layer employs an improved particle swarm optimization algorithm to introduce dynamic inertia weights to achieve global policy search, while the lower layer transforms the scheduling problem into a mixed-integer linear programming (MILP) model for parallel solution. Iterative optimization between the upper and lower layers is achieved through feedback of expected cost and energy deviation to obtain the optimal system operation strategy, including: The upper layer uses the improved particle swarm optimization algorithm IPSO for global search. The algorithm represents candidate running strategies in the form of individual particles and evaluates the economy and energy balance characteristics of the current strategy through the fitness function. The objective function to be optimized is: ; in, Let be the probability of scenario s occurring. The operating cost of the lower layer in scenario s, , These are energy and power deviations, respectively. , For penalty weighting; To balance the algorithm's global search capability with local convergence accuracy, a strategy of adjusting linearly decreasing inertia weights and nonlinear learning factors is adopted. The particle velocity and position update formulas are as follows: ; in, As the number of iterations decreases, The inertia weight represents the current iteration algebra. This represents the initial maximum inertia weight. This represents the minimum inertia weight. Indicates the current iteration number. Indicates the maximum number of iterations; , These represent the velocities of particle i in the kth and k+1th generations, respectively. and Represents a random number between 0 and 1; This represents the historical best position of particle i; , These represent the positions of particle i in the kth and (k+1)th generations, respectively. Indicates the globally optimal position; Learning factor , Dynamically adjust according to error trend: ; In the formula, and Let c1 represent the minimum and maximum values ​​of the individual cognitive factor c1, respectively. and Let c and d represent the minimum and maximum values ​​of the social learning factor c2, respectively. This represents the learning factor adjustment speed coefficient. and It represents the global optimal fitness of the previous generation and the current generation; the balance between exploration and utilization is dynamically adjusted through error feedback. Algorithm iterates until satisfied Terminates upon reaching the optimal policy parameter. ; in, This represents the expected change in cost during the current iteration. Indicates the cost convergence threshold. Indicates energy deviation. Indicates the energy convergence threshold; This indicates the optimized electrolytic cell power. This indicates the optimized energy storage charging and discharging power. This represents the optimized demand response electricity price signal. This represents the optimized load response weighting coefficient; it serves as input for lower-level operation scheduling and system execution. Compared with traditional PSO, IPSO can effectively improve convergence accuracy and convergence speed.

[0036] Under the constraints of power allocation and electricity pricing strategies passed from the upper layer, the lower-level model solves each typical scenario independently to obtain the optimal operating state and expected operating cost of the hydrogen-electric system. The lower-level model is transformed into a mixed integer linear programming (MILP) problem for solution. To eliminate nonlinearity and logically mutually exclusive relationships in the model, linearization and discretization are employed: Introducing 0 / 1 state variables , , , These represent the mutually exclusive states of energy storage charging / discharging and power purchase / sale, respectively. A piecewise linear approximation is used for the partial load efficiency of the electrolyzer and fuel cell; The slack variable linearization method is used for absolute value and complementary constraints; Preserve the linear form of all energy and power balance constraints; After linearization, the original problem can be uniformly expressed as: ; ; ; in, Let represent the operating cost of the s-th scenario in the lower layer, c be the cost coefficient vector, A be the continuous variable coefficient matrix, x be the continuous power and energy variables, B be the discrete variable coefficient matrix, z be the equipment operating state variables, and b be the constraint vector. This represents the dimension of the continuous variable space. Indicates the number of binary variables; The lower layer receives reference values ​​from the upper layer as boundary conditions for model constraints, and generates multi-scenario constraint matrices based on scenario-specific input data (renewable energy output, load, electricity price fluctuations, etc.). And independently build MILP sub-models for each scenario; Each scene sub-model was solved in parallel using the commercial Gurobi solver to obtain the optimal solution set. And calculate the expected operating cost. The results are then fed back to the upper-level model for policy correction.

[0037] This step explains the solution mechanism of the two-layer stochastic optimization model. Different optimization algorithms and computational strategies are employed in the upper and lower layers, and coordinated optimization of the electro-hydrogen coupling system is achieved through parameter iteration and information feedback.

[0038] like Figure 2 As shown, this embodiment also includes a two-layer stochastic optimization operation system for an electro-hydrogen coupling system, using the method described above. The system includes: The acquisition unit is used to acquire and preprocess multi-source historical operating data from the power side, hydrogen energy side, and external environment to construct the input dataset of the electric-hydrogen coupling system. The modeling unit is used to establish a linearized operation model of the electrolyzer, fuel cell, energy storage system, hydrogen storage device and load, forming a mathematical model of the electro-hydrogen coupling system that satisfies energy conservation and equipment constraints; The response characterization unit is used to establish a flexible load response model based on electricity price signals, define the user-side power adjustment amount and response coefficient, and construct a linear mapping relationship between electricity price and load to characterize demand response behavior. The two-layer optimization unit is used to construct a two-layer stochastic optimization framework with the goal of minimizing the expected operating cost of the system. The upper layer is responsible for global power and response strategy optimization, while the lower layer is responsible for multi-scenario operation scheduling and feedback of results to form a closed loop. The solution unit is used in a two-layer stochastic optimization framework. The upper layer uses an improved particle swarm optimization algorithm to introduce dynamic inertia weights to achieve global policy search, while the lower layer transforms the scheduling problem into a mixed integer linear programming (MILP) model for parallel solution. Iterative optimization between the upper and lower layers is achieved through feedback of expected cost and energy deviation to obtain the optimal operating strategy of the system.

[0039] By introducing a demand response mechanism and an improved particle swarm optimization algorithm, a two-layer stochastic optimization framework for the electric-hydrogen coupled system is constructed, achieving a synergistic unification of global strategy optimization and precise scheduling across multiple scenarios. The upper-layer improved particle swarm optimization algorithm employs dynamic inertial weights, enhancing global search capability and convergence accuracy; the lower layer transforms the operational problem into a mixed-integer linear programming model, enabling precise solutions to equipment operational constraints. Through feedback iteration of expected cost and energy deviation between the upper and lower layers, the system can achieve dual optimization of economy and stability under uncertain conditions of renewable energy output and load demand. Compared with traditional methods, this embodiment has significant advantages in reducing operating costs, improving scheduling efficiency, and enhancing system reliability, making it suitable for real-time optimization and engineering deployment of electric-hydrogen co-energy systems.

[0040] Please see Figure 3 The diagram shows a structural schematic of a computer device provided in an embodiment of this application. An embodiment of this application provides a computer device 400, including a processor 410 and a memory 420. The memory 420 stores a computer program executable by the processor 410. When the computer program is executed by the processor 410, it performs the method described above.

[0041] This application embodiment also provides a storage medium 430, on which a computer program is stored, and the computer program is executed by a processor 410 to perform the above method.

[0042] The storage medium 430 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable red-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.

[0043] In the description of this invention, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. "A plurality of" means two or more, unless otherwise explicitly specified.

[0044] In this invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," "linking," and "fixing," etc., should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.

[0045] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Furthermore, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0046] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process, and the scope of the preferred embodiments of the invention includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as will be understood by those skilled in the art to which embodiments of the invention pertain.

[0047] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.

[0048] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0049] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.

[0050] The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc. Although embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present invention.

Claims

1. A two-layer stochastic optimization method for an electro-hydrogen coupling system, characterized in that, Includes the following steps: Acquire and preprocess multi-source historical operating data from the power side, hydrogen energy side, and external environment to construct the input dataset for the electric-hydrogen coupling system; Establish a linearized operation model for the electrolyzer, fuel cell, energy storage system, hydrogen storage device and load, and form a mathematical model of the electro-hydrogen coupling system that satisfies energy conservation and equipment constraints; A flexible load response model is established based on electricity price signals. User-side power adjustment and response coefficient are defined, and a linear mapping relationship between electricity price and load is constructed to characterize demand response behavior. A two-layer stochastic optimization framework is constructed with the goal of minimizing the expected operating cost of the system. The upper layer is responsible for global power and response strategy optimization, while the lower layer is responsible for multi-scenario operation scheduling and feedback of results to form a closed loop. The upper layer of the two-layer stochastic optimization framework adopts an improved particle swarm optimization algorithm to introduce dynamic inertia weights to achieve global policy search, while the lower layer transforms the scheduling problem into a mixed integer linear programming (MILP) model for parallel solution. Iterative optimization between the upper and lower layers is achieved through feedback of expected cost and energy deviation. If the expected operating cost or energy deviation exceeds the set threshold, the power allocation parameters and response weights are corrected, and the lower layer is re-scheduled for multiple scenarios to obtain the optimal operating strategy of the system. The flexible load response model based on electricity price signals defines the user-side power adjustment and response coefficient, and constructs a linear mapping relationship between electricity price and load to characterize demand response behavior, including: By combining price incentive signals with system operational deviation information, a comprehensive demand response signal is generated: ; In the formula, Basic electricity price, This indicates the power imbalance in the system. The rate of change of system operating costs. , This is the signal conditioning coefficient, which comprehensively reflects the system load level, electricity price fluctuations and economic operating constraints, and serves as a trigger variable for user-side and equipment-side responses; Based on the integrated signal on the load side It autonomously adjusts power demand to form a linear response relationship: ; in, This is the baseline load power when not participating in the response. The load response coefficient reflects the user's sensitivity to price changes; The response power is expressed as: ; When electricity prices rise or system load is high, users automatically reduce their electricity demand; when electricity prices fall, the load rebounds, thus achieving peak shaving and valley filling and load balancing. At the system level, the total response power Allocation is based on equipment flexibility and response time: ; in, The proportion of response power undertaken by the battery energy storage device; This is the response component achieved by adjusting the hydrogen charging power of the electrolyzer; Adjustable load power; The demand response constraints are as follows: ; in, Maximum responsive load in the current period Interruptible load; The allocation rule is solved under equipment constraints and system power balance conditions to minimize the total system operating cost and response deviation. ; in, Operating costs; Weights for response accuracy; and These are the target response power and the actual response power, respectively.

2. The two-layer stochastic optimization operation method for the electro-hydrogen coupling system according to claim 1, characterized in that, The process involves acquiring and preprocessing multi-source historical operating data from the power supply side, hydrogen energy side, and external environment to construct the input dataset for the electro-hydrogen coupling system. The data on the power side includes the load power curve P of the distribution network. L (t), real-time electricity price λ(t), renewable energy output photovoltaic P V (t), and the operating status parameter S of the energy storage device ES (t); The data from the hydrogen energy side includes the electrolyzer power P. el (t) and efficiency characteristics η el Rated capacity of hydrogen storage device (w) H Fuel cell rated power P fc_max and conversion efficiency η fc ; The data from the external environment includes user-side response participation data P. dr (t); Historical data is selected from continuous operation data of the past year as the sample basis, covering typical seasons and operation modes. The optimization calculation uses a one-week rolling window to periodically update the system, and the time resolution is uniformly set to a 1-hour step. In the data preprocessing stage, the raw data is time-aligned, outliers are removed, and units are standardized. Statistical sampling and clustering methods are used to analyze photovoltaic output, electricity price fluctuations, and load changes to generate representative operating samples for subsequent random optimization input.

3. The two-layer stochastic optimization operation method for the electro-hydrogen coupling system according to claim 1, characterized in that, The establishment of a linearized operation model for the electrolyzer, fuel cell, energy storage system, hydrogen storage device, and load forms a mathematical model of the electro-hydrogen coupling system that satisfies energy conservation and equipment constraints, including: The operating status of a hydrogen storage device is described by the hydrogen mass balance equation: ; In the formula, the mass of hydrogen in the hydrogen storage tank Based on the hydrogen storage at the previous moment Hydrogen mass flow rate input to the hydrogen production process Hydrogen mass flow rate consumed by fuel cells Joint decision; To improve hydrogen storage and charging efficiency, For hydrogen storage and dehydrogenation efficiency; Hydrogen storage processes are limited by capacity and power constraints: ; ; ; ; In the formula, , Let represent the hydrogen charging and discharging state variables of the hydrogen storage device during time period t, respectively. These are 0-1 variables, and the charging and discharging processes occur mutually exclusively within the same time period. This indicates the mass of hydrogen in the hydrogen storage tank of the hydrogen storage system; To reflect the long-term energy migration characteristics of seasonal hydrogen storage, the hydrogen storage system needs to adopt an annual closed-loop configuration: ; In the formula, and The hydrogen storage quality of the hydrogen storage equipment at the end of the year and the beginning of the year are respectively; The relationship between power consumption and hydrogen production in a proton exchange membrane electrolyzer (PEM) is shown below: ; in The quality of hydrogen produced by the electrolyzer; Input electrical power to the electrolytic cell; The proportionality coefficient for converting power into hydrogen production; The operating power constraint of the electrolytic cell is: ; in, This is a binary variable representing the state of the electrolytic cell. It is 1 when the electrolytic cell is in the active state, and its operating power must be between the minimum starting power and the rated power. It is 0 when the electrolytic cell is closed, and the power is forced to zero. Indicates the minimum operating ratio coefficient of the electrolytic cell; Indicates the hydrogen production of the electrolyzer; This indicates the actual operating power of the electrolytic cell during time period t; The power constraint of the fuel cell is: ; in, This refers to the output power of the fuel cell; Fuel cell rated power; Indicates the length of each scheduling period; Hydrogen consumption - power relationship: ; In the formula, The mass of hydrogen consumed by the fuel cell; For fuel cell efficiency; Battery energy storage devices are used in power distribution systems to achieve energy timing balance and demand response auxiliary regulation. Their operating characteristics are jointly determined by energy balance, power constraints, state of charge constraints, and initial and final state conditions. ; This formula describes the energy change of an energy storage battery over time period t, based on the energy stored at the previous time step. The current charging and discharging power together determine the total power; among which and These represent charging and discharging efficiencies, respectively. and These are the charging and discharging powers, respectively. Energy and power constraints limit energy storage The rated capacity shall not be exceeded. And ensure that the charging and discharging processes are mutually exclusive within the same time period; ; ; ; ; in, and These are the charging and discharging powers, and These are two variables representing the battery's charge / discharge state; This indicates the maximum charging power of the energy storage battery; This indicates the maximum discharge power of the energy storage battery; State of Charge (SOC) Constraints: By normalizing the energy, the SOC is defined. s,t And set upper and lower limits to ensure that the battery operates within a safe operating range: ; ; In the formula, , These are the minimum and maximum values ​​of the state of charge, respectively; This represents the current stored energy of the energy storage battery in time period t under scenario s; Indicates the rated maximum capacity of the energy storage battery; Photovoltaic power generation capacity is: ; In the formula, the photovoltaic power generation is The rated power of photovoltaic power generation is .

4. The two-layer stochastic optimization operation method for the electro-hydrogen coupling system according to claim 1, characterized in that, The proposed two-layer stochastic optimization framework aims to minimize the expected operating cost of the system. The upper layer is responsible for global power and response strategy optimization, while the lower layer is responsible for multi-scenario operation scheduling and feedback of results to form a closed loop. This includes: The upper-level model aims to minimize the overall system operating cost. Under the constraints of electricity price fluctuations, uncertainties in renewable energy output, and demand response behavior, it optimizes the power allocation and operation strategies of each adjustable unit. ; in, Cost of purchasing or selling electricity; Cost of energy storage charging and discharging; Energy consumption cost for hydrogen production via electrolysis; Costs of load adjustment caused by demand response; This indicates the current energy storage capacity or hydrogen storage amount of a hydrogen storage device or energy storage equipment at a certain time period. Upper-level decision variables include: ; in, Adjustable load power; The constraints of the upper-level model include: system energy conservation constraints, equipment operating limit constraints, energy balance constraints between energy storage and hydrogen storage, electricity price and operating cost range constraints, demand response constraints, equipment operating limit constraints, including the operating range restrictions of electrolyzers, fuel cells, hydrogen storage, energy storage and photovoltaic equipment, energy balance constraints between energy storage and hydrogen storage, and demand response constraints. The system's energy conservation constraint ensures that the system's power supply and demand are balanced across different time periods. ; In the formula, This represents the output power of the fuel cell during time period t; The constraints between electricity prices and operating costs are: ; ; In the formula, , These represent the minimum and maximum electricity prices, respectively. By setting upper and lower limits on electricity prices and constraining electricity purchase costs, we can ensure that strategy optimization is feasible within the market price range. The lower-level model, under the power strategy and response parameters given by the upper level, considers uncertainties such as renewable energy output fluctuations and random load disturbances to solve the actual operation and scheduling of the system. The objective is to minimize the expected energy deviation and operational losses. ; in, Let s be the probability of scenario s occurring. This is a penalty for system energy loss or power curtailment; , These are weighting coefficients used to balance economic efficiency and stability; The lower-level constraints include: hydrogen energy balance, energy storage SOC and power constraints, operating limits of electrolyzers and fuel cells, feasible demand response domain within the scenario, hydrogen energy balance, SOC and power constraints, operating limits of electrolyzers and fuel cells, and demand response constraints. The power balance is: ; in, In order to purchase electricity for grid connection, This refers to the power output for electricity sales. Electricity price ranges and grid transactions are mutually exclusive, ensuring that buying and selling will not occur simultaneously in the same time period; M is a sufficiently large constant. ; ; ; ; ; in, , The two variables are mutually exclusive: grid-connected power purchase and power sales. The upper and lower layer models achieve iterative optimization through a two-way feedback mechanism between the expected cost function and the scenario operation results. This interaction process aims to dynamically coordinate the global strategy and local operation of the electro-hydrogen coupling system under uncertain conditions in multiple scenarios, forming an optimization closed loop with adaptive learning capabilities. The decision variables passed from the upper layer to the lower layer are the results calculated by the upper layer, including electrolyzer power, energy storage power allocation, grid trading strategy, demand response weight coefficient, electricity price signal sequence and flexible load adjustment ratio. These variables constitute the strategy constraint boundary and guiding parameters of the lower layer stochastic optimization, which determine the search space and economic priority of scenario scheduling. The lower layer feeds back the operational results to the upper layer: Based on data from various scenarios, including renewable energy output, load demand, and electricity price fluctuations, the lower layer optimizes scheduling and returns a set of scenario operational results. ,in This indicates the mass of hydrogen in the hydrogen storage tank.

5. The two-layer stochastic optimization operation method for the electro-hydrogen coupling system according to claim 1, characterized in that, The upper layer employs an improved particle swarm optimization algorithm with dynamic inertia weights to achieve global policy search. The lower layer transforms the scheduling problem into a mixed-integer linear programming (MILP) model for parallel solution. Iterative optimization between the upper and lower layers is achieved through feedback of expected cost and energy deviation to obtain the optimal system operation strategy, including: The upper layer uses the improved particle swarm optimization algorithm IPSO for global search. The algorithm represents candidate running strategies in the form of individual particles and evaluates the economy and energy balance characteristics of the current strategy through the fitness function. The objective function to be optimized is: ; in, Let be the probability of scenario s occurring. The operating cost of the lower layer in scenario s, , These are energy and power deviations, respectively. , For penalty weighting; To balance the algorithm's global search capability with local convergence accuracy, a strategy of adjusting linearly decreasing inertia weights and nonlinear learning factors is adopted. The particle velocity and position update formulas are as follows: ; in, As the number of iterations decreases, The inertia weight represents the current iteration algebra. This represents the initial maximum inertia weight. This represents the minimum inertia weight. Indicates the current iteration number. Indicates the maximum number of iterations; , These represent the velocities of particle i in the kth and k+1th generations, respectively. and Represents a random number between 0 and 1; This represents the historical best position of particle i; , These represent the positions of particle i in the kth and (k+1)th generations, respectively. Indicates the globally optimal position; Learning factor , Dynamically adjust based on error trend: ; In the formula, and Let c1 represent the minimum and maximum values ​​of the individual cognitive factor c1, respectively. and Let c and d represent the minimum and maximum values ​​of the social learning factor c2, respectively. This represents the learning factor adjustment speed coefficient. and It represents the global optimal fitness of the previous generation and the current generation; the balance between exploration and utilization is dynamically adjusted through error feedback. Algorithm iterates until satisfied Terminates upon reaching the optimal policy parameter. ; in, This represents the expected change in cost during the current iteration. Indicates the cost convergence threshold. Indicates energy deviation. Indicates the energy convergence threshold; This indicates the optimized electrolytic cell power. This indicates the optimized energy storage charging and discharging power. This represents the optimized demand response electricity price signal. This represents the optimized load response weighting coefficient; it serves as input for lower-level operation scheduling and system execution. Under the constraints of power allocation and electricity pricing strategies passed from the upper layer, the lower-level model solves each typical scenario independently to obtain the optimal operating state and expected operating cost of the hydrogen-electric system. The lower-level model is transformed into a mixed integer linear programming (MILP) problem for solution. To eliminate nonlinearity and logically mutually exclusive relationships in the model, linearization and discretization are employed: Introducing 0 / 1 state variables , , , These represent the mutually exclusive states of energy storage charging / discharging and power purchase / sale, respectively. A piecewise linear approximation is used for the partial load efficiency of the electrolyzer and fuel cell; The slack variable linearization method is used for absolute value and complementary constraints; Preserve the linear form of all energy and power balance constraints; After linearization, the original problem can be uniformly expressed as: ; ; ; in, Let represent the operating cost of the s-th scenario in the lower layer, c be the cost coefficient vector, A be the continuous variable coefficient matrix, x be the continuous power and energy variables, B be the discrete variable coefficient matrix, z be the equipment operating state variables, and b be the constraint vector. This represents the dimension of the continuous variable space. Indicates the number of binary variables; The lower layer receives reference values ​​passed from the upper layer as boundary conditions for model constraints, and generates multi-scenario constraint matrices based on scenario-specific input data. And independently build MILP sub-models for each scenario; Each scene sub-model was solved in parallel using the commercial Gurobi solver to obtain the optimal solution set. And calculate the expected operating cost. The results are then fed back to the upper-level model for policy correction.

6. A two-layer stochastic optimization operating system for an electro-hydrogen coupling system, characterized in that, Using the method as described in any one of claims 1 to 5, the system comprises: The acquisition unit is used to acquire and preprocess multi-source historical operating data from the power side, hydrogen energy side, and external environment to construct the input dataset of the electric-hydrogen coupling system. The modeling unit is used to establish a linearized operation model of the electrolyzer, fuel cell, energy storage system, hydrogen storage device and load, forming a mathematical model of the electro-hydrogen coupling system that satisfies energy conservation and equipment constraints; The response characterization unit is used to establish a flexible load response model based on electricity price signals, define the user-side power adjustment amount and response coefficient, and construct a linear mapping relationship between electricity price and load to characterize demand response behavior. The two-layer optimization unit is used to construct a two-layer stochastic optimization framework with the goal of minimizing the expected operating cost of the system. The upper layer is responsible for global power and response strategy optimization, while the lower layer is responsible for multi-scenario operation scheduling and feedback of results to form a closed loop. The solution unit is used in the two-layer stochastic optimization framework. The upper layer adopts an improved particle swarm optimization algorithm to introduce dynamic inertia weights to realize global policy search, while the lower layer transforms the scheduling problem into a mixed integer linear programming (MILP) model for parallel solution. Iterative optimization between the upper and lower layers is achieved through feedback of expected cost and energy deviation to obtain the optimal operating strategy of the system.

7. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method as described in any one of claims 1-5.

8. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the method as described in any one of claims 1-5.