Abstract
Accurate PV power prediction is crucial in efficiently operating intelligent power grid systems. Data-driven approaches have shown high performance in predictive tasks. Deep reinforcement learning (DRL) merges deep learning with reinforcement learning and has been widely studied for optimization challenges in various fields. However, limited research has focused on applying DRL to ultra-short-term PV power prediction. Hence, a soft actor–critic (SAC) model using long short-term memory (LSTM) is proposed for predicting PV power. To accomplish this, first, the PV power problem is modeled as a Markov decision process with historical weather data and PV power data as state inputs. Then, LSTM is integrated into the critic network of SAC to enhance its memory capability, thus improving prediction accuracy. Ultimately, the agent engages with the environment to address the optimization problem. Experimental results indicate that the proposed model attains greater prediction accuracy. This study explores the potential of DRL for PV power prediction, and the proposed method can be extended to other prediction fields, including grid prediction and wind power prediction.
Introduction
Solar energy is among the most popular renewable energy sources today due to its non-polluting nature, low cost, accessibility, and non-transportability. 1 With global emphasis on “carbon peaking and carbon neutrality,” clean energy, particularly solar energy, is gaining increased attention. Solar power, mainly generated through photovoltaic (PV) power generation, is growing rapidly worldwide. Photovoltaic power generation provides clean energy and reduces reliance on fossil fuels, supporting economic and social development. Despite its widespread availability, solar energy generation is highly affected by the variability of illumination and the periodicity of day and night, leading to instability and uncontrollability in PV power systems. These challenges can cause significant disruptions in power systems’ operation, dispatch, and planning, necessitating accurate PV power forecasting. Accurate forecasting enhances the effective utilization of solar energy, improves grid operation efficiency, and reduces economic losses. 2
PV forecasting, generally classified as time series forecasting, can be direct or indirect,3,4 and varies in time scale from ultra-short-term to long-term. Forecasting methods are categorized as physical methods, statistical methods, or machine learning methods.
Factors like solar radiation, battery temperature, local conditions, and sun angle typically affect PV power generation. Physical prediction methods typically do not rely on historical data; rather, they rely on geographic information, precise meteorological data, and comprehensive physical model information of PV cells. 5 Despite their basis in PV power generation principles and current climate conditions, physical prediction methods often suffer from low accuracy due to the difficulty in obtaining high-resolution geographic data and accurate PV module operational parameters. 6
Statistical methods use historical data to predict future power generation by establishing a mapping relationship. 7 However, given the intrinsic volatility and occasional lack of periodicity in PV power generation, statistical methods often exhibit reduced generalization ability. Thus, the process of collecting and computing precise data remains challenging.
Artificial neural network (ANN) techniques have significantly improved PV power prediction accuracy.8,9 Nevertheless, ANNs typically capture only a fraction of the features in PV data, which limits their ability to fully fit the data distributions. 10 Feature extraction and nonlinear mapping tasks in photovoltaic power forecasting pose considerable challenges. Thus, applying deep learning can effectively address ANN limitations in feature extraction and transformation.
Advancements in hardware have spurred the development of deep learning, which has garnered significant research interest in prediction fields, including PV prediction. For instance, deep neural networks were utilized for time-series predictions. 11 Deep learning models can account for nonlinear characteristics of time series data and identify complex data associations from larger datasets. A deep learning approach based on LSTM networks was proposed to capture solar irradiance behavior using day-ahead weather forecasts. 12 An attention-based time series prediction model, which used an attention mechanism incorporating time-step-based feature weights, was outlined. 13 A hybrid model combining convolutional neural networks and LSTM for PV power prediction was proposed, 14 but it overlooked the impact of environmental variables. Models using modal decomposition and wavelet transforms combined with LSTM and CNN to predict PV power were introduced,15,16 yet prediction errors persisted. Although deep learning has significantly advanced PV power prediction, the volatility of PV power and complex weather factors still challenge the attainment of accurate, generalizable models.
Recent studies have also explored the application of deep reinforcement learning (DRL) in PV power prediction. For example, a DRL-based approach for optimizing PV power generation under dynamic weather conditions was proposed, 17 demonstrating improved prediction accuracy. Another study employed a combination of DRL and transfer learning to improve the adaptability of PV power prediction models across various geographic locations. 18 These studies underscore the potential of DRL in addressing the complexities of PV power prediction, although further research is needed to fully leverage its capabilities.
Deep reinforcement learning (DRL) integrates the nonlinear fitting skills of deep learning with the decision-making strengths of reinforcement learning, finding applications in artificial intelligence. DRL has been widely researched and applied in gaming, 19 robotics, 20 and control decision-making. In PV systems, DRL-based models have shown commendable performance in optimal control. For instance, DRL was employed to schedule the capacity of PV battery storage systems, 21 and DRL was used to control PV systems under partial shading to achieve maximum benefits. 22 Despite its promise, DRL’s application to PV power prediction remains unexplored.
To address these challenges, this paper proposes an LSTM-SAC model for PV power prediction, transforming the prediction problem into a decision-making one. The theoretical foundation of the proposed model combines the strengths of both LSTM and SAC: LSTM enhances the model’s memory capability by capturing long-term dependencies in time series data, while SAC provides an efficient framework for optimizing the prediction process through reinforcement learning. By merging these components, the model can effectively handle the volatility and complexity of PV power data.
To address these challenges, this paper proposes a DRL model based on LSTM-SAC for PV power prediction, transforming the prediction problem into a decision-making one.
This paper offers several important insights, including the following key points. 1.We modeled the ultra-short-term PV prediction problem as a Markov decision process (MDP), defining states, actions, and reward functions and solving the optimal problem. 2.We proposed an LSTM-based SAC model with multiple relevant variables for ultra-short-term PV forecasting. 3.We analyzed the prediction results of the LSTM-SAC model, comparing it with SAC and other traditional supervised learning methods, thereby demonstrating our model’s effectiveness.
Research methodology
Deep reinforcement learning
Reinforcement learning
Reinforcement learning (RL) entails learning through trial and error by interacting with the environment, with the goal of maximizing the cumulative reward that the agent receives.
23
RL problems can be represented as Markov decision processes (MDPs), which consist of five components, as illustrated in Figure 1. 1. 2. 3. 4. 5. MDP.

