Adaptive energy dispatch for solar-powered microgrids using Proximal Policy Optimization (PPO) on real irradiance data from Kigali, Rwanda.
# Microgrid Energy Management with Deep Reinforcement Learning
This project compares **PPO, A2C, SAC, and DQN** agents for battery dispatch optimization in a solar-powered microgrid using real hourly solar irradiance data from **Kigali, Rwanda** (NASA POWER, 2022).
### PPO (Proximal Policy Optimization)
- Policy-gradient algorithm with stable and conservative updates.
- Suitable for continuous battery charge/discharge control.
- Balances performance and training stability.
### A2C (Advantage Actor-Critic)
- Actor-critic method that jointly learns a control policy and a value function.
- Computationally efficient and relatively simple to train.
- Can struggle in environments with sparse rewards and long decision horizons.
### SAC (Soft Actor-Critic)
- Off-policy algorithm that combines reward maximization with entropy-based exploration.
- Highly sample-efficient and robust.
- Particularly effective for continuous control problems such as battery energy management.
### DQN (Deep Q-Network)
- Value-based algorithm that estimates the expected return of discrete actions.
- Selects actions with the highest predicted value.
- Well suited for battery dispatch when the action space is discretized into a finite number of operating levels.
---
## Overview
This project applies deep reinforcement learning to the problem of energy dispatch in a grid-connected solar and battery microgrid. The model controls a battery storage system, deciding each hour whether to charge from solar or the grid, discharge to meet demand, or remain idle, with the objective of minimizing electricity imports from the grid.
Four RL algorithms are benchmarked against two baselines:
| Policy | Mean Reward | Mean Cost/Day | vs Rule-Based |
|---|---|---|---|
| **LP Optimal** *(perfect foresight)* | -2.797 | $1.15 | −43% |
| **DQN** | -2.796 | $1.51 | −26% |
| **SAC** | -2.890 | $1.54 | −24% |
| **PPO** | -3.202 | $1.61 | −21% |
| **Rule-Based** *(baseline)* | -3.706 | $2.03 | — |
| **A2C** | -4.309 …