Abstract
This paper presents two forecast-driven energy trading methodologies for a grid-connected photovoltaic-battery system participating in the day-ahead electricity market. Both methodologies use bidirectional long short-term memory neural networks with attention to forecast electricity prices, but they differ in the way the resulting forecasts are converted into operational decisions. The first method uses 24- to 48 h-ahead price forecasts within a mixed-integer linear programming rolling-horizon optimizer to compute the revenue-maximizing schedule for the following day. The second method uses an online twin delayed deep deterministic policy gradient controller that outputs a complete 24 h charge–discharge schedule once per day, using state information that includes battery state, recent price history, forecast prices, and forecast photovoltaic production. The control models are trained using historical data from 2019 to 2022, validated chronologically on 2023 data, and tested on the 2024 annual horizon, while the price forecaster is trained and validated on non-2024 data and evaluated on the held-out 2024 test period. In the realistic execution setting, schedules are planned using forecast photovoltaic production and implemented against actual photovoltaic production, while the day-ahead omniscience benchmark uses actual next-day prices and actual PV production as ideal scheduling inputs. The BiLSTM-MILP framework achieves EUR 10,928.7 over the 2024 test horizon, corresponding to 82.67% of the day-ahead omniscience benchmark. The online BiLSTM-TD3 controller achieves EUR 10,884.9, corresponding to 82.34% of the same benchmark and 99.60% of the BiLSTM-MILP revenue, while outperforming a rule-based baseline by 34.9%. These results show that online deep reinforcement learning can approach the performance of explicit mathematical optimization in day-ahead PV-battery trading while substantially improving over simple rule-based operation. Overall, the results indicate that BiLSTM-based forecasts can support both optimization-based and reinforcement-learning-based day-ahead control for the examined PV-battery system.
1. Introduction
With the growing integration of renewable energy, photovoltaic (PV) systems coupled with battery storage are increasingly participating in electricity markets as active energy resources [1,2]. These PV-battery installations can perform energy arbitrage, storing electricity when prices are low and supplying it when prices are high, while also providing services such as reserve capacity for grid support [3,4]. By leveraging battery storage in this way, PV owners can enhance the value of their solar generation and offer flexibility to the grid, creating new revenue streams and improving overall system reliability. However, optimizing the operation of PV-battery systems in competitive power markets is challenging due to uncertainties in electricity prices and renewable output forecasts, as well as the complex multi-layered structure of modern electricity markets (e.g., day-ahead and spot or intraday markets) [5,6,7].
Traditionally, these challenges have been addressed with mathematical optimization and heuristic control techniques. Many studies formulate the scheduling of PV-battery units as a mixed-integer linear programming (MILP) problem to obtain revenue maximizing strategies [4,8,9]. MILP-based energy management can yield an optimal schedule under assumed perfect foresight, but, in practice, it relies on accurate price and energy generation forecasts, which are commonly developed using statistical, econometric, machine-learning, and deep-learning methods [7,9]. In parallel, simple rule-based control strategies are often used (for example, charging the battery whenever excess PV is available or whenever electricity prices fall below a threshold) [10]. While such rule-based heuristics are easy to implement and are robust, they generally result in suboptimal economic performance under volatile market conditions because they lack the complexity needed to take advantage of rapid price fluctuations, which are challenging to predict, let alone adapt to.
In recent years, artificial intelligence techniques, particularly reinforcement learning (RL), have emerged as promising alternatives for managing distributed energy resources like PV-battery systems [10,11,12]. Instead of requiring an explicit model of future prices or a fixed set of operational rules, an RL agent learns an optimal policy by interacting with the environment (e.g., receiving price signals and observing battery states) and continuously adjusting its actions to maximize long-term rewards. This data-driven, model-free approach allows the controller to inherently handle uncertainties and complex decision-making in a dynamic market setting. Applications of deep RL (DRL) in energy-storage control have demonstrated that learned policies can outperform fixed heuristic baselines and achieve competitive economic dispatch performance, although their relative performance depends strongly on the algorithm, state representation, action space, and forecast information available to the agent [10,12]. These studies indicate that DRL can be useful for storage-control problems when the state representation and training setup reflect the operational setting. By enabling autonomous, adaptive decision-making, DRL approaches are therefore relevant to storage-control settings where the controller must respond to changing price and generation conditions. Nonetheless, deploying such AI-based strategies in real-world market operations still requires careful consideration of price forecast uncertainty and compliance with intricate market structures and regulations—challenges that ongoing research continues to address.
This study proposes and compares two prediction-control frameworks for a grid-connected PV-battery system participating in the day-ahead electricity market. Both frameworks rely on bidirectional long short-term memory (BiLSTM) neural networks with an attention mechanism to provide electricity price forecasts, but they differ in the way forecast information is converted into control decisions. In the first framework, BiLSTM forecasts are used by a mixed-integer linear programming (MILP) optimizer to compute a physically constrained day-ahead dispatch schedule. In the second framework, an online twin delayed deep deterministic policy gradient (TD3) controller learns to generate a full 24 h day-ahead schedule, using battery state information, historical prices, forecast prices, and forecast PV production as the decision context. By evaluating both methods on the same 2024 annual test horizon and benchmarking them against a day-ahead omniscience reference and a rule-based baseline [8,10], this work provides a direct comparison between explicit optimization and online deep reinforcement learning for forecast-driven day-ahead PV-battery trading. Moreover, the resulting schedules and export patterns are analyzed visually, providing insight into the operational behavior of both automated control strategies.
2. Materials and Methods
2.1. System Description
The methodologies derived in this study are applied on a grid-connected solar photovoltaic (PV) installation coupled with a lithium-ion battery energy storage system (BESS), where the PV and the battery are connected to the grid (G) via separate inverters (I2 and I1, respectively), as can be seen in Figure 1.
Figure 1.
PV-battery-grid system configuration.
At one timestep, which in this study has a duration of 1 h, the battery can either charge directly from the PV system or discharge to the grid through inverter I1. In parallel, the PV system can supply electricity to the grid through inverter I2, while part of the PV production may also be used for battery charging when this is selected by the controller. The updated dataset covers the period from 2019 to the beginning of 2025. The controller models are trained on historical data from 2019 to 2022, validated chronologically on 2023 data, and tested on the 2024 annual horizon. The electricity price forecaster follows the separate training and validation split described in Section 2.3.1, with 2024 retained as the held-out test period. The final evaluation horizon contains 364 day-ahead decisions, corresponding to 8736 hourly timesteps from 1 January 2024 00:00:00 to 29 December 2024 23:00:00.
Hourly PV production is represented using two separate time series. The first is the actual PV production, denoted by , which is used during schedule execution. The second is the day-ahead forecast PV production, denoted by , which is used by the BiLSTM-MILP and BiLSTM-TD3 controllers when planning the next-day schedule. This distinction creates a more realistic evaluation setting: the controllers make decisions using forecast PV availability, while the resulting schedules are implemented against actual PV production. Any additional actual PV production that was not included in the planned schedule is curtailed in the present implementation. The main fixed technical constraints used throughout the simulations, including battery efficiency, inverter efficiencies, and SOC bounds, are summarized in Table 1.
Table 1.
Main system constraints used in the simulation. The battery charging/discharging efficiency is based on [3], while the SOC limits and inverter efficiencies are defined as fixed assumptions of the evaluated PV-battery configuration.
2.2. Evaluated System Configuration
The updated experiments focus on one representative PV-battery configuration, selected to provide a direct comparison between the BiLSTM-MILP optimizer and the online BiLSTM-TD3 controller under identical physical constraints. The PV installed power is fixed at 100 kWp, the PV-grid inverter rated power is 80 kW, the battery capacity is 100 kWh, and the battery rated power is 50 kW. The BESS-grid inverter rated power is 80 kW. The battery SOC is constrained between 15% and 95%, with an initial SOC of 15%. The minimum battery transaction is set to 10% of the battery rated power, corresponding to 5 kW. This configuration corresponds to a medium-sized battery relative to the PV installation and is used consistently for all controller comparisons. The complete evaluated PV-battery configuration used in all annual controller comparisons is summarized in Table 2.
Table 2.
Evaluated PV-battery system configuration used for the 2024 annual comparison between the BiLSTM-MILP optimizer and the online BiLSTM-TD3 controller.
2.3. Forecasting Models
2.3.1. Day-Ahead Electricity Price Forecasting
The day-ahead electricity price forecaster is based on a bidirectional long short-term memory neural network with an attention mechanism. The model is used to provide the price forecast information required by both control frameworks. For each prediction instance, the input sequence contains the most recent hourly electricity prices, the corresponding solar-time features, and the price differences between consecutive timesteps. The price-difference input is included to provide information on short-term price momentum. In addition, the solar-time features of the following forecast horizon are provided to the model so that the output can account for deterministic daily and seasonal temporal structures.
The forecasting model receives the previous 23 hourly timesteps of electricity prices and related temporal features and outputs a 48 h electricity price forecast. The network consists of stacked bidirectional LSTM layers, followed by dropout regularization and an attention layer. The bidirectional recurrent layers encode the temporal structure of the input sequence in both forward and backward directions, while the attention mechanism assigns different weights to the encoded timesteps before the final dense output layer maps the extracted representation to the 48 h forecast vector. The final hyperparameter values used for the BiLSTM forecaster are reported in Table 3.
Table 3.
BiLSTM model hyperparameters used for the electricity price forecaster.
Although the model outputs a 48 h forecast, the control algorithms use the effective day-ahead segment required for market scheduling. Specifically, at each daily decision point, the relevant forecast interval from t + 24 to t + 48 is used by the BiLSTM-MILP optimizer and by the online BiLSTM-TD3 controller. This ensures that the forecast horizon used in the control problem is consistent with the day-ahead scheduling setting.
The electricity price forecaster was trained and validated using all non-2024 samples, corresponding to the 2019–2023 period, with a random 15% validation split. The year 2024 was held out as the final test period. Forecasting performance was evaluated using mean absolute error (MAE), root mean squared error (RMSE), mean absolute percentage error (MAPE), and symmetric mean absolute percentage error (sMAPE), as shown in Table 4. Since electricity prices can approach zero, MAPE may become numerically unstable and is therefore interpreted together with sMAPE.
Table 4.
Day-ahead electricity price forecasting performance of the BiLSTM model. The validation row corresponds to the random validation split from the 2019–2023 non-test data, while the test row corresponds to the held-out 2024 period.
The large MAPE value on the 2024 test set is mainly a consequence of near-zero electricity price values, for which percentage errors become disproportionately large. For this reason, sMAPE is reported alongside MAE and RMSE and is considered more informative for assessing forecasting performance in this setting.
2.3.2. Weather Forecasting and PV Generation Forecasting
Forecast PV production is obtained through a two-stage procedure. First, 48 h forecasts of the relevant meteorological variables are generated using the attention-enhanced BiLSTM weather forecasting framework developed in [13]. That model jointly forecasts air temperature, solar irradiance, and relative humidity over a 48 h horizon using historical meteorological data and encoded temporal features. In the present work, these weather forecasts are treated as exogenous inputs to the PV production model. Evaluation metrics can be seen in Table 5.
Table 5.
Weather-driven PV forecast accuracy used for the PV production input.
Second, the forecast meteorological variables are passed to a physics-based PV generation model implemented with pvlib-python [14]. The pvlib model converts the forecast irradiance and temperature information into an expected hourly PV power profile. This produces the day-ahead PV forecast , which is used by both the BiLSTM-MILP optimizer and the online BiLSTM-TD3 controller when planning the next-day schedule. The actual PV production is used only during schedule execution and revenue evaluation.
This separation between forecast and actual PV production creates a more realistic evaluation setting. The controllers make decisions using information that would be available at the time of day-ahead scheduling, while the final revenues are computed using realized PV production. When actual PV production exceeds the amount included in the planned schedule, the unplanned surplus is curtailed in the present implementation.
2.4. Application Scenarios
2.4.1. Day-Ahead Market Trading
In the day-ahead electricity market, energy transactions are scheduled one day in advance [5,6,7]. Participants commit to predefined hourly charge–discharge bids for the following 24 h, aiming to select the actions that maximize expected revenue based on anticipated price movements. In the proposed BiLSTM-MILP framework, the price forecasts described in Section 2.3.1 and the PV generation forecasts described in Section 2.3.2 are passed to an MILP optimizer implemented with GurobiPy [15]. The PV generation forecast used by the MILP is therefore indirectly weather-driven, since it is produced from the 48 h meteorological forecasts through the pvlib-based PV model described above. At each daily decision point, the optimizer uses the relevant day-ahead forecast horizon to compute the following-day schedule under the physical constraints of the PV-battery system. The decision variables used in the MILP formulation, together with their physical interpretation and admissible domains, are summarized in Table 6. The corresponding mathematical constraints, which enforce SOC dynamics, charge–discharge limits, inverter limits, mutual exclusivity, and energy conservation, are presented in Table 7.
Table 6.
Definition of decision variables used in the MILP formulation, including their physical interpretation and variable domain.
Table 7.
Mathematical formulation of the constraints applied in the MILP optimization model. Each constraint enforces physical limitations related to battery dynamics, inverter capacities, and permissible charge/discharge rates.
These constraints enforce the physical meaning of the decision variables and represent the component limits, operating logic, and energy-balance requirements of the PV-battery system. The simulation also considers a nonzero SOC at the start of the first timestep, specifically,
The objective function of the optimization problem, i.e., the quantity maximized by MILP, is the accumulated revenue over a predefined optimization horizon, such as 24 h. It is defined as
This strategy is then implemented using the actual electricity prices and actual PV production at the time of execution. It is benchmarked against a day-ahead omniscience reference, in which both next-day electricity prices and next-day PV availability are assumed to be perfectly known at the time of scheduling. This benchmark is solved under the same rolling day-ahead horizon and physical constraints as the forecast-based MILP case but with actual price and actual PV production used as the scheduling inputs. It therefore represents the ideal revenue achievable by the same day-ahead scheduling framework under perfect price and PV information [4,8,9].
2.4.2. Online Day-Ahead TD3 Trading
In addition to the MILP-based day-ahead optimizer, this study develops an online deep reinforcement learning controller for the same day-ahead trading problem. The controller is based on the twin delayed deep deterministic policy gradient (TD3) algorithm [16] and is trained to generate a complete 24 h battery schedule once per day.
The TD3 controller uses the same forecast information structure as the MILP optimizer but learns a direct mapping from the daily state to a complete 24 h action vector. The state includes the current SOC, the available charge room, the available discharge room, the previous 24 hourly electricity prices, the next 24 forecast electricity prices, and the next 24 forecast PV production values. The action is a continuous 24-dimensional vector, where each component corresponds to the battery decision for one hour of the next-day schedule.
The actor and critic networks use recurrent sequence encoders over the daily market context so that the policy can exploit temporal patterns in the 24 h price and PV forecast sequences. The actor maps the encoded state to the 24 h action vector, while the two critics independently estimate the state-action value. Following the TD3 algorithm, the minimum of the two critic estimates is used in the target-value calculation to reduce overestimation bias [16]. The policy update is delayed relative to the critic updates, and target-policy smoothing is used during critic target construction, following the standard TD3 formulation [16].
To interpret the trained TD3 actor, integrated gradients analysis is applied after training. The explanation target is the aggregate 24 h action magnitude, defined as the mean squared magnitude of the actor’s 24 h action vector. Attributions are computed with respect to the daily actor input and are grouped into four input categories: SOC-related context, past price sequence, forecast price sequence, and forecast PV sequence. This provides a model-based attribution analysis of which input groups most strongly influence the learned day-ahead action profile [17].
The controller is trained using historical data up to 2022. The year 2023 is used for chronological validation and online adaptation, while 2024 is reserved as the final test year. The selected trial uses 600 bootstrap episodes, 8 online updates per day, and zero online exploration noise during the final online evaluation. TD3 hyperparameters are tuned using Optuna with a tree-structured Parzen estimator sampler [18].
The TD3-generated schedule is planned using forecast PV production and executed against actual PV production, following the same realistic execution convention as the BiLSTM-MILP framework. This ensures that the comparison between MILP and TD3 reflects differences in decision-making strategy rather than differences in available information.
2.4.3. Rule-Based Baseline
A rule-based baseline is included as a simple non-learning comparison. The baseline does not solve an optimization problem and does not learn from interaction. For each day-ahead decision window, it computes the mean of the recent price history using a 100 h lookback window and compares each forecast price in the 24 h horizon against fixed thresholds. If the forecast price is greater than 1.8 times the recent mean price, the baseline selects a discharge action; if it is lower than 0.2 times the recent mean price, it selects a charge action; otherwise it remains neutral. These heuristic actions are then converted into a feasible battery schedule using the same battery capacity, SOC bounds, charge/discharge power limit, inverter limits, efficiency, and minimum transaction rule used by the TD3 environment. Forecast PV limits planned charging and PV export, while the final schedule is executed against actual PV production and actual electricity prices. Thus, the baseline uses the same evaluation data as the learning controller, but its decisions are generated by fixed price-threshold rules rather than by forecast-based optimization or reinforcement learning.
3. Results
The controllers are evaluated over the 2024 annual test horizon, corresponding to 364 day-ahead decisions and 8736 hourly timesteps. Electricity prices are obtained from the ENTSO-E transparency platform [19], while PV production is represented using both forecast and actual PV time series. The following results compare the day-ahead omniscience benchmark, the BiLSTM-MILP forecast-based optimizer, the online BiLSTM-TD3 controller, and a rule-based baseline. Figure 2 shows the hourly day-ahead electricity price trajectory over the 2024 test horizon.
Figure 2.
Hourly day-ahead electricity prices over the 2024 test horizon.
3.1. Day-Ahead Market Trading Results and Interpretation
The annual revenues obtained over the 2024 test horizon are summarized in Table 8. The day-ahead omniscience benchmark reaches EUR 13,220.1 and represents the ideal case in which both next-day prices and next-day PV production are known perfectly at the time of scheduling. The BiLSTM-MILP controller achieves EUR 10,928.7, corresponding to 82.67% of the day-ahead omniscience revenue. This result reflects the loss caused by imperfect price and PV forecasts under realistic day-ahead execution.
Table 8.
Annual revenue comparison over the 2024 test horizon for the evaluated PV-battery configuration.
The BiLSTM-MILP controller remains the strongest forecast-based controller, but the online BiLSTM-TD3 agent achieves a very similar result. Its revenue is 99.60% of the BiLSTM-MILP revenue, with an absolute difference of only EUR 43.8 over the annual test horizon. Both forecast-based controllers clearly outperform the rule-based baseline, indicating that the use of forecast context and optimized decision-making provides a substantial economic advantage over fixed heuristic operation.
3.2. Online Day-Ahead TD3 Results and Interpretation
The online BiLSTM-TD3 controller is evaluated on the same 2024 annual horizon as the BiLSTM-MILP optimizer. For visual clarity, Figure 3 shows the cumulative revenue trajectories over July 2024, while the reported revenue values refer to the full 2024 test horizon. The TD3 controller achieves EUR 10,884.9, compared with EUR 10,928.7 for the BiLSTM-MILP controller and EUR 13,220.1 for the day-ahead omniscience benchmark. Therefore, the online TD3 controller reaches 82.34% of the day-ahead omniscience revenue and 99.60% of the BiLSTM-MILP revenue. Although it does not exceed the MILP optimizer in the current best trial, the difference between the two methods is small over the annual horizon.
Figure 3.
Cumulative revenue trajectories over July 2024 for day-ahead omniscience, BiLSTM-MILP, and online BiLSTM-TD3.
The main advantage of the TD3 controller appears when it is compared with the rule-based baseline. The baseline achieves EUR 8068.2 over the 2024 test horizon, while the TD3 controller achieves EUR 10,884.9. This corresponds to a 34.9% improvement, showing that the online reinforcement-learning policy learns economically useful scheduling behavior from the forecast context [10,12]. The validation-year results follow the same trend: the TD3 controller reaches EUR 12,583.1 on the 2023 online validation horizon, compared with EUR 10,988.3 for the rule-based baseline.
Figure 4 shows the hourly export composition of the TD3 strategy over July 2024. Since the TD3 controller operates in a day-ahead setting, the observed export pattern should not be interpreted as purely reactive spot-market behavior. Instead, it reflects a learned schedule generated once per day from forecast prices, forecast PV production, and battery state information. Figure 5 compares the distribution of export events between BiLSTM-MILP and online BiLSTM-TD3 for July 2024. This comparison provides a compact view of how often each controller exports only PV energy, only battery energy, both sources simultaneously, or no energy.
Figure 4.
Hourly export composition under the online BiLSTM-TD3 controller over July 2024. Blue indicates PV export, orange indicates battery export, and blank regions correspond to hours with no export.
Figure 5.
Distribution of hourly export events under the BiLSTM-MILP and online BiLSTM-TD3 strategies over July 2024. Categories indicate export from PV only, battery only, both PV and battery, or no export.
Overall, the online BiLSTM-TD3 controller achieves nearly the same annual revenue as the BiLSTM-MILP optimizer in the examined 2024 test case. The MILP method retains the advantage of exact constraint enforcement and direct optimization under the forecast sequence, while TD3 offers a learned policy that can be updated online and can approach MILP-level performance after training and validation. The results therefore support the use of online reinforcement learning as a practical control strategy for day-ahead PV-battery trading, especially when a rule-based controller is the main operational baseline. The following subsection complements these operational visualizations with a model-based attribution analysis of the TD3 actor.
3.3. Actor Explainability Analysis
To provide a more systematic interpretation of the online TD3 controller, integrated gradients analysis was applied to the trained actor network. The attribution target was the aggregate 24 h action magnitude, computed as the mean squared magnitude of the 24 h action vector. The analysis was performed over the 364 days of the 2024 test horizon using a mean baseline state and 32 integration steps. The resulting attributions were grouped into SOC-related context, past price sequence, forecast price sequence, and forecast PV sequence.
Figure 6 shows the mean absolute attribution assigned to each input group. The SOC-related context dominates the actor attribution, accounting for 86.70% of the total mean absolute attribution. The forecast price sequence contributes 6.62%, the forecast PV sequence contributes 3.41%, and the past price sequence contributes 3.27%. This indicates that the actor’s aggregate action magnitude is primarily constrained by the battery state and available charge–discharge room, while the price and PV forecast sequences provide secondary timing information for the day-ahead schedule.
Figure 6.
Integrated gradients attribution of the trained TD3 actor by input group over the 2024 test horizon. Values represent the mean absolute attribution percentage for the aggregate 24 h action magnitude.
Figure 7 shows the temporal attribution profile for the sequence inputs. The forecast price attribution increases strongly toward the final hours of the 24 h horizon, indicating that the actor is especially sensitive to forecast prices near the end of the scheduled day. The forecast PV attribution is concentrated mainly in the later daytime/evening part of the horizon, while the past price attribution remains smaller and more distributed. These results support the interpretation that the TD3 actor combines battery-state feasibility information with forecast-driven temporal signals when generating its 24 h action vector.
Figure 7.
Temporal integrated gradients attribution profiles for the TD3 actor sequence inputs over the 2024 test horizon. The profiles show mean absolute attribution by hour index for past prices, forecast prices, and forecast PV production.
3.4. Comparative Discussion
The comparison between the BiLSTM-MILP framework and the online BiLSTM-TD3 controller highlights the different characteristics of optimization-based and reinforcement-learning-based control in the same day-ahead market setting. Both methods use forecast information, and both generate schedules for the next day, but they differ in how the decision problem is solved. The BiLSTM-MILP framework solves an explicit constrained optimization problem using the forecast price and PV sequences. In contrast, the BiLSTM-TD3 controller uses a learned policy that maps daily state and forecast context directly to a 24 h action vector.
The BiLSTM-MILP controller achieves the highest forecast-based revenue in the current test, reaching EUR 10,928.7 over the 2024 horizon. This is expected because the MILP formulation directly encodes the physical constraints and optimizes the schedule with respect to the forecast inputs. Its main strength is transparency: the decision variables, constraints, and objective function are explicitly defined, making the resulting schedule easier to audit and interpret.
The online BiLSTM-TD3 controller achieves EUR 10,884.9, corresponding to 99.60% of the BiLSTM-MILP revenue. This result is important because the TD3 controller is not solving the MILP problem directly during inference. Instead, it has learned a scheduling policy through training, validation, and online adaptation. The small performance gap suggests that the learned controller captures most of the economically relevant structure of the day-ahead dispatch problem.
The value of the online TD3 controller is not that it exceeds the MILP solution in the present single-configuration test but that it reaches almost the same annual revenue without solving an explicit constrained optimization problem at inference time. Once trained, the actor produces a complete 24 h schedule through a direct neural-network forward pass, using the current battery state, past prices, forecast prices, and forecast PV production as inputs. This property becomes increasingly relevant in larger applications, where the optimization problem may involve many batteries, multiple market products, network constraints, stochastic scenarios, or repeated real-time re-optimization. In such settings, the learned controller can act as a fast policy approximation that internalizes the structure of the dispatch problem and can be updated online as new data become available. Therefore, a main practical advantage of TD3 is scalability and adaptive deployment, while MILP remains preferable when exact constraint enforcement and full mathematical transparency are the primary requirements.
The TD3 controller is especially strong relative to the rule-based baseline. Its 34.9% improvement over the baseline indicates that forecast-aware learned control provides a substantial advantage over fixed heuristic operation. This is relevant for practical applications where simple rules are often attractive because of their low implementation cost but may fail to exploit price and PV forecast information effectively.
The two methods, therefore, have complementary strengths. MILP is preferable when exact constraint enforcement, deterministic optimization, and full interpretability are the primary requirements. Online TD3 is attractive when the objective is to learn an adaptive control policy that can be updated with new data and deployed without solving a full optimization problem at every decision point. In the present study, both approaches remain substantially below the day-ahead omniscience benchmark, which indicates that forecast uncertainty remains the dominant limitation.
The scope of this work is the methodological comparison between forecast-driven MILP optimization and online reinforcement-learning control rather than a full techno-economic assessment. Battery degradation, transaction fees, grid export constraints, imbalance penalties, and regulatory limitations are therefore not explicitly modeled. As a result, the reported revenues should be interpreted as comparative estimates under a simplified market setting, not as directly bankable project revenues.
Future work should therefore examine richer price and PV forecasts, battery degradation costs, market fees, export limits, and longer multi-year testing to assess robustness under more realistic operational conditions.
4. Conclusions
In this work, two forecast-driven methodologies were developed for day-ahead energy trading in a grid-connected PV-battery system. Both methodologies use BiLSTM-based price forecasting, but they differ in the control algorithm used to convert forecasts into battery dispatch schedules. The first approach combines BiLSTM forecasts with MILP optimization, while the second uses an online TD3 reinforcement-learning controller that outputs a complete 24 h schedule for the following day.
The updated experimental setup uses a multi-year dataset, with controller training performed on 2019–2022 data, chronological validation and online adaptation on 2023 data, and final testing on the 2024 annual horizon. The evaluation covers 364 day-ahead decisions and 8736 hourly timesteps. In contrast to the earlier simplified setup, the current execution distinguishes between forecast and actual PV production. Both controllers plan schedules using forecast PV production and execute those schedules against actual PV production, with surplus unplanned PV curtailed.
The BiLSTM-MILP controller achieved EUR 10,928.7 over the 2024 test horizon, corresponding to 82.67% of the day-ahead omniscience benchmark. The online BiLSTM-TD3 controller achieved EUR 10,884.9, corresponding to 82.34% of the same benchmark and 99.60% of the BiLSTM-MILP revenue. Although the TD3 controller did not outperform the MILP optimizer in the current best trial, it achieved nearly identical annual revenue while operating as a learned policy rather than as an explicit mathematical optimizer. This suggests that online TD3 can serve as a scalable learned-control alternative when fast repeated scheduling is required, while MILP remains the reference method for exact optimization under explicitly modeled constraints.
Integrated gradients analysis further showed that the trained TD3 actor is driven primarily by SOC-related feasibility information, with forecast prices and forecast PV production providing an additional temporal context for the 24 h schedule.
The reinforcement-learning approach showed a clear advantage over the rule-based baseline. The baseline achieved EUR 8068.2, while the online TD3 controller achieved EUR 10,884.9, representing a 34.9% improvement. This confirms that incorporating forecast context into a learned day-ahead control policy can provide substantial economic benefit compared with fixed heuristic operation.
Overall, the results show that explicit optimization and online reinforcement learning can both provide effective forecast-driven control strategies for PV-battery energy trading. MILP remains the most transparent and directly constrained method, while online TD3 offers a flexible learned-control alternative that can approach MILP-level performance and substantially outperform rule-based operation. Future work should extend the framework by including battery degradation costs, market fees, export limitations, probabilistic PV and price forecasts, and broader multi-year testing under different system sizes and market conditions.
Author Contributions
Conceptualization, G.V., K.B. and C.T.; methodology, G.V.; software, G.V.; validation, G.V., K.B. and C.T.; formal analysis, G.V.; investigation, G.V.; resources, K.B. and C.T.; data curation, G.V.; writing—original draft preparation, G.V.; writing—review and editing, G.V., K.B. and C.T.; visualization, G.V.; supervision, K.B. and C.T.; project administration, K.B. and C.T. All authors have read and agreed to the published version of the manuscript.
Funding
This research received no external funding.
Institutional Review Board Statement
Not applicable.
Informed Consent Statement
Not applicable.
Data Availability Statement
The electricity price data used in this study were obtained from the ENTSO-E Transparency Platform [19]. The PV generation data were produced using the pvlib-based modelling procedure described in Section 2.3.2.
Conflicts of Interest
The authors declare no conflict of interest.
Abbreviations
The following abbreviations are used in this manuscript:
| AI | Artificial Intelligence |
| BESS | Battery Energy Storage System |
| BiLSTM | Bi-Directional Long Short-Term Memory |
| CMA-ES | Covariance Matrix Adaptation-Evolution Strategy |
| DNN | Deep Neural Network |
| DRL | Deep Reinforcement Learning |
| ENTSO-E | European Network of Transmission System Operators for Electricity |
| G | Grid |
| I1 | Inverter 1 |
| I2 | Inverter 2 |
| LSTM | Long Short-Term Memory |
| ML | Machine Learning |
| MILP | Mixed Integer Linear Programming |
| PV | Photovoltaic |
| PVGIS | Photovoltaic Geographical Information System |
| RL | Reinforcement Learning |
| TD3 | Twin Delayed Deep Deterministic Policy Gradient |
| Variables | |
| Action | |
| battery capacity | |
| Maximum energy available for charge | |
| Minimum energy available for charge | |
| Part of the battery energy, bound to be discharged | |
| Part of the energy produced by the PV bound for the battery | |
| Part of the energy produced by the PV bound for the grid | |
| Rated battery power | |
| Rated inverter 1 power | |
| Rated inverter 2 power | |
| Peak photovoltaic production power | |
| policy | |
| Optimal policy | |
| State-action value function | |
| Optimal state–action value function | |
| System state | |
| State Of charge | |
| Minimum state of charge | |
| Maximum state of charge | |
| t | Timestep |
| Battery rated storage duration | |
| Timestep duration | |
| Greek symbols | |
| Battery charging/discharging efficiency | |
| Inverter 1 efficiency | |
| Inverter 2 efficiency | |
| Subscripts | |
| Batt | Battery |
| exch,r | Rated storage duration |
| grid | Bound to the grid |
| inv1 | Inverter 1 |
| inv2 | Inverter 2 |
| min | Minimum |
| max | Maximum |
| p | Peak |
| pv | Photovoltaic |
| r | Rated |
References
- Šúri, M.; Huld, T.A.; Dunlop, E.D.; Ossenbrink, H.A. Potential of solar electricity generation in the European Union member states and candidate countries. Sol. Energy 2007, 81, 1295–1305. [Google Scholar] [CrossRef] [Scilit]
- JRC Photovoltaic Geographical Information System (PVGIS)—European Commission. Available online: https://re.jrc.ec.europa.eu/pvg_tools/en/tools.html (accessed on 5 June 2025).
- Farhad, S.; Nazari, A. Introducing the energy efficiency map of lithium-ion batteries. Int. J. Energy Res. 2018, 43, 931–944. [Google Scholar] [CrossRef] [Scilit]
- Fernández-Muñoz, D.; Pérez-Díaz, J.I. Optimisation models for the day-ahead energy and reserve self-scheduling of a hybrid wind–battery virtual power plant. J. Energy Storage 2023, 57, 106296. [Google Scholar] [CrossRef] [Scilit]
- Shah, D.; Chatterjee, S. A comprehensive review on day-ahead electricity market and important features of world’s major electric power exchanges. Int. Trans. Electr. Energy Syst. 2020, 30, e12360. [Google Scholar] [CrossRef] [Scilit]
- Tanrisever, F.; Shahmanzari, M.; Buke, B. European Electricity Day-Ahead Markets: A Review of Models and Solution Methods. SSRN Electron. J. 2020, 3517267. [Google Scholar] [CrossRef] [Scilit]
- Lago, J.; Marcjasz, G.; De Schutter, B.; Weron, R. Forecasting day-ahead electricity prices: A review of state-of-the-art algorithms, best practices and an open-access benchmark. Appl. Energy 2021, 293, 116983. [Google Scholar] [CrossRef] [Scilit]
- Dinh, H.T.; Kim, D.; Kim, D. MILP-based optimal day-ahead scheduling for a system-centric community energy management system supporting different types of homes and energy trading. Sci. Rep. 2022, 12, 18305. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Wang, Z.; Shi, L. Day-Ahead Optimal Scheduling for a Full-Scale PV–Energy Storage Microgrid: From Simulation to Experimental Validation. Electronics 2025, 14, 1509. [Google Scholar] [CrossRef] [Scilit]
- Sage, M.; Campbell, J.; Zhao, Y.F. Enhancing Battery Storage Energy Arbitrage with Deep Reinforcement Learning and Time-Series Forecasting. In Proceedings of the ASME 2024 18th International Conference on Energy Sustainability, Anaheim, CA, USA, 15–17 July 2024; p. V001T01A007. [Google Scholar] [CrossRef] [Scilit]
- Sutton, R.S.; Barto, A. Reinforcement learning: An introduction. In Adaptive Computation and Machine Learning; Nachdruck; The MIT Press: Cambridge, MA, USA, 2014. [Google Scholar]
- Xu, H.; Li, X.; Zhang, X.; Zhang, J. Arbitrage of Energy Storage in Electricity Markets with Deep Reinforcement Learning. arXiv 2019. [Google Scholar] [CrossRef] [Scilit]
- Vamvouras, G.; Braimakis, K.; Tzivanidis, C. An Explainable, Attention-Enhanced, Bidirectional Long Short-Term Memory Neural Network for Joint 48-Hour Forecasting of Temperature, Irradiance, and Relative Humidity. arXiv 2025. [Google Scholar] [CrossRef] [Scilit]
- Holmgren, W.F.; Hansen, C.W.; Mikofski, M.A. pvlib python: A python package for modeling solar energy systems. J. Open Source Softw. 2018, 3, 884. [Google Scholar] [CrossRef] [Scilit]
- Gurobi Optimizer Reference Manual-Python API. Gurobi Optimization, LLC. 2024. Available online: https://docs.gurobi.com/projects/optimizer/en/current/reference/python.html (accessed on 12 July 2025).
- Fujimoto, S.; van Hoof, H.; Meger, D. Addressing Function Approximation Error in Actor-Critic Methods. arXiv 2018. [Google Scholar] [CrossRef] [Scilit]
- Sundararajan, M.; Taly, A.; Yan, Q. Axiomatic Attribution for Deep Networks. arXiv 2017. [Google Scholar] [CrossRef] [Scilit]
- Akiba, T.; Sano, S.; Yanase, T.; Ohta, T.; Koyama, M. Optuna: A Next-generation Hyperparameter Optimization Framework. In Proceedings of the 25th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining; ACM: New York, NY, USA, 2019; pp. 2623–2631. [Google Scholar]
- ENTSO-E Transparency Platform. Available online: https://transparency.entsoe.eu/ (accessed on 5 June 2025).
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.






