Spotted hyena optimizer algorithm for capacitor allocation in radial distribution system with distributed generation and microgrid operation considering different load types

In this paper, the optimal allocation of constant and switchable capacitors is presented simultaneously in two operation modes, grid-connected and islanded, for a microgrid. Different load levels are considered by employing non-dispatchable distributed generations. The objective function includes minimising the energy losses cost, the cost of peak power losses, and the cost of the capacitor. The optimization problem is solved using the spotted hyena optimizer (SHO) algorithm to determine the optimal size and location of capacitors, considering different loading levels and the two operation modes. In this study, a three-level load and various types of loads, including constant power, constant current, and constant impedance are considered. The proposed method is implemented on a 24-bus radial distribution network. To evaluate the performance of the SHO, the results are compared with GWO and the genetic algorithm (GA). The simulation results demonstrate the superior performance of the SHO in reducing the cost of losses and improving the voltage profile during injection and non-injection of reactive power by distributed generations in two operation modes. The total cost and net saving values for DGs only with the capability of active power injection is achieved 105,780 $ and 100,560.54 $, respectively and for DGs with the capability of active and reactive power injection is obtained 89,568 $ and 76,850.46 $, respectively using the SHO. The proposed method has achieved more annual net savings due to the lower cost of losses than other optimization methods.

www.nature.com/scientificreports/ developed to solve convex and non-convex economic dispatch. The optimization results showed that the SHO is capable to solve the economic dispatch problems and this method can converge to global optimal with lower computational cost and better performance of the SHO in problem solution is proved compared with CSA and BBO. In 37 , deterministic and probabilistic allocation of wind energy resources in the distribution networks is presented with the aim of losses and voltage deviation reduction and also voltage stability enhancement using the SHO. The superiority of the suggested method is proved given better losses, voltage profile and stability with faster convergence speed and lower computational cost compared with PSO. In 38 , the SHO is applied for travelling salesman problems. The results indicated that the SHO provided the optimal solutions for travelling salesman problems and its superiority is confirmed compared with well-known GA, ACO, and PSO algorithms. In 39 , the SHO is developed for optimization of proportional integral derivative (PID) parameter in automatic voltage regulator (AVR) system. The obtained results showed the better performance of the SHO than the PSO, SCA, FPA and GWO algorithms given better convergence speed and accuracy. In 40 , the optimal power flow in microgrid based on renewable energy resources is presented using the SHO. The SHO is applied to the optimal determination of controller parameters due to voltage variations. The result cleared that the method based SHO is more effective than the other results especially the PSO. In 41 , the allocation of DGs with network reconfiguration is implemented in the distribution networks aimed with minimizing the losses and voltage deviations and the achieved results are compared with PSO and DE methods which the effectiveness of the SHO is confirmed. In 42 , the SHO is applied to resolve complicated nonlinear physical world tasks and the superiority of the SHO is confirmed with explorative strength compared to the other algorithms. In 43 , as can be seen from recent studies on the use of the SHO method to solve the optimization problems, it is a meta-heuristic algorithm with high power and rate of convergence compared with well-known algorithms. Moreover, the comparisons between the SHO and of other meta-heuristic methods showed that the SHO can handle different types of constraints and offer better solutions than the other optimizers. So, these advantages are main reasons for using the SHO to solve the optimization problem in this study. Moreover, the focus of capacitor allocation in a literature review is based on the objective function type and the use of new optimization methods. The literature review showed that the problem of capacitors placement and sizing along with the optimal allocation of distributed generation resources with the capability to be exploited as microgrids due to islanding is not well addressed in the literature review.
In most studies, the effect of locating these two devices has been done integrated with the whole network. Also, in the actual operation of the network, it is better to consider the effect of load changes as a light load, normal load and heavy load periods and to avoid considering the load as a constant. It is also more desirable to evaluate the effect of different types of load including constant power load, constant current load and also constant impedance load. A review of previous studies has shown that the effect of changes in load levels as well as load types together is not well addressed well. In this paper, the optimal allocation of capacitors in distribution networks is presented to minimize the cost using spotted hyena optimizer (SHO) 44 considering different levels and types of loads. The proposed method is implemented on the 24-bus network that the part of the network is disconnected from the network due to islanding state, which is supplied in the form of microgrids using the distributed generation resources. The system cost is considered as minimization of the energy losses cost, power losses cost in peak load conditions as well as installation, purchase and maintenance costs of the capacitor. DGs utilization is incorporated in two cases including with only active power injection and active and reactive power injection. In this study, three levels load including light, normal, and heavy loads and also different load types as constant power, constant current, and constant impedance are selected in the problem solution for the realistic operation of the network. The performance of the SHO in capacitor allocation is evaluated in two grid-connected and microgrid modes compared with the well-known GWO algorithm.
The highlights of the paper are presented as follows: • Optimal allocation of capacitors in distribution networks with the presence of distributed generations • Multi-criteria objective function as minimizing the costs of energy losses cost, power losses, and capacitor application • Distribution network operation in grid-connected and microgrid (islanding) modes • Problem solution incorporating three levels of the load and also different load types • Using of spotted hyena optimizer (SHO) for optimal allocation of capacitors in distribution networks • The superiority of the SHO compared to well-known GWO algorithm In "Problem formulation" section of this paper, the problem formulation, including load modelling, objective function, and optimization problem constraints, is presented. In "Proposed optimization method" section, the proposed optimization method and its implementation in problem solution are described. The simulation results are presented in "Simulation results and discussion" section, and the conclusion is presented in "Conclusion" section.

