Optimization of Energy Storage System Configuration using Deep Reinforcement Learning and Large Language Models

In the context of the rapid expansion of wind and solar power generation, the issue of curtailed renewable energy has become increasingly prominent. This phenomenon not only leads to significant waste of renewable resources but also highlights structural challenges in energy consumption. To address this problem, a hybrid energy storage system integrating wind-solar power generation with hydrogen production and storage, known as the wind-solar-hydrogen-storage (WSHS) system, has been proposed as a promising solution. In this research, I focus on the optimal capacity configuration of the energy storage system within such a hybrid framework. The objective is to determine the most cost-effective capacities for electrochemical storage and electrolysis equipment under different electricity sales strategies. I employ a deep reinforcement learning (DRL) approach combined with a large language model (LLM) to solve the sequential decision-making problem. This study covers three distinct scenarios: peak-valley arbitrage, power purchase agreement (PPA) sales, and a hybrid strategy combining both. Extensive simulations are conducted to evaluate the economic performance, energy utilization efficiency, and operational safety of the proposed configurations. The results demonstrate that the integration of DRL and LLM provides a feasible and effective pathway for optimizing energy storage system capacity allocation. The findings reveal significant differences in optimal configurations across the three sales modes, offering valuable insights for practical project planning and policy formulation.

1. Introduction

The transition towards low-carbon energy systems has accelerated the deployment of renewable energy sources, particularly wind and solar power. According to the National New Energy Consumption Monitoring and Early Warning Center, China’s wind and solar installed capacities have witnessed sustained growth. Nevertheless, the intermittent and volatile nature of these sources leads to substantial curtailment rates in certain regions, causing economic losses and resource waste. For instance, in Inner Mongolia, the wind curtailment rate reached 6.8% in 2023, resulting in a large amount of unused electricity. To mitigate this issue, the concept of utilizing curtailed power for hydrogen production has gained attention. By combining renewable generation with energy storage systems and electrolysis facilities, a wind-solar-hydrogen-storage system can effectively absorb surplus energy and convert it into valuable hydrogen fuel.

The design of such a system is nontrivial. The capacity of the energy storage system—both electrochemical batteries and electrolysis units—directly influences the initial investment, operational efficiency, and profitability. Oversizing leads to excessive capital expenditure and idle resources, while undersizing may fail to absorb sufficient curtailed energy, undermining the economic viability. Moreover, the operational strategy, including when to store energy, when to sell electricity, and how to manage hydrogen production, plays a critical role in determining overall performance. Therefore, capacity configuration and operational scheduling must be jointly optimized.

Traditional optimization methods, such as mathematical programming, often rely on precise physical models and are limited in handling high-dimensional, nonlinear, and uncertain environments. Deep reinforcement learning (DRL), a data-driven approach, has emerged as a powerful tool for sequential decision-making problems. DRL agents interact with the environment and learn optimal policies through trial-and-error, requiring no explicit system model. In this work, I formulate the capacity configuration problem of a wind-solar-hydrogen-storage system as a Markov decision process and solve it using a variant of the Proximal Policy Optimization (PPO) algorithm enhanced with recurrent neural networks. Furthermore, the integration of a large language model (LLM) is proposed to assist the DRL agent in dynamically adjusting contract electricity volumes in hybrid sales scenarios. This novel coupling of DRL and LLM aims to improve the adaptivity and intelligence of the decision-making process.

The remainder of this article is organized as follows. Section 2 describes the architecture and mathematical model of the WSHS system. Section 3 presents the DRL-based optimization framework, including state, action, and reward definitions. Section 4 details the application of LLM in the hybrid sales mode. Section 5 reports the simulation results and comparative analysis under different sales strategies. Finally, Section 6 concludes the work and discusses future directions.

2. System Model and Cost Analysis

2.1 System Architecture

As shown in the diagram below, the wind-solar-hydrogen-storage system that I study consists of renewable energy inputs (curtailed wind and solar power), an electrochemical energy storage subsystem (battery), and a hydrogen production subsystem (alkaline electrolyzer). The energy storage system acts as a buffer that can either store or discharge electricity depending on the operating conditions. The electrolyzer produces hydrogen from surplus electricity, and the hydrogen can be sold or stored for later use.

