Optimal Solution for Frequency and Voltage Control of an Islanded Microgrid Using Square Root Gray Wolf Optimization

: Voltage and frequency deviation in the islanded operation of a microgrid (MG), due to the uncertainty and lack of inertia in the selection of optimal proportional integral (PI) controller gain, is a challenging task. Although various optimization algorithms have been proposed to achieve this task, most of them require a large number of iterations and are time intensive, making them inefﬁcient for real-time applications. Gray wolf optimization (GWO), a new meta-heuristic algorithm, addresses these issues and has many advantages, including simplicity due to fewer control parameters, ﬂexibility, and globalism. This paper proposes a simple and efﬁcient modiﬁed algorithm, called square root gray wolf optimization (SRGWO) algorithm, to realize superior hunting performance. SRGWO is veriﬁed using twenty-three benchmark test functions. The algorithm is applied for optimal voltage and frequency regulation of a photovoltaic-based microgrid system operating in the islanded mode during distributed generation insertion and load change conditions. The voltage and frequency gain parameters of the PI controller are optimized. A comparison of the simulation results of the SRGWO algorithm with those of the original gray wolf algorithm (GWO), particle swarm optimization (PSO), augmented gray wolf optimization (AGWO), enhanced gray wolf optimization (EGWO), and gravitational search algorithm (GSA) reveal that the proposed SRGWO algorithm signiﬁcantly improves system performance while maintaining its simplicity and easy implementation. Furthermore, the SRGWO algorithm obtains the minimum ﬁtness function value in fewer iterations than other algorithms. Moreover, it improves the power quality of the system with regard to minimum total harmonic distortion.


