A Reinforcement Learning Approach for Optimal Control in Microgrids

Davide Salaorni, Federico Bianchi, Francesco Trovò, Marcello Restelli

Abstract

Effective energy management in microgrids requires balancing immediate market profits with the long-term costs associated with battery degradation. This paper presents a Reinforcement Learning (RL) framework that utilizes a high-fidelity Digital Twin to optimize tertiary control. By modeling the system as a Markov Decision Process and employing Proximal Policy Optimization, the proposed agent, $RL^*$, learns to navigate the complex trade-offs between trading gains and storage longevity. Experimental results using real-world data demonstrate that $RL^*$ outperforms traditional rule-based and existing RL benchmarks, achieving up to a 6.7% reduction in operational costs.

Introduction

The transition toward decentralized energy systems has positioned microgrids (MGs) as a critical infrastructure component. MGs consist of local electricity sources, such as photovoltaic (PV) systems, and loads that can operate independently or in conjunction with the main grid. A primary challenge in MG management is tertiary control: the decision-making process regarding energy storage, grid exports, and market purchases.

Microgrid system architecture showing the interaction between generation, demand, the BESS, and the main grid via a central controller.

Traditional controllers often prioritize immediate economic returns from energy trading, frequently neglecting the "hidden" costs of Battery Energy Storage System (BESS) aging. Over-utilizing a battery to capitalize on short-term price fluctuations can lead to premature degradation, ultimately increasing the total cost of ownership. This research addresses this gap by integrating sophisticated battery degradation modeling into the control logic.

Methodology

The researchers formulated the tertiary control problem as a Markov Decision Process (MDP). The objective is to maximize a reward function that accounts for both market profits and penalties for battery wear.

The Digital Twin and RL Agent

Central to the approach is the use of "ErNESTO-DT," a high-fidelity Digital Twin (DT). Unlike simplified linear models, this DT accurately simulates the battery's State of Charge (SoC), internal temperature, and State of Health (SoH). This allows the RL agent to receive realistic feedback on the long-term physical consequences of its actions.

The agent utilizes Proximal Policy Optimization (PPO) to navigate a continuous action space. It determines the exact proportion of net power to route between the BESS and the grid based on a state space including SoC, temperature, demand/generation forecasts, market prices, and temporal features.

Experimental Setup

The model was validated using real-world data from Italy (2015–2020), including:

  • PV Generation: 3kW residential system profiles.
  • Consumption: Data from 398 Italian households.
  • Market Dynamics: Hourly pricing from the Italian national energy market (GME).
  • Environmental Factors: Ambient temperature profiles to simulate thermal stress on the battery.

Key Results and Discussion

The proposed $RL^*$ method was benchmarked against several strategies: "OnlyGrid" (OG), "BatteryFirst" (BF), and various RL baselines.

Cumulative reward over time for different control strategies, showing $RL^*$ achieving the highest overall performance.

Performance Gains

As shown in the cumulative reward analysis, $RL^*$ consistently outperformed all competitors. It achieved a 3.2% cost reduction over the previous state-of-the-art RL solution and a 6.7% improvement over the best-performing rule-based strategy. Statistical analysis via paired t-tests (p-value = 0.0052) confirmed these gains are significant.

The Degradation Trade-off

A key insight from the study is the agent's ability to manage the trade-off between trading and degradation. The $RL^*$ agent learned to sacrifice marginal market profits to preserve battery health when replacement costs were high. Furthermore, by incorporating temperature into its state space, the agent avoided heavy battery usage during peak heat periods, a major driver of chemical aging often ignored by simpler models.

Conclusion

This research demonstrates that deep reinforcement learning, when paired with high-fidelity physical simulations, can significantly improve the economic and operational efficiency of microgrids. By accounting for battery degradation, the $RL^*$ agent provides a more sustainable and cost-effective solution for decentralized energy management. Future work will explore Multi-Agent Reinforcement Learning (MARL) to enable cooperation between interconnected microgrids and integrate more advanced forecasting techniques like Transformers for improved demand and generation prediction.

Summary updated

BibTeX
@inproceedings{salaorni2025reinforcement,
  author = {Davide Salaorni and Federico Bianchi and Francesco Trovò and Marcello Restelli},
  title = {{A Reinforcement Learning Approach for Optimal Control in Microgrids}},
  booktitle = {IJCNN},
  year = {2025},
}
Figure