The system receives a certain amount of curtailed power each hour. The main decisions are: how much power to charge the battery, how much power to send to the electrolyzer, and how much power to sell directly to the grid (subject to the chosen sales strategy). The battery has a limited capacity and power rating, while the electrolyzer has a nominal power capacity.

2.2 Battery Storage Model

For the electrochemical storage, I consider a lithium-ion battery, which is the most widely adopted technology in modern projects. The state of charge (SOC) is updated according to:

$$SOC(t+1) = SOC(t) + \frac{\eta_{ch} P_{ch}(t) \Delta t}{E_{cap}} – \frac{P_{dis}(t) \Delta t}{E_{cap} \eta_{dis}}$$

where \(P_{ch}(t)\) and \(P_{dis}(t)\) are the charging and discharging powers, \(E_{cap}\) is the storage capacity (MWh), \(\eta_{ch}\) and \(\eta_{dis}\) are the charging and discharging efficiencies (both assumed 95% in my simulations), and \(\Delta t\) is the time step (1 hour). The battery power rating is limited to 0.3 times the capacity, i.e., \(P_{battery}^{max} = 0.3 E_{cap}\). Additionally, constraints prevent simultaneous charging and discharging, and the SOC is kept between 10% and 90% for safety.

2.3 Hydrogen Production Model

For hydrogen production, I select alkaline electrolysis due to its maturity and relatively low cost. The input power \(P_{elect}(t)\) must lie between a minimum and maximum allowable power. The minimum is usually around 20% of the nominal capacity to avoid gas crossover, while the maximum is the rated power. I define the electrolyzer operation as:

$$P_{elect}^{min} \le P_{elect}(t) \le P_{elect}^{max}$$

where \(P_{elect}^{max}\) is the installed power capacity of the electrolyzer (MW). The hydrogen production rate (kg/h) is proportional to the input power multiplied by the system efficiency:

$$\dot{m}_{H_2}(t) = \frac{P_{elect}(t) \cdot \eta_{elect}}{HHV_{H_2}}$$

Here, \(HHV\) represents the higher heating value of hydrogen (approximately 39.4 kWh/kg) and \(\eta_{elect}\) denotes the electrolysis efficiency (84% in this work). When the electrolyzer is turned on, it consumes power and produces hydrogen; switching actions incur start-up and shut-down costs.

2.4 Cost Functions

The total cost of the energy storage system includes capital expenses (CAPEX) and operational expenses (OPEX). I annualize the capital costs using the capital recovery factor (CRF) based on the discount rate \(r\) and project lifetime \(n\). The annualized cost of the battery and electrolyzer are:

$$C_{batt}^{ann} = (c_{E} E_{cap} + c_{P} P_{batt}) \cdot \frac{r(1+r)^n}{(1+r)^n – 1}$$
$$C_{elec}^{ann} = c_{P,E} P_{elec}^{max} \cdot \frac{r(1+r)^n}{(1+r)^n – 1}$$

where \(c_{E}\) is the energy capacity cost (USD/MWh), \(c_{P}\) is the power cost (USD/MW), and \(c_{P,E}\) is the unit capacity cost of the electrolyzer (USD/MW). Additionally, I include fixed and variable operation and maintenance (O&M) costs, as well as penalties for SOC deviation and electrolyzer switching. The complete cost expression is:

$$C_{total}(t) = C_{batt}^{ann}/\Delta_{steps} + C_{elec}^{ann}/\Delta_{steps} + C_{OM} + C_{SOC} + C_{switch}$$

where the annualized costs are divided by the number of steps in the operating period to obtain a per-step equivalent. \(C_{SOC}\) represents the storage cost induced when the battery SOC deviates from an ideal value of 0.5, reflecting accelerated aging. \(C_{switch}\) includes start-up and shut-down costs of the electrolyzer.

3. Deep Reinforcement Learning Framework

3.1 Why DRL for the Energy Storage System Configuration?

Classical optimization approaches require a precise system model and gradient information. However, the WSHS system is subject to significant uncertainties from renewable generation and electricity prices. DRL methods, especially model-free algorithms, do not rely on an explicit environment model and can learn directly from data. Moreover, DRL naturally handles long-term rewards, which is essential when sizing storage capacities that affect performance over many years. Therefore, I model the capacity configuration as a sequential decision problem, where each episode represents a full operating period (e.g., one quarter or one year) and the agent decides at every time step how to dispatch energy.

