A Comparison of Fuzzy ‐ Based Energy Management Systems Adjusted by Nature ‐ Inspired Algorithms

: The growing energy demand around the world has increased the usage of renewable energy sources (RES) such as photovoltaic and wind energies. The combination of traditional power systems and RESs has generated diverse problems due especially to the stochastic nature of RESs. Microgrids (MG) arise to address these types of problems and to increase the penetration of RES to the utility network. A microgrid includes an energy management system (EMS) to operate its components and energy sources efficiently. The objectives pursued by the EMS are usually economically related to minimizing the operating costs of the MG or maximizing its income. However, due to new regulations of the network operators, a new objective related to the minimization of power peaks and fluctuations in the power profile exchanged with the utility network has taken great interest in recent years. In this regard, EMSs based on off ‐ line trained fuzzy logic control (FLC) have been proposed as an alternative approach to those based on on ‐ line optimization mixed ‐ integer linear (or nonlinear) programming to reduce computational efforts. However, the procedure to adjust the FLC parameters has been barely addressed. This parameter adjustment is an optimization problem itself that can be formulated in terms of a cost/objective function and is susceptible to being solved by metaheuristic nature ‐ inspired algorithms. In particular, this paper evaluates a methodology for adjusting the FLC parameters of the EMS of a residential microgrid that aims to minimize the power peaks and fluctuations on the power profile exchanged with the utility network through two nature ‐ inspired algorithms, namely particle swarm optimization and differential evolution. The methodology is based on the definition of a cost function to be optimized. Numerical simulations on a specific microgrid example are presented to compare and evaluate the performances of these algorithms, also including a comparison with other ones addressed in previous works such as the Cuckoo search approach. These simulations are further used to extract useful conclusions for the FLC parameters adjustment for off ‐ line ‐ trained EMS based designs.