In RL,
Classic RL algorithms, such as Q-learning, store Q-values into Q-tables, but struggle with complex environments and high-dimensional spaces. DRL addresses some of these limitations.
Soft actor–critic
Haarnoja et al. proposed soft actor–critic (SAC), an off-policy, maximum entropy DRL algorithm based on the actor–critic framework, suitable for solving both discrete and continuous problems. 24
In SAC, the actor network is tasked with learning a stochastic policy to evaluate the actions chosen under a given state
The agent observes the current state
The objective can be re-expressed as:
After transformation, the above equation can be written as:
The critic network evaluates the Q-values using a neural network. The target of the online critic network is defined by
The parameters of both the target actor network and the target critic network utilize a soft update method, which is essential for maintaining the stability of the algorithm, as shown below:
LSAC
In the conventional SAC approach, the actor and critic networks utilize multi-layer perceptrons (MLPs), which consist of several fully connected layers. A notable limitation of these MLPs is the lack of memory function due to their purely feedforward architecture. To address this, the fully connected layers in the critic networks are enhanced by integrating long short-term memory (LSTM) networks,
25
a variant of recurrent neural networks (RNNs). Despite the challenges of vanishing and exploding gradients that can hinder the learning capabilities of traditional RNNs, resulting in suboptimal practical outcomes, LSTM networks are favored for their ability to retain valuable information over extended periods, making them particularly effective in time series prediction tasks. The LSTM’s advantage stems from its innovative gate mechanisms, depicted in Figure 2. The LSTM model receives three types of inputs: the current input sample LSTM cell structure and integration into the critic network.
The integration of LSTM into the critic network of SAC improves the model’s capability to capture long-term dependencies and temporal correlations in PV power data. Traditional SAC models rely on fully connected layers (MLPs) in the critic network, which lack memory capabilities. By incorporating LSTM, the critic network gains the ability to retain past states and actions, which is crucial for accurate predictions in time series problems. The LSTM’s gate mechanisms allow it to selectively retain or discard past information, thereby improving the model’s capacity for nonlinear fitting and temporal reasoning. This fusion effectively addresses the volatility and complexity of PV power data, leading to enhanced prediction accuracy. First, LSTM networks are intended to capture long-term dependencies in sequential data through their unique gate mechanisms. By integrating LSTM into the critic network of SAC, the model can effectively remember past states and actions, which is crucial for making accurate predictions in time series problems like PV power forecasting. Figure 2 shows the LSTM cell structure and its integration into the critic network. The LSTM cell consists of three key gates: the forgetting gate, the input gate, and the output gate. These gates manage the flow of information, allowing the network to retain or discard past information selectively. By incorporating LSTM into the critic network, the model can effectively capture temporal dependencies and long-term correlations in the data. This integration greatly enhances the model’s capacity to make precise predictions, particularly in situations involving complex time series data like PV power prediction.
PV power prediction modeling
Although traditional supervised learning models such as CNN and LSTM possess strong nonlinear fitting capabilities, they lack the decision-making ability inherent in DRL and are susceptible to random power volatility. This limitation impairs their ability to make accurate PV power predictions at specific moments, thereby reducing overall accuracy. This subsection details the DRL model based on LSTM-enhanced LSAC for PV power prediction. Figure 3 illustrates the research framework of this paper. First, power data are collected from the case PV system at a resolution of 5 min. Relevant meteorological data affecting PV power are introduced to improve prediction accuracy and robustness. Data set creation and preprocessing are followed, including outlier detection and normalization. Based on the same input variables, four common supervised learning models (LSTM, CNN, BPNN, and RF), and SAC were also developed. Finally, the performance of these six models was compared regarding prediction accuracy. Framework diagram.
Data preprocessing
The data preprocessing process involves two main tasks: outlier detection and data normalization. Outliers and low-quality data, which can negatively affect the final model, should be removed before model development. Unrealistic values are replaced by linear interpolation. For normalization, 0-1 data normalization is used to keep each input feature on a similar scale, which aids in finding the global optimum using Adam’s algorithm when applying prediction techniques.
MDP
To utilize reinforcement learning for the problem, the PV prediction problem must first be modeled as an MDP. Hence, states, actions, and rewards need to be defined. In this study, all model predictions are single-step predictions; all power data from the previous hour and the current climate data are used as inputs, with the output being the predicted power at the current moment for each model. The definitions are as follows.
State space
State space.
Action space
The action space includes continuous power values between 0 and 23 (based on historical data). The agent outputs power values in the range [0, 23] based on its observed states during training. The output is the predicted power value.
Reward function
The reward function is defined as follows:
LSAC
The DRL technique can be applied once the PV power prediction problem is reformulated as a decision-making issue problem. The training block diagram of the DRL-based prediction model, utilizing LSTM, is shown in Figure 4. In this algorithm, all power data from the previous hour, along with the current climate data, are used to predict the current power output. Initially, historical PV and weather data are built into an environment for DRL agents to learn from. The agents then observe the current state Schematic of LSAC.
The LSAC algorithm for PV power prediction is shown below.
The training data is normalized according to equation (7) to ensure uniform scales. The model is then trained following the pseudo-code in Algorithm 1. The detailed training process is as follows: to initiate the process, both the online critic network and the actor network are initialized randomly, and the parameters of the online critic network are transferred to the target critic network. The experience buffer
Evaluation indicators
In this study, three evaluation metrics are utilized to assess the prediction accuracy of the proposed model: root mean square error (RMSE), mean absolute error (MAE), and the coefficient of determination (R2). MAE represents the average deviation between actual and predicted values based on absolute error, whereas RMSE indicates the standard deviation of the residuals between actual and predicted values. Both MAE and RMSE are dependent on scale. R2 ranges from 0 to 1 and is frequently used in regression models to evaluate the fit between predicted and actual values. The calculations for these three metrics are as follows:
Case study
Experimental data
Prediction accuracy on additional dataset.
However, it is important to note that the dataset used in this study is limited to a specific PV system and time period. This limitation might affect the generalizability of the results. Future work should consider validating the proposed model on additional datasets from diverse geographic locations and under varying environmental conditions to further demonstrate its robustness and applicability.
Specific information of the 1B DKASC system.