Problem formulation
In this section, the formulation of the optimal capacitor placement problem in DG-embedded distribution networks is presented. Also, the objective function and problem constraints are described.
Load model. In this study, three types of load are considered. The mathematical representation of active and reactive power loads is as follows 45  www.nature.com/scientificreports/ where (a 1 , b 1 ), (a 2 , b 2 ), and (a 3 , b 3 ) are the components of constant power, constant current, and constant impedance, respectively. For a constant power load, a 1 = b 1 = 1 and a 2 = b 2 = a 3 = b 3 = 0; for a constant current load, a 2 = b 2 = 1 and a 1 = b 1 = a 3 = b 3 = 0; and for a constant impedance load, a 3 = b 3 = 1 and a 1 = b 1 = a 2 = b 2 = 0.
Objective function. The objective function in this study is the cost, which has three terms. The first term is the cost of energy losses. The second term is the cost of losses in heavy loading condition, and the third term is the cost of installation and maintenance of the capacitor. This objective function can be represented as follows.
Energy losses cost. This section contains the total daily losses of energy at all three levels of loading and in two network performances or two scenarios i.e. connected to grid and islanding mode, which is shown below.
where, C e is energy cost ($/kWh), M is the number of load levels, N GC and N Is are the number of buses in grid-connected and islanded modes respectively, P j,GC loss and P j,Is loss i are the ith line losses in jth load level in gridconnected and islanded modes respectively (kW), T j is the period of load level j for 1 year (h) and P i,j is the probability of operation in islanded mode at the load level j.
Losses cost in peak load conditions. In peak conditions, the capacity of the lines is close to their maximum value and most of the equipment works at its maximum capacity. Hence, reducing peak losses can be very beneficial causing some parts of the equipment capacity to be empty and increase their lifespan. This section can be expressed as follows.
where the annual cost of energy is at the load peak ($/kWh-year), P peak,GC loss i and P peak,Is loss i are the number of losses at heavy load level in a network-connected and islanded mode.
Capacitor cost. In this study, both fixed and switchable capacitors are applied. These two types of capacitors include installation, purchase, and maintenance costs. The total cost of the capacitors is formulated as below: where M f and M s are the numbers of constant and switchable capacitors, C if and C is are the cost of purchasing and installing of constant and switchable capacitors ($),C vf and C vs are the repair and maintenance cost of constant and switchable capacitors ($/kVAR-year), Q fi and Q si refer to the amount of constant and switchable reactive power (kVAR) respectively. Problem constraints. The capacitor placement problem must be optimized subject to operational constraints. The most important constraints regarding this problem are the voltage magnitude of buses, transmitted power bylines, the amount of reactive power installed on the network and capacitor installation rates according to the available budget. These four constraints are listed below: where V i , V i,min and V i,max are the voltage of bus i, the minimum and maximum of allowed voltages, I i and I i,max are line current and the thermal limit of line i, Q j capacitor i and Q j Load i are the installed reactive power and consumed in the bus i and the load level j respectively, N refers to the number of buses, k represents the allowed percentage of installed reactive power, C capacitor is capacitor placement cost and AB is the total available budget of capacitor placement.