Introduction
The growing energy demand in the industrial, commercial, and residential sectors around the world has significantly increased energy consumption during the last decades. The total primary energy supply, or the energy available in nature before being converted or transformed, has increased from 6.1 billion tons of oil equivalent in 1973 to 13.7 billion tons in 2016 [1]. This increment in energy consumption has generated a negative impact on the concentration of greenhouse gases [2], indicating that many countries focus their resources on improving energy efficiency and increasing the production of clean energy. As a consequence of these actions, there has been a sustained increment in the usage of renewable energy sources (RES), where photovoltaic and wind energies the ones with the highest growth worldwide [3].
However, new problems have appeared when RESs are combined with traditional sources of energy [3]. For instance, unexpected fluctuations in the response of RES can affect the voltage and frequency of the network, constrained power electronics requirements, different control and dispatch methods, etc. Thus, the microgrid (MG) concept appeared to solve some of these drawbacks [4]. A microgrid is a low-voltage distribution network consisting of loads, distributed generation elements, and energy storage systems (ESS), which can be connected to the mains at a single point of common coupling (PCC). It has an associated energy management system (EMS) that allows the reliable, safe, and economic operation of the elements within the microgrid [5].
An EMS controls the power flux of different microgrid elements to achieve certain goals, such as minimize operating costs or maximize revenues [6,7]. Several EMSs have been presented in the literature, each of them considering different types of MG architecture (i.e., AC, DC, and hybrid AC-DC microgrids) [8][9][10] and pursue different objectives under different conditions [11,12]. For instance, [13] presents a stochastic risk-constrained framework for short-term optimal scheduling of autonomous microgrid to maximize the expected profit of the microgrids operator. In [14], an intelligent EMS using mixed-integer linear programming of grid-connected home-type microgrid is presented. This approach reduced energy costs of non-dispatchable distributed energy resources. The study in [15] presents the design of an EMS for a grid-connected microgrid equipped with photovoltaic (PV) generator to manage the load supply with the maximum exploitation of solar energy and improving the thermal comfort of the occupants.
However, RES such as wind and PV feed power into the grid in a very variable way, directly related to the variability of the energy source itself (i.e., wind and irradiance). As these power sources are set to attain very high degrees of penetration level in the current grid, this power variability is of great concern for grid operators [16][17][18]. Therefore, various studies have been developed in recent years to minimize power fluctuations (i.e., ramp-rates) on the power exchanged with the grid [19][20][21]. For instance, the study in [19] analyzes the effect of smoothing the tie-line power fluctuations for grid-connected industrial microgrids using demand-side approach. In addition, the studies in [20] and [21] present a heuristic design of an EMS of residential electrical and electro-thermal grid-connected microgrids, respectively, including an ESS, RES, and a residential electrical load.
Due to its heuristic nature, some studies have focused on the design of the EMS using expert knowledge rule-based systems since they have proven to be easy to implement and low computational run time cost than other sophisticated analytical solutions [22,23]. Thus, a fuzzy logic control (FLC) EMS of two inputs, one output, and 25 rules is developed in [24] and experimentally validated in [25]. The same approach, but now using generation and demand forecasts is described and validated in [26]. These EMSs, and others designs based on FLC [27], pursue a common main objective, which consists of smoothing the power profile exchanged from the MG to the utility network. However, the design of the FLC block involved within these EMSs requires the selection of several parameters such as the type and number of membership functions, rule base, and variation range of each variable. Therefore, a first approach to perform the parameter adjustment of an FLC controller that is part of the EMS of a residential grid-connected microgrid is developed in [28]. This approach performs an off-line parameter tuning of the FLC of an EMS using the real recorded data of RES production and load consumption in one year.
However, the selection of the FLC parameters can be seen as an optimization problem that could be formulated in terms of a cost/objective function [29]. Fortunately, in addition to costly and time-consuming traditional optimization techniques, several metaheuristic nature-inspired algorithms have been proposed to solve optimization problems in a wide range of applications [30][31][32][33]. Some examples of these nature-inspired algorithms that can be found in the literature are genetic algorithms [34], differential evolution (DE) [35], ant colony optimization [36], particle swarm optimization (PSO) [37], firefly algorithm [38], Cuckoo search (CS) [39], among others. In this regard, to improve the parameter adjustment procedure described in [28], a methodology based on the CS algorithm is presented in [40,41]. This approach is applied to the EMS of a residential grid-connected electro-thermal microgrid, improving its performance in terms of smoothing (i.e., minimizing power peaks and fluctuations) the power profile exchanged with the utility network.
Hence, to analyze the behavior of other nature-inspired algorithms, this paper evaluates a methodology for adjusting the FLC parameters of the EMS of a residential grid-connected electro-thermal microgrid through two metaheuristic nature-inspired algorithms, namely PSO and DE. Although there are many nature-inspired optimization algorithms, PSO, DE, and CS are the most classical examples of nature-inspired techniques that are based on different search strategies [42]. DE is a heuristic evolutionary optimization algorithm developed for solving real-valued numerical optimization problems [35]. It is a very effective global search algorithm with a simple mathematical structure. On the other hand, PSO is a stochastic and multi-agent parallel global-search technique [37], which, unlike DE, is based on the mathematical modeling of various collective behaviors of living creatures that display complex social conducts, allowing it to develop local solutions into global optimum solutions. Finally, the CS algorithm is a more recent alternative to PSO that models the obligate brood parasitism of some cuckoo species [39]. A global cost function, including all criteria used to evaluate the quality of the grid power profile, is formulated, which constitutes the optimization objective function. Results show that the evaluated nature-inspired algorithms present similar optimization performance. However, the CS algorithm offers some advantages related to the reduction of fluctuations and power peaks in the grid power profile. It is also important to mention that in terms of computing time, the PSO algorithm is faster than CS and DE algorithms. A comparison with an EMS strategy that uses an off-line parameter tuning for the FLC block [43] demonstrates that the CS, PSO, and DE algorithms get an acceptable response concerning the main objective pursued by the EMS (i.e., smoothing the power profile exchanged with the mains).
The main contributions of this paper are listed below: 1. A complete procedure for adjusting the parameters of an FLC block of the EMS of a residential grid connected electro-thermal microgrid using the PSO and DE algorithms.

