In remote mountainous terrains where extending national utility grids is economically prohibitive, hybrid renewable microgrids offer a critical pathway toward sustainable rural electrification and energy justice. A research team investigated an isolated camping residence situated in the village of Brikcha, located in northern Morocco between Ouazzane and Chefchaouen, to resolve a persistent engineering challenge in clean power design. Typical microgrid design tools rely heavily on synthetic or scaled demand patterns that fail to reflect the irregular, highly seasonal realities of rural occupancy. To bridge this modeling gap, the investigators integrated an Extreme Gradient Boosting algorithm, known as XGBoost, with the microgrid simulation software HOMER Pro. Their combined framework demonstrated how sparse real-world consumption measurements can be reconstructed into full-year hourly demand profiles to optimize standalone solar, wind, and storage capacities without risking costly over-sizing or power deficits.
Designing an off-grid hybrid renewable energy system requires balancing the initial capital expenditure against long-term operational expenditures, formalizing a trade-off captured through the Net Present Cost and the Levelized Cost of Energy. Over-sizing generation and storage hardware imposes crippling upfront costs on rural homeowners, whereas under-sizing hardware causes system failure during critical periods of energy scarcity. In Brikcha, extending the national grid can exceed 100,000 dollars per kilometer across steep mountain topography, rendering centralized infrastructure unviable. While local solar irradiation and wind corridors present substantial potential, the community has historically faced escalating costs and diesel depletion. Sizing standalone renewable microgrids requires exact temporal alignment between stochastic resource availability and residential demand, making standard synthetic load assumptions a major source of system inefficiency.
To overcome local data scarcity, the researchers devised a two-stage machine-learning workflow. The target site in Brikcha provided only 1,781 hours of actual electrical consumption logs, collected across five distinct seasonal periods during holidays in 2023: late January, late March to early April, August, late October, and late November. To reconstruct an uninterrupted 8,760-hour annual profile, the team obtained hourly historical weather data from NASA’s Prediction of Worldwide Energy Resources. Recognizing that the sparse local dataset risked underfitting or overfitting complex architectures, the researchers pre-trained the XGBoost model on hourly consumption data from an apartment in Fresno, California, which shares similar Köppen-Geiger climate classification traits with Brikcha. The pre-trained algorithm was subsequently fine-tuned using the 1,781 real-world observations from Brikcha to capture local behavioral and occupancy habits, effectively correlating environmental fluctuations with residential energy consumption.
The predictive performance of the developed XGBoost model was benchmarked against three neural network architectures: a multilayer Artificial Neural Network, a Long Short-Term Memory network, and a Convolutional Neural Network. Trained and evaluated under identical conditions, XGBoost achieved superior accuracy across all evaluated statistical metrics. The XGBoost model recorded a Root Mean Squared Error of 1.7457, a Mean Absolute Error of 1.1255, a Mean Absolute Percentage Error of 3.8605 percent, and a coefficient of determination, or R-squared, of 0.9790. In comparison, the LSTM achieved an R-squared of 0.9735, the CNN reached 0.9535, and the ANN registered 0.9525. Visual assessment of annual daily mean profiles confirmed that the XGBoost predictions closely overlapped ground-truth demand without the excessive smoothing observed in the deep learning models, while requiring significantly lower computational resources.
The reconstructed full-year demand profile reflected the distinct energy profile of the Brikcha camping residence, which features four bedrooms, a living room, bio-constructed walls, and a zinc roof that eliminates space heating or cooling requirements. Cooking was carried out using traditional wood branches, removing electric oven demands, while electrical consumption stemmed from lighting, television, refrigeration, an 80-liter water heating system, and appliances like a washing machine drawing 1.37 kilowatt-hours per cycle. NASA meteorological records for Brikcha indicated an annual average global horizontal solar irradiance of 5.01 kilowatt-hours per square meter per day, peaking at 6.73 kilowatt-hours per square meter per day in July and dropping to 2.46 kilowatt-hours per square meter per day in December. The area recorded a 10-year average wind velocity of 4.37 meters per second, ranging from 3.73 meters per second in August to 4.92 meters per second in April.
Using the reconstructed load and local meteorological data, the team executed an exhaustive multi-objective optimization in HOMER Pro to identify system configurations minimizing Net Present Cost and Levelized Cost of Energy while maximizing the Renewable Fraction. The simulation scrutinized 1,591,520 distinct operational scenarios under operational reserve margins requiring 10 percent of hourly load, 60 percent of solar output, and 40 percent of wind output. Out of all modeled variations, 377,696 configurations proved technically unfeasible, including 14,272 systems lacking necessary power converters and 362,912 containing redundant converters that introduced unacceptable losses.
Techno-economic evaluations categorized viable microgrid configurations into 100 percent renewable, hybrid renewable-fossil, and purely diesel-based architectures. Standalone solar-plus-battery systems yielded an LCOE of 1.38 dollars per kilowatt-hour, while wind-plus-battery configurations climbed to 2.15 dollars per kilowatt-hour. Although the 1.14 dollars per kilowatt-hour metric exceeds urban grid tariffs, it represents an economically feasible premium compared to multi-kilometer grid extension or difficult mountainous fuel transport logistics.
When fossil backup was introduced, the lowest total Net Present Cost across all evaluated setups was achieved by a photovoltaic-diesel-battery-converter configuration. This hybrid design produced a Net Present Cost of 49,160 dollars, a modest capital investment of 16,544 dollars, an annual operating cost of 2,071 dollars, and a Levelized Cost of Energy of 0.732 dollars per kilowatt-hour, consuming 1,148 liters of fuel annually with a 36.9 percent renewable fraction. Simple diesel generator setups displayed minimal initial capital outlay of 1,300 dollars but incurred severe operational expenses up to 4,393 dollars annually from burning 2,721 liters of fuel. Crucially, in configurations lacking battery storage, solar production during midday failed to align with evening-heavy household demand, forcing the diesel generator to run continuously and reducing the effective renewable contribution to zero.
To evaluate the engineering significance of machine-learning forecasting precision, the researchers conducted an analytical sensitivity analysis examining a ten-percent load variation. In a 100 percent renewable off-grid system sized for 3.769 megawatt-hours per year, a negative ten-percent forecast error would create an annual deficit of roughly 377 kilowatt-hours. In the absence of a diesel generator, this deficit leads to an estimated 4.5 to 6 percent annual capacity shortage, concentrated primarily during December when solar radiation drops to its minimum. Conversely, a positive ten-percent over-prediction imposes an unwarranted financial penalty, escalating Net Present Cost by approximately 7,500 dollars, or 9.9 percent, based on a cost ratio of 20,049 dollars per megawatt-hour.
The findings indicate that energy storage acts as the primary technical enabler for off-grid renewable transitions, while battery procurement represents the largest single capital barrier. The authors conclude that integrating high-fidelity gradient-boosted forecasting into microgrid planning effectively mitigates the economic risks of load uncertainty in remote settlements. For energy planners and policymakers throughout the Global South, these results indicate that rural electrification initiatives should prioritize targeted capital subsidies for battery storage rather than reactive grid extensions, providing a resilient, data-driven framework for sustainable rural development.
Subject of Research: Techno-economic optimization of off-grid hybrid renewable energy systems using machine-learning load forecasting
Article Title: Integrating XGBoost and HOMER pro for resilient renewable transitions: a case study of rural electrification in northern Morocco
Article References: El mrini, Y., Khouili, O., Elkate, R., Zerouaoui, J., & Ettaki, B. (2026). Integrating XGBoost and HOMER pro for resilient renewable transitions: a case study of rural electrification in northern Morocco. Results in Engineering, 32, Article 114216. https://doi.org/10.1016/j.rineng.2026.114216
Image Credits: AI Generated
DOI: 10.1016/j.rineng.2026.114216
Keywords: renewable energy, microgrids, machine learning, XGBoost, HOMER Pro, rural electrification, photovoltaics, wind turbines, battery storage, Morocco, load forecasting, techno-economic analysis, levelized cost of energy, net present cost, energy justice, off-grid systems
Cite Scienmag News
Teresa Odom. (November 20, 2026). Machine Learning and Microgrid Simulation Optimize Off-Grid Moroccan Rural Electrification. Scienmag. https://scienmag.com/machine-learning-and-microgrid-simulation-optimize-off-grid-moroccan-rural-electrification/
Teresa Odom. "Machine Learning and Microgrid Simulation Optimize Off-Grid Moroccan Rural Electrification." Scienmag, 20 November 2026, https://scienmag.com/machine-learning-and-microgrid-simulation-optimize-off-grid-moroccan-rural-electrification/. Accessed 20 November 2026.
Teresa Odom. "Machine Learning and Microgrid Simulation Optimize Off-Grid Moroccan Rural Electrification." Scienmag. November 20, 2026. https://scienmag.com/machine-learning-and-microgrid-simulation-optimize-off-grid-moroccan-rural-electrification/