3.2 State Space

The state representation must capture both the current system status and the relevant historical patterns. In my implementation, the state \(s_t\) includes:

  • Current SOC of the battery storage system;
  • Remaining battery capacity and the installed capacities (\(E_{cap}\) and \(P_{elec}^{max}\)) which are decided at the beginning of the episode;
  • Current and past 24-hour electricity prices (for arbitrage) or fixed PPA price;
  • Hydrogen price;
  • Forecasted curtailed wind and solar power for the next 24 hours.

Formally, for the peak-valley arbitrage mode:

$$s_t = \{ SOC[t], E_{cap}, P_{elec}^{max}, P_{ele}(t-24:t), P_H, P_W[t-24:t], P_S[t-24:t] \}$$

For the PPA mode, the electricity price is replaced by a constant contract price. For the hybrid mode, both the variable price and the PPA contract volume are included.

3.3 Action Space

The action \(a_t\) is a two-dimensional continuous vector:

$$a_t = [a_1, a_2]$$

where \(a_1\) determines the power split between the battery and the electrolyzer. Specifically, I let \(P_{ele}(t) = \sigma(a_1) \cdot P_{avail}(t)\) and \(P_{batt}(t) = (1 – \sigma(a_1)) \cdot P_{avail}(t)\), with \(\sigma\) being the sigmoid activation function. \(P_{avail}(t)\) is the available renewable power at that hour. The second action \(a_2\) represents the capacity decision, but since capacity is typically determined before operation, I treat the capacity variables as hyperparameters that vary across episodes. In other words, the DRL agent learns an operational policy for a given capacity, and then I search over capacities by running multiple training episodes. During training, the capacity pair \((E_{cap}, P_{elec}^{max})\) is randomly sampled from a predefined range, so the agent learns the best dispatch policy for any capacity within that range.

3.4 Reward Function

The reward at each step is the profit obtained from electricity and hydrogen sales minus costs and penalties. Specifically:

$$r_t = \alpha \left( Profit_{ele}(t) + Profit_{H_2}(t) – C_{total}(t) – p_{SOC}(t) – p_{switch}(t) – p_{lim}(t) \right) + \beta \left( \eta_{util}(t) – \eta_{ref} \right)$$

Here, \(Profit_{ele}(t)\) is the revenue from selling electricity (depending on the sales strategy), \(Profit_{H_2}(t)\) is the revenue from selling hydrogen, and \(C_{total}(t)\) is the operating cost. Penalty terms \(p_{SOC}\) and \(p_{switch}\) discourage unsafe SOC levels and unnecessary switching, while \(p_{lim}\) penalizes the agent if the dispatched power exceeds the available resource. The second part of the reward provides a small bonus for achieving high energy utilization, where \(\eta_{util}(t)\) is the ratio of used renewable energy to total available energy. The coefficients \(\alpha\) and \(\beta\) balance the importance of economic profit and utilization efficiency.

3.5 Recurrent PPO Algorithm

I use a recurrent PPO (Recurrent-PPO) algorithm, which extends the standard PPO by incorporating an LSTM layer in the actor and critic networks. This architecture enables the agent to consider historical observations and thus make better decisions in partially observable environments. The loss function is

$$L^{CLIP}(\theta) = \mathbb{E}_t \left[ \min\left( \rho_t(\theta) A_t, \operatorname{clip}(\rho_t(\theta), 1-\epsilon, 1+\epsilon) A_t \right) \right]$$

where \(\rho_t(\theta) = \frac{\pi_\theta(a_t|s_t)}{\pi_{\theta_{old}}(a_t|s_t)}\) is the probability ratio, and \(A_t\) is the generalized advantage estimator. The LSTM hidden state is initialized at the beginning of each episode and updated at every time step. In addition, the advantage values and hidden states are refreshed after each mini-batch update to reduce non-stationarity caused by stale estimates.

4. Large Language Model-Assisted Optimization