Introduction
Nowadays, power systems depend on utility. Heavy power loss often occurs at peak hours. In order to avoid such power loss, ensuring the stability of power generation stations is crucial [1,2]. The demand side management of smart grids allows the customer to control their power consumption depending on their load conditions and services [3]. Microgrids (MGs) are constantly connected to the primary electrical grid under normal conditions, and when a shortage of power occurs, they disconnect to an isolate mode. One of the most important features and advantages of using a microgrid is its ability to be islanded and operate independently. The advantage of island mode lies in its abillity to improve the reliability and power quality of real customers in the MG [4]. It consists of renewable and non-renewable energy resources. The loads in the distribution system, are able to operate both as grid-connected and islanded modes [5]. The voltage and frequency of the system are controlled by the power grid in the grid-connected mode operation. Distributed generators (DGs) inject almost fixed power to the grid [6], which contributes to the economic and secure operation of the power system [6,7]. Generally, voltage and frequency instability is attributed to the large deviation between generated electrical energy and utilized power [8]. Some control strategies with efficient algorithms have been developed for the stability of voltage and frequency to ensure the durability of services [9]. In both modes, the acceptable levels of main parameters can be achieved with respect to the power excellence of the MG [10]. In a conventional power system, the voltage and frequency control can be achieved easily because mostly the power consumption side produces the uncertainties. By contrast, in MGs, due to the difference in power generation and load, functional complexity, structural variation, and changing the nature of renewable energy sources (RES), controlling the voltage and frequency is a complex task [11,12]. Conventional regulators cannot deliver acceptable achievements in some serious functioning situations given the rapidly changing operating conditions of MG. Therefore, voltage and frequency control require a powerful and intelligent controller in an islanded MG [13].
Because the voltage and frequency variations of MG occur mostly in the islanded mode rather than the grid-connected mode, an effective control scheme should be able to sustain the reliability and quality of power supply to the load throughout. The main objective is to preserve, within the acceptable limit, the voltage and frequency of the MG in the islanded mode. There are two power control strategies in the DGs: the voltage-frequency control strategy in the islanded mode, or the active-reactive power control strategy in the grid-connected mode. Several control schemes using different algorithms have been proposed to regulate the frequency and voltage of the MG [14]. But the frequency and voltage of the MG in islanded vary and need autonomous control [5]. In [15], the control loop of power was achieved by the control of the first loop. In [16], a control loop of voltage was used for controlling the main parameters of the MG islanded mode. The reference voltage and reference frequency were received from the voltage controller to the current control loop by reducing the voltage variation using proportional integral (PI) controllers. However, a major drawback of PI controllers is their partial execution because they depend on the precise tuning of their gain coefficients (K p and K i ), which are either established as static during the procedure or calculated to obtain dynamic values. When the static PI gains controller is employed for a voltage control loop, the adaptive or "trial and error" technique [9,17,18] and the Ziegler-Nichols technique [19][20][21] can be used to determine the gain parameters. However, the use of these methods adds to the total time spent in control activities, which might result in considerable delays in unstable operating areas. Hence, the suitable tuning of PI gains is extremely important to improve system efficiency. Nowadays, artificial intelligence (AI) has been adapted into an advanced method to improve the changeable response of MG systems [22,23]. AI-based controllers employed on MG systems confirm better combination and separation of DGs in present electrical grid systems, improve the voltage and frequency of transient response throughout changing the loads, enhance end-user electrical energy control, and ensure transient stability of the MG system. Furthermore, intelligent research methods obtaining optimal solutions yield better problem-solving results than traditional mathematical techniques [24]. Various AI-based techniques have been developed to control the voltage and frequency of MG systems. Further, these techniques did not utilize time-intensive and insufficient conventional PI tuning techniques; for example, fuzzy logic (FL) [25], genetic algorithms (GAs), [24,26], particle swarm optimization (PSO) [13,24], and gravitational search algorithms (GSAs) [14,27,28].
However, AI-based algorithms such as GA, PSO, and FL have a few disadvantages. For instance, GA solves the local convergence rather than solving the global, which requires the translation of groups of dynamic data in the modern MG controls into conventional optimization techniques [15]. PSO also results in a small amount of convergence in the reiterative procedure, limited by a local minimum in a large space [29] and the ambiguity in the choice of its parameters [30]. Although it works relatively well during the initial iterations, optimal results cannot be obtained within limited reference functions [31,32]. Great improvement in heuristic algorithms has inspired researchers to apply them in different fields of power system optimization. Grey wolf optimization (GWO) is the latest successful meta-heuristic algorithm that emulates the gray wolf societal pecking order demeanor. A pack of gray wolves, of an average pack size of five to twelve, are categorized as top predators, who fully trust the leadership chain and hunting demeanors [33]. Enhanced gray wolf optimization (EGWO) uses parameter α, a random number having a value within 0-1, and an alpha search agent. However, the alpha is not suitable for the higher order of the gray wolves' performance and will lead to inactivity in certain local solutions [34]. Modified GWO (mGWO) is a balanced exchange of the exploration and exploitation in original GWO algorithm. However, its suitability for power systems is questionable [35]. Augmented gray wolf optimization (AGWO) is an improved GWO algorithm with regard to exploration and exploitation. To avoid stagnation, exploration is enhanced by making nonlinear reducing parameters from 2-1. The exploitation is expanded by updating search agent rankings with the average positions of the alpha (first best ranking) and the betas (second best ranking) [36]. However, this algorithm is very slow and can be implemented only on the grid-connected mode.
This study proposes a novel modified GWO algorithm called square root gray wolf optimization (SRGWO), which shows improved performance without compromising its interpretability and robustness. The SRGWO algorithm is an efficient meta-heuristic algorithm that emulates the gray wolf societal hierarchy demeanor. Firstly, the proposed algorithm was verified with twenty-three benchmark functions and achieved better results than other algorithms. The proposed algorithm solves the problem of determining optimal parameters of PI controllers to control the voltage and frequency of the MG in an islanded mode under the conditions of inserting the DG and changing the load. To confirm the efficiency of this method, its performance for voltage-frequency regulation was compared with the performance of the regulators of GWO, AGWO, and EGWO under similar working conditions. Further, the combination of SRGWO and the PI controller was used to design the islanded MG system using the voltage and frequency regulate technique. To the best of our knowledge, this is the first time the tuning of the PI controller with SRGWO has been attempted. To achieve the basic advantage of both controllers, SRGWO was used to tune the control parameters of the PI controller in this work. Herein, as a replacement for gain arrangement, the gains of the controller were tuned according to the operating situations. The effective strategy of using a PI controller for advance power systems meets the following stipulations:
Least sensitive to MG uncertainties 4.
Adjustable and flexible in tuning the parameters according to system operating situations.
To ensure that the proposed system meets these specifications, the performance of the proposed controller for the MG system under various operating scenarios was analyzed. Furthermore, the accomplishment of the proposed controller was compared to the numerous powerful methods in the literature.
The main contributions of this paper are as follows: 1. GWO was modified and analyzed with respect to the standard benchmark functions, comparing with the main GWO algorithm and additional modified GWO, PSO, and GSA algorithms.

2.
The parameters of PI controller were optimized using the proposed SRGWO algorithm.

3.
The PI controller parameters tuned with SRGWO were implemented for the voltage and frequency control of an islanded MG system, and its performance was compared with original GWO, AGWO, and EGWO.  4. The robustness of the proposed controller against RES uncertainties and MG uncertainties with diverse operating scenarios in a single framework was tested.
The paper is ordered as follows. The original GWO is described in Section 2. The novel GWO algorithm and tested benchmark functions are described in Section 3. The MG and mathematical modeling of the three-phase islanded technique, along with its control architecture, are explained in Section 4. In Section 5, the problem formulation is described. In Section 6, the results and discussion are presented. Finally, conclusions are presented in Section 7.