Proposed optimization method
In this section, the overview of spotted hyena optimizer (SHO) algorithm and its implementation in problem solution are described.
Overview of SHO. The behaviour of spotted hyena is sometimes similar to human social behaviour. They can fight tirelessly for food and life and usually live in tribes. Male hyena leaves their tribe when reaching puberty and join another tribe for an extended period. Interestingly, they use several sensory generators to recognise familiar people. Hyena informs each other by generating alarm sounds when reaching a new food source. The SHO method used in the present study is based on the hunting and social behaviours of these animals. The SHO can handle various types of constraints and offer better solutions than other powerful optimizers and also Does not get caught up in local optimal by increasing the number of problem variables as well as the complexity of the optimization problem and has high convergence speed and accuracy 44 .
Encircling prey. Other searching factors can be considered their best position related to the prey or target as the best response and update it. The mathematical model of this behaviour is expressed as follows 44 : where D h represents the distance between the spotted hyena and the prey, P P represents the position vector related to the prey, P represents the position vector of the spotted hyena, X represents the current iteration, and B and E represent the coefficient factor vectors 44 . Here, where rd 1 and rd 2 are random vectors in the range of [0, 1], and h can be linearly reduced from 5 to 0.
Hunting. The proposed SHO algorithm hunting strategy is described as follows 44 .
Here, P h represents the best position of the spotted hyena related to the prey, and P k represents another position of the spotted hyena. N represents the total number of spotted hyena and is calculated as follows.
Here, M represents a random vector in the range of [0.5, 1], nos represents the number of answers (the reference answers are counted), and C h represents a group of N optimal answers. Attacking prey (exploitation). The mathematical formula for attacking prey can be defined as follows 44 .
Here P (x + 1) saves the best pass and updates the positions of other factors relative to the position of the best search factor.

Search for prey (exploration).
To identify the correct answer, E must be > 1 or < 1, according to Eq. (19).
The other part of the SHO algorithm, which makes exploration possible, is B. Vector B contains random values that provide the prey's random weights according to Eq. (20). Suppose that the B > 1 vector has priority over the B < 1 vector to show more random behaviour of the SHO algorithm and the effect of the distance 44 .
The SHO implementation. The steps of implementing the SHO in problem solution are presented: www.nature.com/scientificreports/ Step 1. Set optimization parameters such as population size, number of maximum iterations and repetition, number of variables (location and size of capacitors) and the variables constraint.
Step 2. The initial population matrix is then generated. Each row represents a member of the population, and each column represents the bus number in which the capacitor is installed (The priority is to install the capacitor in the bus with higher loss sensitivity, which is detected by the optimization program).
Step 3. Calculate the objective function (Total cost) considering the constraints per member Step 2 and the hyena with the lowest cost is selected as the representative in this step.
Step 4. The SHO population is updated to achieve the next position using a continuous variable.
Step 5. Round all members for moving to discrete search space to the nearest integer and also recalculate the objective function considering the constraints for all members. If the value of the new member's objective function is better than the value obtained in Step 3, replace with it.
Step 6. In this step (termination criterion) if the number of iterations exceeds the maximum iterations number, the SHO will be stopped and otherwise it will return to step 4.
Finally, the results include the location and size of fixed and switchable capacitors, power loss and minimum network voltage at each load level in both islanding and grid-connected operation and the cost before and after capacitor installation are provided.

