A Hybrid Mathematical Framework for Synthetic Energy Data Generation in Morocco Smart Grids ()
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:
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
is expressed as:
This formulation combines deterministic periodic behavior with contextual and stochastic modifications.
Each term is explained below.
Baseline Consumption Component
The term:
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:
is introduced.
where:
= daily amplitude;
= 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:
where:
denotes the seasonal amplitude;
represents the seasonal phase shift;
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:
The behavioral Ramadan adjustment is represented by:
where:
represents daytime consumption reduction;
represents nighttime consumption increase;
is a daytime indicator;
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:
The weekend adjustment term is expressed as:
where:
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:
where:
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:
where:
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:
is introduced.
where:
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
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:
The total complexity becomes:
Therefore:
The proposed algorithm has Linear Time Complexity
.
Our Moroccan context-aware synthetic smart grid generator exhibits linear computational complexity
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.