Optimal Allocation of Renewable Energy Sources and Battery Storage Systems Considering Energy Management System Optimization Based on Fuzzy Inference

: The main problem in planning the optimal operation of renewable energy sources and battery storage systems is the amount of data that must be considered to cover an entire observation period. If the observation period is one year, the characteristic days or averaged data (daily, weekly or monthly averages) are considered to reduce the number of data. Since the average values of the entered data differ from the actual values, it is better to work with hourly or 15-min data at the annual level. The study presents a framework for solving the problem of the optimal allocation and operation of renewable energy sources and battery storage systems. The proposed method simultaneously solves the optimal allocation and energy management problem considering hourly data at the annual level. The fuzzy inference-based system is proposed for scheduling optimal proﬁles of battery storage systems and renewable energy sources. The developed fuzzy inference system manages the power factors of the photovoltaic and wind power systems, the power factor and output of the biogas plant, and the operating status of the battery storage system. The presented method simultaneously ﬁnds the optimal parameters of the energy management system and the optimal allocation and operation of the renewable energy sources and the battery storage system. The developed method is based on the calculation of steady-state power ﬂow. The proposed method is to be used in the design phase for the installation of various renewable energy sources and battery storage systems. In addition, the method is intended to be used to optimally control the power output of energy sources and the operation of energy storage systems during steady-state operation in order to operate the distribution network with minimum annual active energy losses. The developed method is applied to the test distribution system IEEE with 37 nodes. The reduction in annual energy losses in the tested distribution system is about 80% compared to the base case without renewable energy sources and battery storage system.


