Optimized Neural Network-Based Solar Energy Forecasting Using Genetic Algorithm ()
1. Introduction
As global penetration of solar photovoltaic (PV) systems continues to accelerate, accurate and reliable solar power forecasting has become a cornerstone of modern power system management. Solar PV generation acts as a transformative technology in the electricity sector, yet its variable nature poses operational challenges. Photovoltaic power output is inherently intermittent and stochastic, driven by dynamically changing environmental factors such as atmospheric conditions, cloud cover, and seasonal variations. For power system operators and utilities, predicting fluctuations in solar generation is essential to maintain real-time supply-demand balance, schedule operational reserves, prevent voltage instability, and avoid potential blackouts.
In emerging energy markets such as Malaysia, accommodating intermittent renewable generation within the national grid requires strategic operational adaptation. Precise short-term solar forecasting transforms an unpredictable energy source into a manageable generation asset. At the operational level, accurate day-ahead and intra-day forecasts enable grid operators such as Tenaga Nasional Berhad (TNB) to optimize thermal generator unit commitment, schedule demand-response activities, and minimize economic losses due to over-generation or sudden supply deficits. Furthermore, long-term forecasting supports grid infrastructure planning, financial risk assessment, and evaluation of key investment indicators such as Net Present Value (NPV) and Internal Rate of Return (IRR) for Battery Energy Storage Systems (BESSs) and grid expansion projects.
Traditional approaches to solar power forecasting rely on physical, clear-sky, or statistical time-series models, which often struggle to resolve the highly non-linear dynamics of localized weather systems [1]-[4]. Consequently, Machine Learning (ML) techniques have gained widespread adoption due to their capability to extract complex, non-linear relationships from multi-variate historical datasets without explicit physical assumptions [5]-[7]. Data-driven algorithms adapt efficiently to regional microclimates. This adaptability is crucial in tropical regions like Malaysia, where high humidity, rapid convective cloud formations, and seasonal monsoon shifts create abrupt fluctuations in solar irradiance [8]-[10].
Among machine learning architectures, Artificial Neural Networks (ANNs) and Feedforward Neural Networks (FNNs) are widely used for solar power forecasting [11]-[13]. However, standard NNs trained via gradient-based backpropagation algorithms exhibit key structural vulnerabilities [13] [14]. First, backpropagation is prone to getting trapped in local minima on multi-modal error surfaces, leading to suboptimal weight initialization and slow convergence. Second, model accuracy is sensitive to hyperparameter choices such as the number of hidden nodes, learning rate, and momentum factor. Suboptimal hyperparameter choices can lead to model underfitting or overfitting, resulting in unstable predictions and physical inconsistencies such as negative power generation output during low-irradiance periods.
To address these limitations, evolutionary optimization techniques can be integrated with gradient-based learning algorithms [15]-[17]. Genetic Algorithms (GAs) offer global search capabilities inspired by natural selection, cross-over, and mutation mechanisms. Unlike local gradient descent methods, GAs explore complex, non-convex parameter spaces without requiring derivative information, which makes them suitable for searching hyperparameter configurations [18]-[20].
This paper presents a hybrid Neural Network-Genetic Algorithm (NN-GA) model tailored for tropical solar irradiance and temperature-based power forecasting. Utilizing operational field data from a utility-scale solar photovoltaic power facility in Malaysia, this study:
1) Evaluates multi-day temporal correlation lags for irradiance and ambient temperature to establish optimal feature inputs.
2) Implements a GA framework to automatically search for well-performing hidden layer configurations, learning rates, and momentum constants for the neural network.
3) Compares the performance of standalone NN models against the proposed NN-GA hybrid architecture using empirical performance metrics.
2. Methodology
2.1. Dataset and Correlation Analysis
The dataset utilized in this research comprises hourly operational and meteorological records collected from a grid-connected commercial solar farm operating in Malaysia. To establish relevant temporal features for the forecasting model, a cross-correlation analysis was conducted between historical lagged inputs (up to 7 days prior,
to
) and target solar power generation.
The prediction horizon spans the 8 daytime daylight operational hours of day
from 10:00 to 17:00 (
), representing a forecast lead time of 34 to 41 hours after the issue time. Rather than predicting single lagged hourly steps, each input is a complete daily vector profile of
hourly values of an exogenous feature (solar irradiance or ambient temperature) from an antecedent day, mapping directly to the output vector of
hourly power values of day
. The age of the input observation, which is the elapsed time between historical data capture and the forecast target day (2 days for irradiance,
; 3 days for ambient temperature,
), is structurally distinct from the forecast lead time (34 - 41 h). Observations from day
and target day
are excluded at the forecast issue time, eliminating post-issue lookahead bias.
The operational dataset was acquired from a solar farm in Negeri Sembilan, Malaysia. The facility is a grid-connected, utility-scale Large-Scale Solar (LSS) photovoltaic power plant operating with an installed nominal peak capacity of 5.0 MWp (approximately 4.0 MWac). Situated in an equatorial tropical climate zone, the installation is subjected to high ambient humidity, elevated year-round temperatures averaging 26.5˚C, and high cloud attenuation characteristic of Peninsular Malaysia.
Meteorological and operational generation data were acquired on-site from the SCADA monitoring system of the solar farm. Global Horizontal Irradiance (GHI, in W/m2) was captured using an on-site pyranometer, and ambient temperature (˚C) was recorded via an integrated meteorological weather station. Active power generation (kW) was monitored at the plant’s centralized inverter stations and point of interconnection. Raw time-series measurements were recorded at fine sub-hourly intervals and aggregated into 1-hour resolution. To isolate operational generation periods and eliminate nighttime inactivity, each daily profile was structured into an 8-hour diurnal window spanning 10:00 to 17:00 local time (
).
The raw dataset comprised 5 months of continuous measurements collected between May 1 and September 30, 2022. Data filtering removed non-generating nighttime hours (18:00 to 09:00), missing entries, and outlier periods, isolating the 8 active daylight generation hours between 10:00 and 17:00 local time (
). Following cleaning and chronological matrix restructuring, the dataset yielded a total of 146 usable daily profiles, corresponding to 1168 hourly observations. In accordance with the chronological splitting schedule, the usable samples were distributed across three non-overlapping subsets:
1) Training Dataset (May-July 2022; Days 1 - 87): 87 daily profiles × 8 hours = 696 hourly samples.
2) Validation Dataset (August 2022; Days 88 - 116): 29 daily profiles × 8 hours = 232 hourly samples.
3) Testing Dataset (September 2022; Days 117 - 146): 30 daily profiles × 8 hours = 240 hourly samples.
Table 1. Comparative correlation analysis of historical irradiance and ambient temperature inputs with power output.
Day Lag (d − x) |
Irradiance Correlation Coefficient (r) |
Temperature Correlation Coefficient (r) |
|
0.3606 |
0.6606 |
|
0.3727 |
0.6668 |
|
0.3702 |
0.6690 |
|
0.3596 |
0.6687 |
|
0.3614 |
0.6666 |
|
0.3539 |
0.6635 |
|
0.3477 |
0.6609 |
As presented in Table 1, the strongest correlation for solar irradiance occurs at a 2-day lag (
,
), whereas ambient temperature achieves its maximum correlation at a 3-day lag (
,
). Ambient temperature exhibits higher correlation values overall compared to irradiance. This is primarily because solar irradiance measurements from ground sensors are susceptible to transient noise from localized cloud cover, whereas thermal ambience profiles display smoother day-to-day continuous profiles. Consequently,
irradiance and
temperature data were selected as input vectors for model development.
2.2. Data Partitioning and Preprocessing
To evaluate the generalization performance of the models and strictly prevent data leakage, a chronological data-splitting strategy was implemented. The dataset spans 146 complete days across May to September 2022, capturing the daytime generation hours from 10:00 to 17:00 (
), yielding 1168 hourly observations. The data were partitioned into three chronologically ordered, non-overlapping subsets:
1) Training Subset (Days 1 - 87, ~60%): May 1 to July 26, 2022 (
), reserved exclusively for network weight training and bias adjustments.
2) Validation Dataset (Days 88 - 116, ~20%): July 27 to August 25, 2022 (
), used solely for Genetic Algorithm (GA) fitness evaluation and hyperparameter selection for the standalone NN baseline.
3)Testing Subset (Days 117 - 146, ~20%): August 26 to September 24, 2022 (
), reserved for final out-of-sample generalization testing.
T scheduling, functional purpose, and sample breakdown of each partition are summarized in Table 2.
Table 2. Chronological dataset partitioning schedule.
Data Partition |
Calendar Period |
Functional Purpose |
Usable Daily Profiles (
) |
Usable samples (
) |
Training Dataset |
May 1, 2022-July 26, 2022 |
Model parameter training and weight updates |
87 days |
87 × 8 = 696 |
Validation Dataset |
July 27, 2022-August 25, 2022 |
GA fitness evaluation and hyperparameter selection |
29 ds |
29 × 8 = 232 |
Testing Dataset |
August 26, 2022-September 24, 2022 |
Out-of-sample performance generalization test |
30 days |
30 × 8 = 240 |
Total |
May 1, 2022-September 24, 2022 |
Complete operational study dataset |
146 days |
1168 |
To ensure stable gradient descent and prevent premature saturation of the hidden-layer activation functions, input and target features were scaled to the interval
using Min-Max normalization as Equation (1):
(1)
To strictly eliminate lookahead bias and data leakage, all preprocessing parameters were derived exclusively from the training subset:
1) Normalization Bounds: The empirical bounds (
and
) for solar irradiance, ambient temperature, and active power were computed from the training partition (May-July 2022) only. These identical scaling parameters were then applied unchanged to transform the validation and testing datasets. Post-forecasting predictions were mapped back to physical engineering units (kW) using the identical training-set minimum and maximum values.
2) Lag Selection Integrity: The cross-correlation analysis presented in Table 1, which established the optimal
lag for solar irradiance and
lag for ambient temperature, was conducted strictly on the training partition without reference to subsequent dates.
3) Mel Fine-Tuning Isolation: The validation set (August 2022) served exclusively as an unseen benchmark to compute candidate fitness during GA evolution and standalone grid search. The testing set (September 2022) remained untouched throughout all stages of lag selection, scaling, architectural search, and final backpropagation fine-tuning; it was evaluated exactly once to generate the final reported metrics in Section 3.
2.3. Hybrid NN-GA Architecture
The Feedforward Neural Network (FNN) acts as a non-linear mapping function that models the relationship between historical exogenous meteorological profiles and plant-level solar power generation. However, the performance and convergence stability of standard backpropagation networks are highly dependent on initial hyperparameter choices. In this study, a Genetic Algorithm (GA) is implemented as a global optimization layer to determine three key hyperparameter choices:
1) Number of hidden layer nodes (
).
2) Learning rate (
).
3) Momentum constant (
).
The overall operational workflow of the proposed hybrid NN-GA forecasting framework is illustrated in Figure 1.
Each candidate solution in the GA population is encoded as a real-valued chromosome vector
, where
is mapped to the nearest integer. The optimization procedure follows these sequential stages:
1) Initialization: A population of chromes is randomly generated within predefined search bounds (
, and
).
2) Fitness Evaluation: For each candidate chromosome, a FNN is instantiated and trained on the training partition (May-July 2022) using backpropagation. The fitness function is defined as the Mean Absolute Percentage Error (MAPE), Mean Absolute Error (MAE), and Root Mean Square Error (RMSE) computed over the validation dataset.
3) Evolutionary Operations: Selection operators prioritize fitter candidates. Crossover recombines genetic information between pairs, while mutation introduces novel variation with a low probability to avoid premature convergence.
4) Decoding and Fine-Tuning: The evolutionary loop terminates once the predefined termination criteria are met: either reaching the maximum limit of generations (
) or achieving fitness convergence (stall condition where fitness improvement remains
for five consecutive generations). Upon meeting either criterion, the optimal chromosome
is extracted to configure the final neural network architecture. The network is constructed using these optimal hyperparameters and fine-tuned by gradient descent backpropagation using only the training subset (May-July 2022). The out-of-sample testing partition (September 2022) remains strictly excluded from this fine-tuning step, as from all preceding tuning steps.
Figure 1. Flowchart of the hybrid Neural Network model optimized by Genetic Algorithm (NN-GA).
All computational experiments were executed in MATLAB R2022b utilizing the Deep Learning Toolbox and the Global Optimization Toolbox. The detailed hyperparameter configurations and algorithmic settings for both the standalone NN and the GA-optimized network are summarized in Table 3. To ensure fair comparison, the standalone NN baseline configurations reported in Table 4 were selected through an exhaustive grid search over the same validation objective. The grid search evaluated hidden layer nodes
, learning rates
(in steps of 0.05), and momentum constants
(in steps of 0.05), yielding 722 distinct candidate architectures. Each candidate network was trained on the training subset and ranked using the identical validation MAPE criterion. Because the GA was configured with a broader, continuous exploration domain (
and continuous
), performance differences reflect both the evolutionary search mechanism and the expanded architectural parameter space. To account for stochastic weight initialization and GA operators, all experiments were initialized with a fixed random generator state, and reported metrics reflect the best-performing configurations identified across five independent execution runs.
Table 3. Implementation settings of the standalone NN and the hybrid NN-GA framework.
Component |
Parameter |
Setting |
NN |
Architecture |
Feedforward NN: input layer (8 neurons), one hidden layer (
neurons), output layer (8 neurons) |
Activation functions |
Hidden layer: hyperbolic tangent sigmoid (tansig); Output layer: linear (purelin) |
Training algorithm |
Gradient descent with momentum backpropagation (traingdm) |
Stopping rules |
Maximum 1000 epochs; MSE goal:
; minimum gradient:
; early stopping after 6 consecutive validation check failures |
Weight initialization |
Nguyen-Widrow algorithm (MATLAB default initialization) |
Hyperparameter selection |
Exhaustive grid search:
,
(722 configurations); ranked by lowest validation MAPE |
GA |
Chromosome |
Real-valued 3-gene vector
;
rounded to nearest integer |
Search bounds |
;
;
|
Population size |
30 chromosomes |
Maximum generations |
50 generations |
Fitness |
Validation MAPE (minimized) |
Selection |
Stochastic uniform selection |
Crossover |
Scattered crossover; crossover fraction
|
Mutation |
Adaptive feasible mutation; mutation fraction
|
Elitism |
2 individuals (~5% of population preserved across generations) |
Termination |
Reaching maximum generations (50), or fitness convergence (improvement
) for 5 consecutive generations |
2.4. Performance Metric Formulas
Model performance is evaluated using two primary statistical error metrics, which are MAPE and MAE, and the Coefficient of Determination (
) as expressed by Equation (2), Equation (3), and Equation (4), respectively:
1) Mean Absolute Percentage Error (MAPE):
(2)
2) Mean Absolute Error (MAE):
(3)
3) Coefficient of Determination (
):
(4)
where
represents the actual measured photovoltaic power output (kW),
is the predicted power output (kW), and
is the total number of test evaluation samples.
(
, corresponding to 30 testing days × 8 daytime operational hours).
The metrics were computed on denormalized power values in kW, with predictions and measurements aligned synchronously by timestamp across the testing dataset. In Equation (1), to prevent division-by-zero errors and asymptotic distortions at dawn and dusk boundaries, measured power values below a threshold of 50 kW (representing under 1% of nominal capacity) were excluded from the percentage error computation, yielding an effective sample count of
. The linear error metric
and the correlation metric
were evaluated over all
daylight samples.
3. Results and Discussion
3.1. Performance Comparison between Standalone NN and NN-GA
Table 4. Out-of-sample testing performance metrics (September 2022;
).
Primary Input |
Model |
Optimal Configuration (
) |
|
Testing MAE (kW) |
Testing MAPE (%) |
Irradiance |
NN |
|
0.5892 |
33.8896 |
18.6994 |
Irradiance |
Hybrid NN-GA |
|
0.7978 |
27.1127 |
13.5263 |
Temperature |
NN |
|
0.7150 |
32.9703 |
16.8118 |
Temperature |
Hybrid NN-GA |
|
0.8031 |
27.1751 |
13.0470 |
The out-of-sample testing performance of the standard NN and the optimized hybrid NN-GA model across both input configurations (Irradiance and Temperature) is detailed in Table 4.
For solar irradiance-based models, hyperparameter optimization by GA improved performance across all metrics. The
coefficient rose from 0.5892 in the baseline NN to 0.7978 in the NN-GA model, indicating a substantial improvement in explaining output variance under intermittent solar radiation. Correspondingly, the MAE decreased from 33.89 kW to 27.11 kW, and MAPE dropped from 18.70% to 13.53.
For ambient temperature-based models, the hybrid NN-GA model similarly outperformed the standalone NN. The baseline NN achieved an
of 0.7150, whereas the GA-optimized model achieved an
of 0.8031. The error metrics further confirm this improvement, with MAE decreasing from 32.97 kW to 27.18 kW, and MAPE dropping from 16.81% to 13.05.
3.2. Analysis of Irradiance-Based Forecasting Curves
Figure 2 illustrates the temporal generation tracking of the baseline NN using solar irradiance inputs. While the baseline NN captures general daily diurnal cycles, it struggles during peak generation hours. Specifically, the model underestimates maximum power generation during midday spikes. Furthermore, during low-light transitions in early September, the baseline NN yields unphysical negative generation values.
Figure 2. Comparison between actual and forecasted solar power output using the standard NN model with irradiance input.
In contrast, Figure 3 displays the performance of the GA-optimized hybrid model. The NN-GA model tracks the actual generation profile closely through both rising and falling solar phases. In the evaluated test samples, the hybrid model produced no negative power values, and it tracked rapid irradiance changes more closely than the baseline. Although minor discrepancies remain during extreme peak events (e.g., September 13), variance tracking is higher overall.
Figure 3. Comparison between actual and forecasted solar power output using the hybrid NN-GA model with irradiance input.
3.3. Analysis of Temperature-Based Forecasting Curves
Figure 4 displays the forecast performance of the standard NN using ambient temperature inputs. The baseline model exhibits instability, marked by high-frequency variance and negative output dips. Prominent negative forecast spikes occur around September 2 and September 22. These artifacts show that this baseline configuration produced unphysical outputs for the evaluated samples; the experiments do not isolate their cause, and local-minimum entrapment in weight training was not diagnosed.
Figure 4. Comparison between actual and forecasted solar power output using the standard NN model with ambient temperature input.
As shown in Figure 5, the NN-GA model produced no negative outputs in the evaluated test samples and showed less high-frequency variance than the baseline. This is attributed to the hyperparameter configuration selected by the GA (a different hidden-layer size, learning rate and momentum constant; see Table 4), that is, to an improvement in the selected configuration, not to evidence that the GA overcomes local minima in weight training, which was not examined. The predicted output curve follows actual generation across the evaluation period.
Figure 5. Comparison between actual and forecasted solar power output using the hybrid NN-GA model with ambient temperature input.
3.4. Limitations
The empirical findings of this study should be interpreted considering several operational and structural constraints. First, the evaluation relies on operational data from a single utility-scale installation (the 5 MWp Solar Farm) across a single 30-day testing window (August 26 to September 24, 2022;
daylight samples). Consequently, these results demonstrate localized algorithmic efficacy under specific equatorial microclimatic conditions rather than operational robustness across different geographic locations, monsoonal transitions, or multi-step forecast horizons.
Second, while the neural network architectures were initialized with fixed random seeds and the reported configurations reflect the best solutions identified across five independent execution runs, broader statistical dispersion metrics such as cross-validation confidence intervals and variance across multiple stochastic trials were not evaluated. Therefore, minor marginal performance differences between competing hyperparameter configurations should be interpreted cautiously.
Third, the standalone neural network baseline was tuned using an exhaustive discrete grid search over a restricted structural space (
, 722 combinations), whereas the GA navigated an expanded, continuous parameter landscape (
alongside continuous ranges for learning rate and momentum). As a result, the observed performance gain stems from both the evolutionary search technique and the broader hyperparameter space accessible to the algorithm. Comprehensive multi-facility benchmarking, multi-season testing encompassing inter-monsoonal shifts, and rigorous repeated-run variance audits remain necessary to confirm generalizable operational viability for national grid dispatching.
4. Conclusions
This study evaluated a hybrid Neural Network-Genetic Algorithm (NN-GA) forecasting model for solar photovoltaic power prediction under tropical weather conditions. By applying GA to select the hyperparameters, including the number of hidden nodes, learning rate, and momentum constant, the proposed method improved the selected hyperparameter configuration relative to the standalone NN on the evaluated test data. The study did not examine local-minimum entrapment in weight training, and no claim is made that the GA overcomes it.
Using an operational dataset from a utility-scale solar photovoltaic plant in Malaysia, the empirical results for the September 2022 test period indicate improved accuracy for the hybrid approach:
Irradiance Models: GA optimization increased
from 0.589 to 0.798, while reducing MAE from 33.89 kW to 27.11 kW, and MAPE from 18.70% to 13.53%.
Temperature Models: The NN-GA model achieved an
of 0.803, reduced MAE from 32.97 kW to 27.18 kW, dropped MAPE to 13.05%, and produced no negative power predictions in the evaluated test samples.
These findings indicate that GA-based hyperparameter selection is a practical option for improving NN-based solar power forecasting at this plant. Because the evidence comes from one plant and one test period, broader operational robustness remains to be demonstrated with multi-plant, multi-season validation before the approach is relied upon for grid dispatching or demand-response management.
Acknowledgements
The authors acknowledge the Faculty of Electrical Technology and Engineering, Universiti Teknikal Malaysia Melaka (UTeM) and the Centre for Research and Innovation Management (CRIM) for providing technical and administrative support throughout the course of this study.
Author Contributions
Muhammad Zulhafiz Mohd Nizam: Investigation, Software, Data Curation, Formal Analysis, and Writing (Original Draft Preparation). Intan Azmira Wan Abdul Razak: Conceptualization, Methodology, Supervision, Validation, and Writing (Review & Editing). Mohamad Fani Sulaima: Methodology, Validation, and Writing (Review & Editing). Farah Anishah Zaini: Resources, Data Curation, Validation, and Writing (Review & Editing). All authors contributed to the interpretation of the results, critically reviewed the manuscript, approved the final version of the manuscript, and agreed to be accountable for all aspects of the work.