Grey Wolf Optimization Algorithm
A modern meta-heuristic algorithm is known as the GWO algorithm, and mimics behavior of the gray wolves, which live in packs with an average of five to twelve members. In the gray wolf pack, a rigorous pecking order is exercised, wherein the pack has a captain named the alpha (α), accompanied by inferior wolves named betas (β) that help the alpha (α) in decisions, along with δ and ω, as illustrated in Figure 1 [33,37].
2. The parameters of PI controller were optimized using the proposed SRGWO algo rithm. 3. The PI controller parameters tuned with SRGWO were implemented for the voltag and frequency control of an islanded MG system, and its performance was compared with original GWO, AGWO, and EGWO. 4. The robustness of the proposed controller against RES uncertainties and MG uncer tainties with diverse operating scenarios in a single framework was tested.
The paper is ordered as follows. The original GWO is described in Section 2. The novel GWO algorithm and tested benchmark functions are described in Section 3. The MG and mathematical modeling of the three-phase islanded technique, along with its contro architecture, are explained in Section 4. In Section 5, the problem formulation is described In Section 6, the results and discussion are presented. Finally, conclusions are presented in Section 7.

Grey Wolf Optimization Algorithm
A modern meta-heuristic algorithm is known as the GWO algorithm, and mimic behavior of the gray wolves, which live in packs with an average of five to twelve mem bers. In the gray wolf pack, a rigorous pecking order is exercised, wherein the pack has a captain named the alpha (α), accompanied by inferior wolves named betas (β) that help the alpha (α) in decisions, along with δ and ω, as illustrated in Figure 1 [33,37]. The method of chasing a quarry using grey wolves is conducted in four parts: prob ing for the quarry, encompassing the quarry, then chasing and attacking it. The exac model of encompassing quarry is articulated as follows: where the position vector of the gray wolf is denoted by ⃗⃗⃗ , the position vector of th quarry is denoted by ⃗⃗⃗⃗⃗ and t represents the current iteration. The coefficient vecto and the coefficient vector are calculated as follows: The method of chasing a quarry using grey wolves is conducted in four parts: probing for the quarry, encompassing the quarry, then chasing and attacking it. The exact model of encompassing quarry is articulated as follows: where the position vector of the gray wolf is denoted by → X i , the position vector of the quarry is denoted by → X pi and t represents the current iteration. The → A coefficient vector and the → C coefficient vector are calculated as follows: where, r 1 and r 2 are uniformly and randomly distributed vectors ranging from 0-1. The convergence factor → α represents a value that gradually reduces from 2-0 through iteration (t), and iterates until it reaches maximum iteration (Max: iter). The probing of the quarry position could be attained using the discrepancy of exploration agents, which could be attained while |A| > 1. The exploitation of the quarry could be obtained from the converging exploration agents that is studied when |A| < 1. The hunting is controlled through agent α, and with complete assistance from agents β and δ, as follows: Electronics 2022, 11, 3644 5 of 23 where, → X αi represents the position vector of the α wolf, → X βi represents the position vector of the β wolf, and → X δi is the position vector of the δ wolf. → X t+1 represents the updated position of the gray wolves.

Square Root Grey Wolf Optimization Algorithm
The massive power system applications, such as islanded-mode PV solar plants, are nonlinear models, and it is therefore hard to catch the transfer function for optimum performance. Thus, the online optimization of electrical power systems is the best other solution in place of the transfer function. Thus, similar to many proposed algorithms such as PSO, the GWO algorithm can be enhanced and adapted for better performance in exploration and exploitation in various technical field applications. Moreover, concerning the optimization methods based on population, the most appropriate way to converge towards the global minimum may have a two-phase division, fundamentally. During the initial optimization stages, the individuals can be stimulated to scatter through the entire search space.
During the later phase, the individuals should utilize information collected to converge on the global minimum. The current study proposes a novel modification in order to enhance the probing capability of the GWO algorithm, which is called square root gray wolf optimization (SRGWO). With the help of fine adjustment of the parameters Normally, higher exploration of search space produces lower probabilities in order to improve the exploration rate in which exponential functions are employed in place of linear function for decreasing the value of → a over the course of iterations. It is likely that over-exploration may produce excessive randomness and fail to submit ideal optimization results. Similarly, excessive exploitation has been found to produce insufficient randomness and fails to yield effective optimization results. Hence, for the sake of ideal optimization results, a balance between exploration and exploitation appears to be fundamental. The proposed algorithm uses the function of square root for the decay of → a over the course of iterations. In SRGWO, all parameters must measure for exploration and exploitation in parameter → A, which mostly relies on parameter → a , as is the case in (4). In the proposed algorithm, the parameter varies nonlinearly and randomly from 2-1 as in (9). Hence, the possibilities of exploration state and exploitation state are balanced.
Electronics 2022, 11, 3644 6 of 23 Hunting and decision-making rely on the modernizing of alpha (α), beta (β) and delta (δ) in GWO algorithms as in 6-8. However, the hunting will depend only on the two top members α and β in the proposed SRGWO algorithm, as follows:

Benchmark Functions
The 23 standard benchmark functions were tested using the proposed SRGWO algorithm. In [33], all 23 benchmark functions were given in tabular form. The GWO, PSO, AGWO, EGWO, and GSA algorithms were compared with the proposed algorithm for all benchmark functions. In every simulation, the search agents and maximum iterations were 30 and 500, respectively, and the executions number is thirty times to calculate average and standard deviation of all algorithms, which are given in Tables 1-3. Simulation results are shown in Table 1, where the proposed SRGWO algorithm achieved the five best results of seven. Hence, the obtained results verified the exploitability of the proposed algorithm over other nominated algorithms. The obtained results presented in the other two tables illustrate that the proposed algorithm is enhanced in exploration mode compared with the five other algorithms. The convergence characteristics of the SRGWO algorithm was compared with other algorithms, as illustrated in Figure 2. Furthermore, the SRGWO algorithm achieved the best results for 12 out of 23 benchmark functions, while the PSO and GSA algorithms achieved the best results for 4 out of 23, and the GWO algorithm achieved the best results for 3 out of 23. Lastly, the AGWO and EGWO algorithms achieved the best result for 1 out of 23 functions, as shown in Tables 1-3. The high-dimensional nature of the benchmark functions were mostly verified, and the proposed algorithm obtained results that were better than the other algorithms, as shown in Table 1. Further, Tables 1 and 2 shows unimodal and multimodal functions. The gray color boxes indicate the best results. Moreover, Table 3 shows the evolution of functions F14-F23 for fixed dimensions of multimodal functions.    A statistical test based on the non-parametric sign test [37] was used to evaluate the proposed SRGWO algorithm against GWO, PSO, AGWO, EGWO, and GSA. The nonparametric symbols "-", "+", and "≈" demonstrate whether the presentation of SRGWO is statistically inferior to, superior to, or similar to the second optimizer, respectively, in Table 4. Hence, as Table 4 shows, the results' difference verified the superiority of the proposed algorithm compared with the others. The total non-parametric sign test result was 115. The number of results for "+" was 60/115, for "-" was 46/115, and for "≈" was 9/115. A statistical test based on the non-parametric sign test [37] was used to evaluate the proposed SRGWO algorithm against GWO, PSO, AGWO, EGWO, and GSA. The nonparametric symbols "-", "+", and "≈" demonstrate whether the presentation of SRGWO is statistically inferior to, superior to, or similar to the second optimizer, respectively, in Table 4. Hence, as Table 4 shows, the results' difference verified the superiority of the proposed algorithm compared with the others. The total non-parametric sign test result was 115. The number of results for "+" was 60/115, for "-" was 46/115, and for "≈" was 9/115.

Microgrid Modelling
An MG is essentially a group of loads that are delivered from small sources of energy, e.g., wind turbines, microturbines, solar photovoltaics, and fuel cells, working as the only controlled system that is able to deliver heat and energy to the definite part [38]. In addition, for the grid-connected mode with MG running the main grid, the voltage and frequency of the system is regulated using a huge electrical system. In addition to keeping the load balanced, regulating frequency and voltage is very important for MG operation in islanded mode [39]. This is due to the fact that in MG systems with huge infiltrations of DGs, high voltage and frequency fluctuations can occur throughout the insertion of DGs or load changes. Furthermore, the control system of MG confirms, as a prerequisite, the absence of huge circulating reactive currents from small energy sources. The minor errors at fixed points of voltage and frequency due to circulating currents exceed the level of small energy sources [40]. High-switching frequency pulses and problems of power quality are issues owing to the application of power electronic converters [41]. Therefore, MG faces serious problems related to power quality, especially when assimilating a large number of DGs [42,43]. It is relevant to indicate the nonexistence of instability and ambiguity in the sample of optimal PI parameters. Further, these parameters are utilized to gain control amplifications due to huge deviations in power, voltage, and frequency level in the islanded mode. Hence, in this research, we discuss these issues as well as improve MG's achievements in the islanded operating approach.
This section may be divided by subheadings. It should provide a concise and precise description of the experimental results, their interpretation, as well as the experimental conclusions that can be drawn.
The active and reactive power delivered by DGs are determined based on systematic values of voltage and current. The droop controller only generates the reference voltage and frequency for the voltage controller, which produces the reference current for the current controller [44]. Lastly, space vector pulse width modulation (SVPWM) creates controlled signals to deliver the power as either active or reactive to the load within nominal frequency. Further, SVPWM also control the supply voltage to the three-phase voltage source inverter (VSI). Figure 3 illustrates a block diagram of the MG islanding mode. This section may be divided by subheadings. It should provide a concise and precise description of the experimental results, their interpretation, as well as the experimental conclusions that can be drawn.
The active and reactive power delivered by DGs are determined based on systematic values of voltage and current. The droop controller only generates the reference voltage and frequency for the voltage controller, which produces the reference current for the current controller [44]. Lastly, space vector pulse width modulation (SVPWM) creates controlled signals to deliver the power as either active or reactive to the load within nominal frequency. Further, SVPWM also control the supply voltage to the three-phase voltage source inverter (VSI). Figure 3 illustrates a block diagram of the MG islanding mode.  According to Figure 3, , are output voltages; , are output currents in the direct-quadrature (d-q) form; DC capacitance is denoted by C;