2.
A set of comparative one-year simulations and quantification of smoothing indexes, using real data, highlighting the advantages and disadvantages of each analyzed approach.
The remainder of this paper is organized as follows. Section 2 presents the architecture and operation of the electro-thermal microgrid under study. Section 3 describes the fitness function and presents the optimization matrix and search space used in this optimization problem. The PSO and DE algorithms are described in Sections 4 and 5, respectively. Section 6 presents the simulation and comparison results. Finally, Section 7 summarizes the main conclusions of this study.

Structure and Operation of the Grid-Connected Microgrid
This study is an extension of the previous works [40,41], which present a methodology for adjusting the FLC parameters of the EMS of an electro-thermal microgrid employing the CS algorithm. The structure of the microgrid under analysis, as well as its operation in grid-connected mode, is presented below.
Note that the mathematical models of RESs, i.e., PV and wind turbine (WT), the domestic hot water system (DHW) system, the forecast of power generation and load demand, and the battery state-of-charge (SOC) estimator are not included in this study. However, for complete information on these models, the reader could refer to [27].

Microgrid Structure
The microgrid architecture comprises two main blocks, namely the electrical system and the DHW system [27,43,44]. The electrical system includes a hybrid renewable generation system comprising a PV generator of 6 kWp and a WT of 6 kW, an ESS consisting of a lead-acid battery bank with a rated capacity of 72 kWh, and a domestic load of 7 kW, which includes typical domestic appliances, lighting, etc. The DHW system includes a solar thermal collector of 2 kW, an electric water heater (EWH) of 2 kW, a thermal ESS consisting of a hot water tank of 800 L capacity, and thermal demand (i.e., DHW consumption) equivalent to 2 kW. Figure 1 shows the microgrid architecture under study.

Microgrid Operation in Grid-Connected Mode
In grid-connected mode, the microgrid under study is in charge of smoothing the grid power profile through suitable control of the power injected/absorbed by the battery ESS. The EMS is based on a control strategy described in [43]. The goal of the EMS is to perform the suitable use of the energy stored in the battery ESS to cover part of the energy required by the EWH for keeping the water temperature in the thermal storage between established limits.

Power ( kW )
In this regard, the control of the battery power, PBAT, is indirectly performed by controlling the power supplied by the battery ESS for the EWH consumption, B WH P , and imposing the desired grid power profile, PGRID. In [43], the grid power profile is defined as the sum of three components, as follows: where t is the current sample, * CTR P is the output of a central moving average (CMA) filter, which establishes the MG average power profile, PSOC is the output of the battery control loop, which is used to keep the battery SOC close to the 75% of the battery rated capacity, PFLC is the output of an FLC block, which is used to smooth the grid power profile according to the microgrid power forecast error and the battery SOC [40,43], PLG is the microgrid net power, PLOAD is the domestic load demand, PWH,E is the EWH power, PPV is the photovoltaic power, and PWT is the wind turbine power. The EMS block diagram comprises six blocks [43], see Figure 3, which regulates both the power delivered by the utility grid and the power injected or absorbed by the ESS. where PGEN is the renewable power generation, * LG P is the modified MG net power defines as LG to compute the battery power. Note that the step-by-step design of the EMS is out of the scope of this paper. However, for complete descriptions of each block within the EMS design (see Figure 3), readers can refer to [43].
In the diagram shown in Figure 3, block number six constitutes the one that is responsible for smoothing the power profile exchanged with the grid. This block consists of an FLC that assumes a Mamdani-based inference and defuzzification method of the Center of Gravity of two input, one output, and 25 rules. The inputs of the FLC are the current battery SOC and the power forecast error of the previous 3-hours, 3 * H E P , which is defined as: where k is the sample index, M3 is the number of samples in 3-h, and * Regarding the design of the FLC, an offline parameter setting process, described in [28], is followed, which allows the adjustment of all parameters involved in the FLC, such as the number of membership functions (MFs) per input/output, type, mapping, and rule base. This process is performed considering the real recorded and forecasted data of renewable energy source electricity production and load demand for one year. This procedure leads to the MF for inputs and outputs shown in Figure 4 [45], with their respective variation ranges where Pe = 6kW; SOCMIN = 50%, SOCMAX = 100%, PN = 0.8 kW, and PP = 1.35 kW, and the FLC rule base presented in Table 1. Note that the fuzzy subsets depicted in Figure 4 are denoted as NB, NM, NS, NSS, ZE, PSS, PS, PM, and PB, where B represents "Big", M "Medium", S "Small", SS "Smallest", N "Negative", P "Positive", and ZE "Zero".