Partial PV data.
Parameter setting
Through continuous parameter adjustment and optimization, the parameters of SAC and LSAC are set as follows: The learning rate of 0.001 was chosen based on empirical experiments, as it provided a balance between convergence speed and stability during training. A higher learning rate led to unstable training, while a lower rate significantly slowed down the convergence process. This strategy is supported by recent studies on hyperparameter tuning in deep reinforcement learning, which highlight the importance of balancing learning rate and discount factor for optimal performance. 28 The discount factor (γ) was set to 0.1 based on empirical experiments and the nature of ultra-short-term PV power prediction. A lower discount factor prioritizes immediate rewards over future rewards, which is suitable for scenarios where recent data points are more relevant. This setting ensures that the model focuses on short-term accuracy, which is critical for ultra-short-term forecasting. The learning rate of 0.001 was chosen to balance convergence speed and stability during training. A higher learning rate resulted in unstable training, while a lower rate considerably slowed the convergence process. These parameter settings were optimized using a grid search approach to enhance the model’s performance. The hidden layers of the SAC network were designed with 128 and 64 neurons in the fully connected layers, respectively, to capture complex patterns in the data while maintaining computational efficiency. These hyperparameters were optimized through a grid search approach, ensuring the model’s performance was maximized. The LSTM network in LSAC has 50 neurons. The optimization algorithm is Adam, the experience pool size is 10,000, the sample size is 64, and the hyperparameters common to reinforcement learning are used.
The parameters of LSTM, CNN, and BPNN are set as follows: the LSTM network has 50 neurons; the CNN has 30 filters with a kernel size of 2 and a stride of 2; BPNN comprises two fully connected layers with 128 and 64 neurons, respectively. In addition to the basic supervised learning models (LSTM, CNN, BPNN, and RF), we also compared our proposed LSAC model with more advanced models recently applied in PV power prediction. Specifically, we included a Transformer-based model and a Hybrid model combining LSTM with convolutional neural networks (CNNs). These models have shown promising results in handling complex time series data and were chosen to provide a comprehensive comparison. The results demonstrate that while these advanced models offer improved performance over traditional methods, our LSAC model still outperforms them in terms of prediction accuracy and robustness. The detailed comparison is shown in Table 6 and Figures 6–8. The learning rate and optimization algorithm for the deep learning model are the same as the DRL model. The tree depth of RF is set to 5. The specific parameters of the models are shown in Tables 4 and 5. Predicted power results of LSAC and SAC. Two-hour predicted power results of LSAC and SAC. Predicted power results of six models. Parameter setting in LSAC/SAC. Parameter setting in supervised learning methods.