DC-DC
is the resistance perphase; is the capacitance per-phase; and is the inductance per-phase of the output filter. The three-phase MG voltage and current are represented by and , respectively; angular frequency is denoted by and at the grid output voltage, it is denoted by ; the active power and reactive power are denoted by p and q, respectively; the nominal voltage and nominal frequency are denoted by and , respectively; reference voltage and frequency are denoted by * and * , respectively; * , * are the reference currents and * , * are the reference voltages in the d-q form; the equivalent voltage signals are denoted by and β in the αβ form. The power circuit dynamics of the MG system under study was mathematically modeled with the help of the Park's transformation, which is determined by the equations of state space as follows [34]: According to Figure 3, v d , v q are output voltages; i d , i q are output currents in the direct-quadrature (d-q) form; DC capacitance is denoted by C; R f is the resistance perphase; C f is the capacitance per-phase; and L f is the inductance per-phase of the output filter. The three-phase MG voltage and current are represented by v abc and i abc , respectively; angular frequency is denoted by ω o and at the grid output voltage, it is denoted by V g ; the active power and reactive power are denoted by p and q, respectively; the nominal voltage and nominal frequency are denoted by v n and f n , respectively; reference voltage and frequency are denoted by v * and f * , respectively; i * d , i * q are the reference currents and v * d , v * q are the reference voltages in the d-q form; the equivalent voltage signals are denoted by v α and v β in the αβ form.
The power circuit dynamics of the MG system under study was mathematically modeled with the help of the Park's transformation, which is determined by the equations of state space as follows [34]: where, v a , v b , v c and i a , i b , i c represent the per-phase voltage and current, respectively. v vd , v vq represent the output voltage of the filter. i vd , i vq represent the output current of the filter.

Voltage and Frequency Control Model
In the islanded mode of an MG, the main grid is not connected to the MG throughout course of its operation. The controlled pulses produced by the control circuit are provided to the VSI. Then, a smooth sinusoidal waveform of voltage is created, which supply the produced energy from DG to load. The PI controllers have two gains: one is proportional gain (Kp) and other is integral gain (Ki). Both gains are tuned by the SRGWO algorithm to improve the dynamic response of the MG system. The block diagram of the strategy of control is shown in Figure 4. where, , , , , represent the per-phase voltage and current, respectively. , represent the output voltage of the filter. , represent the output current of the filter.

Voltage and Frequency Control Model
In the islanded mode of an MG, the main grid is not connected to the MG throughout course of its operation. The controlled pulses produced by the control circuit are provided to the VSI. Then, a smooth sinusoidal waveform of voltage is created, which supply the produced energy from DG to load. The PI controllers have two gains: one is proportional gain (Kp) and other is integral gain (Ki). Both gains are tuned by the SRGWO algorithm to improve the dynamic response of the MG system. The block diagram of the strategy of control is shown in Figure 4.
In Figure 4, is measured voltage and is measured frequency; the voltage error and frequency error are denoted by and , respectively; the nominal voltage and nominal frequency are denoted by and , respectively. ITAE is the abbreviation of integral time absolute error, while LPF is the abbreviation of low pass filter. Initially, the DGs have to generate the voltage and current signals measured in the main grid. Afterwards, these signals are changed to the reference d-q form through Park's transformation using the equation as follows: The generated active power and reactive power of DGs is already converted to d-q form. Hence, the consumed power in the form of d-q, is determined as follows [24]: In Figure 4, v m is measured voltage and f m is measured frequency; the voltage error and frequency error are denoted by e v and e f , respectively; the nominal voltage and nominal frequency are denoted by v n and f n , respectively. ITAE is the abbreviation of integral time absolute error, while LPF is the abbreviation of low pass filter.
Initially, the DGs have to generate the voltage and current signals measured in the main grid. Afterwards, these signals are changed to the reference d-q form through Park's transformation using the equation as follows: The generated active power and reactive power of DGs is already converted to d-q form. Hence, the consumed power in the form of d-q, is determined as follows [24]: where the active power is denoted by P, and the reactive power is denoted by Q before LPF. The LPF is utilized in this paper as given in Equations (21) and (22). This would help to obtain the basic elements of p (the active power), q (the reactive power), and decrease effect of current as well as the power regulator.
where the cut-off frequency of the filter is denoted by ω c , and Laplace transform operator is denoted by S.

