BiLSTM-attention for electricity demand forecasting and grid stability: supporting Morocco’s 2030 energy transition
摘要
Accurate long-term electricity demand forecasting is imperative for Morocco’s renewable-integrated power system to ensure reliable grid operation and achieve the 2030 renewable energy targets. The present study proposes a novel BiLSTM-Attention model that integrates sequence learning with attention mechanisms to capture complex temporal dependencies and provide interpretable forecasts. The model was benchmarked against nine alternatives, including statistical, standard deep learning (LSTM, GRU, BiLSTM, CNN), hybrid (CNN-LSTM, TCN-GRU), and attention-enhanced (CNN-Transformer) models. The findings reveal that the BiLSTM-Attention model attains superior predictive capabilities, evidenced by metrics such as MAE = 0.483, RMSE = 0.648, MAPE = 2.41%, and R² = 0.9956. This efficacy is accompanied by the model’s effective mitigation of feature-driven volatility under perturbations in GDP growth and temperature. A computational evaluation of the system has been undertaken, the results of which highlight the efficient utilization of a GPU (1168 MiB), low inference latency (0.714 s) and moderate training time (19.8 s). These results underscore the system’s suitability for HPC-enabled, real-time deployment. It is important to note that these forecasts contribute to grid stability by facilitating reliable generation planning, balancing supply and demand, and mitigating the impact of variable renewable energy. The proposed framework provides an accurate, interpretable, and computationally feasible solution for policymakers and grid operators. Extensions to the framework in the future may include probabilistic forecasting, multi-head attention, and adaptive real-time strategies to further enhance system resilience.