Keywords

1 Introduction

1.1 Background

Since the 21st century, the advancements in electronic communication technology have resolved most of the technical and economic limitations of the electric grid. This is the distinction between an electric grid and a smart grid. A smart grid is an electric grid that benefits from a communication infrastructure among its constituting units; i.e. smart meters, smart appliances and renewable energy resources [1]. Thus, finding the optimal energy dispatch of the generation units is a great matter of concern. Several studies have introduced different solution methodologies in this regard. It is a known fact that meteorological phenomena i.e. wind speed and solar irradiation have a sequential pattern. Historical analysis of other smart grid components such as electric load and market price show that they also have sequential behavior. Therefore, machine learning algorithms have turned into a popular choice for predicting the behaviour of the aforementioned units/ aspects of the smart grid. Figure 1 present the increasing trend in the popularity of addressing IoT-related security issues in smart grids.

Fig. 1.
figure 1

Related Literature Publications in the Last 10 Years

A smart IoT-based grid is subject to various security challenges such as impersonation, eavesdropping, data tampering, availability and denial of service issues, etc. [2]. Since IoT devices are vulnerable to cyber-attacks the main problem that needs to be addressed is: “what if the IoT devices’ data in the smart grid is hacked/ manipulated?” This justifies the existence of adversarial machine learning algorithms. If the manipulated data is not detected through a reliable and quick mechanism, the repercussions can inflict economic and technical cost to the smart grid. That is why addressing security issues in smart grids have been a popular topic in recent years. In [3] the authors used wide and deep convolutional neural networks to analyze the periodicity and non-periodicity in electrical energy consumption. The findings of this study have been used in anomaly detection (electricity theft) of a smart grid. In the study presented in [4] the availability of fine-grained time series data has been introduced as a game changer at the distribution systems level. This issue has prevented effective application of complex machine learning algorithms on grid operation. In this paper, the deep generative adversarial network (GAN) is introduced for learning the conditional probability distribution of real datasets. Article [5] presents adversarial machine learning, whereby models are fooled through malicious input, either for financial gain or to cause system disruption. This paper has presented simulation results that show the effect of adversarial machine learning on the operation of smart energy systems and has proposed directions for future research related to detection and defense mechanisms for such attacks. In [6] it is described that detecting False Data Injection (FDI) attacks by current bad data detection systems is impossible. Ergo, three various supervised learning techniques are presented, the accuracy of which are tested on the IEEE 14-bus, IEEE 57-bus and IEEE 118-bus test systems. The authors of [7] have proposed a new metric for the smart grid that is called the entropic state. This metric has two main purposes. First, it provides an indication of the grid’s health on cycle-to-cycle basis. Second, it can be used to detect FDI attacks. The idea of this paper comes from the mentality of addressing state estimation in smart grids and cognitive dynamic systems at the same time.

The aforementioned literature review along with other studies lead us to the conclusion that in regards to adversarial machine learning you can take two main approaches. (1) Designing a robust machine learning algorithm and (2) Detecting attacks and mitigating them. The latter provides us from benefiting current machine learning techniques and is the general approach that has been taken into account. In this study, a regressive model has been introduced to substitute the time-consuming and off-line optimization method that is widely used for energy management in smart grids. Afterwards, the output of this model is given to the OPF solver to gain the power loss and voltage diagram of the main network. The security of the proposed framework is guaranteed using the online discrepancy test (ODIT). The distinction of this method lies within the fact that it eliminates false data, thus avoiding adversarial machine learning while minimizing false alarms.

1.2 Contributions

The present study has major contributions in regards to optimized operation and the OPF of smart grids. The outline of the contributions can be mentioned as follows:

  • Presenting an online machine learning regressive method to find the optimized energy dispatch of a microgrid

  • Presenting a machine learning based method for addressing the OPF problem

  • Avoiding adversarial machine learning using the ODIT

The rest of the paper is organized as follows. In Sect. 2, the problem formulation is stated. Section 3 covers the solution framework implementation. Finally, the concluding remarks can be found in Sect. 4.

2 Problem Formulation

This section presents the operation cost minimization formulation and its associated constraints. The formulation is valid for a 24-h period and the proposed MG is consisted of a MT, a FC, two PVs, two WTs, a BAT and the main grid.

2.1 Cost Function

The cost function of the proposed MG is formulated as described in Eq. (1). Equations (1a1j) express the detailed value of each term in Eq. (1):