Voltage and Frequency Controller
The droop controller created the reference voltage and reference frequency for the voltage controller in this study. The purpose of the regulator was to obtain the required frequency and voltage values by eliminating the error due to load changes or DG insertion. Two PI controllers were used in this controller, whose four gains were tuned using an intelligent meta-heuristic method called the SRGWO algorithm. Mathematically, the dynamic of the PI controller can be shown as follows: It produced a signal of mention current (i * d and i * q ) for the current controller. The output mention currents (i * d and i * q ) could be controlled with the help of reducing the signal of voltage error (e v ), according to control loop of voltage, as in (23) and (24). Therefore, both power flows were optimized by the DG converter by controlling the output mention currents of the voltage control loop.

Current Controller
The current controller used traditional PI controllers to monitor the output of PWM at mention points i * d and i * q . In order to increase the stability of the current controller based on PI, the decoupling operation was accepted by means of current feed-forward reimbursement. It was attained through regarding inverter set currents (i * d , i * q ) in its place of output measured currents i d , i q [45]. In addition, according to the control composition illustrated in Figure 4, the output voltage signal equation of current loop is written as follows: Since PI tuning based on the SRGWO algorithm was used to reduce error in the voltage regulator, it was not necessary to optimize the parameters for the current regulator. Therefore, two fixed gains for the PI regulators were used to minimize the current error. Space pulse width modulation (SVPWM) is received from the output of the current regulator in the αβ form of the mention. It generates the controlled pulses that are used to disable the VSI so as to supply a power controller to the load with the best power quality. A flowchart of the proposed algorithm execution in the MG controller is illustrated in Figure 5. disable the VSI so as to supply a power controller to the load with the best power quality. A flowchart of the proposed algorithm execution in the MG controller is illustrated in Figure 5.

Specify the GWO algorithm parameters
Generate the initial Grey wolf randomly Update α, A, C and Xi+1 as in Eq.(9)-(14) Max. iteration or same global minima in last 30 iterations ?

Yes
Evaluate the fitness function for each candidate and determine the best one

Problem Formation
In this study, the PI gains controller was employed in the control loop of voltage using a newly introduced meta-heuristics algorithm named SRGWO, so as to resolve the given problems. The study accomplished the lowest value of FF with the help of the proposed algorithm. The most common mechanism for minimizing control purposes in research survey is ITAE. This is due to fact that ITAE enables smoother execution and better results than its competitors, e.g., integrated absolute error (IAE), integrated square error (ISE), and integrated time square error (ITSE) [39,40]. Therefore, ITAE is considered to have the best fitness function (FF) for optimizing voltage and frequency response.
Mathematically, ITAE is determined as: where time is denoted by t , the error is denoted by e(t), and the minimum is denoted by Min, which is the variation between the controlled variable and the mention value. The FF is considered to be an easy mathematic addition to the voltage and frequency integration functions of ITAE 1 and ITAE 2, and is calculated as follows: The low FF value found in this study guarantees that the best selection of PI gains was found. This further guarantees the best dynamic achievement of the tested islanded MG system. The values of ITAE for the two PI controllers were calculated and fed into the MATLAB workspace. Afterwards, the optimal values of PI parameters are obtained for the proposed algorithm, variants of GWO, PSO and GSA. Later, the optimal values of the

