Reinforcement Learning for PV-Battery Energy Trading

A forecast-driven control study for a grid-connected photovoltaic-battery system participating in the day-ahead electricity market, comparing explicit MILP optimization with an online TD3 reinforcement-learning controller.

Results

Online TD3
€10,884.9
Annual 2024 revenue from the learned day-ahead PV-battery trading policy.
MILP Reference
€10,928.7
Forecast-based rolling-horizon optimizer revenue under the same physical system constraints.
TD3 vs MILP
99.60%
The learned controller approached the forecast-based MILP revenue without solving MILP at inference time.
Rule-Based Uplift
+34.9%
TD3 improvement over the fixed threshold baseline on the 2024 test horizon.
Perfect-Foresight Share
82.34%
TD3 revenue relative to the Day-Ahead Omniscience benchmark with perfect next-day information.
Test Horizon
8,736 h
A full 2024 evaluation with 364 day-ahead scheduling decisions.

What I built

I developed two forecast-driven battery trading workflows for the same grid-connected PV-battery system. Both use BiLSTM-based day-ahead price forecasts and forecast PV production, but they convert those forecasts into decisions differently: one through a constrained MILP optimizer and the other through an online TD3 reinforcement-learning policy.

The controller was tested under a realistic planning setup: decisions use forecast prices and forecast PV availability, while revenue is evaluated against actual 2024 prices and realized PV production. This keeps the result closer to operational scheduling than a perfect-information simulation.

Control strategy

The MILP model explicitly enforces battery capacity, SOC bounds, inverter limits, charge/discharge efficiency, and mutual exclusivity between charging and discharging. It remains the most transparent reference because its objective and constraints are directly defined.

The TD3 controller learns a direct mapping from daily state to a complete 24-hour action vector. Once trained, it produces a schedule through a neural-network forward pass, approaching MILP-level revenue while improving substantially over simple threshold rules.

Figures

Trading behavior and policy insight

Selected figures from the draft, focused on revenue, dispatch behavior, and actor explainability.

Cumulative revenue comparison
Fig. 1Cumulative revenue comparisonTD3 tracks the forecast-based MILP controller closely over July while both remain below the perfect-foresight benchmark.
TD3 export composition
Fig. 2TD3 export compositionThe learned policy schedules PV and battery exports across the day-ahead horizon rather than reacting hour by hour.
MILP and TD3 export behavior
Fig. 3MILP and TD3 export behaviorExport-event distributions show how the learned policy compares with the optimization-based schedule.
TD3 actor input-group attribution
Fig. 4TD3 actor input-group attributionIntegrated Gradients indicates that SOC feasibility dominates action magnitude, with forecasts providing timing context.
Temporal attribution across the schedule
Fig. 5Temporal attribution across the scheduleForecast price and PV signals become more influential in specific parts of the 24-hour action horizon.