Introduction
The use of renewable energy sources in the power grid has increased in the last decade. Despite the environmental benefits, the installation of renewable energy sources in the electricity distribution networks is challenging from a technical point of view. The production units that use renewable energy sources are usually of a limited size. In order to integrate more smaller units into the power grid, they are called distributed generation (DG). Due to the variable intensity of primary energy from renewable sources, the implementation of battery storage systems (BESS) is also increasingly present in the smart grid concept of the power system [1]. The use of the DG and BESS units in synergy work aims to exploit the available intensity of the energy sources as much as possible. However, using the maximum available energy from DG sources is not always optimal from the point of view of power/energy losses in the power distribution system. Various algorithms for controlling the output of DG and BESS are described in the literature [2]. In [3], the optimal allocation of photovoltaic (PV) DG with BESS is determined by metaheuristic optimization and using daily variable data of PV production and load shape. The authors of [4] use the voltage value of the node of the BESS system in the power grid to determine the BESS operating state (charging or discharging) with the goal of controlling the voltage in the system. The use of BESS for frequency control in a power grid with a high penetration of PV DG is presented in [5]. In [6], BESS is used for peak shaving of load of industrial consumers. In [7], the daily load changes are considered in the optimization problem of allocation and power distribution of BESS, with the aim of minimizing the losses and smoothing the voltage profile in the system. The metaheuristic optimization technique, namely the genetic algorithm (GA), is used to solve the problem. The optimal BESS allocation and control is solved in [8] by the metahueuristic African buffalo optimization (ABO) method. The optimization method comprises two stages (outside and inside) and considers changes in DG production and consumer load at the daily level with hourly resolution. In [9], the algorithm for controlling the voltage profile by multiple BESS units is presented considering daily input data. The authors of [10] use a mathematical programming approach to solve the optimization problem of the energy management system in a smart grid consisting of different types of DG, BESS and electric vehicles (EVs). The objective of the optimization problem is to minimize the cost of importing energy into the smart grid. The mathematical programming formulation is also used in [11] to control the power DG outputs to control the voltage and reactive power in the power grid. In [12], particle swarm optimization (PSO) is used to find an optimal allocation of BESS, and a deterministic strategy for the charge/discharge profile of BESS is proposed. The daily DG production and load profiles are used for optimization, and the cost of BESS installation and operation is considered as an objective function. The various methods of computational intelligence, artificial neural network, fuzzy logic, and metaheuristic optimization are used in [13] to predict the production of DG based on weather data, define the operational state of the microgrid (grid-connected or islanded), and dynamically control the microgrid in islanded mode. For a recent review of the application of computational intelligence techniques to PV system modeling, see [14]. In [15], the metaheuristic optimization methods are applied to optimize the parameters of the PID controller of the DC-DC boost converter. The techno-economic optimization of DG sources for the case study of the Great Canary Island using the HOMER energy software is presented in [16]. The study presents the prediction of renewable energy production for the projected future demand growth for different scenarios. In [17], the optimal allocation of PV DG for hourly data is solved at the daily level, where minimizing losses is the objective function. In [18], the authors use a co-simulation approach and a metaheuristic optimization method to solve the optimization problem with the objective of minimizing losses at constant load values. In [19], a co-simulation approach and metaheuristic optimization are also used to solve the optimal DG allocation as well as the DG power factor and output considering the variable load. The application of fuzzy systems for battery storage control is used for various applications of battery storage systems. In [20], the fuzzy controller is used to dynamically control the battery storage system while driving an electric vehicle to improve vehicle autonomy. The fuzzy controller combined with metaheuristic optimization is used in [21] for dynamic thermal control of a Li-ion battery. In [22], a hybrid neurofuzzy-genetic method for controlling the electric current with the goal of optimizing the battery temperature is presented. In [23], a fuzzy logic controller is used to dynamically control the flow of energy generated by renewable sources to the battery storage system and/or the grid. Usually, a certain local input variable is used as a control variable to control the output of BESS and DG. In the smart grid concept of the modern power distribution system, the application of a power/energy management system (PMS/EMS) is proposed [24]. In such a management system, various measurable variables can be collected and used as input variables for decision making on the output amount of BESS and DG in the power grid. As can be seen from the research on the application of BESS in power distribution, a local variable of the network node where BESS is installed is usually used to control the power and operating conditions of BESS. In this study, a method for solving the complex optimization problem of simultaneous optimization of DG and BESS allocation and power management system parameters is investigated. The objective of the optimization problem is to minimize the annual active energy losses in the power distribution system. The optimization considers an annual period with an hourly resolution of input and output data. Due to this approach, there are 8760 cases for which the optimal steady-state operation of the power generation and battery storage systems must be found, which further increases the complexity of the problem. Moreover, the developed method finds the optimal type of measurable variables for the inputs of the power management block. The study proposes a fuzzy inference system (FIS) based optimization system for power/energy management. The study proposes the use of a simulation approach that combines power system simulation and metaheuristic optimization tools. The FIS-based energy management system generates power factor and power values of DG as well as the operating condition (charging/discharging) and power of BESS. During the optimization process, the FIS block acts as a learning agent for which the optimal parameters are tuned by the optimization procedure. In the previous study, daily profiles were generally used when variable input data (DG production, load) were used in the model. Here, we use variable data at the annual level with hourly resolution. This study is the continuation of the earlier research of the author [25,26]. The rest of the article is organized as follows. In the second section, the mathematical modeling and the description of the optimization problem are presented. In the third section, a brief overview of the co-simulation approach and simulation tools used is given. Section 4 presents the proposed method based on metaheuristic optimization and a co-simulation approach. Section 5 presents the results of implementing the method in the test network. The last section summarizes the conclusions.