$$ \begin{array}{*{20}c} {F\left( X \right) = M(\mathop \sum \limits_{t = 1}^{T} {\text{Cos}}t) = \sum\limits_{t = 1}^{T} {\begin{array}{*{20}c} {(Cost_{Winds}^{t} + Cost_{PVs}^{t} + Cost_{FC}^{t} + } \\ {Cost_{MT}^{t} + Cost_{BAT}^{t} + Cost_{Grid}^{t} )} \\ \end{array} } } \\ { = M(\mathop \sum \limits_{t = 1}^{T} ([\mathop \sum \limits_{a = 1}^{{N_{WTs} }} P_{{WTs_{a} }}^{t} \times Bid_{{WTs_{a} }}^{t} \left] + \right[\mathop \sum \limits_{b = 1}^{{N_{PVs} }} P_{{PVs_{b} }}^{t} \times Bid_{{PVs_{b} }}^{t} ] + } \\ {[\mathop \sum \limits_{c = 1}^{{N_{FC} }} u_{c}^{t} \times P_{{FC_{c} }}^{t} \times Bid_{{FC_{c} }}^{t} + SU_{{FC_{c} }} \times u_{c}^{t} \times (1 - u_{c}^{t - 1} ) + SD_{{FC_{c} }} \times u_{c}^{t - 1} \times (1 - u_{c}^{t} )] + } \\ {[\mathop \sum \limits_{d = 1}^{{N_{MT} }} u_{d}^{t} \times P_{{MT_{d} }}^{t} \times Bid_{{MT_{d} }}^{t} + SU_{{MT_{d} }} \times u_{d}^{t} \times (1 - u_{d}^{t - 1} ) + SD_{{MT_{d} }} \times u_{d}^{t - 1} \times (1 - u_{d}^{t} )] + } \\ {[\mathop \sum \limits_{e = 1}^{{N_{Bat} }} Max(u_{e}^{t} ,0) \times P_{{BAT_{e} }}^{t} \times Bid_{{BAT_{e} }}^{t} ] + P_{Grid}^{t} \times Bid_{Grid}^{t} ))} \\ \end{array} $$
(1)
$$ X = \left[ {P_{g} ,U_{g} } \right]_{1 \times n} $$
(1a)
$$ n = \left[ {2 \times \left( {N_{MT} + N_{FC} } \right) + N_{BAT} + 1} \right] $$
(1b)
$$ P_{g} = \left[ {P_{Grid} ,P_{BAT} ,P_{FC} ,P_{MT} } \right] $$
(1c)
$$ U_{g} = \left[ {U_{FC} ,U_{MT} } \right] $$
(1d)
$$ P_{Grid} = \left[ {P_{Grid}^{1} , \ldots ,P_{Grid}^{T} } \right]\begin{array}{*{20}c} {} & {T \in \left\{ {1, \ldots ,24} \right\}} \\ \end{array} $$
(1e)
$$ \begin{array}{*{20}c} {P_{BAT} = \left[ {P_{{BAT_{1} }} , \ldots ,P_{{BAT_{e} }} } \right]} \\ {P_{{BAT_{e} }} = \left[ {P_{{BAT_{e} }}^{1} , \ldots ,P_{{BAT_{e} }}^{T} } \right]\begin{array}{*{20}c} {} & {e \in \left\{ {1, \ldots ,N_{BAT} } \right\}} \\ \end{array} } \\ \end{array} $$
(1f)
$$ \begin{array}{*{20}c} {P_{FC} = \left[ {P_{{FC_{1} }} , \ldots ,P_{{FC_{c} }} } \right]} \\ {P_{{FC_{c} }} = \left[ {P_{{FC_{c} }}^{1} , \ldots ,P_{{FC_{c} }}^{T} } \right]\begin{array}{*{20}c} {} & {c \in \left\{ {1, \ldots ,N_{FC} } \right\}} \\ \end{array} } \\ \end{array} $$
(1g)
$$ \begin{array}{*{20}c} {P_{MT} = \left[ {P_{{MT_{1} }} , \ldots ,P_{{MT_{d} }} } \right]} \\ {P_{{MT_{d} }} = \left[ {P_{{MT_{d} }}^{1} , \ldots ,P_{{MT_{d} }}^{T} } \right]\begin{array}{*{20}c} {} & {d \in \left\{ {1, \ldots ,N_{MT} } \right\}} \\ \end{array} } \\ \end{array} $$
(1h)
$$ \begin{array}{*{20}c} {U_{g} = [u_{{c_{1} }}^{1} ,u_{{c_{1} }}^{2} , \ldots ,u_{{c_{1} }}^{T} , \ldots ,u_{{c_{{N_{FC} }} }}^{1} , \ldots ,u_{{c_{{N_{FC} }} }}^{T} ,u_{{d_{1} }}^{1} ,u_{{d_{1} }}^{2} ,} \\ { \ldots ,u_{{d_{1} }}^{T} , \ldots ,u_{{d_{{N_{MT} }} }}^{1} , \ldots ,u_{{d_{{N_{MT} }} }}^{T} ] \in \left\{ {0,1} \right\}} \\ \end{array} $$
(1i)
$$ U_{E} = \left[ {u_{{e_{1} }}^{1} ,u_{{e_{1} }}^{2} , \ldots ,u_{{e_{1} }}^{T} , \ldots ,u_{{e_{{N_{BAT} }} }}^{1} , \ldots ,u_{{e_{{N_{BAT} }} }}^{T} } \right] \in \left\{ { - 1,0,1} \right\} $$
(1j)