Problem Formation
In this study, the PI gains controller was employed in the control loop of voltage using a newly introduced meta-heuristics algorithm named SRGWO, so as to resolve the given problems. The study accomplished the lowest value of FF with the help of the proposed algorithm. The most common mechanism for minimizing control purposes in research survey is ITAE. This is due to fact that ITAE enables smoother execution and better results than its competitors, e.g., integrated absolute error (IAE), integrated square error (ISE), and integrated time square error (ITSE) [39,40]. Therefore, ITAE is considered to have the best fitness function (FF) for optimizing voltage and frequency response.
Mathematically, ITAE is determined as: where time is denoted by t, the error is denoted by e(t), and the minimum is denoted by Min, which is the variation between the controlled variable and the mention value. The FF is considered to be an easy mathematic addition to the voltage and frequency integration functions of ITAE 1 and ITAE 2, and is calculated as follows: The low FF value found in this study guarantees that the best selection of PI gains was found. This further guarantees the best dynamic achievement of the tested islanded MG system. The values of ITAE for the two PI controllers were calculated and fed into the MATLAB workspace. Afterwards, the optimal values of PI parameters are obtained for the proposed algorithm, variants of GWO, PSO and GSA. Later, the optimal values of the PI parameters were then allocated to the controllers in the model (MATLAB/SIMULINK). Therefore, the proposed controller is optimally dynamic (receiving optimal values whenever a change in system's parameter occurs) during the complete operational response of the investigated MG system.

Results and Discussions
The SRGWO algorithm was used in this paper to select the best values for the PI coefficient gain of the MG in an islanded mode system through minimizing specified objective function. The outcomes were also later compared with controllers based on GWO, AGWO, and EGWO for the same working situations. For comparison, the particle counts and 50 iterations were defined for each algorithm.

Frequency and Voltage Control at the time of DG Insertion and Load Change
Due to frequency dives and reduced voltage, to achieve the rated frequency and voltage of the investigated MG network during DG insertion and load changes, a controller based on the SRGWO algorithm must select the better gain value for PI controllers. This was obtained using four various intelligence meta-heuristic algorithms (SRGWO, GWO, AGWO, and EGWO) to minimize FF. The main objective was to minimize FF, and therefore, the minimum values were considered to be best value. The convergence behavior of the four investigated methods under the same working situations. is illustrated in Figure 6.
PI parameters were then allocated to the controllers in the model (MATLAB/SIMULINK). Therefore, the proposed controller is optimally dynamic (receiving optimal values whenever a change in system's parameter occurs) during the complete operational response of the investigated MG system.

Results and Discussions
The SRGWO algorithm was used in this paper to select the best values for the PI coefficient gain of the MG in an islanded mode system through minimizing specified objective function. The outcomes were also later compared with controllers based on GWO, AGWO, and EGWO for the same working situations. For comparison, the particle counts and 50 iterations were defined for each algorithm.

Frequency and Voltage Control at the time of DG Insertion and Load Change
Due to frequency dives and reduced voltage, to achieve the rated frequency and voltage of the investigated MG network during DG insertion and load changes, a controller based on the SRGWO algorithm must select the better gain value for PI controllers. This was obtained using four various intelligence meta-heuristic algorithms (SRGWO, GWO, AGWO, and EGWO) to minimize FF. The main objective was to minimize FF, and therefore, the minimum values were considered to be best value. The convergence behavior of the four investigated methods under the same working situations. is illustrated in Figure  6. In Figure 6, the AGWO provides a much better optimum solution than GWO, but with less flexibility than GWO. Meanwhile, it has been established that controllers based on the SRGWO algorithm achieve faster and better optimal solutions than controllers based on the GWO, AGWO, and EGWO algorithms. Table 5 shows the optimized final value and iteration numbers where the minimum FF was achieved. When the simulation was performed, this search process ended once the optimal value of objective function was obtained, or after the indicated number of iterations had In Figure 6, the AGWO provides a much better optimum solution than GWO, but with less flexibility than GWO. Meanwhile, it has been established that controllers based on the SRGWO algorithm achieve faster and better optimal solutions than controllers based on the GWO, AGWO, and EGWO algorithms. Table 5 shows the optimized final value and iteration numbers where the minimum FF was achieved. When the simulation was performed, this search process ended once the optimal value of objective function was obtained, or after the indicated number of iterations had been executed. In the proposed algorithm, the value of maximum iterations has been set to 50.
The optimized parameters achieved the final value, i.e., the two gains are K pv and K iv for the PI voltage controller, and K pf and K if for the PI frequency controller, for the controllers based on each algorithm in this study. These figures are presented in Table 6. In addition, at the beginning of the simulation, an evaluation of the performance of the control system was implemented, when a load of 50 kW (20 kVAR) was connected with DG. The DG unit employed a voltage-frequency power control model dependent on the SRGWO algorithm to maintain voltage and prevent serious frequency variation due to the rapid insertion of the DG. After that, another 30 kW (20 kVAR) load was injected into system in 0.4 s. Figure 7a,b shows, under the same working circumstances, the comparison of active power (kW) and reactive power (kVAR) variations among the four various regulators. In addition, at the beginning of the simulation, an evaluation of the performance of the control system was implemented, when a load of 50 kW (20 kVAR) was connected with DG. The DG unit employed a voltage-frequency power control model dependent on the SRGWO algorithm to maintain voltage and prevent serious frequency variation due to the rapid insertion of the DG. After that, another 30 kW (20 kVAR) load was injected into system in 0.4 s. Figure 7a,b shows, under the same working circumstances, the comparison of active power (kW) and reactive power (kVAR) variations among the four various regulators.
It may be noted that when another load of 30 kW, 20 kVAR was injected in 0.4 s into the system, the voltage reduced quickly. This has happened because of more voltage drop across the filter components, and more load resistance. The controller was running to instantly recover the rated voltage and frequency of the system, as shown in Figure 8a,b.
It is quite tough, but possible, to achieve online optimization in real-time, in practical applications and under various working situations, due to the process of long search, random load switching, and simulation time. Consequently, the parameters optimized for operating conditions were selected using SRGWO, GWO, AGWO, and EGWO, i.e., load changes and DG insertion during the simulation worked. The main advantages of this technique include the smooth adjustment of optimized parameters. Furthermore, the achieved parameters were good in all working situations. As the MATLAB editor ran optimization algorithm code, the application algorithm began to search for optimal parameters of PI by reducing the cost function.  It may be noted that when another load of 30 kW, 20 kVAR was injected in 0.4 s into the system, the voltage reduced quickly. This has happened because of more voltage drop across the filter components, and more load resistance. The controller was running to instantly recover the rated voltage and frequency of the system, as shown in Figure 8a

Steady-State and Dynamic Response
One of the key parameters that must be eliminated during the islanded mode of operation is the sinusoidal nature of the output voltage and current of the inverter. The optimal parameters of the PI controller provide a smooth, and sinusoidal waveform, which minimizes the total harmonic distortion (THD). The controller based on the SRGWO algorithm given a very small percentage value of THD by a fast Fourier transform analysis of the waveform of output current. which demonstrates its performance in controlling the It is quite tough, but possible, to achieve online optimization in real-time, in practical applications and under various working situations, due to the process of long search, random load switching, and simulation time. Consequently, the parameters optimized for operating conditions were selected using SRGWO, GWO, AGWO, and EGWO, i.e., load changes and DG insertion during the simulation worked. The main advantages of this technique include the smooth adjustment of optimized parameters. Furthermore, the achieved parameters were good in all working situations. As the MATLAB editor ran optimization algorithm code, the application algorithm began to search for optimal parameters of PI by reducing the cost function.

Steady-State and Dynamic Response
One of the key parameters that must be eliminated during the islanded mode of operation is the sinusoidal nature of the output voltage and current of the inverter. The optimal parameters of the PI controller provide a smooth, and sinusoidal waveform, which minimizes the total harmonic distortion (THD). The controller based on the SRGWO algorithm given a very small percentage value of THD by a fast Fourier transform analysis of the waveform of output current. which demonstrates its performance in controlling the frequency and voltage of the investigated MG system, along with the high quality of its power. In Table 6, the algorithms compare the proposed SRGWO-based controllers with GWO-, AGWO-, and EGWO-based controllers. It shows the current waveform THD level of the output of 15 cycles on 50 Hz of fundamental frequency. According to IEEE standard 1547-2003 [46], the percentage of THD allowed in an electrical supplier must be always less than 5%. The THD in percentage achieved by controllers based on the proposed algorithm, GWO, AGWO, and EGWO, due to the insert of DG and load changes, are shown in Table 7.

Conclusions
A novel optimal voltage and frequency control for DG units in a microgrid is proposed as a simple and an efficient algorithm. Twenty-three benchmark functions have been tested using the SRGWO method. The results have proved that the implementation of the proposed algorithm showed better performance in real power systems as compared to other GWO, PSO, AGWO, EGWO, and GSA algorithms. To enhance the capability of the proposed algorithm, the PI controller parameters were optimized by minimizing the error, which increased its efficacy. Additionally, the proposed algorithm-based control architecture provides a superior and optimal response compared to traditional GWO-, adaptive GWO-and enhanced GWO-based controllers, which makes it applicable to modern power systems, with high-speed response to disturbances. It also achieves a better minimum final optimized value of the FF as compared to GWO, AGWO, and EGWO, which ensures a high-quality solution for the stated optimization problem. A power quality analysis established that the SRGWO-based controller provides the least THD (%) as compared to GWO-, AGWO-, and EGWO-based controllers, and thus meets the IEEE standard 1547-2003.
The voltage and frequency magnitudes obtained by SRGWO offer minimum overshoot and settling time for the DG insertion condition, as well as the load variation condition. This leads to high-speed recovery of stability in a real-time power system. Furthermore, the proposed method has achieved an optimal fitness function and better power quality, which will ensure the economic and secure operation of power systems. In the future, real-time voltage and frequency control using machine learning will be performed using systems with a high penetration of renewable energy. The implementation of the proposed algorithm to a more complex power system network, such as hybrid renewable energy resources, as well as a real-time power networks, such as experimental prototypes, is suggested for future work.