For the hybrid sales strategy, where the system can sell electricity both under a PPA contract and on the spot market, the contracted PPA volume plays a crucial role. If the contracted volume is too high, the system may be forced to deliver electricity at the expense of flexibility; if too low, the benefits of stable revenue are diminished. To determine a suitable PPA volume at each episode, I incorporate a large language model (LLM) into the DRL framework. The LLM receives the current system status and recent performance metrics in textual form and outputs a recommended PPA volume for the next episode. This approach leverages the reasoning capabilities of the LLM to guide the DRL agent.

Specifically, I deploy a LLaMA-3-8B-Instruct model on a cloud server using FastAPI as the inference interface. The DRL agent sends a prompt containing the following information: the current episode number, average utilization, total profit, and the previous PPA volume. The LLM then generates a response with a new proposed PPA volume. The response is parsed using a regular expression and constrained to the allowed range \([0, P_{max}]\).

Below is the workflow of the DRL-LLM coupling:

Component Description
DRL environment Simulates the WSHS system for one episode (quarter or year) given a fixed capacity pair.
DRL agent Recurrent-PPO policy that provides hourly dispatch decisions.
LLM module Analyzes the performance summary and recommends a new PPA contracted volume for the next episode.
Interface FastAPI-based communication between DRL and LLM.

The interaction process is repeated every episode until convergence. The LLM is not retrained; I use the generic instruction-following capability to generate sensible recommendations based on textual input. This adds a layer of “expert knowledge” that helps the DRL agent explore more profitable configurations.

5. Simulation Results and Discussion

5.1 Data and Parameter Settings

I use publicly available hourly curtailed wind and solar data from the California ISO, scaled to a total annual energy volume of 10 times the baseline to provide sufficient decision space. The PPA price is set to a typical European PPA price of 50.29 USD/MWh. Hydrogen is sold at 3.54 USD/kg. The battery storage system has an energy cost of 15,000 USD/MWh and a power cost of 20,000 USD/MW. The electrolyzer cost is 425,000 USD/MW with an efficiency of 84%. Other parameters include a discount rate of 3%, a project lifetime of 10 years, and a simulation period of one quarter (2,160 hours). The capacity ranges for battery and electrolyzer are set to [5,100] MWh and [50,800] MW for the arbitrage mode, [5,100] MWh and [500,1500] MW for PPA mode, and [15,63] MWh and [383,470] MW for the hybrid mode.

5.2 Results under Peak-Valley Arbitrage

After training the Recurrent-PPO agent for 34 million steps, the profit curve gradually converges. The top 10 profit points are identified and their corresponding capacities are analyzed. The best economic configuration is found at \(E_{cap} = 82.5\) MWh and \(P_{elec}^{max} = 480\) MW, yielding a quarterly profit of 1.86 thousand USD. The associated energy utilization is about 82.6%. Interestingly, the utilization achieved at this optimal point is also the highest, indicating that economic and utilization objectives are aligned in this scenario.

The operational statistics of the electrolyzer show a utilization of 47.44% over the quarter, with 177 start-ups and an average runtime of 7.79 hours. The battery operates safely without deep discharges, maintaining an SOC floor above 25% during discharging and no charging when fully charged.

5.3 Results under PPA Mode

In the PPA mode, the contracted electricity volume is fixed at 30 MWh per hour. The best profit is 2.39 thousand USD, achieved at \(E_{cap} = 40\) MWh and \(P_{elec}^{max} = 395\) MW. Interestingly, the PPA mode shows a higher profit despite using a smaller battery and smaller electrolyzer compared to the arbitrage mode. This is because the stable income from the PPA contract reduces the reliance on uncertain spot market prices and also reduces the need for large energy storage. The average utilization in PPA mode is around 90%, much higher than the arbitrage mode’s 30%, indicating better energy absorption.

The battery in PPA mode exhibits smoother charge/discharge cycles, which is beneficial for battery life. The electrolyzer runtime distribution is similar to the arbitrage case, with a quarterly utilization near 47.5%.

5.4 Results under Hybrid Mode with LLM

For the hybrid mode combining peak-valley arbitrage and PPA, I utilize the LLaMA-3-8B-Instruct model to dynamically set the PPA contracted volume each episode. Figure 4 in the original text displays the PPA volumes generated by the LLM over the training process. The LLM successfully adjusts the contract volume based on the system’s performance, providing a varied and reasonable search space.

