A Hybrid Mathematical Framework for Synthetic Energy Data Generation in Morocco Smart Grids

Abstract

The development of accurate energy forecasting models for smart grids is strongly dependent on the availability of high-quality and high-resolution datasets. However, in many developing regions, particularly in Morocco, such datasets remain scarce, incomplete, or non-public. This limitation significantly constrains the application of advanced machine learning and deep learning techniques for energy demand prediction and grid optimization. This paper proposes a novel hybrid synthetic energy data generation framework specifically designed for the Moroccan context. The proposed approach integrates temporal dynamics, climatic influences, and socio-cultural behavior into a unified mathematical model for hourly electricity consumption simulation. In particular, the model explicitly incorporates seasonal variations, temperature-dependent effects, and behavioral shifts induced by socio-cultural events, including Ramadan and weekend patterns.

Share and Cite:

Marah, R. , Marah, R. and Chehayebat, A. (2026) A Hybrid Mathematical Framework for Synthetic Energy Data Generation in Morocco Smart Grids. Open Access Library Journal, 13, 1-13. doi: 10.4236/oalib.1115538.

1. Introduction

The global energy sector is undergoing a major transformation driven by increasing electricity demand, urbanization, and the integration of renewable energy sources. Smart grids [1] have emerged as a key solution to enhance energy efficiency, reliability, and adaptability through real-time monitoring and intelligent control systems.

Morocco is one of the leading countries in Africa in renewable energy and Smart Grid development. Key infrastructure projects include large-scale solar and wind farms, such as the Noor Ouarzazate Solar Complex. The national energy strategy aims to achieve more than 52% renewable energy in the electricity mix by 2030.

Artificial intelligence techniques, particularly machine learning and deep learning, play a central role in energy forecasting and demand prediction [2]. However, these approaches require large-scale, high-quality datasets. In regions such as Morocco, the lack of publicly available hourly energy datasets represents a critical limitation. Moreover, energy consumption is not only influenced by technical and climatic factors but also by socio-cultural behaviors [3], which are rarely considered in existing models.

This paper addresses these limitations by proposing a hybrid synthetic energy dataset generation framework that integrates temporal, climatic, and cultural dimensions by providing the following contributions: A novel synthetic energy dataset generation framework, a hybrid mathematical model, integration of Ramadan-specific consumption dynamics, generation of a realistic hourly dataset, and statistical validation against real-world energy patterns.

This latest is organized as following: section 2 reviews related work. Where section 3 presents the methodology. Then section 4 describes the dataset. Section 5 presents experiments and validation. After, section 6 discusses results. And finally, section 7 concludes the paper.

2. Related Work

2.1. Smart Grids and Energy Forecasting

Smart grids represent the evolution of traditional electrical power systems toward intelligent, adaptive, and data-driven infrastructures [4]. These systems enable bidirectional communication between consumers and suppliers, allowing real-time monitoring, demand response, and optimized energy distribution.

Morocco has launched several strategic initiatives to modernize its electrical system and promote Smart Grid development [5]. These initiatives are strongly aligned with the national energy transition strategy and focus on integrating digital technologies into the power sector. Key programs include large-scale renewable energy projects such as the Noor solar complex, as well as national energy efficiency programs and gradual digital transformation initiatives led by energy institutions.

2.2. Smart Grids in Morocco

Morocco is considered one of the leading African countries in renewable energy deployment. The integration of renewable energy sources into the national grid managed by the National Office of Electricity and Drinking Water (ONEE) [6], is a central pillar of the Smart Grid transition. The country has significantly expanded its capacity in:

  • Solar energy, with major projects such as Noor Ouarzazate

  • Wind energy, with large-scale farms in regions like Tarfaya and Essaouira

  • Hydropower, through a network of dams contributing to grid stability

However, the intermittent nature of renewable energy sources increases the need for intelligent grid management systems capable of balancing supply and demand in real time.

Several national institutions play a central role in the development and deployment of Smart Grid technologies in Morocco:

  • ONEE (National Office of Electricity and Drinking Water): responsible for electricity production, transmission, and distribution

  • MASEN (Moroccan Agency for Sustainable Energy): leading renewable energy project development

  • AMEE (Moroccan Agency for Energy Efficiency): promoting energy efficiency policies and programs

These institutions collaborate to support the transition toward a more intelligent, efficient, and sustainable electrical grid.