Simulation results and discussion
In this section, simulation results of optimal allocation of capacitors in distribution networks with non-dispatchable distributed generations are presented with operation capability as a microgrid to minimize cost using the gray wolf optimizer algorithm, considering the levels and types of load. The objective function of simulation is considered as minimization of energy losses costs, peak power losses and capacitor utilization and the proposed method is implemented on a 24-bus network. The basic objective of the capacitor allocation is power losses minimization in the distribution network. This objective determines the best locations for capacitors to be installed to obtain the minimum losses while the other places may not achieve this objective. This objective can be defined as the sensitivity of active power loss to reactive power injection at a bus. So the buses with higher sensitivities are selected as candidate bus for capacitor installation by the optimization program in this study. Further explanation of this is given in detail in Ref. 18 . The simulation results are presented in two operation modes of grid-connected and islanded (for microgrid), and the results before and after the optimization are investigated. Also, to verify the SHO method, the results were compared with GWO and also the results have been compared with the reference 45 which the GA is employed to problem solution. The single-line diagram of the 24-bus network is shown in Fig. 1. According to Fig. 1, a part of the 24-bus test case has distributed generation resources, which is called the microgrid section due to islanding state. The distributed generations are applied in two modes with unit power factor without the capability of reactive power injection and non-unit power factor with reactive power injection  Simulation results at cosφ = 1. In this section, it is assumed that distributed generation sources operate with a unit power factor and generate only active power. The convergence curve of SHO and GWO methods is presented in Fig. 2. As shown in Fig. 2, the SHO method has a lower cost than the GWO for capacitor placement. Also, statistic analysis of different algorithms performance with cosφ = 1 due to 25 repetition is presented in Table 4. According to the obtained results, the SHO is achieved to lower-cost given Best, Mean, Worst and standard deviation (STD) values compared with the GWO.
The optimal location and sizing results of the capacitors by various methods of optimization in the 24-bus network are presented in Table 5. The SHO methods installed 2100 kVAR capacitors, at the second level (normal loading) and at the third level (heavy loading) too and also 1650 kVAR placed in normal and heavy loading by GWO. At the first level (light loading), SHO placed 1650 kVAR and GWO installed 1950 kVAR capacitor. In contrast, the GA method 20 also installed 1650, 1500, and 2100 kVAR capacitors, at the first to third levels, respectively. So, the SHO has a value of 5850 kVAR, and GWO and GA methods each have a total of 5250 kVAR capacitor placement in the network. Various values of cost in the 24-bus network before and after the capacitor placement are given in Table 6. Before capacitor placement, the cost of network losses is 150,425.5 $ which after capacitor placement the amount of this cost in SHO, GWO, and GA 14 methods is 59,447 $, 61,120 $, and 61,422.222 $, respectively. Total cost amount before capacitor placement is 206,340.54 $, which was reduced to 105,780, 106,310, and 107,228.51 after applying the capacitor by SHO, GWO and GA method 20 respectively. Also, annual savings by SHO method are more than the other methods. Therefore, the SHO has better performance on reducing the cost of losses than the other methods.   Table 3. Transformers and load information 20 . www.nature.com/scientificreports/   Table 5. optimal capacitor placement on 24-bus network with cosφ = 1. www.nature.com/scientificreports/ According to Table 6, spending $ 24,886 annually for SHO's capacitor utilization has led to saving and reducing costs up to approximately 100,560.54 $. The existence of capacitors in the network will reduce losses and improve the voltage profile, and this loss reduction will be accompanied by a reduction in the cost of purchasing power from the upstream network. On the other hand, the cost of installing and maintaining of capacitors compared to a reduction of losses cost is much less. It should also be noted that the lifetime of the capacitors is relatively high and the cost of installing these capacitors will only be in the first year, which could be another reason for the proper operation of this equipment in reducing network costs. To better see the results and performance of the presence of capacitors in the network, the losses amounts, as well as the minimum network voltage before and after the presence of capacitors at different load levels in Tables 7 and 8, are presented in scenarios of connected to the network and islanding mode, respectively. According to Tables 7 and 8, in both scenarios, the presence of capacitors in the network has had a significant positive effect on the reduction of losses, as well as the improvement of the minimum voltage. In Table 8, the performance of the SHO method was compared with the GA method, which confirmed the performance of the proposed method in reducing the losses and improving the minimum voltage of the grid compared to the GA method.

Bus number
The voltage profiles of the 24-bus network in the grid-connected mode and at the heavy load with cosφ = 1, before and after the capacitor placement are compared in Fig. 3. As it is clear that, the voltage profile is better after the capacitor placement in the network than the base state.
Simulation results with cosφ#1. In the second case, it is assumed that distributed generation sources also can generate reactive power and operate under the power factor of 0.95 lag. The convergence curve in this case is also given in Fig. 4, which indicates the achievement of a lower cost value by the SHO method than the GWO method. The value of the cost objective function is obtained by the SHO proposed method equal to Table 6. Different cost sections in the 24-bus network before and after the capacitor placement with cosφ = 1.