The profit under hybrid mode is relatively stable, with the top 5 profits ranging from 2.0614 to 2.064 thousand USD. The optimal economic configuration is \(E_{cap} = 33\) MWh and \(P_{elec}^{max} = 453\) MW. The maximum utilization configuration is \(E_{cap} = 63\) MWh and \(P_{elec}^{max} = 465\) MW, achieving 92.8% utilization. The economic difference between these two configurations is only 0.015 thousand USD, but the utilization difference is about 1%. This suggests that in the hybrid mode, the system can flexibly choose between slightly higher profit or slightly higher utilization.

5.5 Comparative Analysis

The following table summarizes the optimal configurations and economic indicators for the three sales strategies:

Sales Strategy Battery Capacity (MWh) Electrolyzer Power (MW) Electricity Revenue (K USD) Hydrogen Revenue (K USD) Total Cost (K USD) Profit (K USD)
Peak-Valley Arbitrage 82.5 480 1.644 1.509 1.290 1.86
PPA 40 395 0.433 3.517 1.558 2.39
Hybrid (optimal profit) 33 453 0.017 3.486 1.439 2.064
Hybrid (optimal utilization) 63 465 0.017 3.523 1.491 2.049

From the table, it is evident that the PPA mode yields the highest profit among all strategies. The hybrid mode offers a balanced compromise, with similar profit to the PPA mode but slightly lower. The peak-valley arbitrage mode relies heavily on battery capacity, leading to a larger storage system, yet achieves the lowest profit due to the uncertainty of price spreads. The revenue structure also differs significantly: in arbitrage mode, electricity sales contribute about half of the revenue, while in PPA and hybrid modes, hydrogen sales dominate, contributing over 99% of total revenue. This underscores the importance of aligning capacity configuration with the revenue streams of the chosen sales strategy.

Another key observation is the relationship between storage capacity and sales strategy. In the arbitrage mode, a large battery is required to exploit price differences, whereas in the PPA and hybrid modes, a smaller battery suffices because the surplus electricity is primarily used for hydrogen production, which does not require the same temporal shifting capability. Therefore, project developers must carefully assess the intended market participation when sizing the energy storage system.

5.6 Safety and Reliability

Across all simulations, the DRL agent consistently respects the technical constraints of the energy storage system. The SOC never exceeds its limits, and both charging and discharging are forbidden at extreme SOC values. The electrolyzer is operated within its power bounds, and start-stop frequencies remain moderate, minimizing wear and tear. These results confirm that the DRL-LLM framework not only seeks optimal economic performance but also learns to operate the system in a safe and reliable manner.

6. Conclusion

In this study, I have addressed the capacity configuration problem of a wind-solar-hydrogen-storage system by developing a deep reinforcement learning-based optimization framework. The Recurrent-PPO algorithm was applied to learn hourly dispatch policies for given capacity configurations, and a large language model was integrated to dynamically adjust contractual volumes in hybrid sales scenarios. Through comprehensive simulations under three different electricity sales strategies, I derived optimal capacity configurations and analyzed their economic and operational characteristics.

The main conclusions are as follows:

  • The proper sizing of the energy storage system depends critically on the electricity sales strategy. For peak-valley arbitrage, a larger battery capacity is beneficial to capture price spreads, whereas for PPA-based and hybrid strategies, a smaller battery with a larger electrolyzer is more profitable.
  • The PPA mode provides the highest economic return among the studied strategies, thanks to the stable contracted revenue and high energy utilization.
  • The hybrid mode, supported by the LLM-generated PPA volumes, offers a balanced performance between profit and utilization, demonstrating the effectiveness of combining DRL with LLM for complex decision-making in the energy domain.
  • The DRL agent successfully operates the energy storage system within all safety constraints, confirming that the learned policy is practical and reliable.

In future work, I plan to extend the framework to include multiple storage technologies, more detailed degradation models, and additional market mechanisms such as capacity payments and green certificates. The integration of LLM can also be further refined by incorporating real-time expert knowledge and making the prompt design adaptive to the current learning stage. The proposed methodology contributes to the intelligent and efficient utilization of renewable energy through advanced optimization techniques.

Scroll to Top