2.2 Constraints

Considering the above formulation, X denotes the decision variables’ vector, which is mainly consisted of two elements. The first element is that is constituted from the grid, battery, fuel cell and micro turbine’s power. Note that since the renewable energy sources are not dispatchable; meaning that the main aim is to benefit their output power the most, they are not being considered as decision variables. The next element of the decision variable vector is Ug specifying the ON/OFF status of the fuel cell and micro turbine. One of the other coefficients in (1) is Uet, defining the battery charge status. This variable is equal to −1, when the battery is discharging and it equals 1 during the charging process. In order to demonstrate the battery state when the battery is neither being charged nor discharged, Uet equals zero. Note that the term SU/SD denotes the startup/shutdown cost of the MT or FC depending on the index. Also here, “a” denotes number of WTs, “b” is for number of PVs, “c” denotes number of FCs, “d” is for MTs and “e” stands for BAT numerator.

The main constraints that are associated with the proposed MG optimized operation are analyzed in this section. The most important constraint in this problem is the power balance constraint as described below:

  • Power/Load Balance Constraint

The load and supply balance equation is considered as the major constraint that must be fulfilled. This constraint is formulated as Eq. (2):

$$ \begin{array}{*{20}c} {\mathop \sum \limits_{a = 1}^{{N_{WTs} }} P_{{WTs_{a} }}^{t} + \mathop \sum \limits_{b = 1}^{{N_{PVs} }} P_{{PVs_{b} }}^{t} + \mathop \sum \limits_{c = 1}^{{N_{FC} }} u_{c}^{t} \times P_{{FC_{c} }}^{t} + } \\ {\mathop \sum \limits_{d = 1}^{{N_{MT} }} u_{d}^{t} \times P_{{MT_{d} }}^{t} + \mathop \sum \limits_{e = 1}^{{N_{Bat} }} Max\left( {u_{e}^{t} ,0} \right) \times P_{{BAT_{e} }}^{t} + P_{Grid}^{t} = } \\ {\mathop \sum \limits_{f = 1}^{{N_{LOAD} }} P_{Load}^{t} - \mathop \sum \limits_{e = 1}^{{N_{Bat} }} Min\left( {u_{e}^{t} ,0} \right) \times P_{{BAT_{e} }}^{t} } \\ \end{array} $$
(2)
  • Battery Constraint

The utilization of energy storage systems in the proposed MG leads to some constraints that are mainly associated with the batteries’ state of charge (WtBAT), the charge/discharge rate (Pch/dch), their corresponding boundaries and the batteries’ efficiency (\( \eta \)). These constraints are described in Eqs. (38):

$$ W_{BAT}^{t} = W_{BAT}^{t - 1} + \eta_{ch} \times P_{ch}^{t} \times time - \frac{1}{{\eta_{dch} }} \times P_{dch}^{t} \times time $$
(3)
$$ W_{{BAT_{{e,{\mathrm{min}}}} }} \le W_{{BAT_{e} }}^{t} \le W_{{BAT_{{e,{\mathrm{max}}}} }} $$
(4)
$$ P_{ch}^{t} \le P_{{ch,{ \hbox{max} }}} $$
(5)
$$ P_{dch}^{t} \le P_{{dch,{ \hbox{max} }}} $$
(6)
$$ P_{ch}^{t} = Max\left( {u_{e}^{t} ,0} \right) \times P_{{BAT_{e} }}^{t} $$
(7)
$$ P_{dch}^{t} = - Min\left( {u_{e}^{t} ,0} \right) \times P_{{BAT_{e} }}^{t} $$
(8)

The limitations on the maximum and minimum levels of output powers of the fuel cell, the micro turbine, the grid and the battery must be taken into account, as described in Eqs. (9)–(12).

$$ u_{c}^{t} \times P_{{FC_{c,min} }}^{t} \le P_{{FC_{c} }}^{t} \le u_{c}^{t} \times P_{{FC_{c,max} }}^{t} $$
(9)
$$ u_{d}^{t} \times P_{{MT_{d,min} }}^{t} \le P_{{FC_{c} }}^{t} \le u_{d}^{t} \times P_{{MT_{d,max} }}^{t} $$
(10)
$$ P_{Grid,min}^{t} \le P_{Grid} \le P_{Grid,max}^{t} $$
(11)
$$ u_{e}^{t} \times P_{{BAT_{e,min} }}^{t} \le P_{{BAT_{e} }}^{t} \le u_{e}^{t} \times P_{{BAT_{e,max} }}^{t} $$
(12)