Parameter
Before cap placement  www.nature.com/scientificreports/ 89,568 $ and by the GWO method is 90,423 $ which is obtained by the GA in 45 equal to 103,098.5$. Therefore, the results indicate that the SHO method is superior to the GWO and GA methods. Also, statistic analysis of different algorithms performance with cosφ#1 due to 25 repetitions is presented in Table 9. According to the obtained results, the SHO is achieved to lower cost in view of Best, Mean, Worst and standard deviation (STD) values compared with the GWO. It is clear that due to reactive power injection, in this case, the cost of the capacitor placement is greatly reduced. Also, in this case, the total cost of the system, including the cost of losses and peak losses is severely reduced. Therefore, it can be concluded that the participation of distributed generation resources in the    www.nature.com/scientificreports/ production of reactive power can greatly reduce network costs. The optimal placement of the capacitors in the 24-bus network is presented in Table 10. All three optimization methods have placed the 1650 kV fixed capacitor in the network. At Level 2, the SHO, GWO, and GA 45 have placed 600, 300 and 1500 kVAR capacitors respectively on the network, and at the third level, have respectively placed, 600, 300 and 2100 kVAR capacitors in the network. In Table 11, the cost of losses, peak losses, cost of capacitor placement, the total cost as well the amount of annual saving is presented. The results show that the cost of losses and cost of peak losses in SHO method decreased more than GA and GWO methods and in total, the annual amount of savings by the SHO was 76,850.46 $. According to Tables 12 and 13, it is observed that in grid-connected and islanded modes the network losses are reduced considerably in different loads using SHO. Also, the network minimum voltage is improved in different loading condition. Also, the SHO method is better in both the network connection scenario   www.nature.com/scientificreports/ and the islanding scenario than the GWO method for reducing losses, as well as the minimum voltage levels at different load levels. The losses and the minimum voltage before and after the capacitor placement in the mode of connected to the network in the second mode at different load levels are given in Table 12.
The voltage profiles of the 24-bus network in the grid-connected mode and at the heavy load with cosφ#1, before and after the capacitor placement are compared in Fig. 5. As it is clear that, the voltage profile is better after the capacitor placement in the network than the base state.
Simulation results considering different types of loads. In this section, the effect of different types of loads including constant power, constant current and constant impedance on the cost of losses, cost of energy losses and total annual cost using the SHO method has been studied. In addition to considering the three-level load, different types of load are also included in the problem. Different amounts of cost in a network obtained for different types of loads in the mode of cosφ = 1 and cosφ#1 in Tables 14 and 15 are presented, respectively. According to the results obtained in both cases, the amount of annual cost of the system, the cost of losses of power, energy losses and the cost of the capacitor placement in the constant power load is less than the other types of load. Also by comparing the results in two modes cosφ = 1and cosφ#1, it can be observed that the cost of annual losses, the cost of losses of power, the cost of peak losses, as well as the cost of the capacitor due to the injection of reactive power in the case of cosφ#1 has been reduced. The annual cost reduction in constant power loads, constant current and constant impedance loads was 15.32, 15.92 and 10.79%, respectively.   www.nature.com/scientificreports/

Conclusion
The optimal allocation of capacitors for distribution network operation is studied in researches to compensate the reactive power. Of course, due to the occurrence of the islanding state in distribution networks, capacitors allocation requires more care and consideration. Therefore, the islanding state of the network can be one of the limitations in the problem solution, which in this study is well addressed and the optimization program must be able to manage the provision of the microgrid load demand in islanding state. In addition, changing of the network load level, as well as observing the voltage range of the buses and the current of the network lines are the other limitations of the study in islanding state. Therefore, using an intelligent and flexible methodology in islanding conditions is critical for problem solution as well as microgrid load supply based on distributed generation sources. In this paper, the optimal allocation of the capacitor for a distribution network in the presence of a microgrid including DG resources is presented using SHO algorithm. Optimal placement of fixed and switchable capacitors is implemented to minimize energy losses, peak losses, and capacitor costs in two grid-connected and islanded modes, considering different load levels. Non-dispatchable distributed generations are considered in two modes: generation and non-generation of reactive power. To solve the optimization problem, the grey wolf algorithm is employed to solve the problem and its implementation on a 24-bus test network. Simulation results are presented in two grid-connected and islanded modes. The simulation results showed that the SHO is a powerful method with high convergence speed for achieving the optimal solution to the problem with the lowest total cost compared to the GWO and GA methods. The total cost value for DGs only with the capability of active power injection is achieved 105,780 $ and 106,310 $ using the SHO and GWO, respectively. Also, this cost for DGs with the capability of active and reactive power injection is obtained 89,568 $ and 90,423 $ using the SHO and GWO, respectively. Moreover, the annual net savings are higher with the SHO method than with the other methods. Furthermore, the results showed that in the case of reactive power injection by distributed generations, the cost of the capacitor placement dropped sharply, and the total cost of the system decreased significantly. Therefore, we conclude that the participation of distributed generations capable of reactive power injection can reduce network costs. The results also cleared that the total cost, loss cost, and peak loss of power in constant power load are less than in the other types of loads. According to the study conducted in this paper, evaluation of power quality indices in islanding conditions is suggested for future work.
Received: 10 November 2020; Accepted: 13 January 2021 Table 15. Different amounts of cost in the network after the capacitor placement in the mode of cosφ#1.