Comparative analysis
Comparative analysis of LSAC and SAC
Figure 6 depicts the results of the prediction of these two models in single-step prediction. The solid line represents the ideal fit line, indicating that the predicted value equals the actual value. The two dashed lines represent the ±15% error range, indicating that the expected value is within 15% of the actual value. The horizontal axis shows the true PV power value, and the vertical axis shows the predicted PV power value. It can be observed that the predictions from LSAC are more accurate compared to SAC, as the number of prediction points outside the ±15% error range is reduced. More prediction points are concentrated near the ideal fit line in LSAC, highlighting its improved accuracy due to the memory capability of LSTM. This finding is consistent with recent studies that demonstrate the benefits of incorporating memory mechanisms like LSTM into reinforcement learning frameworks. 11
Additionally, Figure 7 shows the two-hour prediction results of these two models. During peak fluctuations, LSAC fits the raw PV data better, while SAC performs slightly worse.
Comparative analysis of DRL and supervised learning methods
Similarly, we further analyzed the prediction results of these six methods over 2 hours, as shown in Figure 8. These results underscore the advantages of deep reinforcement learning over traditional supervised learning methods in handling complex, dynamic systems. 29 This figure depicts that the prediction performance of LSAC and SAC is superior to that of the supervised learning models. The prediction bias of CNN and BPNN is more significant compared to the other models. LSTM and RF demonstrate good prediction performance, with LSAC and SAC showing better prediction volatility than other supervised learning models.
Prediction accuracy on testing data.
The results are shown in Table 6. The test set results indicate that LSAC and SAC have higher prediction accuracy than the other models. Under the evaluation metrics of MAE and RMSE, the LSAC model reduces the error by 16.72% and 18.02% compared to SAC; the LSAC model reduces the error by 36.78% and 23.41% compared to LSTM; the SAC model reduces the error by 24.2% and 6.58% compared to LSTM. LSTM performs better than CNN and BPNN. Under the evaluation metric of R2, LSAC improves by 1.14% over SAC.
CNN has the largest overall prediction deviation, while LSAC, SAC, and LSTM exhibit smaller deviations and outperforms the supervised learning methods.
Computational efficiency evaluation
To assess the computational efficiency of the proposed LSAC model, we evaluated its hardware usage, training time, and prediction overhead. Evaluating computational efficiency is crucial for practical deployment, as it ensures that the model can be implemented in real-world scenarios without significant delays. 22 The experiments were performed on a standard desktop computer with an Intel Core i7 processor and 16 GB of RAM. The training time for the LSAC model was approximately 18 hours, which is comparable to other deep learning models. The prediction overhead, measured as the time taken to generate a single prediction, was 20 milliseconds. These results indicate that the LSAC model is feasible for practical deployment in real-time PV power prediction systems. Future work will focus on optimizing the model’s efficiency to further reduce training and prediction times.
Conclusion
This paper presents a DRL PV power prediction model based on LSTM for ultra-short-term PV power forecasting. First, we model the PV prediction problem as an MDP and then use DRL to solve the MDP. By comparing four standard supervised learning models (LSTM, CNN, BPNN, and RF), we demonstrate that LSAC outperforms the other models for single-step prediction, verifying the effectiveness of the proposed model. The predictive performance of the DRL model for PV is significantly superior to that of the supervised learning model.
The proposed scheme is applicable to single-step prediction and achieves satisfactory results. In the future, we will expand to more application scenarios and longer prediction sequences.
Footnotes
Funding
The author(s) received no financial support for the research, authorship, and/or publication of this article.
Declaration of conflicting interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