2.3. Morocco Renewable Energy Strategy

Morocco’s energy strategy [7] is built on three pillars: diversification of energy sources, development of renewable energy and improvement of energy efficiency.

Renewable energy projects include:

  • Solar power (Noor complex)

  • Wind farms in coastal regions

  • Hydropower systems

These initiatives position Morocco as a regional leader in sustainable energy and Smart Grid.

Despite these advancements, several challenges persist such as: grid instability due to renewable intermittency, limited energy storage capacity, infrastructure modernization requirements and lack of integrated data systems. These challenges highlight the need for Smart Grid development [8].

2.4. Existing Energy Datasets

Morocco does not yet have a full public Smart Grid open-data platform or real-time national smart meter dataset access. That’s why researchers suffer from lack of open real-time grid data, no continuously recorded high resolution data, and often aggregated (per year/monthly instead of hourly/daily) data because of security restrictions and national energy critical infrastructure protection [9].

In the other hand, several large-scale energy datasets are widely used in research: ENTSO-E Transparency Platform (Europe), PJM Interconnection electricity market data and China State Grid datasets. While these datasets are high quality, they exhibit critical limitations: geographic and climatic mismatch with developing regions, lack of socio-cultural context and absence of behavioral variability specific to local populations. As a result, models trained on these datasets often exhibit poor generalization when applied to regions such as Morocco or North Africa and the Middle East.

3. Proposed Methodology

This section presents the proposed hybrid framework for generating a realistic synthetic electricity consumption dataset tailored to the Moroccan smart grid [10] ecosystem. The methodology integrates multiple interacting dimensions of electricity demand, including temporal dynamics, climatic variability, socio-cultural behavior, and stochastic fluctuations [11]. Unlike conventional synthetic generation approaches based solely on statistical approximation, the proposed framework seeks to reproduce realistic electricity consumption behavior through a context-aware mathematical formulation adapted to Moroccan conditions [12].

The methodological objective is to generate an hourly electricity consumption dataset capable of preserving realistic energy demand characteristics while remaining sufficiently flexible for artificial intelligence applications, particularly deep learning-based forecasting systems.

The methodology is designed around the following principles: realism of temporal behavior; climate responsiveness; socio-cultural contextualization; stochastic variability; reproducibility and scalability.

3.1. Mathematical Model

The proposed mathematical formulation models electricity consumption as the superposition of several independent yet interacting components.

The total electricity demand at time t is expressed as:

C( t )=B+ A d sin( 2πt 24 + ϕ d )+ A s sin( 2πt 365 + ϕ s ) +R( t )[ η d 1 day ( t )+ η n 1 night ( t ) ]+W( t ) A w +αT( t )+βT (t) 2 +γH( t )+ϵ( t )

This formulation combines deterministic periodic behavior with contextual and stochastic modifications.

Each term is explained below.

Baseline Consumption Component

The term: B represents the baseline electricity demand.

It corresponds to the minimum average energy requirement independent of: weather; social events; temporal peaks.

In Morocco, baseline demand remains relatively stable but varies slightly across seasons.

Daily Periodicity Component

Electricity demand exhibits strong circadian periodicity.

To represent this phenomenon:

A d sin( 2πt 24 + ϕ d )

is introduced.

where:

  • A d = daily amplitude;

  • ϕ d = phase shift.

Seasonal Periodicity Component

In Morocco, electricity demand patterns vary considerably across seasons due to:

  • increased cooling needs during summer;

  • moderate heating demand during winter;

  • variations in residential occupancy;

  • changes in industrial and commercial activity.

To model this phenomenon, an annual sinusoidal component is introduced:

A s sin( 2πt 365 + ϕ s )

where:

  • A s denotes the seasonal amplitude;

  • ϕ s represents the seasonal phase shift;

  • t corresponds to the day index.

Ramadan Behavioral Component

One of the most innovative aspects of the proposed framework is the explicit modeling of Ramadan-induced electricity demand behavior [13] [14].

Ramadan is a major religious period in Muslim-majority countries and significantly modifies daily human activity.

To model this phenomenon, a Ramadan indicator function is introduced:

R( t )={ 1, during Ramadan 0, otherwise

The behavioral Ramadan adjustment is represented by:

R( t )[ η d 1 day ( t )+ η n 1 night ( t ) ]

where:

  • η d represents daytime consumption reduction;

  • η n represents nighttime consumption increase;

  • 1 day ( t ) is a daytime indicator;

  • 1 night ( t ) is a nighttime indicator.

Weekend Effect Component

Electricity demand also varies according to weekly behavioral cycles [15].

To account for this effect, a weekend indicator is introduced:

W( t )={ 1, weekend 0, weekday

The weekend adjustment term is expressed as:

W( t ) A w

where:

  • A w denotes the weekend behavioral coefficient.

The parameter controls the intensity of weekend-related demand variation [16].

Temperature Modeling Component

Temperature constitutes one of the strongest determinants of electricity demand.

To capture temperature sensitivity, the framework introduces:

αT( t )+βT ( t ) 2

where:

  • T( t ) represents ambient temperature;

  • α controls linear thermal sensitivity;

  • β models nonlinear effects.

Humidity Component

Although less influential than temperature, humidity also affects electricity demand.

The humidity term is modeled as:

γH( t )

where:

  • H( t ) denotes relative humidity

  • γ represents humidity sensitivity.

Stochastic Noise Component

Real-world electricity demand is inherently uncertain. Even after accounting for temporal, climatic, and behavioral factors, unexplained variability remains.

To represent this uncertainty:

ϵ( t )~N( 0, σ 2 )

is introduced.

where:

σ 2 denotes variance.

The proposed equation models electricity consumption as an interaction between periodic temporal behavior, climate sensitivity [17], socio-cultural modifications, and stochastic uncertainty.

Moroccan smart grid dataset generator

The Moroccan Smart Grid Dataset Generator is a multi-factor time-series simulation model that generates synthetic electricity consumption C( t ) based on our mathematical formulation combining temporal, climatic, and socio-cultural influences.

Algorithm

INITIALIZE empty dataset

FOR each hour t of the year:

EXTRACT hour(t)

EXTRACT day(t)

EXTRACT month(t)

DETERMINE season(t)

DETERMINE weekend(t)

DETERMINE Ramadan(t)

GENERATE temperature T(t)

GENERATE humidity H(t)

COMPUTE daily cycle:

Daily = Ad * sin((2π * t / 24) + φd)

COMPUTE seasonal variation:

Seasonal = As * sin((2π * t / 365) + φs)

IF Ramadan(t) == 1:

IF hour between 06h and 18h:

RamadanEffect = -ηd

ELSE:

RamadanEffect = +ηn

ELSE:

RamadanEffect = 0

IF weekend(t) == 1:

WeekendEffect = Aw

ELSE:

WeekendEffect = 0

COMPUTE temperature effect:

TempEffect = α*T(t) + β*T(t)^2

COMPUTE humidity effect:

HumEffect = γ*H(t)

GENERATE random noise:

Noise ~ N(0, σ²)

COMPUTE final consumption:

C(t) = B

+ Daily

+ Seasonal

+ RamadanEffect

+ WeekendEffect

+ TempEffect

+ HumEffect

+ Noise

ADD row to dataset

END FOR

EXPORT dataset as CSV

This algorithm is a synthetic data generator for a Moroccan smart grid electricity consumption dataset. It is a computational method designed to simulate realistic hourly electricity consumption data by reproducing the main factors that influence energy demand in Morocco. Its Inputs are: temporal range; weather parameters; seasonal coefficients; ramadan calendar and noise variance. And its Output is the synthetic smart grid dataset.

3.2. Algorithm’s Complexity Analysis

Our proposed algorithm generates a synthetic Moroccan smart grid dataset by simulating hourly electricity consumption over a full year while integrating: temporal dynamics, seasonal behavior, weather conditions, socio-cultural effects (Ramadan) and stochastic fluctuations.

The computational complexity analysis evaluates: time complexity, space complexity, scalability and algorithmic efficiency.

Since all operations are constant-time:

T iteration =O( 1 )

The total complexity becomes:

T( N )=N×O( 1 )

Therefore:

T( N )=O( N )

The proposed algorithm has Linear Time Complexity O( N ) .

Our Moroccan context-aware synthetic smart grid generator exhibits linear computational complexity O( N ) in both time and memory usage, making it computationally efficient and scalable for large-scale energy simulation tasks.

3.3. Experiments and Validation

To Validate our Algorithm, we must verify whether the curves resemble real-world data and whether the distributions are coherent, then we compare your output with real-world behaviors known energy profiles specially ONEE trends [18], [19].

Our Algorithm’s Scientific Workflow is as follow:

First, we create time, weather, Ramadan and weekend indicators. Then, we choose a realistic initial coefficient. After, we generate the first synthetic dataset. Finally, we compare with ONEE trends.

3.4. Consumption Distribution

In Figure 1 bellow, we verify whether our dataset follows similar statistics:

We can observe from the figure, that two close distributions (real vs synthetic), globally similar shapes and slight controlled shift. The scientific interpretation of the figure is: our model reproduces the global consumption statistics and the probabilistic structure is validated.

Figure 1. Distribution of electricity consumption.

So, the synthetic distribution closely approximates the empirical distribution of the real system.

3.5. Time Series

In Figure 2, we verify energy dynamics:

Figure 2. Time series comparison.

We can observe from Figure 2: the same daily oscillations, the same peaks and valleys, and highly similar dynamics.

As scientific interpretation, we verify the validation of smart grid temporal dynamics, the reproduction of Moroccan energy cycles and realistic system behavior.

Thing that proofs the validation of time-series fidelity.

3.6. Daily Profile

To verify the peaks, thing that is very important in smart grids, we use Figure 3:

In Figure 3, we can observe: a bell-shaped daily curve, a morning peak and especially evening peak, and strong overlap between real and synthetic data.

Scientific interpretation of that observation: a validation of human energy habits, a capture of Moroccan residential behavior and highly important for smart grids.

Thing that means that daily load shape is preserved with high fidelity.

3.7. Ramadan Profile Simulation

In Figure 4, we are verifying our Moroccan scientific contribution:

Figure 3. Daily load profile.

Figure 4. Ramadan night consumption pattern.

We can observe a high nighttime consumption, a coherent behavior between real and synthetic data and partial inversion of the classical cycle.

We interpret this as: a validation of your original Moroccan contribution, an integration of socio-cultural behavior and strong differentiation in the literature.

Modeling Ramadan energy consumption behavior is our scientific Innovation.

4. Discussion

Our prototype demonstrates 4 major validations: statistical distribution, temporal dynamics, daily profile and cultural behavior (Ramadan). This means that our proposed framework demonstrates a high statistical similarity with expected real-world behavior, accurate reproduction of temporal energy dynamics, accurate reproduction of temporal energy dynamics and strong integration of socio-cultural effects. The Ramadan modeling significantly improves realism compared to classical energy forecasting approaches.

Our synthetic framework successfully reproduces statistical distribution, temporal dynamics, and culturally-driven consumption patterns observed in Moroccan electricity demand, including Ramadan-specific behavioral shifts.

5. Conclusion and Future Work

This paper presented a hybrid synthetic energy dataset generation framework for smart grids in Morocco. The model integrates temporal, climatic, and socio-cultural factors into a unified mathematical formulation. This work highlighted the importance of contextualized energy modeling in smart grid systems, particularly in Morocco.

Our proposed Algorithm, called MOROCCAN SMART GRID DATASET GENERATOR provides first Moroccan-context synthetic energy Smart Grid dataset, an integrated cultural-climatic energy modeling by including hybrid mathematical energy model, socio-cultural integration (Ramadan-aware modeling), synthetic Moroccan energy dataset and validation methodology for generated data.

Experimental results demonstrate that the generated dataset accurately reproduces key energy consumption patterns, including daily peak shifts, seasonal variations, and Ramadan-induced behavioral changes. The proposed framework provides a robust and scalable solution for addressing data scarcity in smart grid research and offers a valuable foundation for training AI-based energy forecasting models.

Conflicts of Interest

The authors declare no conflicts of interest.

References

[1] Siano, P. (2014) Demand Response and Smart Grids—A Survey. Renewable and Sustainable Energy Reviews, 30, 461-478.[CrossRef]
[2] Hong, T. and Fan, S. (2016) Probabilistic Electric Load Forecasting: A Tutorial Review. International Journal of Forecasting, 32, 914-938.[CrossRef]
[3] Rinaldi, A., Schweiker, M. and Iannone, F. (2018) On Uses of Energy in Buildings: Extracting Influencing Factors of Occupant Behaviour by Means of a Questionnaire Survey. Energy and Buildings, 168, 298-308.[CrossRef]
[4] Sweeney, C., Bessa, R.J., Browell, J. and Pinson, P. (2020) The Future of Forecasting for Renewable Energy. WIREs Energy and Environment, 9, e365.[CrossRef]
[5] Asiri, M.M., Aldehim, G., Alotaibi, F.A., Alnfiai, M.M., Assiri, M. and Mahmud, A. (2024) Short-Term Load Forecasting in Smart Grids Using Hybrid Deep Learning. IEEE Access, 12, 23504-23513.[CrossRef]
[6] Office National de l’Électricité et de l’Eau Potable (2022) Rapport d’activité 2022 [Rapport Annuel]. ONEE, Maroc.
https://www.one.org.ma/fr/pdf/Rapport%20arabe%202022%20Final.pdf
[7] ACWA Power (2016) NOORo IV Ouarzazate 70 MW Photovoltaic Power Project: Stakeholder Engagement Plan [Rapport]. Moroccan Agency for Sustainable Energy (MASEN).
https://www.masen.ma/sites/default/files/documents_rapport/6.pdf
[8] Marah, R. and El Hibaoui, A. (2018) Algorithms for Smart Grid Management. Sustainable Cities and Society, 38, 627-635.[CrossRef]
[9] Marah, R., El Guabassi, I., Bousalem, Z. and Haj, A. (2023) Smart Grid: A Communication Model and Security Challenges. In: Lecture Notes in Networks and Systems, Springer, 189-196.[CrossRef]
[10] Marah, R., Guabassi, I.E. and Yatimi, H. (2024) Moroccan Smart Grid’s Projection: Resource-Allocation Problem. In: Lecture Notes in Networks and Systems, Springer, 594-602.[CrossRef]
[11] Al-Maamary, H.M.S., Kazem, H.A. and Chaichan, M.T. (2016) Changing the Energy Profile of the GCC States: A Review. International Journal of Applied Engineering Research, 11, 1980-1988.
[12] Marah, R. and El-Hibaoui, A. (2016) Modelization of Smart Grid—Managing the Local Level. 2016 International Renewable and Sustainable Energy Conference (IRSEC), Marrakech, 14-17 November 2016, 1141-1145.[CrossRef]
[13] Yakoub, H. (2024) What Is the Effect of Ramadan on Domestic Occupancy Patterns and Energy-Use in Muslim Households in London Compared to Pre-Ramadan. In: Gauthier, S., Nicol, F., Brotas, L. and Altamirano, H., 13th Masters Conference: People and Buildings, NCEUB, 1-6.
https://eprints.soton.ac.uk/494893/1/MC2024KT8001_Hanaa_Yakoub.pdf
[14] Abdullabekov, I. and Sapaev, K. (2023) Un système de commande écoénergétique pour les unités de relevage d’eau de la station de pompage du Ramadan, basé sur des entraînements électriques à fréquence variable. AIP Conference Proceedings, 2552, Article 040023. (in English)[CrossRef]
[15] Fouad, M., Ragheb, M., Abdelbary, I. and Mohamed, A. (2025) Influence of Natural Parameters and Human Behaviour on Household Electricity Consumption: Analysis of Seasonal and Non-Seasonal Periods. MSA-Management Sciences Journal, 4, 78-104.[CrossRef]
[16] Alquthami, T. and Alaraishy, A. (2021) Comprehensive Energy and Cost Evaluation through Detailed Auditing and Modeling for Mosque in Saudi Arabia. International Journal of Applied Engineering Research, 16, 778-792.
[17] Hor, C.L., Watson, S.J. and Majithia, S. (2005) Analyzing the Impact of Weather Variables on Monthly Electricity Demand. IEEE Transactions on Power Systems, 20, 2078-2085.[CrossRef]
[18] MASEN and EDF Renouvelables (2021) Projet de Repowering du parc éolien de Koudia Al Baida—Plan Cadre d’Acquisition des Terres (Réf. C 399/R505-03) [Rapport Technique].
https://www.masen.ma/sites/default/files/documents_rapport/Masen_Koudia_Baida_PAT.pdf
[19] Office National de l’Électricité et de l’Eau Potable (2023) Rapport d’activités—Énergie électrique 2023 [Rapport Annuel]. ONEE, Maroc.
https://www.one.org.ma/fr/pdf/Rapport%20d'Activit%C3%A9s%202023%20VF.pdf

Copyright © 2026 by authors and Scientific Research Publishing Inc.

Creative Commons License

This work and the related PDF file are licensed under a Creative Commons Attribution 4.0 International License.