2.1. Rule-Based Control
Figure 1 represents the adaptive MG structure controlled in this paper. The MG is composed of PV, grid (GR), ESS, load (LD), electrolyzer (EL), and fuel cell (FC). The ESS is composed of a battery (BAT), fuel tank (FT), and water tank (WT). The MG’s ESS reduces peak demand from a cluster of loads in the distribution network [
46].
stands for the total demand of these loads, while
represents the power obtained from the upstream network, constrained by the network operator’s set boundaries (
). The symbols
and
denote the efficiency of the ESS during the charging and discharging phases, respectively.
C represents the nominal capacity of the ESS, expressed in kWh.
denotes the power exchanged with the network during the current operational time. A positive value of
indicates the charging state, while a negative value indicates the discharging state. The State of Charge (
) during the current operational period (
k) is determined by the energy exchanged through the ESS and its value from the previous period (
k-1).
The rule-based EMS controls the ESS, which uses the measured values of
and
to establish the proper set-point for power exchange.
Figure 2’s flow chart shows this EMS, emphasising the importance of
as a critical parameter for sending control commands. Utilising the following relationships, the
of the ESS during the current operational period (
k) is determined by the energy exchanged through the ESS. It is calculated using the following equations:
The illustrated EMS has an hourly control horizon and weekly operational periods (k), which need the EMS to take the necessary control actions. By maintaining a 50% at the end of the control horizon, the ESS will have enough energy reserves to provide peak reduction in the following days. It is considered that the distribution network’s chosen location for peak reduction services, with a ranging from 20% to 100%, has an ESS that is optimally sized to support it. The purpose of setting the bottom boundary of the is to guarantee the ESS runs smoothly. In order to ensure effective operation and peak demand mitigation, the rule-based EMS uses measured values of and to calculate the optimal power exchange set-point for the ESS.
Furthermore, since the main goal is to determine the best imputation technique for missing data within the ESS, it is assumed that there are no missing values in .
The control decisions of the adaptive MG are defined to find the optimum system control, state, and output vectors for the rule-based control.
Define the adaptive MG’s system-state, control, and output vectors with the help of Equation (
1):
where
is the state of charge for the ESS.
The system-control (input) vector of the adaptive MG is defined as follows:
where
,
, and
are the power flow from PV to the LD, GR, and ESS, respectively.
is the power flow from the ESS to the LD. In this case, the ESS is in discharge mode.
The system-output vector of the adaptive MG is as follows:
where
is the power import from the GR for the LD and
is the power flow from the ESS to the GR.
Define the objective functions for the rule-based control on the adaptive MG:
The power imported from the utility grid is minimized.
The usage of the ESS is penalized to prevent the charging from the utility grid.
The exported energy to the utility grid is encouraged.
By merging Equations (
5)–(
7), the overall cost function (objective function) for the adaptive MG:
Define the constraints for the adaptive MG as follows:
Power flows from the PV, GR, and ESS are non-negative values and are subject to their maximum values.
The sum of the PV energy supplied directly for the LD
, the ESS for the charging
, and the energy exported to the GR
should be smaller than the energy flow from the PV array,
.
Also, the sum of the LD from the PV and ESS should equal the building’s load demand.
The
for the ESS is restricted between its minimum and maximum values.
Charging and discharging for the ESS cannot happen simultaneously, as is implied by the following:
It is worth noting that Equations (
9)–(
12) are convex, whereas Equation (
13) is non-convex. In order to accomplish convex optimization in rule-based control design, the non-convex constraints into two switched cases: (i) charging: (
and
) and (ii) discharging: (
.
-
Charging: The constraint can be re-written by:
Constraints (
9)–(
11), and (
14) can be compactly re-written by:
where
where
is an identity matrix, and
is creating an array of all zeros.
-
Discharging: The constraint can be re-written by:
Constraints (
9)–(
11) and (
16) can be compactly re-written by:
where
2.2. General Formulations of Deep Learning Techniques
Deep learning models are crucial for improving the control system’s intelligence and adaptability. These models capture intricate patterns and correlations by using the benefits of the temporal dependencies included in the data, allowing for real-time, updated control decisions. The hybrid control system includes integrations with the subsequent deep learning architectures:
2.2.1. Long Short Term Memory
LSTM networks are a form of RNN architecture that addresses the vanishing gradient problem and captures long-range dependencies in sequential input. LSTMs have specialised memory cells and gating mechanisms that allow them to retain and update information selectively across several steps.
The LSTM computation for each time step (
k) is defined as:
where
is the input,
is the hidden state, and
is the cell state. The cell state serves as a long-term memory component, storing information across time, whilst the hidden state catches and transports short-term dependencies.
The LSTM architecture has three main gates: the input gate (), the forget gate (), and the output gate (. These gates control the flow of information into, out of, and within the LSTM cell, allowing it to filter out irrelevant facts while retaining useful information. Furthermore, LSTM cells have an internal memory cell () that allows them to store and update data with time.
LSTM networks excel at capturing long-range dependencies, making them appropriate for tasks involving sequential data and complex temporal dynamics. In a hybrid control system, LSTM models are critical for learning and anticipating the temporal behaviour of the MG system. LSTM-based control strategies improve the adaptability and performance of the hybrid control system by efficiently capturing and utilising temporal relationships, resulting in increased efficiency and stability during MG operation.
2.2.2. Gated Recurrent Unit
GRU networks are a type of RNN architecture that looks like LSTM but has a simpler topology. GRUs are intended to capture long-term dependencies in sequential data while remaining computationally more efficient than LSTMs.
At each time step (
k), the GRU computation is described as follows:
Unlike LSTM cells, GRU cells lack discrete memory cells and instead use a single concealed state to record both short-term and long-term reliance.
The GRU architecture consists of two primary gates: the reset gate () and the update gate (. These gates, which regulate information flow within the GRU cell, allow the hidden state to be selectively updated based on the input and previous hidden states. The update gate determines how much of the new data should be absorbed, whereas the reset gate specifies how much of the old disguised state should be forgotten.
GRU networks achieve a balance between model complexity and performance, thereby being appropriate for tasks involving sequential data of intermediate complexity. In the context of a hybrid control system, GRU-based models provide an efficient and effective way to capture temporal dependencies and make sound control decisions. By exploiting GRU network capabilities, the hybrid control system improves adaptability and performance, increasing efficiency and stability in MG operation.
2.4. Dataset Preprocessing
Within this phase, we consider how to prepare the data for RNN-based deep networks since the data contains the hourly power recirculation of adaptive MG systems in a year. The dataset includes 13 attributes. To better represent the data in the RNN-based models we have designed, we grouped them, as illustrated in
Table 1.
Accumulated: The column is the total need of the smart building; hence, the sum of the columns , , and fulfils it. The photovoltaic energy source distributes the power to the columns , , and .
Additional elements: The power needs in these columns are at negligible levels since , , , and require a small amount of power for ignition.
Main elements: Since the presented smart building system mainly circulates power within LD, PV, GR, and BAT, the corresponding columns are considered the main elements.
As a result of the aforementioned details and correlation analysis (
Figure 3),
,
,
,
, and
are left to be used in RNN models. Moreover, the first RNN-based models were trained using the different data portions to see the real-time effects of eliminated columns. Because these experiments resulted in negative
values, it is considered that the column elimination process is cross-checked.
Several notable correlations are observed within the dataset in
Figure 3. For instance, there is a strong positive correlation between power supplied by photovoltaic (PV) systems and the actual PV power generated (
), as expected. Additionally, the power consumed from the grid (
) exhibits a significant positive correlation with power consumption (
), indicating that grid power is a substantial contributor to the overall power consumption in the building.
Interestingly, there are negative correlations between certain attributes, such as between battery power consumption () and power consumption from fuel cells (). This suggests that when one power source is utilized more, the other may be utilized less, indicating a potential trade-off or balancing act in power usage within the building.
Figure 4 depicts a comprehensive picture of power dynamics within the smart building, highlighting various properties across different time intervals. Several major observations arise from extensive research and are backed by particular numerical results:
Significant changes in power qualities are found during different time periods. For example, on May 31, 2017, total power usage was 316.75 kWh, with PV generation accounting for 83.65 kWh, power from PV to the grid () (44.65), and electricity from PV to local distribution () (49.90 kWh). In contrast, on March 31, 2018, overall power consumption increased to 635.77 kWh, accompanied by changes in PV generation (192.31 kWh) and other power distribution components.
Seasonal variations are evident in the dataset, with distinct trends observed across different months. For example, during the summer months, such as June and July 2017, both power consumption and generation peaked, indicating higher energy demand and increased solar irradiance. Conversely, in winter months, such as December 2017, power consumption remained relatively stable, while PV generation decreased due to reduced daylight hours.
Figure 4 underscores the role of RESs in power generation. For instance, on April 30, 2018, the PV contributed significantly to overall power generation, with PV generation reaching 124.53 kWh and WT to EL (
) at 0.33 kWh. These assets are crucial in reducing dependency on conventional grid power and mitigating environmental impact.
ESSs, particularly batteries, facilitate efficient power management within the smart building. Notably, while certain power components such as , , , , , and are essential for energy transfer and system operation, their individual contributions to overall power consumption and generation are minimal. For instance, on May 31, 2017, , , , , , and collectively accounted for less than 1 kWh of power transfer.
In conclusion, the numerical results from the dataset provide valuable insights into the dynamics of power circulation within the smart building, emphasizing the importance of renewable energy integration, energy storage technologies, and efficient energy management practices. Further analysis and modelling based on this data can inform the development of sustainable and resilient smart building systems tailored to specific energy needs and environmental considerations.
2.5. Model and Hyperparameter Search
Deep learning networks’ shape (layers and neurons per layer) significantly impacts performance [
47]. We perform a search space for the most suitable solution for the obtained data. In order to prevent confusion from now on, we use the term RNN-based for all recurrent types of architectures. Since the possibility pool for experimental sets to be created with combinations of different parameters is infinite, we focused mainly on the effects of the types and number of RNN units, including the number of hidden states, optimizers, and learning rate schedulers.
2.5.1. RNN-Based Architectures:
We identify three different variants of RNN-based approaches: Simple RNN (sRNN), LSTM and GRU. The number of hidden states is restricted between 1 and 3. Initially, we started the experiments using the number of units in the hidden layers selected as multiples of the number of columns of the input data.
2.5.2. Optimizers:
The optimizer decides how the neural network weights are adjusted following each training iteration. This study concentrates on three widely employed optimizers:
SGD (Stochastic Gradient Descent): SGD is the primary optimizer employed in Deep Learning. Although Gradient Descent theoretically updates the weights after processing each training sample, it is common to optimise the weights after processing each batch of data.
RMSprop (Root Mean Squared Propagation): RMSprop improves the performance of stochastic gradient descent (SGD) by including fading average partial gradients to adapt the step size of each parameter. This optimizer prioritises recent gradients to a greater extent.
Adam (ADAptive Moment estimation) [48]: Adam, like RMSprop, allocates specific learning rates to each parameter. While RMSprop calculates the average of the first moment, Adam takes into account the average of the second moment as well when adjusting the learning rates.
2.5.3. Learning Rate Schedulers:
Learning rate schedules aim to modify the learning rate when training by reducing the rate per a predetermined schedule. In this study, we used 4 common approaches:
Constant: As the name implies, in this scheduler, the model does not change the rate of the learning rate during the training phase. We accept the default value as 0.001.
Time-Based Decay: This approach intends to reduce the learning over epochs as seen in Equation
18. While
and
k are hyperparameters, the current learning and decay rates,
t is the iteration number. As in the constant learning rate scheduler, we assign 0.001 as the initial learning rate. The decay rate is found by dividing the current learning rate by the current number of the epoch.
Step Decay: This learning rate schedule, where the number of epochs is a hyperparameter, reduces the learning rate by a factor every few epochs.
Exponential Decay: This schedule applies an exponential decay function to an optimizer step, based on a defined initial learning rate, as described in Equation
19.
2.6. Implementation Details
We use an 80-20 training test split. Further, the training data is split into training and validation sets of 80% and 20%, respectively. When we refer to ’batch size’ in the context of data analysis, it indicates the number of consecutive data points grouped together for processing. For instance, if we select a batch size of 7 for daily power consumption data, we organise the yearly dataset into segments of 7 consecutive days each. Each segment represents a week’s worth of data. This approach facilitates the computational learning process by enabling the models to discern patterns and trends occurring every week. Therefore, opting for a batch size of 7 assists in examining and understanding the weekly variations in power consumption.
We employ the Glorot uniform initializer [
49] to initialize the parameters within our networks. This initializer ensures that the weights are uniform across all layers regarding the variance of the activations, thereby preventing the gradient from either exploding or vanishing due to a consistent variance. After eliminating unnecessary columns, we obtained 5 columns, as mentioned earlier, and hence, the output dense layer has 6 neurons.
After the first attempts, we discovered that the high number of epochs did not perform satisfactorily; thus, we kept it constant at 20. In addition, the constant learning rate performed better among other candidates, such as Time-Based Decay, Step Decay, and Exponential Decay.
Finally, the activation function provides the non-linear element within the networks. Due to the nature of the case, the power consumption predictions in the output-dense layer should not produce negative values. To overcome this issue, we used ReLU. On the other hand, the activation functions of RNN-based layers were not interfered with.
Finally, the hidden state is defined to update the control decision of the proposed method. It is at time step k and depicts the adaptive MG system’s dynamics as learned by the RNN model. It encodes information about the MG system’s current state using past observations and inputs.
The hidden state,
, can be defined as follows:
The hidden state captures the current SOC of the ESS, providing information about the energy storage level and potentially other relevant variables affecting the MG system dynamics.
In LSTM networks, the cell state at time step k functions as a long-term memory component and complements the hidden state. It allows the model to capture long-range dependencies in the sequential data by storing and updating data over numerous time steps.
The cell state
in this situation can be described as follows:
The forward-passed features and represent the power flows from the GR to the LD and ESS to the GR. These features collect essential information about the MG system’s power consumption and storage dynamics, which helps the model predict future states and make control decisions.
In summary, the rule-based control logic serves as a basic control method, providing a framework for decision-making in the MG system. It can handle known scenarios and take prompt action based on specified rules. Deep learning models are used to supplement rule-based control by learning from data and delivering adaptive control actions in instances when rules may be insufficient or when the system confronts unexpected conditions. Deep learning models can detect complicated patterns and non-linear correlations in data and optimise control decisions. Then, a decision-making mechanism is created that dynamically switches between rule-based control and deep learning models based on the MG system’s current state, performance metrics, or other relevant variables. For instance, the system may use rule-based control under typical settings but switch to deep learning models when there is a lot of ambiguity or when dealing with new scenarios. Next, the integrated control strategy will be tested through simulation or real-world testing to confirm that it meets the MG system’s objectives and criteria. Following that, its performance will be evaluated in terms of stability, efficiency, dependability, and flexibility in various working environments. To improve the iterative process, regularly monitor and analyse the performance of the integrated control strategy while gathering feedback from the adaptive MG system. Use this feedback to improve overall system performance by refining rule-based control logic, fine-tuning deep learning models, or adjusting the decision-making mechanism. By integrating rule-based control and deep learning methods, we can use both approaches to provide a more resilient, adaptive, and economical control strategy for the adaptive MG system.