Fitness Function
Since the main objective of the EMS is to smooth the MG power profile by managing the energy balance between renewable energy sources, electric loads, energy storage systems, and the main electrical grid, a set of six quality criteria, which quantify the effectiveness of energy management, is defined according to [20,21,25,26,[40][41][42], as follows: Hz are the initial and final frequencies defined to evaluate variation periods of above one week or less [20,21,25,26].
On the other hand, since the FLC tuning procedure can be considered as an optimization process [29], it will require the definition of an optimization (cost) function involving all energy management quality criteria to coherently represent the designer's preferences between objectives in terms of a weighted sum function [46]. This function is defined according to [40], and it is normalized in terms of the reference energy management quality criteria obtained from a previous study where a heuristic-based optimization procedure is applied [43]. From this perspective, the optimization function is defined as follows: , , where w ≥ 1 is a fixed real number that balances the designer's preference between F1 and F2, prioritizing one of them during the iterative optimization process [40].

Optimization Matrix and Search Space
The optimization matrix comprises the variables to be optimized. Its dimension is n x d, where n represents the maximum number of agents selected for optimization, i.e., nest for CS, particles for PSO and individuals or population for DE algorithm, and d refers to the total of variables (i.e., size of the dimensional problem). The search space (SS) refers to the domain of the function to be optimized.
The optimization matrix for PSO and DE algorithms is defined in (15). It includes the FLC parameters, such as MFs of inputs ( 3 *

H E P
and SOC) and output (PFLC), the output universe of discourse   ( )( ) k x , and the rule base (RB). Table 2 presents the number of variables to be optimized for each parameter, which gives a total of 72 (i.e., d = 72). In short, both inputs comprise five fuzzy subsets and 11 variables (i.e., three variables for MFs NS, ZE, and PS, and one variable for MFs NB and PB). The FLC output comprises 9 fuzzy subsets and 23 variables (i.e., three variables for MFs NM, NS, NSS, ZE, PSS, PS, and PM, and one variable for MFs NB and PB). The FLC rule base comprises 25 rules, thus, 25 variables. Finally, this study considers two variables to define the universe of discourse of the FLC output. Note that this study assumes a fixed universe of discourse for input variables.

Particle Swarm Optimization Algorithm
PSO is a stochastic technique for the optimization of nonlinear continuous functions designed by Kennedy and Eberhart in 1995 [47]. The operation of this particular metaheuristic is based on the ideal behavior of bird flocks when they look for food. One of the advantages of the PSO algorithm is its rapid convergence without the need for complex calculations when it is compared to other metaheuristic algorithms, such as genetic algorithm and CS, among others.
In the PSO algorithm, the particle swarm has the position (x) and velocity (v) matrices of i × j dimension within a search space SS. Note that it is necessary to add an extra column in the matrix x to record the result of the fitness function fitxi, as follows: The velocity and position of each particle are given by (23) and (24), respectively, as follows: where vi (k + 1) and vi (k) are the new and current particles velocities, respectively; xi (k + 1) and xi (k) are the positions of the new and current particles, respectively; w(k) is the inertia weight; C1 and C2 are acceleration constants, which determine the swarm behavior; R1 and R2 are random numbers within the range [0, 1] [31]; Pbest is a matrix defined by (25), which records the personal best position of each particle; and, Gbest is a vector, defined by (26), which records the best global position of all swarm. Similarly, matrix (25)  best best best Gbest G G G fit (26) For each particle, its fitness xi (k + 1) is compared with its best-recorded position in i best P . If the new fitness is less than the best value seen so far, i best P is updated with xi (k + 1). After that, the lowest value of fitness in i best P is found and compared to Gbest. If the fitness of the best particle is lower than the best global position, Gbest is updated by i best P .

Differential Evolution Algorithm
The DE algorithm is a nature-inspired metaheuristic algorithm proposed by Rainer Storn and Kenneth Price in 1995 [49]. It is an evolutionary algorithm, which is based on the natural and genetic selection of populations. In general, the DE algorithm uses mutation, crossing, and selection operators to generate new individuals. The main characteristic of the DE algorithm is the use of a minimum number of parameters, such as the scale factor, F, crossover rate, Cr, the size of the dimensional problem, d, and the number of individuals or population, n, [31].
Initially, the DE algorithm performs a random selection of a population of n vectors, with uniform distribution, which will cover the entire search space [49]. This selection delivers the initial vector xi, which is used to carry out the mutation, crossover, and selection processes.
where i = 1, 2, ..., n for each solution xi in any generation t.
The DE algorithm attempts to replicate the biological behavior of evolution in a computer program. The mutation in the evolution of an individual consists of the random variation of one of its genes. The DE algorithm takes this behavior as a reference. For each target vector xi, a mutation vector, vi, is generated according to the following mutation scheme: where xp, xq, and xr are the target vectors at t, which are created from three randomly chosen individuals in the population to cause a vector, in any of its values, to vary randomly. Note that the scale factor, F, is a real value between [0, ∞), which is used to scale the differential variation of the scanning vector (xq − xr). This study considers a scale factor between [0, 1], according to [50]. Then, after a random set of vectors have been selected, the crossover operation is carried out. In addition, a mutation operation is also applied to the recombined vector in order to generate the final population. This process is controlled by the parameter Cr ∈ [0, 1], which controls the crossover rate [51]. This study uses a binomial crossover scheme, which performs a crossover on each of the variable components. The test vector u is obtained as follows: where j = 1, 2,…,d, rj ∈ (0, 1), Cr ∈ [0, 1] is a user-defined constant, and Jr 1,…,d is a randomly index, which is chosen to ensure that 1 Finally, selection in evolution refers to choosing which individuals pass to the next generation. After the mutation and crossover stages, in which all n vectors served as a target vector, for selection, the fitness value of each test vector  [31]. Then, the selection of the vectors that will be preserved for the next generation is the one who has the best performance function value [49], i.e., The DE algorithm pseudo-code used to find the best population for adjusting the FLC parameters of the EMS is presented in Algorithm 2. Note that this study considers F = 0.7, Cr = 0.9, and n = 25 according to [31,50,52].

Fuzzy Logic Control Parameters Comparison
The result of adjusting the FLC controller parameters through the PSO and DE algorithms is presented below. In addition, the results achieved by the CS algorithm [40,41] are included for comparison purposes. The FLC parameters obtained through the CS, PSO, and DE algorithms are presented in Figures 5, 6 and 7, respectively, where each MF, for inputs variables, is superposed to the respective achieved by heuristic method (HM). In addition, the resulting rule base achieved by each algorithm is presented in Tables 3-5.

Energy Management System Performance Comparison
This section presents the results achieved by the EMS after the FLC controller parameter setting process through the nature-inspired algorithms described above. Furthermore, a comparison is made with the results obtained through the EMS described in [43] where the parameters of its FLC block are adjusted using a heuristic process and also with the results obtained by the EMS presented in [40,41] where the adjustment of the FLC parameters is made through the CS algorithm.
The comparison is made over the same FLC parameters optimization problem in terms of the quality of the solutions and the computation time. Therefore, the same initial set of random solutions (i.e., initial population), the optimization function defined in Section 3, and the standard algorithm's parameters [31] have been implemented.
A weighting factor of w = 2 is used in the optimization function defined in Section 3 to prioritize the minimization of PG,MAX, PG,MIN, and MPD over APD, PPV, and PVR since the main objective of the EMS is to smooth the power profile exchanged with the grid (i.e., minimizing grid power ramp-rates, power peaks [40]. Numerical simulations, using Matlab ® (MathWorks, Natick, MA, USA), are carried out in an INTEL ® Core™-i7 6500U CPU 2.50 GHz computer, where the three algorithms are executed under the same initial conditions to solve 300 iterations.
For the case study, the convergence of the optimization function and the number of iterations required by the algorithms under analysis to converge to its feasible optimum is shown in Figure 8. As can be seen in Figure 8, the CS and DE algorithms perform similarly in terms of convergence rate. However, the obtained solution through DE is slightly better than the one achieved by the CS in terms of the solution quality since the optimization function's value for DE is lower than the CS value, as shown in Table 6. On the other hand, an analysis of the convergence time is shown in Table 7, where the population length represents the number of population agents, such as the CS-nest, PSO-particles, DE-candidate solutions; the time per iteration is the time that takes to analyze each agent in one iteration; the convergence iteration is the iteration in which the algorithm converges; and the convergence time represents the total execution time until the convergence iteration is reached. In short, the PSO algorithm presents a less convergence time than the CS and DE algorithms for the case under study. Despite that PSO presents better behavior than the CS and DE algorithms in terms of the convergence rate, the obtained solutions by the CS and DE algorithms are slightly better than the solution achieved by the PSO algorithm for the case under study. In this regard, Table 8 presents the results of evaluating the power profile that the MG exchanges with the utility network achieved by the EMSs under analysis. In addition, Figure 9 shows the grid power profile for each EMS design, where it can be seen that all the designs meet the objective of smoothing the power profile exchanged with the main grid (i.e., minimizing power peaks and fluctuations). Finally, Figure 10 shows the grid power profile ramp-rates, along one year, achieved by the analyzed EMSs. As can be seen, the fuzzy logic-based EMS obtained through nature-inspired algorithms present a considerable reduction in the power ramp-rates of the grid power profile, which facilitates the control of grid operators and the penetration of RES into the mains.

Conclusions
This paper has addressed the tuning of parameters using the nature-inspired PSO and DE algorithms of an FLC that is part of the EMS of a residential grid-connected electro-thermal microgrid. The FLC-based EMS has been designed to smooth the power profile exchanged with the grid. Numerical simulations have allowed the performance comparison between PSO-tuned and DE-tuned EMSs as well as with heuristically tuned and CS-tuned EMSs presented in previous works. In the adjustment process, the algorithms perform the optimization of 72 variables corresponding to the MF mapping of inputs and the output as well as the FLC rule base. The results have shown that all the designs are capable of meeting the objective pursued by the EMS, obtaining a smooth grid power profile, and the evolution of the battery SOC within the permitted ranges. Moreover, it has been shown that all EMSs designs resulting from a tuning process based on PSO, DE, and CS nature-inspired algorithms have obtained a reduction in the maximum grid power ramp-rates (MPD) of over 40% when being compared to a fuzzy-based EMS where the adjustment of the FLC uses a heuristic approach. In addition, simulation results have revealed that the PSO algorithm performs better than CS and DE algorithms regarding the convergence time. Finally, the quality criteria comparison have shown that the CS algorithm has achieved an improved solution in terms of the MPD and PPV quality criteria, whereas the DE algorithm presents a better behavior concerning the PG,MAX, PG,MIN, and APD criteria. Therefore, this study has shown that the different nature-inspired optimization algorithms present similar results when it comes to improving FLC-based EMSs. However, convergence time is a critical parameter that should be considered in any deployment, especially if a real-time implementation is required. Furthermore, the set of input parameters needed for each algorithm must be understood to provide stability and robustness to the optimization task. Finally, these nature-inspired optimization algorithms are able to optimize the FLC rule base and the MF mapping simultaneously, using a single cost function for both activities.
Future work will focus on the design of a real-time adaptive fuzzy-based energy management system. This new design will update the fuzzy logic control parameters at the same time as the forecast variables, which could improve the EMS efficiency.