0% found this document useful (0 votes)
17 views23 pages

Article Saida

Uploaded by

Karim Elmezdi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views23 pages

Article Saida

Uploaded by

Karim Elmezdi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Energy Conversion and Management 304 (2024) 118190

Contents lists available at ScienceDirect

Energy Conversion and Management


journal homepage: www.elsevier.com/locate/enconman

Research paper

Efficient real-time cost optimization of a two-layer electric water heater


system under model uncertainties
Saida El Bakali ∗, Hamid Ouadi, Saad Gheouany
ERERA, ENSAM Rabat, Mohammed V University in Rabat, Rabat, Morocco

ARTICLE INFO ABSTRACT

Dataset link: https://nsrdb.nrel.gov/, https://w The objective of this paper is to implement an automated system for the control of all energy resources
ww.loadprofilegenerator.de/ and devices within smart buildings. The paper develops a Two-Layer Electric Water Heater Management
(TL-EWHM) system tailored for efficient power distribution within a smart microgrid connected to both a
Keywords:
Two-layer electric water heater energy
photovoltaic (PV) system and the Electric Grid (EG). The TL-EWHM consists of two distinct layers: the Offline
management system Optimization Layer (OFF-OL) and the Online Optimization Layer (ON-OL). Within the OFF-OL, an optimization
MLP regression stacking forecasting algorithm known as Particle Swarm Optimization (PSO) is employed to determine the optimal power settings
Off-line optimization for Electric Water Heaters (EWH) based on forecasts of several factors including PV generation, ambient
On-line optimization temperature (𝐴𝑇 ), water demand (𝑊 𝐷), and the consumption of fixed appliances (𝐹 𝐴𝐶) for the upcoming
Multi-objective optimization 24 h. These parameters are forecasted using a novel prediction algorithm referred to as regressor stacking,
Extremum seeking controller which is developed based on actual data. Within the ON-OL, real-time data is effectively utilized, and an
Extremum-Seeking (ES) Controller is employed to continuously adapt the EWH power settings in response
to uncertainties in the predictions. Furthermore, a strategic approach is being devised to generate the water
temperature setpoints (𝑊 𝑇 𝑆) by considering dynamic data factors like 𝑃 𝑉 power, total energy consumption
(𝑃𝐿 ), and the water demand profile to ensure that user comfort is maintained. A comprehensive comparative
analysis is carried out to evaluate the effectiveness of our strategy approach. This strategy is characterized
by the inclusion of a Water Temperature Setpoint Generator (𝑊 𝑇 𝑆𝐺) and the integration of a two-layer
optimization methodology that combines the OFF-OL and the ON-OL. In this comparative study, our strategy
is assessed in comparison to other conventional approaches, with the objective of highlighting the distinctive
advantages of our method in terms of cost reduction and the enhancement of user comfort. On the one hand,
comparisons are made with strategies that give priority to offline optimization. On the other hand, the strategy
that maintains a constant water temperature setpoint throughout the day. The results of this paper establish
the effectiveness of the proposed strategy. In particular, the energy cost savings associated with the two-layer
optimization approach is 13.73%. Even more noteworthy is the significant reduction in energy costs, which
reaches an impressive 18.63% when the variation of water temperature setpoints is taken into account. These
results underscore the significant benefits of using a two-stage optimization strategy over relying solely on
offline optimization. They also underscore the value of incorporating a WTSG as opposed to maintaining WTSC.

1. Introduction make a significant contribution to meeting the growing demand for


energy by replacing fossil fuels [3]. As a result, modern networks
1.1. Motivation will integrate RES and enable energy management based on supply
forecasting and demand planning using advanced technologies. This
Energy demand is set to increase significantly due to economic includes the wireless smart home network, which can monitor usage for
expansion, population growth and rising per capita electricity consump- building occupant comfort and efficient home management [4,5]. With
tion [1]. Concurrently, one of the main needs of human beings today
the growing expansion of the smart grid concept and the incorporation
is to obtain comfort in their living environment [2]. This complex
of the Demand Response (DR) control strategy [6], attention is focused
situation raises fundamental questions about how we should perceive
on exploiting the assets and benefits presented by these advances. These
and manage energy resources in the era of these changing dynamics.
advantages translate into the potential to improve energy efficiency,
Indeed, the use of Renewable Energy Sources (RES) is expected to

∗ Corresponding author.
E-mail addresses: [email protected] (S. El Bakali), [email protected] (H. Ouadi), [email protected] (S. Gheouany).

https://doi.org/10.1016/j.enconman.2024.118190
Received 18 December 2023; Received in revised form 30 January 2024; Accepted 8 February 2024
Available online 16 February 2024
0196-8904/© 2024 Elsevier Ltd. All rights reserved.
S. El Bakali et al. Energy Conversion and Management 304 (2024) 118190

