1. Introduction and Literature Review
Rural areas often struggle with unreliable electricity. This problem calls for using renewable energy sources (RESs). In regions like Diamond Harbour, India, such innovations can optimize the microgrid performance to meet energy needs, consistently reduce the reliance on fossil-fuel-based energy systems, and, thus, reduce emissions. However, the benefits of microgrids are reduced by the substantial challenges they face in balancing energy supply and demand, mainly because RESs are variable due to their dependence on weather conditions. Therefore, an effective energy management system (EMS) within microgrids ensures these systems operate efficiently and reliably. Achieving this requires using optimal methods that can accurately forecast the energy demand-to-supply ratio, incorporate multiple types of energy, and implement strategies for managing energy storage and distribution while promoting cleaner energy transitions and empowering sustainable rural growth.
Much research has been performed in terms of the energy management of microgrid systems where different techniques are used in the existing methodological framework. A study presented a comparative analysis of three models of photovoltaic systems. Among all these models, the support vector machine (SVM) with the Grey Wolf Optimizer was more effective in fault classification [
1]. Also, the inclusion of regions of interest (ROIs) provided a boost to the cloud distribution predictions [
2], and the deep learning (DL) adaptive model did quite well in providing high-accuracy results [
3], which suggests that the use of these advanced methods is improving the prediction accuracy. Another study surveyed DL models for forecasting solar PV power generation using the ant colony optimization hybrid SVM-GRU model. The results showed high accuracy, which indicates the model’s potential for enhancing actual-time predictions of PV power and enhancing renewables’ application in intelligent grids [
4]. Similarly, a study incorporated hybrid models combining ML techniques with real-time weather data for wind power production and, therefore, the stability of microgrids.
Table 1 provides a concise overview of various ML models involved in weather prediction and includes the specifics of the methods, parameters, and performance metrics. The CAE-PCA model, as well as the SVM-GPR model [
5], provides high precision and low error rates. The adaptive learning neural networks and the attentive gated recurrent residual network (ResAttGRU) [
6] utilize data on the solar irradiance and temperature to predict the weather with moderate to high accuracy.
Unlike traditional forecasting approaches like ARIMA, SARIMA [
11], SVM-GRP [
5], and GRU [
4], these models have limitations in capturing microgrid systems’ non-linear and dynamic nature, leading to less optimal performance. The novelty of this model lies in its ability to leverage LSTM to capture the temporal dependencies in weather data while using ANN to forecast the load under fluctuating conditions accurately. This dual-model strategy significantly enhances the predictive accuracy, surpassing conventional methods and improving energy management in microgrids. This study presents an innovative solution for optimizing microgrid performance, ensuring a stable energy supply, and reducing emissions in rural areas by addressing these critical challenges. The study’s objectives are as follows:
Develop and validate hybrid ML models combining LSTM and ANN for energy demand forecasting in rural microgrids while addressing energy efficiency.
Analyze the model performance under varying weather conditions to ensure its reliability and the adaptability of renewable energy systems in mitigating energy supply fluctuations and associated emissions.
Enhance the operational efficiency of rural microgrids to reduce the carbon footprints.
Propose solutions to the energy challenges of the Diamond Harbour region.
To achieve the above-stated objectives, this study will assess (i) LSTM optimization in forecasting and (ii) ANN optimization in energy demand prediction within microgrids, particularly when historical data are limited. It will also assess the variables that determine the execution of these models based on various types of weather.
2. Materials and Methods
2.1. Experimental Setup
Accurate future meteorological and load data are crucial for designing a sustainable microgrid model applicable to any location globally.
Figure 1 shows the experimental flowchart for the data collection. The data acquisition system was based on a single Campbell Scientific CR1000X data logger. Data were obtained using a logger that recorded the required data around the clock. All these data were then forwarded to our data file for use in the data analysis process. The status of the grid was extracted from the university logbook, and the actual energy consumption was obtained through electricity bills provided by the state electricity distribution company (WBSEDCL), which were cross-checked with the smart meter installed at the university.
Table A1 summarizes the instruments’ specifications, accuracy, and operational ranges. Sensors were strategically placed across the site to minimize the environmental interference after the calibration [
12].
2.2. Data Collection
The data were collected at the Neotia University (TNU), Diamond Harbour, Kolkata, West Bengal, India; the coordinates for it are 22°15′38.87″ N and 88°11′44.45″ E. The climate of this area differs considerably in different seasons. Data collection was performed from 1 January 2019 to 31 December 2023, and data were recorded at one-hour intervals. All the seasonal changes expected for the region were incorporated.
2.3. Overall Flow
This study involved developing and implementing a hybrid ML model for assessing the behavior of community power loads in rural microgrids. As stated, the approach had several significant steps: data acquisition/pre-processing, model development and training, and model evaluation, as outlined in
Figure 2. In the beginning, the experimented dataset was loaded. After this, statistical analysis was carried out to assess the statistical characteristics using the Pearson correlation and pairwise correlation approaches. The data pre-processing involved handling missing values and inconsistencies. Then, the dataset was split into an 80/20 training and testing data ratio. The data were then fed into the proposed LSTM-ANN model, and the performance metrics were analyzed.
2.4. Pre-Processing of Data
After data collection, the data were then pre-processed to ensure uniformity in identifying and rectifying anomalies within the dataset, which involved several critical steps. First, the independent variable scales were standardized to reduce the dominance of other variables in the analysis and maintain the integrity of the model. In case of data gaps, an attempt was made to fill them based on the data’s nature and distribution. This included the mean substitution, interpolation, and other algorithms. Noise reduction procedures were employed to eliminate outliers and enhance the nature and quality of the obtained dataset.
2.5. Model Architecture
Figure 3 shows the overall architecture of an integrated model (LSTM-ANN) for load forecasting in rural microgrids. The LSTM model generates the forecast data from the experimental data inputs. The predicted LSTM data thus feed the ANN model to accurately predict the current-time power demand forecasts. These values are then fed into the EMS to manage traditional power generation.
LSTM Model for Weather Prediction: The input layer takes in sequences of weather data; the shape of the input is defined by the look_back period and number_of_features. Such a configuration allows the model to predict a history of weather observations. The LSTM layer-1 comprises 50 units, and return_sequences = True to pass values to the next LSTM layer. This layer captures the temporal dependencies usually embedded in the sequential data. The LSTM layer-2 comprises 50 units, and return_sequences = False to return only the last output in the sequence, which summarizes information captured by the first layer into a final feature vector. Following the LSTM layers, a dense layer-1 with 25 nodes is introduced to make the feature space compact, simplifying the model without losing essential features. The output layer consists of the number_of_features neurons, representing the various weather parameters. The Adam optimizer is used in the model for its adaptive learning capabilities and efficiency in processing large datasets. The MSE loss function is used to reduce the errors in the prediction process and improve the accuracy.
ANN Model for Power Demand Prediction: The input features for the ANN model are the weather predictions generated by the LSTM model, allowing the ANN to power the temporal patterns identified by the LSTM. The dense layer-1 consists of 64 neurons. The rectified linear unit (ReLU) is used to initiate non-linearity in the model. This enables the ANN to map the non-linear relations of the weather aspects regarding the power demand. A dense layer-2 with 32 neurons allows for the further processing of the feature space with the activation function of the ReLU being used to enhance the training facility and network accuracy. The output layer contains a single unit with a linear activation task, which provides a continuous function that produces the predicted power load. Like the LSTM model, the Adam optimizer also compiles the ANN. The MSE is used as the loss function to measure and rectify prediction errors during training.
2.6. Training Configuration
The LSTM model was trained on experimental data to predict future data. Key hyperparameters, such as the number of LSTM layers, units per layer, batch size, and epochs, were optimized. The feature selection was systematic in the grid search to balance accuracy and efficiency by determining the best combinations of hyperparameters and the best configuration for the LSTM model. The LSTM model used in this study was trained with a batch size of 500 instances. The training parameters were fine-tuned through experiential approaches to improve the model execution. The chosen parameters involved a learning rate of 2.5 × 10−4, a past history window length of 30-time steps, and 5 output cells. The architecture comprised 300 LSTM units distributed across 4 hidden layers. The training process was set to terminate when the error loss reached 1.0 × 10−5 or after completing a maximum of 300 epochs, whichever came first. For forecasting, the LSTM model provided 5 outputs, each predicting the weather conditions 10 min ahead, resulting in a total prediction horizon of 50 min.
The ANN model was then trained using the weather prediction from the LSTM as an input variable to predict the power load. This included multiple layers that used the rectified linear unit ReLU initiation task, which is known to speed up convergence during training to achieve high accuracy while simultaneously reducing the computational costs. The ANN model for the power demand prediction contained an input layer, one or more hidden layers, and an output layer. Following empirical adjustments, the ANN optimal configuration for the power forecasting included 4 hidden layers with neuron counts of 300, 500, 500, and 300, respectively. The batch size was adjusted to 500 instances, and the model trained over 200 epochs. ReLU activation functions were applied to each neuron in the hidden layers, chosen for their effectiveness in mitigating vanishing gradient issues and enhancing the learning efficiency in deep networks.
To train the model, the dataset was split into training (80%) and testing (20%) subsets. The training subset was used to build the model, while the testing subset was used for the model performance evaluation. Feature scaling was applied to the dataset to prevent bias in the training process. Equations (1) to (15) explain the model implementation algorithm.
2.6.1. LSTM Layer Implementation
The input sequence for the LSTM layer is:
The hidden state at a time
is denoted as:
Here, —hidden state at time t, and —hidden state at a previous time step.
The key processes for the LSTM cells at each time step are as follows:
The new cell state
is then updated as:
where the weight matrices:
,
,
,
; bias vectors:
,
,
,
; and hyperbolic tangent function:
The LSTM model output is:
The LSTM model loss function is given by the
where the true value is (
) and the predicted value is (
).
2.6.2. ANN Layer Implementation
The ANN model input is denoted as:
Each layer in the ANN performs the following operations:
First layer: the first layer computes the pre-activation
and activation
:
Second layer: the second layer computes the pre-activation
and activation
as:
where
sigma—sigmoid activation function, often used in the output layer for binary classification tasks, produces a value 0~1 (interpreted as a probability).
Loss function and training ANN:
where the activations in the ANN layers:
,
,
;
Pre-activations in the ANN layers: ,
The backpropagation algorithm updates the weights and biases by estimating the gradients of the loss function with regard to each parameter. Later, the gradients are utilized to adjust the parameters to minimize the loss.
2.7. Performance Evaluation Metrices
The performance of the proposed LSTM-ANN model was evaluated using statistical metrics: MAE, RMSE, MSE, and R2. The MAE measures the average error magnitude, the RMSE emphasizes large errors, the MSE minimizes the deviations, and the R2 indicates the model accuracy. These metrics help compare LSTM-ANN with the ARIMA, SARIMA, and GRU models. Lower MAE, RMSE, and MSE values signify better accuracy, while a higher R2 suggests strong predictive performance.
4. Conclusions
The hybrid LSTM-ANN model demonstrated superior accuracy in predicting the power load compared with the traditional approaches. The model effectively addressed complex non-linear relationships and temporal dependencies, which are key characteristics of vital microgrid operations. By addressing the variability of the RES under different weather conditions, the model enhanced the operational efficiency, ensured energy reliability and load optimization, and significantly reduced the carbon footprints. This study provides a robust framework for sustainable energy management in rural microgrids. Future studies should incorporate socio-economic indicators, such as population growth and energy consumption behavior. Such additions could enhance the performance of the given model and provide timely and reliable energy management solutions. This study advances data-driven approaches to climate-resilient rural electrification, supporting global decarbonization goals.