The Optimization Problem Definition
In this study, the two-objective optimization problem is considered, so the multiobjective problem is applied in this case. The problem is solved with optimization software using the Pareto definitions of the solution of the multi-objective problem. The objective function consists of the annual active energy losses W loss and the annual apparent energy W exc exchanged between the distribution system and the higher-level system at the transfer point (a substation). The problem is described mathematically as follows: where specific objectives are calculated using active power losses P i,loss , active P i,exc , reactive Q i,exc and apparent S i,exc powers exchanged in substation for n time periods t i over a year, according to The constraints of the optimization problem consider the ranges of the node voltages and the current limits of the power lines. The node voltage, line current and box (decision variable ranges) constraints are in the form of inequality constraints: V min ≤ V i,j ≤ V max for each period t i and each node j I i,k ≤ I max for each period t i and each line k where V min , V i,j , V max are the minimum, calculated and maximum nodal voltages, respectively, and I i,k , I max are the calculated and maximum (rated) line currents, respectively. The proposed FIS energy management block consists of some steps based on fuzzy logic. The FIS inputs and outputs are called linguistic variables, and each variable has some intensity levels called linguistic values. The degree to which a linguistic value belongs to a fuzzy set is defined by the membership function. The membership function is defined for each linguistic value of each linguistic variable. The membership function can be of different types, e.g., triangular, trapezoidal, Gaussian, and bell-shaped. Each of these types has parameters that define the shape of the membership function. The crisp value of the input variables is represented in FIS by the membership functions in the fuzzification process. After fuzzification, the fuzzy rules are applied to produce a truth domain. The defuzzification process is then applied to the truth domain to produce a crisp value for the FIS output variable. The schematic overview of the FIS can be seen in Figure 1. The parameters of the FIS membership functions and fuzzy rules are optimized during the solution of the optimization problem (1). The solution of the optimization problem is the optimal values of the decision variables. The decision variables are the parameters of the FIS membership functions (x m f ,i , i ∈ (1, . . . , N m f ), the allocation of the DG and BESS (x size,j , x loc,j , j ∈ (1, . . . , N dg,bess ), the locations in the network where the FIS inputs are measured (x inFIS,k , k ∈ (1, . . . , N inFIS ), fuzzy rules (x f r,r , r ∈ (1, . . . , 3) and the type of FIS input (x type,q , q ∈ (1, . . . , N inFIS ):

Co-Simulation Approach and Used Software Tools
The research is based on the so-called co-simulation approach. The co-simulation approach enables the use of software simulation tools for power system calculation and software tools for optimization algorithms. This approach ensures a more realistic modeling of the physical system (in this case, the power distribution network) with fewer approximations. The main drawback of using co-simulation in optimization is the limitation of the type of optimization algorithm that can be used to solve the optimization problem. Since the simulation software provides only numerical values as the result of the calculations, this approach is a so-called "black box" optimization case. In this case, only metaheuristic algorithms are suitable to perform the optimization process without knowing the analytic notation of the objective function of the problem. The co-simulation approach used ( Figure 1) can be set up with any simulation/computation tool for power systems and optimization methods. The main requirement for the tools used in the cosimulation is the existence of compatible interfaces between the software used. We used the Python programming environment and two well-known and widely used tools. For the modeling of the distribution system, the software OpenDSS [27] is used, which is a modern simulation tool for the analysis of the power distribution system (in particular, modern distribution networks with DG and BESS). This tool allows modeling all objects present in the power system, starting from sources, transformers, lines, loads to DG, BESS, capacitor banks, various regulators and so on. OpenDSS is suitable for the modeling and simulation of a general power system with balanced and unbalanced lines, loads and other objects. A metaheuristic optimization tool based on the ant colony optimization (ACO) method, called the mixed-integer distributed ACO (MIDACO) solver [28], is used in the research. The MIDACO solver is a general-purpose optimizer that can solve single-and multi-objective, continuous, integer, mixed-integer, constrained, and unconstrained problems. In other words, the MIDACO solver is capable of solving mixed-integer nonlinear programming (MILP) optimization problems. Due to the above characteristics of OpenDSS and the MIDACO solver, the tools are used here for simulating power systems and performing optimization in a co-simulation environment.

Proposed Procedure for Optimization BESS and DG Allocation and Output Profiles
The FIS proposed for managing the profiles of the power factor of all DG types (PV, wind, and biogas) and the power profiles of biogas DG and BESS use measurable quantities as input. In developing the method, it was necessary to use "easily" measurable quantities in the power system, such as node voltage, line current, and active and reactive power flows in the lines. The proposed procedure simultaneously optimizes the BESS and DG allocation and the parameters of the FIS energy management system. The whole procedure is based on a co-simulation approach, where the simulation program for the power flow calculation of the power distribution system works in a loop with the optimization program. The optimization program (in this case, the MIDACO solver) optimizes the location and size of the DG and BESS along with the FIS input variables and the FIS controller parameters. The optimization program sends the BESS and DG allocation along with the FIS input variables and the membership function parameters of all input and output FIS variables to the power system simulation tool (in this case, the OpenDSS software). The power system simulation tool runs the serial power flow at the annual level and calculates the data needed to compute the objective function values. In such a setup, the FIS controller acts as an agent during optimization using the reinforced learning approach. In the optimization procedure, the FIS parameters are not optimized directly based on the FIS output values, but based on the objective function whose values are affected by the FIS output values. The schematic overview of the developed method is shown in Figure 2.
In order to reduce the complexity of the FIS structure and the number of decision variables of the optimization problem, an energy management system consisting of one of the simplest FISs for each controllable output variable is proposed, as shown in Figure 3. The linguistic output variables of the FIS are the power factor of the PV, wind, and biogas plants DG, the output power of the biogas plant, and the operating status and power of BESS. Each linguistic variable has three linguistic values and the Gaussian membership functions are used for linguistic values. The optimization procedure tries to find the optimal mean and deviation of membership functions. The overview of the linguistic FIS variables and their values can be found in Table 1. The FIS input variables are normalized in the range (−1, 0, 1, 0) by comparing them to the minimum and maximum values obtained for the base case (without DG and BESS in the distribution system). This means that the universe of discourse of the FIS input variable is in the range of (−1, 0, 1, 0). The universe of discourse of the FIS output variable is different for the different FISs. FIS 1-3, used to generate the optimal power factor from DG, have a universe of discourse defined by the constraints on the power factor ranges depending on the DG type (PV, wind, or biogas). FIS 4 and 5, used to generate the optimal biogas DG and BESS output power, have a universe of discourse for output variables in the range (0, 1.0) for biogas DG and (−1.0, 1.0) for BESS (negative values for BESS charging and positive for BESS discharging). This range represents the normalized value of the DG or BESS output with respect to their rated power. Thus, the results of FIS 4 and 5 are relative coefficients of the nominal power of DG and BESS, respectively. The possible fuzzy rules that can be used in the FIS controllers are listed in Table 2. The fuzzy rules shown in Table 2 are simply generated as a combination of all the linguistic values of the input and output variables. These all possible fuzzy rules are generated by simply enumerating all combinations for three linguistic input values and three output values, resulting in nine possible fuzzy rules. One of the most important issues in the implementation of FIS is the definition of the fuzzy rules. The fuzzy rules are usually defined based on expert knowledge, correlations between input and output data, and physical laws (when a physical system is considered). The type of FIS input (current, active power, reactive power, or nodal voltage) is not known in advance in the proposed method. Rather, the type of FIS input is determined during the optimization process. For this reason, it is difficult to define the fuzzy rules based on the physical laws or mathematical rules that apply to the power flow calculation in the power system. The number of rules incorporated in the proposed FIS energy management block is limited to three fuzzy rules. Therefore, the optimization method tries to find three fuzzy rules for each FIS by selecting from nine possible combinations (Table 2). So, the optimization algorithm excludes three fuzzy rules from the set of all fuzzy rules ( Table 2) and implements them into the FIS (Figure 2).   The main objective of the proposed method is to find the optimal allocation and operation of DG and BESS in the design phase of the installation of DG and BESS in the power distribution network. The input data used to solve the optimization problem in the planning phase of the installation of DG and BESS are based on hystoric data. Therefore, once DG and BESS are installed (in the operational phase), the real data in the distribution network may differ from the data used for optimization. The proposed method overcomes this problem by proposing input variables for the FIS energy management system that are easily measurable in the grid operation. In the study, the optimized FIS energy management system is tested with input data that are completely different from the data used in the optimization to verify the generality and robustness of the proposed method. With this approach, it is possible to adapt the outputs of DG and BESS to the real conditions of the power system in the operational phase.

Application of the Proposed Procedure to the Test Power Distribution Network
The presented method for implementing the simultaneous optimization of the allocation of the DG and BESS and the parameters of the FIS-based power management system is applied to the IEEE 37-node distribution feeder [29]. The tested feeder has three-phase lines and unbalanced loads. Additionally, in this application, there are voltage regulators whose taps are fixed in the center position. A PV system, a wind turbine and a biogas plant DG and a BESS are also integrated into the original test grid. The power generation profiles of the PV and wind turbines DG are generated using the online tool [30]. The load profile of the consumers is created with the estimation tool [31]. The input data (load profile and DG generation profiles) are created at an annual level with hourly resolution, i.e., 8760 input data are used simultaneously to solve the optimization problem. With respect to the defined optimization problem in Section 2, the following ranges are used for the constraints: During the optimization, the solution space is explored with 5000 possible solutions. The number of power flow calculations for the 8760 input data used and 5000 solutions explored was 5000 × 8760 = 43,800,000. The computation time of the optimization process for the given data was about 125,000 s (34.7 h). Once the optimization process is completed, the calculation of the FIS output for the given input data is performed in a time of 1.9 ms. This means that in the implementation phase of the proposed FIS controller, the FIS outputs are actually generated in real time compared to the intervals of load and DG production changes (which can be considered at the minute, 15 min or hour level). The obtained optimal allocation of the units BESS and DG and the location of the measured variables for the FIS inputs are visualized in Figure 4. Table 3 shows the type of measured quantities for the FIS inputs obtained during the optimization, and Table 4 gives an overview of the obtained energy losses and exchange reductions for optimal solutions of (1). Table 5 shows the optimized fuzzy rules for each FIS used in the procedure ( Table 3). As mentioned at the beginning of the optimization procedure, the constraint of the three fuzzy rules per FIS is applied, and the optimized rules are found by the optimization process among the generic rules given in Table 2. The base case represents the situation without BESS and DG installed in the power distribution network.  Table 3. Optimized types of the physical quantities used as FIS inputs.  The power factor profiles for the period of a week for example weeks in year of PV, wind and biogas DG, profiles of PV and wind generation, profile of BESS charge/discharge and BESS SoC are shown in Figures 5-7.

Application of the Optimized FIS Energy Management System for Different Load Shapes
In the optimization phase, the parameters of the FIS energy management system are set to minimize the values of the objective function based on the input data. The actual input data in the FIS implementation phase in the system may be more or less different from the data used to optimize the FIS agent. For this reason, the optimally tuned FIS is tested for data that are different from the data used for optimization to check the generalization and robustness of the proposed method. The results of this testing step are presented in Table 6. The load curves used are denoted as L sh1 , L sh2 , and L sh3 for the load curve data used in the optimization and test step, respectively.

Discussion
The working hypothesis established at the beginning of the research was that it is possible to simulatively optimize the FIS energy management system and BESS and DG allocation using the co-simulation approach and computational intelligence techniques (such as fuzzy logic and metaheuristic optimization methods). Based on the results presented in the previous section, we can state that the hypothesis is proved. The optimization problem is very complex and involves the simultaneous treatment of different aspects of power/energy management in the smart grid concept, including different DG sources and BESS. The requirement that the optimization process be solved simulatively for a year horizon with 8760 data makes the problem even more difficult to solve. The obtained reductions of the defined objective functions show that it is possible to apply and tune the FIS-based energy management system for such a complex, defined optimization problem. It is quite difficult to find research papers that all have the same optimization problem, the same objective function, and the same decision variables. Moreover, the input data generated in different studies usually differ from each other, and the resolution of the data (e.g., constant load, monthly data, hourly data) is also different in the studies. Considering these facts, the results obtained here are compared with those of previous studies that considered a similar, but not the same, optimization problem of optimal BESS and DG allocation and power control. It should be noted that this study considers optimization of the allocation of BESS and DG, optimization of the generation of BESS and DG power profiles, optimization of the generation of DG power factor profiles, optimization of fuzzy power management, and optimization of input type for FIS in a single optimization problem. The PV, wind and biogas plants DG, BESS and hourly data resolution at the annual level are considered in this study. The following discussion briefly describes the similarities and differences between the optimization problem used here and the optimization problem used in other studies, as well as the main results. Based on the described differences in the studied optimization problem, the relative (percentage) loss reduction is discussed. In [17], only PV DG is considered without the BESS. The objective function is to minimize the losses. The input data are collected on 12 typical days (over one year) with minute resolution. The proposed method is applied to the example of IEEE 14-bus test network for data. The obtained results show a reduction in the network losses to about 38% compared to the losses for the base case (without installed PV DG). In [18], the objective function is to minimize the network losses. Two generic types of DG, type I and III, are used in the study. The constant outputs of load and DG are considered without using the time-varying outputs of load and DG production. The proposed method is applied to the distribution network IEEE with 123 busses and results in about 79% reduction in power losses, compared to the original power losses (without DGs). In [19], the optimal placement, sizing, and power factor of DG are studied. The variable load and DG generation profiles as well as the optimal allocation and power management are considered. The presented method is applied to a power distribution network consisting of 69 busses. The PV, wind and biogas plants DG are considered without installing BESS. The presented results show a reduction of energy losses in ranges (depending on the number of DGs) of 63-69% and 89-98% of the original energy losses for constant load and power factor one and constant load and optimized power factor, respectively. In the variable load scenario, the reduction in energy losses is in the range of 72-95% of the original energy losses (depending on the impact of the targets in the objective function). The study also considers the injection of active energy from the upstream grid. The results obtained for this objective are in the range of 60-90% and reduce the value of the base case (without DG installed). Our earlier study of optimal allocation and power control of DG [32] used the same tested distribution network and input data as this study. The earlier study did not consider the installation of BESS and proposed an artificial neural network to generate DG power profiles. In addition, the earlier study only considered line losses, not substation losses, which are considered in this study. The achieved reductions in annual losses and energy exchange in [32] are in the ranges of 47-92% and 74-95% of the energy losses and energy exchange in the base case, respectively. The study conducted here shows that annual energy losses could be reduced by 80% and energy exchange by 77% of the values without DG and BESS. In addition, it is important to note that a similar reduction in annual energy losses and energy exchange is achieved for load data other than those used in the optimization procedure-a reduction in losses of about 80% and a reduction in energy exchange of 92% and 86%, shown in Table 6.

Conclusions
The presented research shows that it is possible to solve a very complex power management problem in a modern power distribution system using computational intelligence techniques and co-simulation approaches. The presented method considers the influence of different controllable variables (location, output power, and power factor of DG and BESS) on the optimal allocation of DG and BESS, by including the optimization of DG and BESS outputs in the optimization problem. The co-simulation approach can be used with the goal of more detailed and realistic modeling of the power system under study. The co-simulation approach can facilitate the modeling of the power system for the purpose of optimization, but on the other hand, such an approach requires a high computational effort due to the use of metaheuristic optimization techniques. The obtained results show that the use of biogas DG, whose output can be controlled, dominates over the non-controllable ones, such as wind and PV DG. The optimization algorithm provides a solution for the size of the biogas plant equal to the upper limit (2000 kVA for the tested network) set in the optimization problem for the nominal power of the biogas DG. This shows that most of the losses are reduced by controlling the output of the biogas plant DG. Controlling the output power and operating condition of BESS and the power factors of the PV and wind biogas plants DG contribute much less to reducing annual losses.