Nomenclature 𝑜𝑝𝑡
𝑃̂𝐸𝑊 𝐻
(𝑡) Estimated EWH power
𝜏 Initial time (min)
Abbreviations 𝜁 Initial parameter of the integrator
𝐴𝑑𝑎𝑚 Adaptive Moment Estimation 𝑏 Low amplitude of a sinusoidal sig-
𝐴𝑇𝑑 &𝐴𝑇𝑑−𝑗 Current and Past Days of Ambient Temper- nal
ature Data 𝐶𝑝 Specific heat of water (J/(K kg))
𝐷𝐻𝑊 Domestic Hot Water 𝐶𝑜𝑠𝑡𝐵 &𝐶𝑜𝑠𝑡𝐵,𝑚𝑖𝑛 &𝐶𝑜𝑠𝑡𝐵,𝑚𝑎𝑥 Energy cost, Minimum and Maxi-
𝐷𝑅 Demand Response mum energy cost [cents]
𝐷𝑉 𝑠 Decision Variables 𝐶𝑜𝑠𝑡∗𝐵 Normalized Energy cost
𝐸𝐺 Electrical Grid 𝐶𝑜𝑠𝑡𝐶 &𝐶𝑜𝑠𝑡𝐶,𝑚𝑖𝑛 &𝐶𝑜𝑠𝑡𝐶,𝑚𝑎𝑥 Comfort cost, Minimum and Maxi-
mum comfort cost [K]
𝐸𝑆 Extremum Seeking
𝐶𝑜𝑠𝑡∗𝐶 Normalized Comfort cost
𝐸𝑊 𝐻 Electric Water Heater
𝐷 Density of water (D = 1 kg/L)
𝐹 𝐴𝐶 Fixed Appliance Consumption
𝑑𝑒𝑔 Degradation factor and is approxi-
𝐹 𝐴𝐶𝑑 &𝐹 𝐴𝐶𝑑−𝑗 Current and Past Days of Fixed Appliance
mately 0.2%–0.5% annually.
Consumption data
𝐸𝑇𝑏𝑢𝑦 Import Electricity tariff profile
𝐹 𝑖𝑇 Feed-in-Tariff
[cents/kWh]
𝐺𝑊 𝐻 Gas Water Heater
𝐸𝑇𝑠𝑒𝑙𝑙 Export Electricity tariff profile
𝐼𝐿&𝑂𝐿 Input Layer & Output Layer
[cents/kWh]
𝑀𝐴𝐸 Mean Absolute Error
𝐼𝑖𝑟𝑑 Actual solar radiation of the PV
𝑀𝐿 Machine Learning panel (kW/m2 )
𝑀𝐿𝑃 Multi-Layer Perceptron 𝐼𝑠−𝑖𝑟𝑑 Solar radiation of the PV panel
𝑀𝑂𝑂 Multi-Objective Optimization under standard conditions
𝑀𝑃 𝐶 Model-based Predictive Control (𝐼𝑠−𝑖𝑟𝑑 = 1 KW/m2 ).
𝑁𝑀𝐴𝐸 Normalized MAE 𝐾 Learning rate
𝑁𝑅𝑀𝑆𝐸 Normalized RMSE 𝐾𝑇 Temperature coefficient
𝑂𝐹 𝐹 − 𝑂𝐿 Offline Optimization Layer (𝐾𝑇 = −3.7 × 10−3 ◦ C).
𝑂𝑁 − 𝑂𝐿 Online Optimization Layer 𝑁 Length of the time series of the in-
𝑃 𝐴𝐶𝐹 Partial Autocorrelation Function put and output data (N equal to 96
𝑃 𝐶𝐶 Pearson Correlation Coefficient in the OF𝑂 L and 288 in the ON-OL.
𝑃 𝑆𝑂 Particle Swarm Optimization 𝑂𝑏𝑗𝑏𝑖𝑙𝑙 Comfort bill function
𝑃𝑉 PV Power Generation 𝑂𝑏𝑗𝑑𝑖𝑠𝑐 Comfort cost function
𝑃 𝑉𝑑 &𝑃 𝑉𝑑−𝑗 Current and Past Days of PV Data. 𝑂𝑏𝑗𝑔𝑙𝑜𝑏𝑎𝑙 Objective function
𝑅 Thermal Resistance 𝑃𝐿 (𝑡) Total Energy consumption load (W)
𝑅𝐵 Rule-based Algorithm 𝑃𝐸𝐺 (t) Electricity power grid at time t (W)
𝑅𝑒𝐿𝑈 Rectified Linear Unit 𝑃𝐸𝑊 𝐻 (𝑡) Optimal EWH power (W)
𝑖𝑛𝑖𝑡 (𝑡)
𝑃𝐸𝑊 EWH power setpoint given by first
𝑅𝐸𝑆 Renewable Energy Sources 𝐻
𝑅𝑀𝑆𝐸 Root Mean Square Error layer at instant t
𝑆𝐴 Stacking Algorithm 𝑃𝐹 𝐴𝐶 (𝑡) Fixed appliance consumption (W)
𝑆𝐴 Surface Area 𝑃𝑚𝑎𝑥 &𝑃𝑚𝑖𝑛 Maximum and Minimum EWH
𝑆𝑅 Solar Radiance power (W)
𝑆𝑅𝑑 &𝑆𝑅𝑑−𝑗 Current and Past Days of Solar Radiation 𝑃𝑃 𝑉 (𝑡) Photovoltaic power (W)
Data 𝑃𝑟𝑎𝑡𝑒𝑑 PV Rated Power (kW)
𝑇 𝐿 − 𝐸𝑊 𝐻𝑀 Two-Layer Electric Water Heater Energy 𝑅 Tank thermal resistance (m2 K/W)
Management System 𝑟𝛼 Significant Level of the Correlation.
𝑇 𝑜𝑈 Time of Use 𝑆𝐴 Surface area of tank (m2 )
𝑊 𝐷𝑑 Current days of Water Demand data 𝑇𝑎 External environment temperature
𝑊𝑆 Wind Speed under current conditions (◦ C).
𝑊 𝑆𝑑 &𝑊 𝑆𝑑−𝑗 Current and Past Days of Wind Speed Data 𝑡𝑖 &𝛥𝑇 Time and Time slot duration [s]
𝑊 𝑇 𝑆𝐶 Water Temperature Setpoints Constant 𝑇𝑠 PV cell temperature (◦ C).
𝑊 𝑇 𝑆𝐺 Water Temperature Setpoints Generator 𝑇𝑏𝑎𝑐 Maximum temperature to eliminate
Legionella from the water in the
Symbols absence of water demand [s]
AT Ambient temperature outside tank (K) 𝑇𝐶𝑊 incoming water temperature (K)
𝛼 Weighting Coefficient to assign a prefer- 𝑇𝐻𝑊 (𝜏) initial temperature (K)
ence order to the multi-objectives 𝑇𝐻𝑊 (t) temperature of water in tank at
𝜂𝑃 𝑉 PV Power derating time t (K)

2
S. El Bakali et al. Energy Conversion and Management 304 (2024) 118190

model-based predictive control (MPC) to deal with system uncertain-


𝑇𝑚𝑎𝑥 &𝑇𝑚𝑖𝑛 Maximum and Minimum temperature in the ties. In [12], the authors investigated the optimization of hot water
presence of water demand (K) temperature control for tankless gas water heaters, based on several
𝑇𝑟𝑒𝑓 PV cell temperature at standard conditions linear MPC controllers. In [13], the authors presented an algorithm
(𝑇𝑟𝑒𝑓 = 25 ◦ C). that identifies the optimum operating hours for EWHs, taking into
𝑇𝑆 Temperature Seasonal average (K) account consumption patterns, temperature data and fluctuating elec-
𝑣𝑠 Wind speed (m/s). tricity prices. In [14], the study explores the use of MPC to enhance
𝑤 Forcing frequency of the modulation and the efficiency of DHW systems through demand forecasting. In [15],
demodulation signals the authors have proposed a differential thermodynamic model for
𝑤ℎ High-pass filter cutoff frequency the controller design. The MOO model is established by introducing
𝑊 𝐷(t) Water demand as a function of time an index reflecting the users’ degree of comfort, so that the optimal
(m3 /min) use of DHW energy can be achieved by mixed linear programming.
𝑊 𝑇 𝑆(𝑡𝑖 ) Water temperature setpoints at time 𝑡𝑖 (K) In [16], the authors presented two control concepts to improve DHW
tanks operation. The first one uses the smart energy meter. The second
𝑋𝑖 &𝑌𝑖 Weather parameter (𝑆𝑅, 𝐴𝑇 , and 𝑊 𝑆)
is based on the use of a scaled proportional gain with an additional
𝑌𝐻𝑃 Filtered cost function signal
temperature sensor. In [17], the authors proposed a multi-agent deep
reinforcement learning algorithm which could optimized the supply
water temperature. In [18], the authors developed an energy manage-
ment system for a hybrid solar-electric water heater, with the aim of
reduce expenditure, optimize power grid management and promote
assessing its potential for energy and cost savings. In [19], the authors
more environmentally friendly and responsible energy use. Moreover,
presented an intelligent planning and control system for EWHs using
efficient management of electrical loads can result in significant sav-
data-driven disturbance forecasts in robust MPC to achieve various
ings, with cost reductions of up to 14% on electricity bills, according to
demand management objectives. In [20], the authors have introduced
some studies and successful implementations [7]. In fact, EWHs account
a flexibility product for a water heater aggregator. They used a control
for around 25% of a residential household’s total energy consumption
strategy based on mean-field theory, adapted to the control of large
[8]. This statistic underlines the importance of optimizing the energy
groups of water heaters. In [21], the authors presented a demand
efficiency of EWHs, making them a key area of focus for reducing
management system for domestic hot water to reduce energy costs by
residential energy consumption [9]. On the other hand, compared to a
applying a control logic. In [22], The authors have proposed a control
gas water heaters (GWHs), the EWH offers several advantages. Firstly,
algorithm to determine heating load periods in order to minimize the
it is easier to install, requiring neither a gas connection nor a specific
energy required from the main grid. In [23], the authors have proposed
ventilation system to evacuate combustion gas emissions. Moreover, a heating controller that minimizes the EWH energy consumption with-
their compact size means they can be installed in confined spaces, out compromising user comfort, using the A* search algorithm. In [24],
unlike GWHs, which require more space for ventilation and safety. In the authors have proposed a EWHs control strategy using mixed integer
terms of safety, EWHs pose fewer risks than their gas counterparts, linear programming. It balances cost savings and comfort. In [25], the
as they emit no flames or combustion gases, reducing the danger of authors have formulated two parallel control approaches, integrated
fire or explosion, and do not require connection to leaky gas pipes. In into an AI-based MOO algorithm. This algorithm aims to minimize costs
terms of initial costs, EWHs are generally more affordable to purchase while maximizing comfort levels. In [26], the authors have proposed
and install. In addition, given the greater accessibility of electricity a demand response strategy for heating element activation based on
compared with gas in many areas, they are more practical for many multi-objective minimization of electricity cost and user discomfort.
households. These advantages are even greater when the electricity In [27], the authors presented a predictive control method based on
used comes from renewable sources. Besides, EWH load modeling is occupant behavior prediction using a data mining algorithm for a
therefore essential to the implementation of an EWHM strategy. The domestic hot water system. In [28], the authors presented a nationwide
latter can interact with users, appliances, local generation sources and aggregate EWH load model for each hour of the simulation period using
grid operators to make decisions for intelligent and efficient energy a technique of shifting the EWH load from periods of low renewable
flow management. Furthermore, the implementation of EWHM requires resources and high demand to periods of high renewable resources and
the forecasting of several key variables. Indeed, to ensure efficient low demand. In [29], the authors proposed a demand side management
energy management, it is imperative to accurately forecast certain key framework that concurrently optimizes the use of electric and thermal
variables. Of these, three are of the utmost importance: water demand, storage in office buildings that are subject to a Time-of-Use and/or
PV production and energy consumption. Nevertheless, although the demand-based rate structures.
notable strengths of EWHM are undeniable, various difficulties remain, However, several gaps exist, which are addressed in this research
including the uncertainty surrounding forecasts, the complexity of work.
multi-objective optimization (MOO), computational constraints and so In the aforementioned works [10,13,20,22,25,26], the authors do
on. These issues will be addressed in this paper. not take into account the uncertainties inherent in forecasting, partic-
ularly those related to input data such as power 𝑃 𝑉 , 𝐴𝑇 , 𝑊 𝐷, and
1.2. Related works 𝐹 𝐴𝐶. This oversight could potentially have a significant impact on
the accuracy and reliability of their proposed optimization strategy.
Researchers were interested in EWHM, and several models and Unpredictable fluctuations in 𝑃 𝑉 production due to changing weather
solutions have been proposed in the literature. In [10], the authors conditions, and variations in 𝑊 𝐷 due to external factors, can consid-
introduced a heuristic algorithm for scheduling EWHs under varying erably influence the effectiveness of forecasts and control strategies.
electricity prices. This approach considers factors like comfort and By ignoring these uncertainties, proposed solutions may not adapt to
energy pricing, and hot water usage patterns. The goal is to minimize actual operating conditions, which are subject to variations. For a more
energy expenses while maintaining a desired comfort level. In [11], robust and reliable approach, it is essential to take into account and
the authors proposed a hybrid heating system that combines a wall- evaluate these uncertainties linked to input data. This requires the
mounted gas boiler with an integrated EWH. Optimization aims to integration of uncertainty management methods.
minimize energy costs, including gas and electricity expenditure, while In [10,11,13–16], the authors applied a fixed water temperature
maximizing thermal comfort for occupants. In addition, the authors use setpoints for their study. However, it is important to remember that

3
S. El Bakali et al. Energy Conversion and Management 304 (2024) 118190

maintaining the water temperature setpoints at all times is not always In [30,31], a single prediction model is used, while others authors
the best choice, especially if the bathroom is not used for long periods are used methods such as the stacking algorithm [32,33]. However, it
of the day, or if there are seasonal variations in room temperature. For is important to note that, these basic models have been trained on the
example, in a situation where the hot water temperature is maintained same dataset. This practice has certain limitations, particularly with
at a constant level, e.g. 40 ◦ C, even when no one is using the hot water regard to the diversity of perspectives taken into account for prediction.
for a long period of time, such as at night or during working hours. When basic models are trained on similar data, they tend to share
In this situation, the EWH will continue to heat the water to 40 ◦ C similar biases and assumptions, which can reduce the robustness of pre-
without any real demand, resulting in unnecessary energy consumption dictions. Moreover, this can limit the model’s ability to capture complex
and financial waste. relationships between variables and adapt to changing conditions.
In [17,28,29], the authors chose to use variable water temperature
setpoints in their study. However, it is important to note that these 1.3. Contributions and organization
water temperature setpoints vary only within a specific range, delim-
ited by a minimum and maximum value, with a certain margin of In contrast to the studies cited above, this paper presents a strat-
tolerance [28]. Moreover, the temperature setpoint is updated based on egy called TL-EWHM aimed at solving an optimization problem with
the price of electricity for each hour [17]. In addition, the daily setpoint continuous DV variation. The proposed strategy is specifically designed
temperature profile is defined using a B-spline [29]. A limitation of to manage EWHs in situations where forecast uncertainties have a sig-
these approaches is that the authors did not take into account changing nificant impact. The considered EWH system uses two primary energy
data such as WD, AT, FAC and PV power generation, which have a sig- sources: the PV system and the EG. A variety of electrical loads are
nificant influence on the determination of water temperature setpoints. taken into account, both fixed and adaptable.
This omission can have an impact on the accuracy and efficiency of TL-EWHM consists of two well-defined layers: the first layer, called
water heater system optimization, as these external factors can play a OFF-OL, works in delayed time, on day d for the planning of day
key role in setting optimum water temperature setpoints. d+1, on the basis of several forecast data, such as WD, AT, PV power
In [19,23], the authors are only interested in one objective: the generation and FAC. It determines the optimum hot water setpoints
energy bill. In this approach, their priority was to reduce electricity for the coming 24 h period, based on a multi-objective stochastic
costs, regardless of consumer comfort. In situations where user comfort optimization technique known as PSO. The PSO method possesses the
plays a crucial role, a balanced assessment between costs and consumer capability to explore the entire search space systematically, facilitating
the discovery of globally optimal solutions. By contrast, the second
well-being may be necessary.
layer, called ON-OL, operates in real time, taking into account forecast
In [10,15,18,21,23–25], the authors undertook a study of the opti-
uncertainties. It adjusts domestic hot water power setpoints in real
mization problem using binary decision variables (DVs). When binary
time using ES optimization, based on real data. The paper findings
DVs are used to control the power supply to the heating element, this
underscore the potential of ES as a robust tool for enhancing the
means that the device operates alternately in ‘‘on’’ and ‘‘off’’ mode,
real-time performance of TL-EWHM strategy, even when confronted
depending on the binary decisions made by the optimization algorithm.
with forecast uncertainties. One of the notable advantages of the ES
These frequent transitions between the two states can result in oscilla-
technique is its model-free nature [34], which eliminates the need
tory commands for the heating element. This oscillation behavior leads
for a predefined mathematical model. However, it is important to
to a significant reduction in the lifetime of the heating element, which
recognize that ES has a vulnerability: it can become trapped in local
is a crucial aspect to take into account. It is therefore important to note
optima, which can limit its overall efficiency. To avoid the problem of
that the use of binary variables does not necessarily lead to optimal
convergence to a local minimum, the ON-OL algorithm is periodically
results.
reset by the solution given by the OFF-OL algorithm. This reset is
In [10,13,16,21], the authors implemented a rule-based resolution
performed every 5 min. The proposed strategy harmonizes the strengths
tool to solve their problems. This methodology involves the establish-
of both methods, harnessing the model-free flexibility of ES and the
ment of specific thresholds or criteria to guide decision-making and global exploration capabilities of PSO to enhance the optimization
system management processes. However, it is important to emphasize process significantly.
that this approach may have limitations when it comes to dealing with The main objective of this study is to reduce overall energy costs,
unforeseen situations or atypical cases. while taking into account the costs associated with the discomfort
In [11,12], The authors opted to use gas-fired water heaters, but this caused by differences between the effective water temperature and the
decision presents a number of drawback. Among these, it is important water temperature setpoints (𝑊 𝑇 𝑆). It is essential to highlight that
to note that gas water heaters tend to have a greater environmental the choice of the reference temperature represents a fundamental issue.
impact, mainly due to greenhouse gas emissions. Furthermore, these The proposed strategy is to generate the WTS according to actual hot
systems can pose additional safety issues, including potential risks such water demand, changing weather conditions, photovoltaic production
as gas leaks, among others. and energy consumption to avoid wasting energy, rather than keeping
In [14,19], they used an MPC framework to control de EWH. How- the reference temperature constant at all times. The proposed strategy
ever, these approaches encountered challenges, notably maintaining can reduce energy costs while preserving user comfort, a key objective
the temperature below the comfort level specified by their optimization in the management of EWHs. To achieve these simultaneous objectives,
strategy. In addition, it should be noted that this work [19] excluded a MOO method is developed, which is converted into a single-objective
several factors for reasons of study simplification. Among these factors, optimization problem. One of the main motivations behind this strategy
the integration of on-site photovoltaic generation was not included, and is to fully satisfy users by minimizing any sense of discomfort, while
other elements that could have made the analysis more complex were achieving substantial energy savings. Transforming the multi-objective
excluded. However, it is important to recognize that this simplification problem into a single-objective one simplifies the decision-making task,
has its limits, and that integrating on-site photovoltaic generation and while enabling an optimal compromise to be found between conflicting
other complex variables into the optimization strategy could lead to objectives.
more qualified conclusions suitable for practical applications. Furthermore, it is essential to emphasize the importance of water
In [14,27], the MPC prediction and optimization horizon has been demand forecasting in this optimization problem. Indeed, the pre-
defined at 120 min with 10 min time steps and 24 h with one-hour time diction system developed to anticipate a variety of operating data,
steps in [14,27] respectively. As the time horizon is large, the approach including WD, PV power generation, AT, and FAC, is based on an MLP
can hardly be used for real-time prediction and control. Regressor Stacking [35,36]. This approach offers a series of significant

4
S. El Bakali et al. Energy Conversion and Management 304 (2024) 118190

advantages over using a single prediction model and training the base each MLP regressor was trained on the different datasets to facilitate
models on the same dataset. The application of MLP Regressor Stacking predictor learning.
helps to reduce the risk of model overfitting. By using a combination of The remainder of the paper is organized as follows: Section 2
models, this method enables different perspectives to be taken into ac- describes the proposed strategy for TL-EWHM. Section 3 presents the
count and data to be interpreted more robustly. As a result, predictions predicitve system . Section 4 presents the offline optimization layer.
are less likely to be influenced by random variations or disturbances in Section 5 describes the online optimization layer. Section 6 presents
the training data. In addition, this technique considerably enhances the the results and discussion. Finally, the paper is concluded in Section 7.
flexibility and adaptability of the prediction model. Each MLP regressor
2. EWH system management structure
in the stack can specialize in predicting a specific parameter using
tailored features, making it easier to exploit the complex relationships
This section presents the architecture used to manage the electric
between the target variable and different input characteristics. This water heating system, shown in Fig. 1. This illustration highlights the
increased flexibility is particularly useful when relationships between various energy sources used, including the PV system and the power
parameters are subject to variations according to conditions or data grid, as well as non-modifiable electrical loads, such as the TV, refrig-
evolution. To date, it is important to note that none of the previous erator and lamps. In addition, we also identify controllable electrical
studies cited in the literature appear to have considered all of these loads, including domestic hot water. The aim of this management struc-
elements simultaneously. The novelty and contribution of the proposed ture is to optimize the distribution of energy generated by renewable
approach include: sources and the power grid, while satisfying the energy needs of fixed
-Unlike [10,13,20,22,25,26], this paper presents a two-layer strat- and controllable loads. To operationalize the TL-EWHM strategy in the
egy designed for the management of EWH energy systems, with a residential context, several essential pieces of information need to be
particular focus on the challenges posed by forecast uncertainties. acquired. This includes crucial data such as water demand profiles and
The strength of two-layer management lies in the fact that it makes physical weather data. This data can be collected using specialized
management robust to operating conditions and forecast uncertainties. sensors, which transform it into usable information. Once collected, this
-Unlike [10,11,13–17,28,29] this paper presents a new strategy data is routed to a dedicated server, where it is stored and subjected
for the adaptation of the water temperature set point with respect to analysis and processing. The water demand profile is of paramount
to ambient temperature, PV production, energy consumption and hot importance in understanding residents’ water needs. It allows us to
water demand. The aim is to minimize energy costs while maximizing determine peak periods, seasonal variations and water temperature
occupant comfort. preferences, which are essential for optimizing hot water supply while
-Unlike [19,23], which focuses on only one objective: minimiz- reducing energy consumption. Weather data provides information on
ing energy costs, in our work, the proposed strategy pursues a dual environmental conditions, such as outside temperature, sunshine and
objective: reducing energy costs while maximizing user comfort. wind speed. This data is of crucial importance in forecasting the PV
production source using a predictive system, facilitating a more precise
-Unlike [10,15,21,23–25], which treats the heater management
adjustment between energy supply and demand.
problem as an optimization problem with a binary decision variable,
The proposed management strategy TL-EWHM consists of two lay-
in our work the decision variable is considered to be continuous. This
ers: The OFF-OL serves as the function responsible for production/
ensures smooth control of the heater and avoids the control oscillations
consumption planning based on forecasting data. This planning oc-
that can occur with on-off control, which can reduce the lifetime of the
curs with a deferred time frame, spanning a one-day horizon, and
system.
operates with a time step of 15 min. It effectively leverages meta-
-Unlike [14,27], which respectively used a time horizon of 120 min heuristic techniques to explore an extensive solution search space for
with time steps of 10 min and 24 h with time steps of one hour, the optimization problem described in this paper. In our case, the PSO
in this paper the time horizon considered is 24 h, with a step of method is used. Notably, the optimization criterion involved in this
15 min for OFF-OL and a step of 5 min for ON-OL, allowing the energy planning problem encompasses multiple objectives. It entails striking a
consumption of the EWH to be optimized with a high level of accuracy. balance between the financial cost of energy consumption throughout
-Unlike [10,13,16,21], which uses rule-based management, the lat- the planning horizon, the satisfaction of services required by occupants.
ter is not treated as an optimization problem. RB algorithms are often To carry out its tasks, the OFF-OL operates in delayed time, on day
less flexible, meaning that they may have difficulty adapting to unfore- d for the planning of day d+1 and receives predicted data, including
seen situations or complex data variations. Consequently, the solution forecasted WD profile reflecting users’ water requirements, PV power
generated cannot be considered optimal. In this paper, EWH man- generation, AT, and FAC for the upcoming day, from a forecasting
agement is posed as a constrained optimization problem solved by system. On the other hand, the ON-OL is the auxiliary optimization
hybridizing PSO and ES techniques. unit that operates in real time. It adjusts EWH power setpoints to
-Unlike [11,12], which considered a GWH. The water heating sys- actual operating conditions, taking forecast errors into account. This
tem envisaged is based on an EWH. It is a more environmentally- adjustment takes place every five minutes, requiring relatively fast
friendly alternative. In addition, EWHs are generally considered safer optimization methods. In our case, the ES algorithm is used. As this
in terms of operational risks, since they involve neither combustion nor layer only adjusts the existing planning, the exploration area to find
the use of flammable gases. Moreover, they are gaining in practicality the optimized solution is limited to a small neighborhood around the
thanks to their efficiency and growing compatibility with RES, notably solution provided by the upper layer OFF-OL. In this context, input data
solar power. This approach reduces dependence on fossil fuels and is measured directly during operation. This guarantees the system’s
promotes a more sustainable energy ecosystem. immediate responsiveness, allowing it to dynamically adapt to evolving
circumstances and adjust the EWH power setpoints every five minutes
-Unlike [14,19], the proposed management strategy uses a short
in response to forecast uncertainties.
time horizon to simplify the prediction system and take into account
data variation in real-time optimization. In addition, water temperature 3. Data presentation
is regulated according to water temperature setpoints.
-Unlike [30–33], which respectively used a stacking algorithm with This section explores the fundamental aspects of the data analysis
the base models are trained on the same dataset and used a single process. It is divided into two subsections, each of which plays an
prediction model. In the present paper, the MLP regressor stacking essential role in our study. The first focuses on the use of statistical
approach proves to be a promising prediction method, offering signifi- techniques to reveal insights and trends within our data set. The second
cant advantages such as reducing the risk of overfitting and improving deals with the crucial task of preparing the data for consistent and
the flexibility and adaptability of the prediction model. In addition, accurate analysis.

5
S. El Bakali et al. Energy Conversion and Management 304 (2024) 118190

Fig. 1. Proposed Electric Water Heater Energy Management System Structure.

Table 1 Table 2
Residential hot water consumption data set information. Summary statistics for water demand , fixed appliances consumption, solar radiation,
Name Description ambient temperature, wind speed, and relativity humidity.
WD FAC SR AT WS RH
Geographical Location Germany (Berlin)
House Type Normal house with electric water heater Mean 16.37 0.09 215.19 12.37 3.04 79.06
Type of Household Modular Household Mode 5.0 0.02 9 3.8 1.1 100.0
Modular Household Couple, 30–64 years, 1 at work , 1 at home SD 18.26 0.13 229.22 7.91 1.62 19.48
Time Resolution (min) 00:15:00 Range 102.5 2.06 911 37.6 12.0 85.06
Number of samples 105 120 Q1 5.0 0.03 25.0 5.60 1.8 65.69
Data Collection Period January 01, 2017–December 31, 2019 Q2 10.0 0.04 120.0 11.7 2.90 85.79
Q3 20.0 0.09 357.0 18.3 4.0 95.44
Skewness 1.77 3.40 1.07 0.37 0.76 −0.87

3.1. Statistical data analysis

This section is devoted to a comprehensive analysis of the data, tail that extends to the right, while a negative asymmetry indicates a
including its origin and interpretation. The data used in this report tail that extends to the left (the skewness of WD is 1.77, indicating
are divided into two distinct categories according to their source. The a rightward skewed distribution). Finally, Q1, Q2 (median), Q3, these
first group comprises related meteorological data, such as SR, AT, RH values represent the quartiles of the data set. Q1 is the first quartile, Q2
and WS. These data were extracted from the ‘‘NSRDB: National Solar is the second quartile (which is also the median) and Q3 is the third
Radiation Database’’, available on the [37] website. The second group quartile. These values help to understand the distribution of the data
of data concerns the water demand and energy consumption of fixed- and identify potential outliers (Q1 for WD is 5.0, meaning that 25% of
load appliances, and comes from the "LoadProfileGenerator’’, available the data is below this value). This table provides valuable information
on the [38] website. This latter generates load profiles based on the en- on the central tendency, variability and distribution characteristics of
vironmental conditions, technical specifications and behavioral model the variables mentioned, making it a useful reference for data analysis
described in Table 1. All these data are generated at 15 min intervals, and interpretation.
equivalent to 96 data points per day, over a significant period of
3 years, covering January 2017 to December 2019 in Berlin, Germany. 3.2. Data normalization
Data analysis represents a stage in which various statistical op-
erations are performed. It is part of quantitative research, aimed at Before training the machine learning (ML) models development, the
quantifying data while generally applying some form of statistical training data set underwent a normalization process. This normaliza-
analysis [39]. Fig. 2 shows the distribution of WD, FAC, SR, AT, RH tion step is an essential preprocessing procedure aimed at ensuring
and WS data, represented in a histogram. a balance in the input data when they are fed into the predictive
The Table 2 represents a complete summary of statistical measures model, as mentioned in [35]. Specifically, the min–max normalization
technique, as referred to in Eq. (1), is used. This method effectively
for each input data, such as mean, mode, standard deviation (SD),
handles significant fluctuations and peaks in the data and ensures that
range, Q1, Q2, Q3 and skewness. The mean represents the average
all parameters are brought to a common scale.
value of each variable(WD is about 16.37, while AT is about 12.37).
The mode is the value that appears most frequently in the data set (the
mode for WD is 5.0, indicating that 5.0 is the most common value in 𝑋 − 𝑋min
𝑋Norm = (1)
the data set for WD). The SD, which measures the dispersion or spread 𝑋max − 𝑋min
of data points around the mean. A higher standard deviation indicates Where the variable 𝑋 designates input data before normalization, 𝑋min
greater variability in the data. For example, the standard deviation for and 𝑋max are the minimum and maximum values in the 𝑋 data set
SR is around 229.22, suggesting relatively high variability. The range, before normalization.
which represents the difference between the maximum and minimum
values of the data set. It gives an idea of the overall dispersion of the 4. Forecasting system
data (the WD range is 102.5, indicating that WD values vary from
a minimum of 0 to a maximum of 102.5). Skewness measures the The purpose of forecasts is to inform the EWHM system of the future
asymmetry of the data distribution. A positive asymmetry indicates a behavior of certain operating data, in order to schedule sources, loads

6
S. El Bakali et al. Energy Conversion and Management 304 (2024) 118190

Fig. 2. Visualization showing water demand, fixed appliance power, and Weather Conditions (Ambient Temperature, Wind Speed, and Solar Radiation) in histogram form for each
available 15 min interval over a 3-year period.

and reference temperature calculations. This section delves into our hy- where 𝑋𝑖 and 𝑌𝑖 are WD, FAC and Weather data (𝑆𝑅, 𝐴𝑇 , 𝑅𝐻 and
brid approach, which combines two distinct methods to achieve these 𝑊 𝑆), and 𝑋̄ and 𝑌̄ are the sample mean of 𝑋 and 𝑌 respectively.
predictions: a data-driven predictive model and a physics-based math- Calculating a PCC is only the first step in analyzing the relationship
ematical model. First of all, a comprehensive exploration of the cor- between two variables. It is at most an exploratory step, which must be
relations among various parameters, including WD, FAC, and weather validated by testing the significance of the correlation and verifying its
data (SR, AT, RH, and WS). Additionally, an autocorrelation analysis validity. To determine whether a correlation is significant, a hypothesis
is conducted on these parameters. Afterwards, this predictor uses a test must be carried out as follows: we establish a null hypothesis,
window of input data comprising past (d - i) and current (d) obser- H0, which states that there is no significant correlation between the
vations, as well as past output data (d - i observations), to anticipate two variables X and Y. A risk of error is chosen, such that an alpha
future variables, as shown in Fig. 3. The forecasting system com- of 5% is defined as the threshold for rejecting H0. This means that
prises two crucial steps. In the first, we use an MLP-based regressor
if the probability of obtaining a correlation is less than 5%, H0 will
stacking algorithm [40] to predict the values of key variables—WD, ̂ 𝑟 is
be rejected. The absolute value of the correlation coefficient 𝐶𝑜𝑒𝑓
FAC, and meteorological data —across a 24 h period with 15 min
calculated on the basis of the observed data. The theoretical value 𝑟𝛼
intervals. The second involves the application of a dedicated mathemat-
is calculated using the Eq. (3). We test whether the Null Hypothesis
ical model for PV production estimation. This hybrid model considers
is true by comparing the theoretical value 𝑟𝛼 with the observed value
the predicted weather data and incorporates the specific characteris-
̂ 𝑟 ]. If the theoretical value is greater than the observed value,
abs[𝐶𝑜𝑒𝑓
tics of the PV system. This integration enables precise predictions of
PV production. This section provides a comprehensive exploration of there is insufficient evidence to reject H0. Finally, depending on the
the correlations among various parameters, including WD, FAC, and test results, the H0 is accepted or rejected. If the theoretical value is
weather data. Additionally, an autocorrelation analysis is conducted on lower than the PCC, this suggests a significant correlation between X
these parameters. and Y, and H0 is rejected. Otherwise, H0 is accepted, indicating that
no significant relationship has been detected.
4.1. Data correlation analysis 1.96
𝑟𝛼 = √ (3)
The Pearson Correlation Coefficient (PCC) (𝐶𝑜𝑒𝑓 ̂ 𝑟 ) quantifies both 𝑁 −1
the strength and direction of the linear relationship between the water Fig. 4 represents the correlations between the different variables being
demand, meteorological data, PV power generation and fixed energy analyzed visually. It shows the correlation between multiple variables
consumption. This coefficient is computed based on sample data of size in tabular form. It displays the correlation coefficients between every
‘N’ and its formula is expressed as shown in Eq. (2). pair of variables on a scale ranging from −1 to 1. The coefficients reflect
∑𝑁 ( )(
̄ 𝑌𝑖 − 𝑌̄
) the strength and direction of the correlations. Positive values signify
̂ 𝑟= √ 𝑖=1 𝑋𝑖 − 𝑋
𝐶𝑜𝑒𝑓 (2) a positive correlation (when one variable increases, the other also
∑𝑁 ( )2 ∑ ( )2
𝑋𝑖 − 𝑋̄ ∗ 𝑁 𝑌𝑖 − 𝑌̄
𝑖=1 𝑖=1
increases), and negative values indicate a negative correlation (when

7
S. El Bakali et al. Energy Conversion and Management 304 (2024) 118190

Table 3
Correlation analysis results.
Data exploited WD FAC AT SR WS RH
WD * * * * *
FAC * * * * *
AT * * *
SR * * *
WS * * *

Table 4
Autocorrelation table at lag = 30 for various parameters (WD, FAC, SR, AT, RH and
WS).
Lags 𝑊 𝐷𝑑 𝐹 𝐴𝐶𝑑 𝑆𝑅𝑑 𝐴𝑇𝑑 𝑅𝐻𝑑 𝑊 𝑆𝑑
1 * * * * * *
2 * * * * * *
3 * * * * * *
4 * * * * * *
5 * * * * *
6 * * * * *
7 * * * * *
8 * * * * *
9 * * * * *
10 * * * *
11 * * * *
12 * * * * *
13 * * *
14 * * * *
15 * * * *
16 * * * * *
Days 17 * * * * *
(d-j) 18 * * * * *
19 * * * * *
20 * * *
21 * * * *
22 * * * *
23 * * * * *
24 * * * *
Fig. 3. Proposed method for modeling a global forecasting system integrating PV
25 * * * *
power, temperature, fixed appliance consumption, and water demand.
26 * * * * *
27 * * *
28 * * * *
29 * * *

4.2. Partial auto-correlation coefficient

Autocorrelation is the measurement of the relationship between the


values present in a time series and those that precede it in time [41]. It
is used to select the appropriate previous days for accurate estimation
of parameters such as WD, AT, PV power and FAC. This method is based
on the use of the partial autocorrelation function (PACF) to analyze
the correlation between the current values in the series and those of
past values. It identifies which past values are most likely to predict
Fig. 4. Relationship between demand water, fixed appliance consumption, and future values. This is done by using formula (4) and respecting the
meteorological data (SR, AT, WS, and RH) through correlation matrix analysis. same condition mentioned above. Table 4 shows the days in the past
(observations d-j) that have an impact on the predictions of WD, PV
power, AT, and FAC with an lag of 30 (30 days). This table is based
one variable increases, the further decreases). A coefficient of 1 shows a on all the days in the database (1095 days). Table cells are marked
strong positive correlation, −1 represents a strong negative correlation, with an asterisk (*) to indicate past days that have an effect on the
and 0 indicates no correlation. Then a significance level is calculated to parameters WD, FAC, SR, AT, RH and WS. Empty cells indicate that
deduce whether or not the value can be considered a strong correlation. there is no correlation between time series data. Analysis of Table 4
Then, the critical threshold is calculated (𝑟𝛼 = 0.006) and a data history
for water demand data (given as an example) shows that past values
of 105120 samples. The correlation analysis results obtained is shown
influence this variable at time t, recent values from d-1 to d-12 and
in Table 3. Table cells are marked with an asterisk (*) to indicate input
past values from d-16, d-19. However, each variable has its own past
data that have an effect on the predicted parameters WD, FAC, AT, SR
days.
and WS. Empty cells indicate that there is no correlation between the
data. Analysis of the Table 3 for water demand data (example data) 1.96
√ (4)
shows that this is influenced by several parameters, including AT, SR, 𝑁
RH, WS and FAC.

8
S. El Bakali et al. Energy Conversion and Management 304 (2024) 118190

hidden layer is selected, as modeling complexity increases with the


number of hidden layers [47]. Finally, the size of the OL is linked to
the target variable for prediction. A distinctive aspect of our approach is
that each basic model integrated into the stacking process is trained on
different datasets in order to assess the influence of each input variable
on the predicted variables. To illustrate this point, when predicting WD,
the Level 0 models are trained on a variety of parameters, including AT,
WS, SR, RH and FAC. Similarly, when predicting FAC, Level 0 models
are trained on a variety of variables, including AT, WS, RH, SR and
WD. Similarly, when predicting AT, Level 0 models are trained on a
variety of parameters, including SR, WS and RH. This approach is also
used to predict SR and WS, with separate data sets for each variable, as
shown in Fig. 5. The Level 1 model for each target variable (WD, FAC
and weather data) then combines the predictions generated by these
diverse base models. This method captures the complex relationships
between input and target variables in a more precise and nuanced way,
improving forecast quality and reliability.

4.3.2. Physics-based PV power mathematical model


The significant decrease in the prices of photovoltaic (PV) modules
over the past decade has opened new avenues for the adoption of PV
systems in diverse applications [48]. The microgrid considered in this
paper is made up of the conventional electricity grid and a photovoltaic
(PV) system. The main focus is on exploiting the energy generated by
the PV system, considered an abundant and economical resource.
PV power is affected by various factors such as SR, AT and WS.
In addition, it is important to consider the potential degradation of a
PV system, a critical indicator of its performance over time, including
elements such as weathering, oxidation, corrosion and thermal stress.
To account for the effects of degradation, the rated power of a PV
system is modified by the degradation factor (1-deg). It is common
practice to suggest an annual degradation rate of about 0.2 to 0.5% for
crystalline silicon (c-Si) PV cells under real-life conditions [49]. The
estimated PV power (𝑃𝑃 𝑉 ) is calculated using the following formula
(Eq. (5)):
Fig. 5. Illustration of the prediction algorithm block diagram.

𝐼𝑖𝑟𝑑 (𝑡𝑖 )
𝑃𝑃 𝑉 (𝑡𝑖 ) =𝑃𝑟𝑎𝑡𝑒𝑑 × 𝜂𝑃 𝑉 ×
𝐼𝑠−𝑖𝑟𝑑 (5)
4.3. Forecasting model development × [1 + 𝐾𝑇 × (𝑇𝑠 (𝑡𝑖 ) − 𝑇𝑟𝑒𝑓 )] × (1 − 𝑑𝑒𝑔)

This section delves into our hybrid approach, which combines two Where
distinct methods to achieve the prediction data: a data-driven predic- 𝑃𝑟𝑎𝑡𝑒𝑑 is the rated power (kW) of the PV (𝑃𝑟𝑎𝑡𝑒𝑑 = 2.5 kW); 𝜂𝑃 𝑉 is the
tive model [42,43] and a physics-based mathematical model. This latter power derating of the PV (𝜂𝑃 𝑉 = 0.9); 𝐼𝑖𝑟𝑑 is the actual solar radiation
are particularly useful in the cases of a historical production data is (kW/m2) on the PV panel; 𝐼𝑠−𝑖𝑟𝑑 is the solar radiation on the PV panel
not available [44]. They are based on mathematical models that take under standard conditions (𝐼𝑠−𝑖𝑟𝑑 = 1 kW/m2 ) ; 𝐾𝑇 is the temperature
system characteristics into account. In contrast, data-driven models coefficient (𝐾𝑇 = −3.7 × 10−3 ); deg is the degradation factor and is
are well suited to predicting water demand, energy consumption and approximately 0.2%–0.5% annually; 𝑇𝑟𝑒𝑓 is the PV cell temperature
weather conditions. Consequently, it is widely recognized that the use (◦ C) at standard conditions (𝑇𝑟𝑒𝑓 = 25 ◦ C); 𝑇𝑠 is the PV cell temperature
of a hybrid approach, combining both physics-based and data-based (◦ C), calculated as follows:
models, is considered the most accurate technique for forecasting PV 𝑇𝑠 (𝑡𝑖 ) =𝑇𝑎 (𝑡𝑖 ) + 0.0138 × [1 + 0.031 × 𝑇𝑎 (𝑡𝑖 )]
production. (6)
× [1 − 0.042 × 𝑣𝑠 (𝑡𝑖 )] × 𝐼𝑖𝑟𝑑 (𝑡𝑖 )
4.3.1. Data-driven predictive model Where
The Stacking Algorithm (SA) is an ML technique that exploits mul- 𝑇𝑎 is the external environment temperature (◦ C) under current
tiple base models (level 0) trained on different datasets. These models conditions; 𝑣𝑠 is the wind speed (m/s).
produce predictions used as input features for a meta-model (level 1),
as illustrated in Fig. 5. The meta model learns from the strengths and 4.4. Forecasting performance indicators
biases of the base models, enhancing the effectiveness of their predic-
tions [45,46]. In this specific implementation of SA, multi multilayer One of the objectives of this paper is to provide highly accurate
perceptrons (MLPs) operate at level 0, and one MLP operates at level 1. forecasts of WD, PV production, AT, and FAC over the next 24 h
These models make use of both current and historical data to forecast with a minimum level of error. The assessment of forecast accuracy
future values. The structure of the AS is centered on three essential is generally based on the use of Mean Absolute Error (MAE), Root
elements: the size of the input layer (IL), the hidden layer (HL) and Mean Square Error (RMSE), Normalized MAE (NMAE), and Normalized
the output layer (OL). The size of the input layer (IL) corresponds RMSE (NRMSE) measures defined in [50,51] and calculated using the
to the number of input variables, the size of the hidden layer (HL) Eqs. (7), (8), (9), and (10), respectively. RMSE provides a measure of
corresponds to the number of hidden layers — in our case, only one the magnitude of the error and helps to assess the overall prediction

9
S. El Bakali et al. Energy Conversion and Management 304 (2024) 118190

Table 5 below. The objective function is expressed as a combination of two


Model accuracy in different classes. terms: energy bill and incomfort cost, and is presented as follows:
Classes NRMSE values (%) Precision state
1 NRMSE < 10 Excellent 𝑂𝑏𝑗𝑔𝑙𝑜𝑏𝑎𝑙 = 𝛼 ∗ 𝑂𝑏𝑗𝑑𝑖𝑠𝑐 + (1 − 𝛼) ∗ 𝑂𝑏𝑗𝑏𝑖𝑙𝑙 (11)
2 10 < NRMSE < 20 Good
where 𝛼, ranging from 0 to 1, is the coefficient that reflects the relative
3 20 < NRSME < 30 Fair
4 NRMSE > 30 Poor importance of the two objectives.

5.1.1. Comfort cost model


The comfort cost (discomfort) is described as a linear function which
accuracy. In comparison, MAE measures the mean absolute difference expresses the difference between the actual hot water temperature and
between predicted and actual values and is less sensitive to outliers the water temperature setpoints, normalized according to a minimum
than RMSE. NMAE and NRMSE are commonly used to evaluate the comfort cost.
accuracy of predictions because they allow measurements at different
𝑂𝑏𝑗𝑑𝑖𝑠𝑐 = 𝑚𝑖𝑛𝑖𝑚𝑖𝑧𝑒(𝐶𝑜𝑠𝑡∗𝐶 ) (12)
scales to be normalized, as shown by [35], and making them easy to
interpret and providing a standardized measure of error. Due to frequent water temperature changes, it is decided to calcu-
late the hot water temperature (𝑇𝐻𝑊 (𝑡𝑖 )) at one-minute intervals. In
contrast, EWH power is available every 15 min. This is done to reduce
1 ∑| ̂
𝑁
|
𝑀𝐴𝐸 = |𝑋 − 𝑋𝑖 | (7) the computational load on the PSO algorithm and avoid excessive
𝑁 𝑖=1 | 𝑖 |
complexity.

√ The comfort cost for time slot i is given by Eq. (13):
√1 ∑ N
( )2
RMSE = √ 𝑋̂ 𝑖 − 𝑋𝑖 (8) ∑∑
24×4 15
N 𝑖=1
𝐶𝑜𝑠𝑡𝐶 = (𝑇𝐻𝑊 (𝑡𝑖 × 15 𝑚𝑖𝑛 + 𝑡𝑘 × 1 𝑚𝑖𝑛)
1 ∑𝑁 | ̂ | (13)
𝑖=1 ||𝑋𝑖 − 𝑋𝑖 ||
𝑖=1 𝑘=1
𝑁 2
𝑁𝑀𝐴𝐸 = ∑ (9) − 𝑇𝐷 (𝑡𝑖 × 15 𝑚𝑖𝑛))
1 𝑁
𝑁 𝑖=1 𝑋𝑖
√ The comfort cost performance is estimated by the normalized comfort
1 ∑N ( ̂ )2
cost, as given by Eq. (14):
N 𝑖=1 𝑋𝑖 − 𝑋𝑖
NRMSE = (10)
1 ∑𝑁 𝐶𝑜𝑠𝑡𝐶
N 𝑖=1 𝑋𝑖 𝐶𝑜𝑠𝑡∗𝐶 = ∑ (14)
24×4×15
𝑖=1 (𝑇𝐻𝑊 ,𝑚𝑎𝑥 − 𝑇𝐷 (𝑡𝑖 ))2
A good model is the one for which NMAE and NRMSE are the lowest
as possible. According to [52,53], the accuracy of the model can be where, 𝑇𝐻𝑊 ,𝑚𝑎𝑥 : Represents the maximum acceptable temperature, set
divided into four classes as shown in Table 5. This established criteria at 60 ◦ C. For every case, 0 ≤ 𝐶𝑜𝑠𝑡∗𝐶 ≤ 1. Regarding the comfort cost
for evaluating the performance of predictive models. According to these performance, the best case corresponds to 𝐶𝑜𝑠𝑡𝐶 = 0 (minimum energy
criteria, a model is considered excellent if the normalized measure cost) and the worst case corresponds to 𝐶𝑜𝑠𝑡𝐶 = 0 (maximum energy
(NRMSE and NMAE) is less than 10%, good if it is between 10% and cost).
20%, and poor if this measure exceeds 30%.
5.1.2. Cost bill model
The building concerned has been designed and operated to en-
5. Off-line optimization layer
courage the use and sharing of locally produced energy resources.
This approach involves proactive management of the energy generated
The proposed strategy operates in two layers: offline optimiza- within the building, with the emphasis on energy efficiency and mini-
tion and online optimization. This two-layer approach combines the mizing losses. In this context, When the amount of energy generated by
strengths of both optimization modes to achieve a comprehensive and the PV system exceeds energy requirements, the surplus is fed into the
adaptable solution [44]. Offline optimization, which we discuss in this general power electrical grid (𝑃𝐸𝐺 ), resulting in income from the sale
section, sets the scene by strategically planning EWH energy consump- of electricity, noted 𝐸𝑇𝑠𝑒𝑙𝑙 (cents/kWh). On the other hand, in the event
tion for the day ahead. It is involves a multi-objective metaheuristic of insufficient solar production, the system compensates by drawing
optimization process aimed at improving the energy efficiency of EWH. the remaining energy required from the public power grid, resulting
This optimization aims to minimize both energy costs and discomfort in energy costs noted 𝐸𝑇𝑏𝑢𝑦 (cents/kWh) that must be covered. Thus,
over the coming 24 h period. It represents the first layer of our proposed the daily energy bill, represented by 𝐶𝑜𝑠𝑡𝐵 , results from this dynamic
strategy and forms the basis for subsequent optimization steps. The interaction between local production and grid resources.
overall strategy therefore comprises an initial OFF-OL, complemented
by a subsequent ON-OL. This combination effectively reduces energy 𝑂𝑏𝑗𝑏𝑖𝑙𝑙 = 𝑚𝑖𝑛𝑖𝑚𝑖𝑧𝑒(𝐶𝑜𝑠𝑡∗𝐶 ) (15)
costs and improves comfort, while adapting to dynamic factors and The energy cost for time slot i is given by Eq. (16):
maintaining optimum performance.

24×4
𝛥𝑇
𝐶𝑜𝑠𝑡𝐵 = ((𝑃𝐸𝐺 (𝑡𝑖 ) × 𝐸𝑇𝑏𝑢𝑦 (𝑡𝑖 )) × × 𝜉𝑡𝑏𝑢𝑦
5.1. Optimization objective 𝑖=1
3600 𝑖
(16)
𝛥𝑇
× 𝜉𝑡𝑠𝑒𝑙𝑙 )
− (𝑃𝐸𝐺 (𝑡𝑖 ) × 𝐸𝑇𝑠𝑒𝑙𝑙 (𝑡𝑖 )) ×
Two objectives, the minimization of energy bill and incomfort cost 3600 𝑖

are considered in this paper. In fact, a high level of comfort corresponds Where 𝑃𝐸𝐺 is the electrical Grid power (KW) measured at a time step 𝑡𝑖 ;
to high money expenses. Attempting to reduce these expenses could 𝜉𝑡𝑏𝑢𝑦 denotes the sign function in the case of buy electricity. It is equal
𝑖
have a negative impact on the comfort level. The inverse proportional- to one when 𝑃𝐸𝐺 is positive (the home is importing energy from grid);
𝑠𝑒𝑙𝑙
𝜉𝑡 denotes the sign function in the case of sell electricity. It is equal
ity existing between these two objectives is commonly known as the 𝑖
‘‘Cost-Comfort Dilemma’’. Therefore, the challenge is to find a way to one when 𝑃𝐸𝐺 is negative (the home is injecting energy from grid).
ensuring a good comfort level, while reducing costs. This case study The energy cost performance is estimated by the normalized energy
will analyze the relationship between cost and comfort to find a suitable cost, as given by Eq. (17):
trade-off between these two objectives. It is, therefore, a MOO which 𝐶𝑜𝑠𝑡𝐵 − 𝐶𝑜𝑠𝑡𝐵,𝑚𝑖𝑛
simultaneously considers the cost and the comfort function defined 𝐶𝑜𝑠𝑡∗𝐵 = (17)
𝐶𝑜𝑠𝑡𝐵,𝑚𝑎𝑥 − 𝐶𝑜𝑠𝑡𝐵,𝑚𝑖𝑛

10
S. El Bakali et al. Energy Conversion and Management 304 (2024) 118190

Fig. 6. Feed-in tariff and time-of-use pricing rate.

where, 𝐶𝑜𝑠𝑡𝐵,𝑚𝑖𝑛 and 𝐶𝑜𝑠𝑡𝐵,𝑚𝑎𝑥 are the minimum and the maximum
energy cost, respectively. For every case, 0 ≤ 𝐶𝑜𝑠𝑡∗𝐵 ≤ 1. Regarding
the energy cost performance, the best case corresponds to 𝐶𝑜𝑠𝑡𝐵 = 0
(minimum energy cost) and the worst case corresponds to 𝐶𝑜𝑠𝑡𝐵 = 0
(maximum energy cost).
The import tariff (ToU) is an electricity pricing tariff that varies
according to the time of day. Under this tariff, electricity is billed at
different rates during peak, shoulder and off-peak hours. ToU encour-
ages consumers to shift their consumption to off-peak hours, which can
lead to energy savings and more efficient use of the power grid [54].
The export tariff (FiT), on the other hand, is a support mechanism
for renewable energy production [55]. It guarantees renewable energy
producers a fixed and often preferential tariff for the electricity they
feed into the grid. FiTs aim to stimulate investment in renewable ener-
gies by offering a guaranteed return to producers, thereby encouraging
the transition to cleaner, more sustainable energy sources. A graphical
representation of these prices is provided in Fig. 6.

5.2. Optimization problem constraints

The EWHM problem is subject to different constraints. These con- Fig. 7. Proposed offline optimization algorithm using PSO algorithm.
straints delimit the search space for admissible solution. The necessity
of maintaining energy balance is a critical constraint in this optimiza-
tion process. This power balance [44] is given by: 5.3. EWHM optimization problem resolution
𝑃𝐸𝐺 (𝑡𝑖 ) + 𝑃𝑃 𝑉 (𝑡𝑖 ) = (𝑃𝐸𝑊 𝐻 (𝑡𝑖 ) + 𝑃𝐹 𝐴𝐶 (𝑡𝑖 )) (18)
This section introduces the metaheuristic optimization method kn-
The second essential constraint to be taken into account relates to own as PSO, used to minimize both energy bills and comfort-related
the power capacity of the EWH, which must be carefully framed by costs. The proposed PSO algorithm is designed to determine the op-
predefined maximum and minimum values, as shown as in Eq. (19). timal operating EWH power setpoints. Several approaches have been
As with all electrical loads, the power allocated to the water heating suggested to solve the challenges posed by MOO. Among them are
system must not exceed a value imposed by the manufacturer. This techniques such as the mixed-integer linear programming, the PSO,
translates into an inequality constraint, given by: the grasshopper optimization algorithm [56], the dynamic program-
ming [55] and so on. In this article, the PSO method is used, commonly
0 ≤ 𝑃𝐸𝑊 𝐻 (𝑡𝑖 ) ≤ 𝑃𝑚𝑎𝑥 (19)
used in the field of domestic energy management, to specifically solve
The power exchanged with the main grid is also subject to limitations the MOO problem addressed in this study.
imposed by the subscription contract. This constraint is put in place to The PSO algorithm optimizes a problem by iteratively exploring a
maintain grid stability and avoid overloads, given by : set of candidate solutions. It relies on a population of particles, each
with dimension N, and moves them through the search space following
− 𝑃2 ≤ 𝑃𝐸𝐺 (𝑡𝑖 ) ≤ 𝑃1 (20)
a stochastic law. Two key elements of this algorithm are learning (cog-
This constraint aims to define an acceptable range for the hot water nitive factor) and communication (social factor) [57]. Fig. 7 provides a
temperature (𝑇HW (𝑡𝑖 )) in relation to a desired temperature (𝑇𝐷 (𝑡𝑖 )), so visual representation of the process involved in determining the optimal
that the hot water temperature must be between 97% and 103% of the power consumption of the EWH using the PSO algorithm.
desired temperature, and the maximum difference allowed is 3% of the The objective is to minimize a predefined objective function. The
desired temperature. process begins with the random initialization of a population, each
{ solution of which is referred to as a ‘‘particle’’. Each particle essentially
0.97𝑇𝐷 (𝑡𝑖 ) − 𝑇HW (𝑡𝑖 ) represents the plan for operating the devices throughout the day. The
𝐽cons = 𝐶 × max ,
0.97𝑇𝐷 (𝑡𝑖 ) PSO algorithm continuously updates both the velocity and position of
}
1.03𝑇𝐷 (𝑡𝑖 ) − 𝑇HW (𝑡𝑖 ) each particle during each iteration. It does this by using two main
0, (21) memory components: one that stores the best solution that a particle
1.03𝑇𝐷 (𝑡𝑖 )
has found locally (referred to as ‘‘pbest’’), and the other that stores the
where the coefficient C of penalty function needs to be tuned, 0.97𝑇𝐷 (𝑡𝑖 ) best solution that the entire population has found collectively up to that
is the lower bound and 1.03𝑇𝐷 (𝑡𝑖 ) is the upper bound. point (referred to as ‘‘gbest’’). Over the course of these iterations, the

11
S. El Bakali et al. Energy Conversion and Management 304 (2024) 118190

Table 6
PSO hyperparameters.
Parameter name Value
Population Size 800
Number of decision variables 96
Cognitive Component (c1) 1.0
Social Component (c2) 1.9
Stopping Criteria 180
Inertia Weight (w) 0.9
Inertia Weight Damping Rate 0.99
sample time (s) 900

particles gradually converge on the optimal solution [58]. The velocity


𝑣𝑖 (t) and position 𝑥𝑖 (t) of the PSO algorithm are represented by the
following equations:
𝑣𝑖 (𝑡) =𝑤 × 𝑣𝑖 (𝑡 − 1) + 𝑟1 × 𝑐1 × (𝑝𝑏𝑒𝑠𝑡𝑖 − 𝑥𝑖 (𝑡 − 1))
(22)
+ 𝑟2 × 𝑐2 × (𝑔𝑏𝑒𝑠𝑡 − 𝑥𝑖 (𝑡 − 1))

𝑥𝑖 (𝑡) = 𝑥𝑖 (𝑡 − 1) + 𝑣𝑖 (𝑡) (23)

The Table 6 shows the hyperparameters that influence resolution per-


formance which contains limits for the number of DVs, population size, Fig. 8. Water Temperature Setpoint Generator Flowchart.
cognitive component, social component, inertia weight, inertia weight
damping rate and sample time. It is essential to note that the parameter
values and limits mentioned in the table may vary depending on the
specific implementation, problem domain and optimization objectives.
These hyperparameters are chosen experimentally, enabling the
performance of the PSO algorithm to be optimized. This experimental
approach is essential to find the parameters that maximize optimization
efficiency, as there are no universal values for these parameters. Never-
theless, the 24 h planning obtained will certainly be subject to change,
as it is based on forecasts which are obviously subject to uncertainties.

5.4. Water temperature setpoints generator

The choice of water temperature set points is critical to optimizing


both energy costs and comfort. This approach aims to adjust the water
temperature set points with respect to various parameters including
PV production, energy consumption, ambient temperature, presence or
absence of hot water demand to guarantee energy savings without com-
promising comfort for occupants. By presenting two different cases for
the generation of 𝑇𝐷 , this approach takes into account the adaptability
of the water temperature setpoints to changing conditions, as shown in
Fig. 8. In fact, two formulations are developed, as shown in Eq. (24).
One of these formulations is designed for situations where no hot water
demand and is dependent on water demand profile, PV generation and
energy consumption. It thus creates a range of variations, extending
between the minimum possible ambient temperature and the maximum
temperature required to eliminate Legionella bacteria present in the
water, as illustrated in Fig. 9(a).
⎧ 𝐴𝑇 (𝑡𝑖 ) + ((𝑇𝑏𝑎𝑐 − 𝐴𝑇 (𝑡𝑖 ))
⎪ 𝑃 (𝑡 )
⎪ × ( 𝜋2 × 𝑎𝑟𝑐𝑡𝑎𝑛( 𝑃𝑃 𝑉(𝑡 )𝑖 ))) 𝑖𝑓 𝑊𝐷 (𝑡𝑖 ) ≤ 0
⎪ 𝐿 𝑖
𝑇𝐷 (𝑡𝑖 ) = ⎨ (24)
⎪ 𝑇𝑚𝑖𝑛 + (𝑇𝑚𝑎𝑥 − 𝑇𝑚𝑖𝑛 ) × (1 − ( 𝜋2
⎪ 𝐴𝑇 (𝑡𝑖 )
⎪ × 𝑎𝑟𝑐𝑡𝑎𝑛( ))) 𝑖𝑓 𝑊𝐷 (𝑡𝑖 ) > 0
⎩ 𝑇𝑆

It is essential to note that Legionella are bacteria commonly found


in water EWH system. These bacteria remain inactive (at temperatures
below 20 ◦ C) or do not survive (at temperatures above 60 ◦ C). The
water temperature setpoints are adjusted according to the amount of
Fig. 9. Curve illustrating the choice of reference water temperature in the tank.
overproduced PV solar energy. Significant overproduction will direct it
towards the maximum reference temperature (60 ◦ C). However, more
moderate overproduction will bring it closer to ambient temperature.
On the other hand, ambient temperature is also a modifiable param- event of water demand. However, this influence remains limited to the
eter that influences the generation of water temperature setpoint in the limits defined by the minimum possible temperature and the maximum

12
S. El Bakali et al. Energy Conversion and Management 304 (2024) 118190

required temperature. Indeed, when the ambient temperature is high, In the online phase, on the other hand, the time resolution is reduced
the water temperature setpoints tend to be closer to the minimum to 5 min. This adaptation of the online resolution enables greater
value (30 ◦ C), whereas when it is low, it is more oriented towards the responsiveness to variations in the EWH system. The mathematical
maximum temperature (50 ◦ C), as illustrated in Fig. 9(b). It should formulation of the objective function can be expressed as follows:
be noted that the choice of average indoor temperature (𝑇𝑆 ) varies
according to the season. The warm season is characterized by an 𝑂𝑏𝑗𝑔𝑙𝑜𝑏𝑎𝑙2 = 𝛼 × 𝐶𝑜𝑠𝑡∗𝐶 + (1 − 𝛼) × 𝐶𝑜𝑠𝑡∗𝐵 + 𝐽cons (26)
average daily maximum temperature in excess of 24 ◦ C. Conversely,
the cool season sees an average daily maximum temperature below 6.2. EWH system optimization using ES technique
19 ◦ C. For our purposes, we have chosen a 𝑇𝑆 value of 15 ◦ C, which
corresponds to the warm season. ES is a real-time, model-free adaptive control strategy that operates
without reliance on system models [64,65]. In this paper, the ES
5.5. Environmental impact assessment method is employed to dynamically calculate the power setpoints of
the EWH in response to real-time measurements at 5 min intervals and
Environmental impact assessment, particularly with regard to car- with consideration for outcomes derived from offline optimization. The
bon emissions, represents a crucial area of research in the current illustration of the ES scheme is presented in Fig. 10. The scheme utilizes
context of growing concern about climate change. The traditional real-time data inputs, encompassing the actual power generated by the
power grid is often identified as a major source of greenhouse gas PV system, the fixed appliance consumption, the water demand, and
(GHG) emissions. The emissions calculation model is a crucial element the ambient temperature.
of the environmental analysis. In our study, we rely on the emissions The synchronization between both stages (offline and online op-
calculation model mentioned in [59]. This model takes into account timization) is crucial for the efficient operation of the management
various factors such as the source of electricity generation, the specific system. The first stage performs optimization over a 24 h period, with
emissions of each source and other parameters related to electricity a time resolution of 15 min. During this phase, forecasts are made to
distribution. anticipate the system’s energy requirements over this period. Then, the
{∑ second stage intervenes to optimize in real time the instantaneous costs
24×4
𝐸𝐶𝑂2 (𝑡𝑖 ) = 𝑖=1 𝑃𝐸𝐺 (𝑡𝑖 ) × 𝑒𝐶𝑂2 𝑖𝑓 𝑃𝐸𝐺 (𝑡𝑖 ) > 0
(25) of the energy bill and the comfort level, by adjusting the water heater
0 𝑖𝑓 𝑃𝐸𝐺 (𝑡𝑖 ) ≤ 0 power. This adjustment is made in a neighborhood around the value
Where, 𝑒𝐶𝑂2 as the carbon emission factor, equivalent to 0.354 kg co2 pre-calculated by the first stage, enabling the real-time optimization
eq /kWh for Germany [60]. loop to converge rapidly on the optimal solution. To facilitate this
convergence, the integrator in the real-time optimization loop is pe-
6. Online optimization layer riodically reset, every 5 min, to the heating power value calculated
by the first stage. This approach guarantees dynamic and efficient
The ON-OL is designed to ensure that power setpoints, calculated adaptation of the heater power, ensuring optimal system management
after the occurrence of uncertainties, are closely aligned with the under changing conditions. In the ES scheme, the aim of modulation
optimal solution provided by the OFF-OL. For real-time optimization, is to perturb the value of the parameter (𝐾𝜁 ) to be optimized by
the ES technique is used. With ES, the EWH system is treated as a applying a low-amplitude sinusoidal signal (𝑏 × sin(𝑤𝑡)), which resulted
black box, and the optimization algorithm adjusts according to exper- in a sinusoidal output perturbation around the initial output value, as
imental measurements in real time, without the need to understand shown in Eq. (27). The system being optimized reacts to the parameter
the underlying physical equations of the EWH system [44,61]. This perturbations. This reaction causes a corresponding change in the
section provides an introduction to ES, as well as the objective function objective function value. The aim of demodulation is to multiply the
and associated constraints, and an overview of the proposed real-time objective function signal (𝑂𝑏𝑗𝑔𝑙𝑜𝑏𝑎𝑙2 ) by a sinusoid (sin(wt)) having the
optimization model. same frequency as the modulation signal. This step includes an optional
high-pass filter to eliminate bias from the objective function signal.
6.1. Introduction: Objective function and constraints Finally, update the parameter value by integrating the demodulated
signal. This latter is integrated over time to generate a control signal
The ES technique is able to maintain optimum performance in the 𝑃̂𝐸𝑊 𝐻 (𝑡), as shown in Eq. (28). The parameter value corresponds to the
face of forecast uncertainty. ES operates by iteratively perturbing the state of the integrator. At this stage, The integrator block is initialized
every five minutes by the estimated EWH power setpoint (𝑃𝐸𝑊 𝑖𝑛𝑖𝑡 ). The
input parameters and monitoring the resulting changes in the objec- 𝐻
tive function [62]. This process enables ES to dynamically adapt and initialization of the integrator produces a moving average EWH power
find the EWH power optimal operating, even when uncertainties and value from the initial global optimum to the new local optimum.
disturbances are present. Considering the dynamic nature of real-time 𝑃𝐸𝑊 𝐻 (𝑡) = 𝐾 × 𝑃̂𝐸𝑊 𝐻 (𝑡) + 𝑏𝑠𝑖𝑛(𝑤𝑡) (27)
optimization scenarios and the need to respond swiftly to changing
conditions, ES offers an adaptive and robust approach [63]. In fact, the 1
𝑃̂𝐸𝑊 𝐻 (𝑡) = 𝐿−1 ( ) × 𝑌𝐻𝑃 × 𝑠𝑖𝑛(𝑤𝑡) (28)
ES is used to find the new optimal solution in a limited neighborhood 𝑠
around the result given by the offline optimization. To achieve this, The initialization of the ES integrator can be formulated mathemati-
the optimal solution generated by ES is periodically reset to the value cally as follows:
determined during the offline phase, with this reset occurring every 𝑖𝑛𝑖𝑡 (𝑡 ) − 𝑏𝑠𝑖𝑛(𝑤𝑡 )
5 min. 𝑃𝐸𝑊 𝐻 𝑖 𝑖
𝜁= (29)
The real-time optimization process aims to minimize an objective 𝐾
function that includes both the energy bill and the cost associated with Table 7 provides an overview of the parameter values carefully
ensuring occupant comfort. In addition, the ON-OL model takes into selected for the ES algorithm. The choice of K, 𝑤ℎ and b is made
account the same constraints as the OFF-OL model, i.e. maintaining experimentally in accordance with the selection criteria given in [34].
power balance and taking into account EWH and grid power limit Moreover, the choice of these parameters is made with the intention
constraints. of striking a balance between the speed of convergence and overall
The objective function remains the same in both online and offline stability. The aim is to create an optimization process that is both
phases, although some differences are taken into account. In the offline efficient and dependable, ensuring that the system can efficiently reach
phase, the time horizon extends to 24 h, with a resolution of 15 min. optimal solutions without sacrificing stability.

13
S. El Bakali et al. Energy Conversion and Management 304 (2024) 118190

Table 8
Specifications of EWH model, PV system and FAC.
Component Specifications
Capacity: 50 liters
Rated power: 5000 W
Water density: 1000 Kg/m3
Dimensions : 450 × 568 mm
EWH system
Specific heat of water : 4184 J/Kg K
Tank volume : 0.05 m3
Tank thermal resistance : 0.01 m2 . K/W
Inlet temperature : (20 + 273) K
Rated power: 2 kW
PV System Power derating: 0.9
Degradation factor: 0
FAC Average consumption: 3168.81 kWh/year

7.1. Simulation protocol

In this section, the characteristics of the sources and loads used in


this paper are described, i.e. PV system, EWH and fixed-load energy
consumption. The EWH simulates the demand for domestic hot water,
the PV System generates electricity from solar energy, while the fixed-
load energy consumption represents the constant energy demand in our
simulation.
December 17, 2019 is selected as the reference day for our simula-
tions of the proposed strategy.
The proposed management strategy requires the water temperature
to be measured. However, no real EWH model exists to obtain this
measured temperature. Under these conditions, a mathematical EWH
model widely used in the literature [66,67] was employed to calculate
Fig. 10. A real-time EWH power setpoint control strategy based on an ES model-free the water temperature, as shown in Eq. (30).
strategy.
−( ′ 1 (𝑡𝑖 −𝜏))
𝑇𝐻𝑊 (𝑡𝑖 ) = 𝑇𝐻𝑊 (𝜏)𝑒 𝑅 𝑉𝑇 𝐷𝐶𝑝
Table 7 [ ]
1
Extremum seeking controller parameters. + 𝑆𝐴( )𝑅′ 𝐴𝑇 (𝑡𝑖 ) + 𝐵(𝑡𝑖 )𝑅′ 𝑇𝐶𝑊 + 𝑃𝐸𝑊 𝐻 (𝑡𝑖 )𝑅′ (30)
𝑅
Parameter name Value [ ]
−( ′ 1 (𝑡𝑖 −𝜏))
Amplitude of modulation signal 30
× 1 − 𝑒 𝑅 𝑉𝑇 𝐷𝐶𝑝
Amplitude of demodulation signal 3000
Learning rate (k) −10 With,
Sinusoid frequency (Hz) 2 1
HP filter cutoff frequency (Hz) 0.1 𝑅′ = (31)
Pulse generator amplitude 1 𝐵(𝑡𝑖 ) + 𝑆𝐴( 𝑅1 )
Pulse generator width (%) 2 1h
Controller sample time (s) 0.01 𝐵(𝑡𝑖 ) = 𝐷 × 𝑊 𝐷(𝑡𝑖 ) × 𝐶𝑝 × ( ) (32)
3600s
The specifications are summarized in Table 8. We use these specifica-
tions to create a realistic simulation strategies.
7. Results and discussion The input data used in the optimization algorithm on the day
considered are shown in Fig. 11.

This section focuses on the simulation study carried out to validate 7.2. Forecasting outcome
the performance of the proposed TL-EWHM strategy. The study is
This subsection presents the forecast results for water demand,
divided into four main parts. The first part presents the simulation
weather data (AT, SR, WS), PV power, and fixed appliances consump-
protocol. The second part presents the results of forecasting input
tion. The architecture of the ANN is determined by specifying several
data (e.g. water demand, weather data, photovoltaic power and fixed parameters as presented in Table 9.
appliance consumption), as well as evaluating the performance of the This table provides a comprehensive overview of the parameters
forecasting algorithm using several error measurements. The third part governing our neural network-based prediction model, which com-
presents the proposed solution, the results of offline optimization using prises two key elements: the base model (BM) and the meta-model
predicted data, and online updating in the presence of estimation (MM). These elements are tailored to predict various data types, in-
error. The fourth part presents a comparative study between the pro- cluding WD, FAC, SR, AT, WS, and RH, as discussed in Fig. 5. Each
posed strategy and two other approaches, the first limited to off-line prediction model (M1 to M19 in the table) possesses a specific number
of neurons in its inner layers for BM. Additionally, the number of
optimization and the second limited to the use of a fixed reference
neurons in the hidden layers (HL - Hidden Layers) is specified for
temperature. The aim of this comparative study is to demonstrate the both BM and MM, corresponding to each predicted parameter. To
advantages of taking estimation errors into account, and to demonstrate determine the optimal number of neurons in the hidden layers, we use
the advantages of using a variable temperature setpoint as a function an optimization method by gradually varying the number of neurons
of operating conditions. in the hidden layer, from fifty to nine hundred for the basic models

14
S. El Bakali et al. Energy Conversion and Management 304 (2024) 118190

Table 9
Prediction model’s neural network parameters.
Predicted data Neurons Epochs
IL HL OL BM MM
BM MM
M1 4512
M2 4512
WD M3 4512 500 500 96 500 1000
M4 2496
M5 3648
M6 4896
M7 4896
FAC M8 4896 300 200 96 800 600
M9 2880
M10 3648
M11 5760
SR M12 3744 800 400 96 800 1000
M13 5760
M14 5760
AT M15 3477 900 300 96 900 500
M16 5760
M17 3477
WS M18 3477 600 500 96 600 800
M19 3477

parameters remain constant for all models. The "batch size’’, indicating
the number of data samples processed in each learning iteration, is
uniformly set at 50 to maintain consistency and efficiency. We have
chosen the ReLU activation function, while neural network weights are
initialized using the "He uniform" method, known for promoting rapid
convergence during learning. Finally, we employ the Adam algorithm
as the optimizer.
The daily predicted and real-time parameters results (WD, FAC, AT,
SR, WS and PV) are presented in Fig. 12. In addition, several metrics are
used to evaluate the prediction accuracy, such as RMSE, MAE, NRMSE,
and NMAE.
Two error measurement studies are shown in Table 10. The first
study evaluates the average error of 20% on all global data (test data).
This is essentially an error metric that evaluates the overall accuracy
of the predictions on all test data. It can be referred to as mean error
over all test data. The second study evaluates the error for a specific
date (17-12-2019). This is an evaluation of the prediction accuracy for
a specific day, which is more specific than the first metric. In terms of
test data, WD has an NRMSE of 5.384%, AT has an NRMSE of 4.106%,
SR has an NRMSE of 2.589%, while FAC has an NRMSE of 3.444%.
Thus, the NRMSE and NMAE values for all parameters are below 10%.
This indicates that the model can accurately estimate these values.
As far as WD is concerned, the NRMSE and NMAE show values are
below 10%, suggesting that the proposed model can be considered as
performing well. However, there are still uncertainties that are taken
into account by the two-layer optimization. For the evaluated day,
the parameters show a positive percentage error, indicating that the
predicted values are lower than the actual values. This situation can
lead to an underestimation of these parameters, which can result in
Fig. 11. Measured daily input data on December 17, 2019. unexpected energy deficits and higher energy bills.

7.3. Proposed strategy management: TL-EWHM


and the simultaneous meta-learner. The combination that produces
the lowest error when evaluated against the test data is considered The proposed TL-EWHM strategy represents a hybrid of two op-
the optimal configuration among the evaluated combinations. For the timization approaches, OF-OL (is limited to forecasting results, does
output layers, a uniform set of 96 output neurons is established. These not take forecasting uncertainties into account) and ON-OL (takes into
correspond to forecasts for the upcoming 24 h at 15 min intervals, account forecast uncertainties), by integrating PSO for offline optimiza-
maintaining a consistent structure for all predictions. Another crucial tion, which relies on predictive data, and ES for real-time optimization,
parameter is the number of epochs defined for each model, which which uses real-time data. The weighting factor (𝛼) is set to 0.8 to
governs the number of iterations performed during neural network optimize the multi-objective function. In addition, water temperature
training. These specifications result from an extensive grid search, en- control is achieved through the use of a variable temperature setpoint.
suring optimal configurations for the predictions. Certain fundamental In this subsection, the results of these two approaches are presented.

15
S. El Bakali et al. Energy Conversion and Management 304 (2024) 118190

Fig. 12. Comparison of measured and predicted daily input data using stacking algorithm on December 17, 2019.

Table 10
Evaluate predicted parameters using error metrics (MAE, RMSE, NRMSE, and NMAE).
Parameter MAE RMSE NMAE NRMSE
(%) (%)
WD 0.117 0.150 4.195 5.384
L/min L/min
SR 0.252 0.347 1.882 2.589
W/m2 W/m2
AT 0.087 0.119 2.998 4.106
Test data ◦ ◦
C C
WS 0.096 0.137 2.851 4.079
m/s m/s
FAC 0.003 0.004 2.764 3.444
W W
WD 0.097 0.120 3.914 4.863
L/min L/min
AT 0.169 0.186 3.061 3.373
◦C ◦C
Fig. 13. Daily distribution of power for different energy sources, and total energy
Considered day consumption using OFF-EWHM Strategy.
FAC 0.002 0.003 2.515 3.169
W W
PV 17.77 22.19 2.859 3.571
W W highlights the contribution of each energy source to overall consump-
tion. It is shows that the total demand over the course of a day is
covered by the utility and the photovoltaic generator.
7.3.1. First layer: OFF-EWHM strategy outcome Fig. 14 shows the EWH power distribution in the case of a offline
optimization, as well as the offline water temperature distribution in
The OFF-EWHM strategy manages EWH energy over the coming
comparison with the offline water temperature setpoint generator. This
day, using predicted input data to minimize energy bills and discomfort figure illustrate that the water temperature is very close to the water
costs. This approach allows us to fully exploit the global exploration temperature setpoints.
capabilities of the PSO algorithm. Fig. 13 illustrates the daily distribu-
tion of energy generated by two energy sources, as well as total energy 7.3.2. Second layer: On-line optimization
consumption, including photovoltaic energy, grid energy, EWH energy Unexpected occupant behavior and weather fluctuations lead to
and consumption by fixed appliances. This graphical representation significant forecast inaccuracy. It therefore becomes imperative to meet

16
S. El Bakali et al. Energy Conversion and Management 304 (2024) 118190

Fig. 14. Distribution of water temperature, desired temperature and EWH power, in
the case of OFF-EWHM strategy.

Fig. 16. TL-EWHM Proposed strategy for real-time adaptation of the EWH power
setpoint in response to the offline optimization layer.

new optimum. The ES process is dynamic, with transitional and stable


periods. This process allows the EWH power setpoints to be adapted
in real time to changing conditions. The proposed strategy ensures
dynamic EWH energy management, taking into account real-time data
and variations in energy demand and availability.
With the integration of the online stage (second stage), the manage-
ment strategy is even more robust. The online stage dynamically adjusts
power distribution to take account of forecast uncertainties. This con-
stant ability to adapt makes the management strategy highly resilient,
enabling it to respond proactively to unforeseen events introduced by
forecast uncertainties.
Fig. 15. Measured and predicted daily input data under forecasting uncertainties on
December 17, 2019. Table 11 quantifies the update provided by the online phase when
various disturbances occur. It shows the results of a sensitivity analysis
evaluating the system response to these disturbances. The magnitudes
real-time requirements in order to adjust EWH power setpoints in of disturbances for water demand, photovoltaic power, ambient tem-
real time on the basis of actual measurements. This approach enables perature and fixed appliance consumption are shown, together with the
dynamic adaptation to actual conditions. corresponding relative variations (𝛥𝑃 ) . The results reveal significant
To demonstrate the robustness of the TL-EWHM strategy under fore- system sensitivity, with variations of up to 100% in response to changes
casting uncertainties, an unexpected situation is presented in which the in water demand. These data offer crucial insight into the system’s
forecasting system does not perform optimally on the considered day. behavior in the presence of specific disturbances, highlighting its ability
Consequently, uncertainty errors are introduced into the operational to adapt to variable-related disturbances.
data. Consequently, the inputs data affected by this unexpected situa- This reactivity is expressed by the following formula:
tion, including water demand and fixed loads, are shown in Fig. 15. |𝑃EWH-OFF − 𝑃EWH-ON | × 100
It shows that water demand and fixed loads are both underestimated 𝛥𝑃 (%) = | | (33)
𝑃EWH-ON
and overestimated over the course of the day. The water demand has
an MAE of 2.625 L/min, an NMAE of 9.6%, an RMSE of 12.55 L/min, Where, 𝑃𝐸𝑊 𝐻−𝑂𝐹 𝐹 : represents the result provided by the first stage
while an NRMSE of 45.91%. The fixed appliances consumption has an ignoring disturbances, and 𝑃𝐸𝑊 𝐻−𝑂𝑁 is the result of the update per-
MAE of 311.51 W, an NMAE of 10.19%, an RMSE of 556.36 W, and an formed by the second stage.
NRMSE of 18.21%. These under- and overestimates can have negative This metric (𝛥𝑃 ) makes it possible to assess the sensitivity of the
consequences, including unexpected energy shortages and high energy management strategy to disturbances, thus providing insights into the
bills. The proposed strategy aims to reduce these negative effects. effectiveness of the online stage in adapting to unforeseen changes
In this context, the ES technique is used to solve EWH energy introduced by these disturbances. The numerical results in the table
management problems in real time. quantitatively reflect the ability of the online stage to react and improve
Fig. 16 provides a visual representation of the ES algorithm opti- overall system performance in the presence of disturbances.
mization process. It shows that every 5 min, the real-time optimization Where, Amplitude: Indicates the magnitude of the perturbation for
algorithm is initialized with the OFF-OL setpoint EWH to reach a each input data.

17
S. El Bakali et al. Energy Conversion and Management 304 (2024) 118190

Table 11 Table 12
Sensitivity analysis of system response to perturbations. Perturbations applied to operating data.
Nature of disturbance Disturbance amplitude (%) 𝛥𝑃 (%) Forecast errors NMAE (%) NRMSE (%)
Water demand 100 100 Water demand 9.6 45.91
PV power 25 06.28 PV Power 2.859 3.571
Ambient temperature 33 12.66 Ambient Temperature 3.061 3.373
Fixed appliances consumption 65 35.66 Fixed Appliances Consumption 10.19 18.21

Table 13
CO2 emissions associated with different hot water management strategies.
OFF-line OFF-line ON-line ON-line
& & & &
constant WTS variable WTS constant WTS variable WTS
𝐸𝐶𝑂2 (kg) 1684 1305 1362 1148

7.3.3. Model validation and robustness


The management strategy proposed in this paper is structured in
Fig. 17. Daily power distribution for energy sources (PV, EG) and total energy two distinct phases. The first phase is based on the results of the
consumption using the TL-EWHM strategy. forecasts, while the predominant role of the second phase lies in
improving the robustness of the management by taking into account
the disturbances generated by forecast errors. To assess the robust-
ness of the algorithm, various disturbances were deliberately intro-
duced during the simulations. Forecast inaccuracies related to wa-
ter demand, photovoltaic production, ambient temperature and fixed
appliance consumption were deliberately incorporated, as shown in
Table 12.
Simulation results show that the TL-EWHM strategy is remarkably
robust in the face of all these disturbances. Indeed, occupant comfort
levels were maintained even in the presence of these disturbances.

7.4. Environmental impact assessment of hot water management strategies


Fig. 18. Distribution of water temperature, desired temperature and EWH power, in
the case of the proposed TL−EWHM Strategy. This section focuses on the evaluation of the environmental impact
of distinct strategies employed for hot water management. The primary
metric used to gauge the strategies’ environmental performance is the
𝛥𝑃 (%): Represents the percentage change of EWH power in the carbon dioxide (CO2) emissions associated with electricity consump-
system’s response caused by the introduced perturbation. tion. The Table 13 provides a comparative overview of the estimated
Fig. 17 shows a daily distribution of power for PV power, electrical CO2 emissions for each strategy.
grid, EWH power, and total energy consumption, in the case of the The carbon footprint varies across the strategies, demonstrating the
proposed TL-EWHM strategy. The power balance make it possible to significance of the chosen management approach. The ‘‘OFF-line &
compare how this excess energy is managed and used according to constant WTS’’ strategy, characterized by constant water temperature
cost and comfort priorities, providing valuable information for en- setpoints and offline optimization, results in the highest estimated
ergy management decisions. On the other hand, the proposed strategy CO2 emissions, reaching 1.684 kg per unit of electricity consumed.
demonstrate the ability to effectively balance energy demand with In contrast, the ‘‘ON-line & variable WTS’’ strategy, which integrates
available supply. This observation indicates that the proposed strategy online optimization and variable water temperature setpoints, exhibits
succeed in satisfactorily balancing energy demand with available pro- the lowest carbon emissions, with an estimated 1.148 kg of CO2 per
duction, which is fundamental to ensuring a stable and reliable energy unit of electricity consumed.
supply. This table underscores the role of hot water management strategies
Fig. 18 shows the EWH power distribution in the case of a TL-EWHM in influencing environmental sustainability. Strategies that incorporate
strategy, as well as the water temperature distribution in comparison real-time optimization and variable setpoints demonstrate a notable
with the water temperature setpoint generator. Fig. 18 illustrates the reduction in CO2 emissions, aligning with broader goals of energy
close alignment between the water temperature and the setpoints gen- efficiency and reduced environmental impact.
erator. This alignment is also evident when comparing it to predefined 7.5. Comparative study
conditions and temperature thresholds discussed earlier. Such consis-
tency underscores the efficacy of our proposed strategy in maintaining In this section, two advantages of our proposed strategy are high-
the water temperature within the specified range and acceptable limits. lighted. Firstly, the advantage of real-time optimization is explored, an
This precision in control ensures an environment that meets thermal approach that takes into account imprecisions in the estimated values.
requirements and performance criteria. Traditionally, water heating These imprecisions are frequently encountered in real-life scenarios
temperatures range between 36.4 ◦ C and 43 ◦ C [10], highlighting due to uncertainties or variations inherent in energy production or
the challenges of energy waste when unnecessarily heating water to consumption. This approach will enable domestic hot water production
higher temperatures. Additionally, during the day, it is crucial for to be dynamically adjusted in response to fluctuations in real-life
the water temperature to reach 60 ◦ C to 75 ◦ C to eliminate bacteria. conditions. Secondly, the benefits of varying the water temperature set-
Consequently, our strategy prioritizes adapting water heating to actual point according to operating conditions is analyzed. Real-time setpoint
demand, with a key goal of significantly reducing energy waste and variation minimizes operating costs by aligning energy production with
ensuring sanitary safety by avoiding unnecessary water heating and actual requirements. This reduces unnecessary energy consumption
meeting required temperature levels. and, consequently, the associated costs.

18
S. El Bakali et al. Energy Conversion and Management 304 (2024) 118190

Fig. 19. Comparison of daily temperature distribution obtained using the proposed Fig. 21. Daily distribution of power for different energy sources, and total energy
TL-EWHM strategy and an offline optimization. consumption using TL-WTSC Strategy.

Fig. 22. Distribution of water temperature, desired temperature and EWH power, in
Fig. 20. Comparison of daily energy bill obtained using the proposed TL-EWHM the case of TL−EWH−WTSC Strategy.
strategy and an offline optimization.

7.5.1. Benefits of integrating second-layer optimization


In this subsection, a comparative study of real-time and offline
optimization results is undertaken. In the offline phase, real-time data
are used, but the power of the offline EWH is used to assess the
impact of estimation errors. In the online phase, on the other hand,
both real data and online EWH power are used. The main objective
of this study is to evaluate and compare the effectiveness of online
and offline optimization approaches, focusing on their ability to handle
the uncertainties inherent in real-time data. This is intended to enrich
our understanding of the practical implications of estimation errors Fig. 23. Daily energy bill obtained using proposed TL-EWHM and TL-WTSC strategy.

on the optimization process. Fig. 19 shows the comparison between


online water temperature, based on actual data, and offline water
temperature, calculated from offline EWH power and online operating overview of power variations throughout the day. The analysis is part
data. Examination of the on-line water temperature curve reveals a of the TL-WTSC strategy, specifically designed for the simultaneous
good match with the desired on-line temperature. In contrast, the optimization of costs and comfort. The observed power distribution
offline water temperature curve does not follow this desired trajectory. shows how each energy source contributes to meeting energy needs.
This disparity is explained by the absence of corrections in the case of Fig. 22 shows the water temperature profile in relation to a fixed
offline water temperature, which does not take into account forecast target temperature of 40 ◦ C. From this illustration, we can see that
uncertainties, especially when they are present in the EWH system. the water temperature remains relatively close to the target value of
This underlines the importance of real-time optimization and dynamic 40 ◦ C throughout the day. As a result, the water temperature fails to
power adjustment of the EWH to ensure accurate temperature control. reach the critical threshold of 60 ◦ C required for effective elimination
Fig. 20 illustrates the daily total energy bill over 24 h obtained using of bacteria from the water. Maintaining a water temperature well below
this critical value risks compromising the quality of the hot water
the proposed TL-EWHM and an OFF-EWHM strategies.
produced. What is more, maintaining a constant water temperature of
around 40 ◦ C, even when there is no demand for hot water, leads to a
7.5.2. Benefits of variable water temperature setpoints as a function of
significant waste of energy. Indeed, when there is no real demand and
operating conditions
water is heated to high temperatures, this represents an unnecessary
In this section, the proposed TL-EWH strategy, based on the use of use of energy, likely to result in higher energy costs. Fig. 23 shows
a variable setpoint temperature, are compared with another two-stage the energy bills resulting from the proposed TL-EWHM and TL-WTSC
strategy, which is limited to the application of a fixed setpoint temper- strategies. It is clearly visible that the TL-WTSC strategy generates the
ature. The aim is to evaluate the performance of these two approaches highest energy bill, reaching 3847.8 cents. However, the TL-EWHM
in terms of water temperature setpoint control. The proposed strategy approach stands out as the most advantageous, with a lower energy
is based on an adaptable setpoint temperature, meaning that it can bill of 3243.4 cents.
be changed according to operational conditions in real time. Fig. 21 The two-stage strategy, based on fixed water temperature setpoints,
provides an analysis of the daily distribution of power, highlighting offers a relatively simple management approach, eliminating the need
the contribution of various key energy sources. Four main components to continually adjust domestic hot water production in response to
are examined: PV power, grid-generated power, EWH power, and total fluctuations in demand and operational data. Nevertheless, this simplic-
energy consumption. This visual representation provides a detailed ity is accompanied by some notable drawbacks. Maintaining constant

19
S. El Bakali et al. Energy Conversion and Management 304 (2024) 118190

Table 14 remarkable improvement of 63.09%. This significant reduction in user


Cost analysis of water heating management strategies: OFF-line & Constant WTS,
discomfort places it at the top of the various approaches considered.
OFF-line & Variable WTS, ON-line & Constant WTS, and ON-line & Variable WTS.
On the environmental front, this strategy makes a significant contri-
Electricity bill (Cents) User discomfort (◦ C) GOF
bution to the reduction of carbon emissions, showing a substantial
OFF-line & constant WTS 4758,021 6.958 957.171
31.83% reduction compared to the benchmark strategy. This robust
OFFl-line & variable WTS 3689,018 3.547 740.641
ON-line & constant WTS 3847,793 4.202 772.920
environmental performance is consistent with overall sustainability
ON-line & variable WTS 3243,429 2.568 650.740 efforts. In conclusion, the ‘‘ON-line & variable WTS’’ strategy emerges
as the optimal solution, combining financial benefits, increased user
comfort and a reduced carbon footprint. These results underline the
Table 15
Benefits of the proposed strategy in comparison to other strategies.
effectiveness and relevance of this approach in the context of hot water
ON-line & variable WTS
management.
Electricity Bill −46,69%
OFF-line & constant WTS User Incomfort −63,09%
7.6. Experimental bench prototype
Carbon Emission −31,83%
Electricity Bill −13,74% A prototype experimental test bench is currently being developed
OFF-line & variable WTS User Incomfort −27,6% to experimentally validate the performance of various hot water man-
Carbon Emission −12,03% agement strategies. This test bed will be an essential tool for assessing
Electricity Bill −18,63% the efficiency, reliability and robustness of different management ap-
ON-line & constant WTS User Incomfort −38,88% proaches under real-life conditions. The Fig. 24 provides a visual
Carbon Emission −15,71% representation of the overall structure of this prototype.
The smart microgrid consists of a PV system composed of six rigid
panels and six flexible panels with a total power of 2000 W. Regarding
setpoint temperatures entails the risk of wasting energy. Indeed, heat- electrical loads, a Load Emulator (LE) is developed to generate random
ing water to high temperatures without reasonable necessity leads to energy consumption profiles, as well as a 50-liter electronic water
overconsumption of energy, which can translate into higher energy heater. The LE is developed based on 10 lamps, switchable relay cards,
costs. and an ESP8266 card, allowing it to consume a maximum power of
Table 14 summarizes the comparison of four distinct strategies in 1 kW. In addition, an inverter is installed to generate AC voltages and
terms of electrical cost, user discomfort level and overall objective func- currents from a DC PV system. A smart meter is installed to measure
tion. The different approaches evaluated are distinguished by whether the energy supplied/demanded by the EPG. The dimmer to modify
they are managed online (takes into account forecast uncertainties) or the water heating power. The scaled-down building also includes a
offline (is limited to forecasting results, does not take forecasting uncer- weather station that collects weather data and other sensors that mea-
tainties into account), and by whether they use a constant or variable sure quantity of liquid, cold and warm temperatures. This data is then
water temperature setpoint. Analysis reveals significant trends. The ON- transmitted to a data logger in real-time for viewing and evaluation
line & variable WTS strategy stands out, with the lowest electrical cost by a monitoring station. The management algorithm will be run on a
at 3243.4293 Cents, a marked reduction in user discomfort at 2568, and DSP1104 board programmed in Matlab (see Fig. 24).
an optimized overall target function at 650,740. Conversely, the OFF-
line & constant WTS strategy has the highest electrical cost at 4758,021 8. Conclusion
Cents, a higher level of user discomfort at 6958, and a less favorable
global objective function at 957,171. These results suggest that the This paper focuses on the development of a two-layer EWH system.
ON-line approach with a variable setpoint temperature performs best, The EWH system consists of two distinct layers, each with a specific role
minimizing both electrical costs and user discomfort while optimizing in hot water management. The first layer, which we call the OFF-OL, is
the global objective function (GOF). based on the concept of model-based predictive control. In this layer,
A significant reduction in energy bills is observed by adopting the we exploit an optimization algorithm called PSO. We rely on forecasts
TL-EWHM strategy, with a 13.73% reduction in the case of online of hot water demand, photovoltaic generation, ambient temperature
optimization (real-time optimization gain). An equally significant re- and fixed-load consumption using the proposed forecasting algorithm,
duction in energy bills is observed, reaching 18.63% in the case of based on real data collected during the study. The results demonstrate
the water temperature setpoint generator. These results convincingly the significant ability of the proposed forecasting algorithm to predict
demonstrate the benefits of online optimization and the positive impact these parameters. This layer aims to anticipate these parameters and
of the water temperature setpoint generator. The proposed TL-EWHM proactively adjust heating accordingly. The second layer, which we call
strategy differs significantly from traditional approaches by combining the ON-OL, is specifically designed to operate in real time. It relies
the two optimization layers with precise adjustment of water tempera- on an ES to respond instantaneously to variations in these factors,
ture setpoints. This approach gives it an effective ability to manage the taking into account real-time data. This means that this layer is able
uncertainties inherent in forecasting, while achieving optimal overall to dynamically adjust hot water heating to meet real-time needs while
solutions. As a result, it reduces energy costs while maintaining an minimizing energy waste. One of the most important attributes of our
adequate level of comfort for the user. This strategy optimizes the system is its ability to manage the uncertainty inherent in the forecasts
energy bill while fully respecting the given constraints, guaranteeing of WD, PV production, AT, and FAC. By combining these two layers
a balance between energy efficiency and optimum user comfort. in a coordinated manner, our system is able to efficiently adjust to
The Table 15 provides a detailed view of the benefits of the ‘‘ON-line unexpected variations in these parameters, while making optimal use
& variable WTS’’ strategy compared with other hot water management of forecast data when available. In addition, the development of an
approaches. By analyzing the three main indicators – electricity bill, equation for the water temperature setpoints generator as a function of
user comfort and carbon emissions – significant trends emerge. Firstly, modifiable data such as PV production and total energy consumption
in financial terms, this strategy stands out for a significant 46.69% based on the water demand profile, while satisfying user comfort.
reduction in electricity bills compared with the reference strategy ‘‘OFF- In addition, a comparative analysis is carried out between the pro-
line & constant WTS’’. This increased efficiency also extends to the posed approach using a variable reference temperature and two-layer
other strategies, underlining its energy-saving potential. In terms of optimization and conventional approaches using a predictive control
user comfort, the ‘‘ON-line & variable WTS’’ strategy stands out with a model or keeping the reference temperature constant throughout the

20
S. El Bakali et al. Energy Conversion and Management 304 (2024) 118190

Fig. 24. Implementation of the Proposed Management Strategy.

day exclusively. The results underline the effectiveness of the proposed Data availability
approach, which significantly reduces the daily energy bills, while satis-
fying user comfort and ensuring compliance with all system constraints. The dataset used in this paper are divided into two distinct cat-
The results highlight the effectiveness of the proposed approach in egories according to their source. The first category comprises re-
achieving a significant reduction in energy bills, which are cut by lated meteorological data extracted from the NSRDB, accessible via
13.73% in the case of online optimization. Equally remarkable is the the following link: https://nsrdb.nrel.gov/. The second category of
substantial reduction in energy bills, reaching 18.63% in the case of data concerns the water demand and energy consumption of fixed-load
variation of the water temperature setpoints. These results convincingly appliances, sourced from the LoadProfileGenerator, accessible via the
demonstrate the benefits of online optimization and the positive impact following link: https://www.loadprofilegenerator.de/.
of adjusting the water temperature setpoints.
As part of our future prospects, an energy storage system is planned Acknowledgments
to be implemented in order to provide a targeted response to night-time
energy demand. This work was supported by the Ministry of Higher Education,
Scientific Research and Innovation, Morocco, the Digital Development
Agency (DDA), Morocco and the CNRST of Morocco (Alkhawarizmi/
CRediT authorship contribution statement 2020/39).

Saida El Bakali: Writing – original draft, Software, Methodology, References


Investigation, Conceptualization. Hamid Ouadi: Writing – review &
[1] Shahinzadeh H, Moradi J, Gharehpetian GB, Abedi M, Hosseinian SH. Multi-
editing, Supervision, Resources, Conceptualization. Saad Gheouany:
objective scheduling of CHP-based microgrids with cooperation of thermal
Software, Methodology. and electrical storage units in restructured environment. In: 2018 smart grid
conference. 2018, p. 1–10. http://dx.doi.org/10.1109/SGC.2018.8777885.
[2] Zanjani S, Shahinzadeh H, Oskui AB, Yaïci W, Longo M, Zanjani SM. Performance
Declaration of competing interest assessment of heat pump and solar thermal heating with seasonal storage
systems for smart microgrid research center building at IAUN. In: 2022 10th
international conference on smart grid. 2022, p. 345–50. http://dx.doi.org/10.
1109/icSmartGrid55722.2022.9848623.
The authors declare that they have no known competing finan-
[3] Yildiz B, Bilbao JI, Roberts M, Heslop S, Dore J, Bruce A, et al. Analysis of
cial interests or personal relationships that could have appeared to electricity consumption and thermal storage of domestic electric water heating
influence the work reported in this paper. systems to utilize excess PV generation. Energy 2021;235:121325.

21
S. El Bakali et al. Energy Conversion and Management 304 (2024) 118190

[4] Jrhilifa I, Ouadi H, Jilbab A. Q-learning-based optimization of smart [31] Kavya M, Mathew A, Shekar PR, Sarwesh P. Short term water demand forecast
home’s wireless sensors network lifetime. Int J Renew Energy Res -IJRER modelling using artificial intelligence for smart water management. Sustainable
2023;13:302–10. Cities Soc 2023;95:104610.
[5] Jrhilifa I, Ouadi H, Jilbab A. Smart home’s wireless sensor networks lifetime [32] Xenochristou M, Kapelan Z. An ensemble stacked model with bias correction for
optimizing using Q-learning. In: IECON 2021 – 47th annual conference of the improved water demand forecasting. Urban Water J 2020;17:212–23.
IEEE industrial electronics society. 2021, p. 1–6. http://dx.doi.org/10.1109/ [33] Wang R, Lu S, Feng W. A novel improved model for building energy consumption
IECON48115.2021.9589460. prediction based on model integration. Appl Energy 2020;262:114561.
[6] Mirhedayati A-s, Shahinzadeh H, Nafisi H, Gharehpetian GB, Benbouzid M, [34] Ariyur K, Krstić M. Real-time optimization by extremum-seeking control. John
Shaneh M. CHPs and EHPs effectiveness evaluation in a residential multi-carrier Wiley & Sons; 2003, http://dx.doi.org/10.1002/0471669784.fmatter.
energy hub. In: 2021 25th electrical power distribution conference. 2021, p. [35] El Bakali S, Hamid O, Gheouany S. Day-ahead seasonal solar radiation prediction,
42–7. http://dx.doi.org/10.1109/EPDC53015.2021.9610816. combining VMD and stack algorithms. Clean Energy 2023;7:911–25.
[7] Chen J, Qi B, Rong Z, Peng K, Zhao Y, Zhang X. Multi-energy coordinated mi- [36] El Bakali S, Ouadi H, Giri F, Gheouany S, El-Bakkouri J. Data-based solar
crogrid scheduling with integrated demand response for flexibility improvement. radiation forecasting with pre-processing using variational mode decomposition.
Energy 2021;217:0360–5442. In: 2023 9th international conference on control, decision and information
[8] Clift DH, Suehrcke H. Control optimization of PV powered electric storage and technologies. 2023, p. 2061–6. http://dx.doi.org/10.1109/CoDIT58514.2023.
heat pump water heaters. Sol Energy 2021;226:489–500. 10284151.
[9] Gaonwe T, Hohne P, Kusakana K. Optimal energy management of a solar- [37] Sengupta, et al. NSRDB: National solar radiation database. 2023, https://nsrdb.
assisted heat pump water heating system with a storage system. J Energy Storage nrel.gov. [Last accessed 01 October 2023].
2022;56:105885. [38] Noah Pflugradt. LoadProfileGenerator. 2023, https://www.loadprofilegenerator.
[10] Kapsalis V, Safouri G, Hadellis L. Cost/comfort-oriented optimization algorithm de. [Last accessed 06 September 2023].
for operation scheduling of electric water heaters under dynamic pricing. J Clean [39] Gnanadesikan R. Methods for statistical data analysis of multivariate observa-
Prod 2018;198:1053–65. tions. Wiley; 2011, URL https://books.google.co.ma/books?id=2h4oWPpMm2kC.
[11] Wang J, Liu J, Li C, Zhou Y, Wu J. Optimal scheduling of gas and electricity [40] K. A, J. M. Ensemble learning for AI developers. Apress Berkeley; 2020, http:
consumption in a smart home with a hybrid gas boiler and electric heating //dx.doi.org/10.1007/978-1-4842-5940-5.
system. Energy 2020;204:117951. [41] Flores JHF, Engel PM, Pinto RC. Autocorrelation and partial autocorrelation func-
[12] Quintã AF, Ehtiwesh I, Martins N, Ferreira JA. Gain scheduling model predictive tions to improve neural networks models on univariate time series forecasting.
controller design for tankless gas water heaters with time-varying delay. Appl In: The 2012 international joint conference on neural networks. 2012, p. 1–8.
Therm Eng 2022;213:118669. http://dx.doi.org/10.1109/IJCNN.2012.6252470.
[13] Tejero-Gómez JA, Bayod-Rújula AA. Energy management system design ori- [42] Jrhilifa I, Ouadi H, Jilbab A. Multi-horizon short-term load consumption fore-
ented for energy cost optimization in electric water heaters. Energy Build casting using deep learning models. In: International conference on advanced
2021;243:111012. intelligent systems for sustainable development. Springer Nature Switzerland;
[14] Maltais L-G, Gosselin L. Energy management of domestic hot water systems with 2023, p. 281–92.
model predictive control and demand forecast based on machine learning. Energy [43] Mounir N, Ouadi H, Jrhilifa I. Short-term electric load forecasting using an
Convers Manag X 2022;15:100254. EMD-BI-LSTM approach for smart grid energy management system. Energy Build
[15] Wu M, Bao Y-Q, Zhang J, Ji T. Multi-objective optimization for electric water 2023;288:113022.
heater using mixed integer linear programming. J Mod Power Syst Clean Energy [44] Gheouany S, Ouadi H, Giri F, El Bakali S. Experimental validation of multi-
2019;7:1256–66. stage optimal energy management for a smart microgrid system under forecasting
[16] Tahiri A, Smith KM, Thorsen JE, Hviid CA, Svendsen S. Staged control of uncertainties. Energy Convers Manage 2023;291:117309.
domestic hot water storage tanks to support district heating efficiency. Energy [45] El Bakali S, Ouadi H, Gheouany S. Solar radiation forecasting using artificial
2023;263:125493. intelligence techniques for energy management system. In: International con-
[17] Shen R, Zhong S, Wen X, An Q, Zheng R, Li Y, et al. Multi-agent deep ference on advanced intelligent systems for sustainable development. Springer
reinforcement learning optimization framework for building energy system with Nature Switzerland; 2023, p. 408–21.
renewable energy. Appl Energy 2022;312:118724. [46] Massaoudi M, Refaat SS, Chihi I, Trabelsi M, Oueslati FS, Abu-Rub H. A
[18] Hohne P, Kusakana K, Numbi B. Optimal energy management and economic novel stacked generalization ensemble-based hybrid LGBM-XGB-mlp model for
analysis of a grid-connected hybrid solar water heating system: A case of short-term load forecasting. Energy 2021;214:118874.
Bloemfontein, South Africa. Sustain Energy Technol Assess 2019;31:273–91. [47] Zaim S, El Ibrahimi M, Arbaoui A, Samaouali A, Tlemcani M, Barhdadi A. Using
[19] Shen G, Lee ZE, Amadeh A, Zhang KM. A data-driven electric water heater artificial intelligence for global solar radiation modeling from meteorological
scheduling and control system. Energy Build 2021;242:110924. variables. Renew Energy 2023;215:118904.
[20] Pied M, Anjos MF, Malhamé RP. A flexibility product for electric water heater [48] Hachchadi O, Tapsoba GR, Dery P, Mechaqrane A, Bourbonnais M, Meloche P,
aggregators on electricity markets. Appl Energy 2020;280:115168. et al. Experimental optimization of the heating element for a direct-coupled solar
[21] Clift DH, Stanley C, Hasan KN, Rosengarten G. Assessment of advanced demand photovoltaic water heater. Sol Energy 2023;264:112037.
response value streams for water heaters in renewable-rich electricity markets. [49] Chawki N, Rouchdi M, Alla M, Fares B. Simulation and analysis of high-
Energy 2023;267:126577. performance hole transport material SrZrS3-based perovskite solar cells with a
[22] Mugnini A, Ferracuti F, Lorenzetti M, Comodi G, Arteconi A. Day-ahead optimal theoretical efficiency approaching 26. Sol Energy 2023;262:111913.
scheduling of smart electric storage heaters: A real quantification of uncertainty [50] Mounir N, Ouadi H, Jrhilifa I. Short-term electric load forecasting using an
factors. Energy Rep 2023;9:2169–84. emd-bi-lstm approach for smart grid energy management system. Energy Build
[23] Engelbrecht J, Ritchie M, Booysen M. Optimal schedule and temperature control 2023;288:113022.
of stratified water heaters. Energy Sustain Dev 2021;62:67–81. [51] Mounir N, Ouadi H. Short-term electric load forecasting model based on SVR
[24] Najafi F, Fripp M. Stochastic optimization of comfort-centered model of electrical technique. In: International conference on advanced intelligent systems for
water heater using mixed integer linear programming. Sustain Energy Technol sustainable development. Springer Nature Switzerland; 2023, p. 331–42.
Assess 2020;42:100834. [52] Bounoua Z, Ouazzani Chahidi L, Mechaqrane A. Estimation of daily global solar
[25] Rochd A, Benazzouz A, Ait Abdelmoula I, Raihani A, Ghennioui A, Naimi Z, radiation using empirical and machine-learning methods: A case study of five
et al. Design and implementation of an AI-based & IoT-enabled home energy Moroccan locations. Sustain Mater Technol 2021;28:e00261.
management system: A case study in Benguerir — Morocco. Energy Rep [53] Li M-F, Tang X-P, Wu W, Liu H-B. General models for estimating daily global
2021;7:699–719. solar radiation for different solar radiation zones in mainland China. Energy
[26] Pardiñas ÁÁ, Durán Gómez P, Echevarría Camarero F, Carrasco Ortega P. Convers Manage 2013;70:0196–8904.
Demand–response control of electric storage water heaters based on dynamic [54] Gheouany S, Ouadi H, El Bakali S. Hybrid-integer algorithm for a multi-objective
electricity pricing and comfort optimization. Energies 2023;16:4104. optimal home energy management system. Clean Energy 2023;7:375–88.
[27] Cao S, Hou S, Yu L, Lu J. Predictive control based on occupant behavior [55] Guerrero J, Gebbran D, Mhanna S, Chapman AC, Verbič G. Towards a transactive
prediction for domestic hot water system using data mining algorithm. Energy energy system for integration of distributed energy resources: Home energy
Sci Eng 2019;7:1214–32. management, distributed optimal power flow, and peer-to-peer energy trading.
[28] Ali SMH, Lenzen M, Tyedmers E. Optimizing 100%-renewable grids through Renew Sustain Energy Rev 2020;132. 1364–0321.
shifting residential water-heater load. Int J Energy Res 2019;43:1479–93. [56] Mirhedayati A-s, Hadadi Z, Zanjani S-M, Shahinzadeh H, Bayindir R, Shaneh M,
[29] Meinrenken CJ, Mehmani A. Concurrent optimization of thermal and electric et al. Optimal operation of combined heat and power in competitive electricity
storage in commercial buildings to reduce operating cost and demand peaks markets: a case study in IAUN. Int J Renew Energy Res -IJRER 2021;11:1013–22.
under time-of-use tariffs. Appl Energy 2019;254:113630. [57] Gheouany S, Ouadi H, El Bakali S. Energy demand management in a residential
[30] Pesantez JE, Berglund EZ, Kaza N. Smart meters data for modeling building using multi-objective optimization algorithms. In: International con-
and forecasting water demand at the user-level. Environ Model Softw ference on advanced intelligent systems for sustainable development. Springer
2020;125:104633. Nature Switzerland; 2023, p. 368–77.

22
S. El Bakali et al. Energy Conversion and Management 304 (2024) 118190

[58] Rafia H, Ouadi H, Elbhiri B. Induction motor current control with torque ripples [63] Li Y, Tong Z. Development of real-time adaptive model-free extremum seek-
optimization combining a neural predictive current and particle swarm opti- ing control for CFD-simulated thermal environment. Sustainable Cities Soc
mization. In: 9th international conference on control, decision and information 2021;74:2210–6707.
technologies. IEEE; 2023, p. 2067–72. http://dx.doi.org/10.1109/CODIT58514. [64] Mu B, Li Y, House JM, Salsbury TI. Real-time optimization of a chilled water
2023.10284469. plant with parallel chillers based on extremum seeking control. Appl Energy
[59] Chen X, Liao Z, Gao Z, Li Q, Lv P, Zheng G, et al. A calculation model of carbon 2017;208:766–81.
emissions based on multi-scenario simulation analysis of electricity consumption. [65] Kebir A, Woodward L, Akhrif O. Real-time optimization of renewable en-
Sustainability 2022;14:8765.
ergy sources power using neural network-based anticipative extremum-seeking
[60] Real time live emissions from energy production by country. 2024, https://www.
control. Renew Energy 2019;134:914–26.
nowtricity.com. [Last accessed 15 January 2024].
[66] Alden RE, Gong H, Rooney T, Branecky B, Ionel DM. Electric water heater
[61] El-bakkouri J, Ouadi H, Giri F, Khafallah M, Gheouany S, Bakali SE. Extremum
modeling for large-scale distribution power systems studies with energy storage
seeking based braking torque distribution for electric vehicles’ hybrid anti-lock
braking system. IFAC-PapersOnLine 2023;56:2546–51. CTA-2045 based VPP and CVR. Energies 2023;16:4747.
[62] Gheouany S, Ouadi H, Berrahal C, bakali SE, bakkouri JE, Giri F. Multi-stage en- [67] Abbas AO, Chowdhury BH. A stochastic optimization framework for realizing
ergy management system based on stochastic optimization and extremum-seeking combined value streams from customer-side resources. IEEE Trans Smart Grid
adaptation. IFAC-PapersOnLine 2023;56:5457–62. 2022;13:1139–50.

23

You might also like