3 Solution Implementation

3.1 Machine Learning Substitution for Optimization Algorithm

Classical operation of microgrids is usually performed via solving the optimal dispatch of the system whilst considering the constraints explained in Sect. 2. Figure 2 illustrates the traditional chronology of microgrid operation.

Fig. 2.
figure 2

Traditional microgrid operation

In this study, we have utilized the output of a solution methodology called the bird mating optimization (BMO) algorithm. The fundamental of this algorithm is based on the mating of birds. Male or female birds choose their elite mate or mates based on a series of preferences. This mating behaviour is scored in a descending order and it will be considered as the fitness function of the algorithm of the initial population. Detailed description of the BMO algorithm can be found in [8]. After implementing the BMO algorithm on the proposed microgrid and analyzing the results, it came to the authors’ attention that the temporal behaviour of different units can be considered as training data for a regression-based supervised machine learning algorithm. Therefore, the optimization section in Fig. 2 was substituted with the machine learning algorithm.

The distribution of various constituting units of the microgrid on the IEEE 33-bus test system is illustrated in Fig. 3.

Fig. 3.
figure 3

Proposed microgrid topography

Considering the constraints of buses and lines in Fig. 3, it is obligatory that the OPF problem be solved for the IEEE 33-bus test system. Note that the dotted line illustrates the traveling path of the electric vehicle. Similar to the observations of the BMO algorithm, the OPF output has a temporal response as well. Ergo, the output data can be used to train another supervised machine learning algorithm to substitute the OPF calculations. It must be noted that the main motive for such substitutions lies within the fact that the traditional methods have two main deficiencies: (1) their performance is dependent on the initial population and (2) The computational complexity of these solutions is very high.

3.2 Online Discrepancy Test

It is a known fact that IoT devices are vulnerable to cyber attacks. The main question is: how can we avoid the manipulated data in machine learning? two main approaches can be taken: (1) Designing a robust machine learning algorithm and (2) Detecting attacks and mitigating them. The latter provides us from benefiting current machine learning techniques and is the general approach that has been taken into account. In this study, a regressive model has been introduced to substitute the time-consuming and off-line optimization method that is widely used for energy management in smart grids. Afterwards, the output of this model is given to the OPF solver to gain the power loss and voltage diagram of the main network. The security of the proposed framework is guaranteed using the online discrepancy test (ODIT). Detailed description of the ODIT can be found in [9]. The distinction of this method lies within the fact that it eliminates false data, thus avoiding adversarial machine learning while minimizing false alarms. The final scheme of the proposed operational framework is illustrated in Fig. 4.

Fig. 4.
figure 4

Final operation scheme of the proposed ML-based framework

There are two important factors in regards to the final scheme of the system as illustrated in Fig. 4. (1) Both the optimization and OPF sections have substituted via regression methods. (2) The ODIT is used to declare any possible anomalies. The yellow surge signs in Fig. 4 show the possible parts of the scheme that can be subject to cyber attacks. The attack can occur in the optimization or OPF section, which supplies the training data for the regression method or it can occur on the system after the machine learning substitution. In either case, the ODIT’s strategy is to get constant feedbacks from the actual values and the forecasted values and make a decision on the existence of anomalous activities using a cumulative criterion [9].

4 Conclusion

With the emergence and development of telecommunication technologies, a new generation of electric grid has been born; i.e. “the smart grid”. Smart grids have facilitated several energy management limitations of classic grids. In this regard, two main points must be taken into consideration:

  • The repetitive patterns of renewable energy resources such as solar irradiation and wind speed can be modeled using a regressive machine learning technique. Furthermore, other aspects that form the energy management of smart grid have a sequential pattern. For example the energy price and load demand are lower in the beginning and at the end of the day while they both have peaks sometime around noon. This justifies the usage of machine learning algorithms as a substitute for current off-line meta-heuristic algorithms that require high number of iterations to converge to the global optimal operation point.

  • The security aspects of machine learning- based models in IoT systems. If the machine learning algorithm is fooled with false or manipulated data, then the final output of the computations will be false. This can lead to serious financial or even life-threatening consequences. In order to address this issue it is necessary to provide an anomaly detection method that is both quick and reliable.

Finally, The findings of this work can be summarized as follows:

We presented an online machine learning algorithm to substitute the optimized operation and optimized power flow of a smart grid. The benefits of using machine learning algorithms in energy management of smart grids can be reflected in addressing computational complexities in: (1) Time: Reducing the operation time and anomaly detection time. (2) Space: Real-life systems are large-scaled and solving the optimization problem for a grid-connected smart grid is mathematically complex.

We introduced an online anomaly detection method to detect and mitigate cyber attacks to IoT devices in smart grid so that: (1) the false alarms are minimized. (2) The false data is eliminated.