Real-Time Implementation of the Predictive-Based Control with Bacterial Foraging Optimization Technique for Power Management in Standalone Microgrid Application

: In this paper, the predictive-based control with bacterial foraging optimization technique for power management in a standalone microgrid is studied and implemented. The heuristic optimization method based on the social foraging behavior of Escherichia coli bacteria is employed to determine the power references from the non-renewable energy sources and loads of the proposed conﬁguration, which consists of a ﬁxed speed diesel generator and battery storage system (BES). The two-stage conﬁguration is controlled to maintain the DC-link voltage constant, regulate the AC voltage and frequency, and improve the power quality, simultaneously. For these tasks, on the AC side, the obtained power references are used as input signals to the predictive-based control. With the help of the system parameters, the predictive-based control computes all possible states of the system on the next sampling time and compares them with the estimated power references obtained using the bacterial foraging optimization (BFO) technique to get the inverter current reference. For the DC side, the same concept based on the predictive approach is employed to control the DC-DC buck-boost converter by regulating the DC-link voltage using the forward Euler method to generate the discrete-time model to predict in real-time the BES current. The proposed control strategies are evaluated using simulation results obtained with Matlab/Simulink in presence of different types of loads, as well as experimental results obtained with a small-scale microgrid.


Introduction
Diesel generator (DG) is still used as the main energy source in many remote areas. Although, diesel is costly, pollutant, and inefficient at light loads [1]. Moreover, in presence of nonlinear loads, the DG lifetime is affected by the harmonic currents. On the other hand, isolated areas often have a large potential for renewable energy sources (RES) such as solar and wind. Generally, the integration of RES in these isolated microgrids allows to decrease the operation cost as well as increase the reliability and efficiency of the system [2,3]. The RES are stochastic, so battery energy system (BES) is suggested to compensate for their intermittent properties. BES is a DC source in nature, it needs a controlled power converter such as a DC-DC buck-boost converter to operate properly and to adapt its output voltage to the DC-link voltage for standalone microgrid application. Moreover, with the help of the controlled power converters, one controls the power flows and protects the storage element [4,5]. However, the integration of non-renewable energy sources (NRESs) and their power converters with the existing diesel generators makes standalone microgrid applications more complex. Therefore, accurate control strategies and power management techniques should be employed to always ensure secure and effective operation [6].
For microgrid application control, centralized and decentralized control are used [7]. Regrading, the centralized control, a central decision controller gathers information and decides the action for the hierarchical control. This control requires communication between the central controller and all system elements [8]. For the decentralized control, each element is independent and achieves the tasks locally using the local measurements. According to [9], a compromise can be made between these two types of control by using control levels that differ by their time frame, time response, and communication requirement. Generally, the hierarchical control consists of three levels: primary, secondary, and tertiary [9]. The primary control, or local control, is characterized by its fastest response time and it operates with a decentralized approach. The secondary level, referred to as the energy management system, aims to fulfill the economic objective of the microgrid, i.e., it controls different energy sources in presence of load and weather conditions variations as well as the state of charge of the BES. This level of control is characterized by its slower time response so that the secondary and the primary control are decoupled, they employ sample measurement data to reduce the communication link bandwidth. This can improve the control performance because it allows more time to perform complex calculations. The tertiary control level is considered as a part of the utility grid, it is not considered in this paper.
Several control strategies for the primary control level had been reported in the literature [10]. Among these control strategies, predictive-based control is proposed in [11]. This technique shows a fast dynamic response compared to the existing technique, and it can handle nonlinearities. This technique uses the measured system data and parameters to predict the future behavior of the system. These predictions are then evaluated by a cost function to reduce the error between the prediction and its reference. This concept is applied to achieve many tasks in many applications for grid-connected microgrid [11][12][13] and islanding microgrid [4,14], for power management [11,12], power quality [4,13,14], and synchronization [15]. However, predictive control also has drawbacks as reported in [16]. Some compromises need to be made when selecting the discretization method, between model accuracy and calculation complexity; but also, when selecting the sampling time, between better performance and computation time [16].
Generally in power management, the objective function may include high order polynomial function, so heuristic optimization methods are proposed to handle this issue [17][18][19]. Particle swarm optimization (PSO) is proposed in [17] and ant colony optimization (ACO) in [18]. Further in 2002, Passino proposed the bacterial foraging optimization (BFO) method, this technique emulates the behavior of E. coli bacteria [20]. This technique is proposed for different applications, including tuning proportional-integral (PI) controller parameters [21,22], power system reconfiguration and power loss minimization [23], or estimating PV parameters [24]. Furthermore, hybrid BFO/PSO methods are proposed for solar tracking [25] or multi-loop controller design [26]. The BFO technique is compared to other optimization techniques in the literature and it shows better performance under severe conditions for many applications. In [27], the performance BFO method is compared to an enhanced non-dominated storing genetic algorithm (NSGA-II) and multi-objective PSO (MOPSO) for a multi-objective problem. The obtained results show that the multi-objective BFO is robust, stable, and precise compared to other techniques. According to [28], the efficiency of the genetic algorithm (GA) is affected by the premature convergence but the BFO method possesses a much higher possibility to override the local minima. Moreover, the performance of GA and BFO are compared for automatic generation control to optimize parameters. The obtained results show that the BFO method performs well with faster results due to the smaller number of iterations. In [29], authors have compared the BFO method with GA, PSO, GA/PSO, and simulated annealing (SA) methods to find the optimal location and size of several DGs in a 33 bus and 69 bus test systems, to minimize the losses and operational costs, and to improve the voltage stability in the distribution system in presence of different types of loads. Compared to other optimization methods, the BFO method presents accuracy and precision to find the optimum solutions. In [30], the heuristic optimization methods as, GA, binary particle swarm optimization (BPSO), BFO, wind-driven optimization (WDO), and the proposed hybrid genetic wind-driven (GWD) algorithm are compared to the BFO technique for power management in a smart grid application. Many features as scheduling residential loads between peak hours and off-peak hours while maximizing user comfort, minimizing the electricity cost, and the peak to the average ratio for a single home, and later for multiple homes are evaluated. The obtained results show that the GWD method performs well in reducing the electricity costs, and the GA method provides an optimal global solution and gives a better convergence rate. Regarding, the small population groups, BPSO and BFO converge faster but BFO shows the smallest computational burden. In [31], the BFO and PSO methods are compared for a real-time calculation of active and reactive power references, both methods show accurate results however, the BFO method possess less calculation steps.
In this paper, the implementation of a two-level control strategy based on the BFO method and the predictive control in a standalone microgrid is proposed. The BFO technique is employed to determine the power references from the load and NRESs power. The two-level control strategy is designed to maintain constant the DC-link voltage, regulate the voltage and frequency at the point of common coupling (PCC) and improve the power quality simultaneously. For the AC side, the obtained power references are used as input to the predictive control so that it can control the power exchanges while regulating the PCC voltage and frequency but also improve the power quality. Regarding the DC side, predictive control is used for the DC-link voltage regulation.
The proposed standalone microgrid configuration is presented in Section 2. The predictive and BFO controllers are detailed in Section 3. Simulation and experimental results as well as a discussion are given in Section 4. Finally, the presented work is concluded in Section 5.

Microgrid Description
The proposed microgrid configuration is shown in Figure 1. It consists of Diesel Engine (DE) coupled with a Synchronous Generator (SG), forming a DG that is connected directly to the PCC. A BES is connected to the DC-link through a DC-DC buck-boost converter. An inverter and a RLC filter are used between the AC and the DC sides of the standalone microgrid. Both converters are controlled with predictive control. The DC-DC buck-boost converter is responsible for the DC-link voltage regulation by controlling the BES current, and the inverter is responsible for the PCC voltage and frequency regulation, power quality but also power management. For these tasks, the BFO and predictive control are employed. RES is not considered in this study but could be connected to the DC-link. Finally, the standalone microgrid supplies dynamic linear and non-linear loads. distribution system in presence of different types of loads. Compared to other optimization methods, the BFO method presents accuracy and precision to find the optimum solutions. In [30], the heuristic optimization methods as, GA, binary particle swarm optimization (BPSO), BFO, wind-driven optimization (WDO), and the proposed hybrid genetic wind-driven (GWD) algorithm are compared to the BFO technique for power management in a smart grid application. Many features as scheduling residential loads between peak hours and off-peak hours while maximizing user comfort, minimizing the electricity cost, and the peak to the average ratio for a single home, and later for multiple homes are evaluated. The obtained results show that the GWD method performs well in reducing the electricity costs, and the GA method provides an optimal global solution and gives a better convergence rate. Regarding, the small population groups, BPSO and BFO converge faster but BFO shows the smallest computational burden. In [31], the BFO and PSO methods are compared for a real-time calculation of active and reactive power references, both methods show accurate results however, the BFO method possess less calculation steps.
In this paper, the implementation of a two-level control strategy based on the BFO method and the predictive control in a standalone microgrid is proposed. The BFO technique is employed to determine the power references from the load and NRESs power. The two-level control strategy is designed to maintain constant the DC-link voltage, regulate the voltage and frequency at the point of common coupling (PCC) and improve the power quality simultaneously. For the AC side, the obtained power references are used as input to the predictive control so that it can control the power exchanges while regulating the PCC voltage and frequency but also improve the power quality. Regarding the DC side, predictive control is used for the DC-link voltage regulation.
The proposed standalone microgrid configuration is presented in Section 2. The predictive and BFO controllers are detailed in Section 3. Simulation and experimental results as well as a discussion are given in Section 4. Finally, the presented work is concluded in Section 5.

Microgrid Description
The proposed microgrid configuration is shown in Figure 1. It consists of Diesel Engine (DE) coupled with a Synchronous Generator (SG), forming a DG that is connected directly to the PCC. A BES is connected to the DC-link through a DC-DC buck-boost converter. An inverter and a RLC filter are used between the AC and the DC sides of the standalone microgrid. Both converters are controlled with predictive control. The DC-DC buck-boost converter is responsible for the DC-link voltage regulation by controlling the BES current, and the inverter is responsible for the PCC voltage and frequency regulation, power quality but also power management. For these tasks, the BFO and predictive control are employed. RES is not considered in this study but could be connected to the DClink. Finally, the standalone microgrid supplies dynamic linear and non-linear loads.

Control Strategies
This section details the different control strategies for the two-level-based configuration. For the inverter side, the predictive-based control, which is used to predict the inverter current, and BFO, which is used to estimate the inverter reference current, are detailed. In addition, in this section, the predictive-based control for the DC-DC buck-boost converter used to estimate the BES current to regulate the DC-link voltage is given in detail. Figure 2 shows the relation between the BFO technique and predictive-based control for the inverter. As one can see, the BFO technique uses measured power data (P load , P inv , Q load , Q dg , Q inv ) and a rated value (P dg,rated ) to estimate the active and reactive power references (P ref and Q ref ) that are used by the predictive control algorithm as input signals to estimate the inverter current reference.

Control Strategies
This section details the different control strategies for the two-level-based configuration. For the inverter side, the predictive-based control, which is used to predict the inverter current, and BFO, which is used to estimate the inverter reference current, are detailed. In addition, in this section, the predictive-based control for the DC-DC buck-boost converter used to estimate the BES current to regulate the DC-link voltage is given in detail. Figure 2 shows the relation between the BFO technique and predictive-based control for the inverter. As one can see, the BFO technique uses measured power data (Pload, Pinv, Qload, Qdg, Qinv) and a rated value (Pdg,rated) to estimate the active and reactive power references (Pref and Qref) that are used by the predictive control algorithm as input signals to estimate the inverter current reference.

Inverter Predictive Control
As shown in Figure 2, the predictive-based control is made of three steps: (1) reference current estimation, (2) current predictive model, and (3) a cost function.

Inverter Reference Current Estimation
The current reference is needed to ensure the power management, as well as the power quality and voltage and frequency regulation at the PCC. For power management, the output signals of the optimization technique are used, as shown in Figures 2 and 3.
For the power quality, the measured load current (Iload) and PCC voltage (Vpcc) are transformed into complex quantities using the Clark transformation (1). Then, the instantaneous active and reactive power are computed using (2). The active power is obtained based on an average (p ̅) and an oscillating component (p ) which contains the harmonics. The low pass filter is used to keep only the oscillating component, which is then substracted to the new active power reference (Pref) obtained using the BFO technique. Regarding, the reactive power reference, (Qref) is used simply to compute the new current references (Iinv,refα and Iinv,refβ) as demonstrated in Figure 3 and expressed in (3).

Inverter Predictive Control
As shown in Figure 2, the predictive-based control is made of three steps: (1) reference current estimation, (2) current predictive model, and (3) a cost function.

Inverter Reference Current Estimation
The current reference is needed to ensure the power management, as well as the power quality and voltage and frequency regulation at the PCC. For power management, the output signals of the optimization technique are used, as shown in Figures 2 and 3. For the power quality, the measured load current (I load ) and PCC voltage (V pcc ) are transformed into complex quantities using the Clark transformation (1). Then, the instantaneous active and reactive power are computed using (2). The active power is obtained based on an average (p) and an oscillating component ( p) which contains the harmonics. The low pass filter is used to keep only the oscillating component, which is then substracted to the new active power reference (P ref ) obtained using the BFO technique. Regarding, the reactive power reference, (Q ref ) is used simply to compute the new current references (I inv,refα and I inv,refβ ) as demonstrated in Figure 3 and expressed in (3).  The Clark transformation is employed because it allows to simplify the analysis of three-phase quantities, the system is transformed from a two rotating axes reference frame into a two stationary axes reference frame, without estimating the phase angle at the PCC using the conventional phased locked loop (PLL). Therefore, three dimensions problems are transformed into two dimensions problems. (1) [

Current Predictive Model
In this step, a vector with the possible values of the inverter current on the next sampling time is computed. First, the vector of the possible inverter output voltage is needed, it is obtained based on the behavior of the inverter switches as expressed in (4). With the help of Kirchhoff's laws, one obtains the mathematical model of the PCC voltage (5). To implement a digital controller, the PCC voltage as expressed in (5) is transformed into a discrete-time equation using Euler forward method which is detailed in (6). Based on (5), and (6), one obtains the vector of the inverter output current possible values on the next sampling time (IINV(k+1)) as expressed in (7). The Clark transformation is employed because it allows to simplify the analysis of three-phase quantities, the system is transformed from a two rotating axes reference frame into a two stationary axes reference frame, without estimating the phase angle at the PCC using the conventional phased locked loop (PLL). Therefore, three dimensions problems are transformed into two dimensions problems.

Current Predictive Model
In this step, a vector with the possible values of the inverter current on the next sampling time is computed. First, the vector of the possible inverter output voltage is needed, it is obtained based on the behavior of the inverter switches as expressed in (4). With the help of Kirchhoff's laws, one obtains the mathematical model of the PCC voltage (5). To implement a digital controller, the PCC voltage as expressed in (5) is transformed into a discrete-time equation using Euler forward method which is detailed in (6). Based on (5), and (6), one obtains the vector of the inverter output current possible values on the next sampling time (I INV(k+1) ) as expressed in (7).

Cost Function
To select the prediction, which is closer to the reference, the cost function (8) is employed. It uses the square error of the active and reactive parts of the reference and the predictions. For each prediction, the cost function is computed and the prediction with the smallest cost is the closest to the reference. Due to the calculation of the predictions using the inverter output voltage and the switches behavior, one knows the switches profile which corresponds to each prediction. Therefore, from the cost function values, one can deduce the switch's profile to apply to the inverter so that on the next sampling time the inverter current follows the reference.

Bacterial Foraging Optimization Technique
The BFO technique is employed to calculate the active and reactive power references using the powers of the NRESs as shown in Figure 2. It consists of five steps as (1) initialization, (2) chemotaxis, (3) swarming, (4) reproduction, and (5) elimination and dispersal. The following subsections give more details about these steps. The flowchart given in Figure 4 shows the steps of the BFO technique.

Cost Function
To select the prediction, which is closer to the reference, the cost function (8) is employed. It uses the square error of the active and reactive parts of the reference and the predictions. For each prediction, the cost function is computed and the prediction with the smallest cost is the closest to the reference. Due to the calculation of the predictions using the inverter output voltage and the switches behavior, one knows the switches profile which corresponds to each prediction. Therefore, from the cost function values, one can deduce the switch's profile to apply to the inverter so that on the next sampling time the inverter current follows the reference.

Bacterial Foraging Optimization Technique
The BFO technique is employed to calculate the active and reactive power references using the powers of the NRESs as shown in Figure 2. It consists of five steps as (1) initialization, (2) chemotaxis, (3) swarming, (4) reproduction, and (5)

Initialization
For the initialization, many parameters such as the number of bacteria (S), number of chemotaxis steps (Nc), number of swim steps (Ns), number of reproductive steps (Nr), and number of elimination and dispersal steps (Ned), should be defined. Unfortunately, there is no mathematical approach to define the optimal value of these parameters, for this reason, a heuristic method is employed, and the values of these parameters are given in Table A1. The initial positions of the bacteria are defined randomly around the measured powers. The reference vector θr is defined as detailed in (9). As already indicated,

Initialization
For the initialization, many parameters such as the number of bacteria (S), number of chemotaxis steps (Nc), number of swim steps (Ns), number of reproductive steps (Nr), and number of elimination and dispersal steps (Ned), should be defined. Unfortunately, there is no mathematical approach to define the optimal value of these parameters, for this reason, a heuristic method is employed, and the values of these parameters are given in Table A1. The initial positions of the bacteria are defined randomly around the measured powers. The reference vector θ r is defined as detailed in (9). As already indicated, the main task of the proposed BFO technique is to estimate the power references. For this application, the objective is to operate the DG at its rated power, the DG should deliver the same amount of active power all the time. Furthermore, the reactive power should be supplied by the inverter. In addition, the frequency of activation of the BFO technique should be defined. To make sure that the objectives will be accomplished, the new power references should be computed often. Seeing that the developed BFO controller consists of many interconnected control loops, the computation time is important. A compromise needs to be made here and to ensure a soft transition. For the optimal operation of the BFO technique, the new power references are computed every 5 ms.
where P load , Q load , P dg,rated and Q dg represent the measured active and reactive power at the load, the active rated power of the DG, and the measured reactive power at the DG, respectively.

Chemotaxis
Regarding the chemotaxis step, the bacteria's movement is emulated. When a bacterium keeps moving in the same direction, it is called swimming and when it changes direction, it is called tumbling. Equation (10) describes these phenomena.
where θ(i,j,k,l) represents the ith bacteria, at the jth chemotaxis step, at kth reproduction step, and lth elimination and dispersal step. Then, θ(i,j + 1,k,l) represents the same bacteria at the next chemotaxis step. The parameters c and ∆ respectively represent the length and the direction of the movement. They are generated randomly. A cost function is used to evaluate how each bacterium is close to the reference. As expressed in (11), the cost function is defined as the absolute value of the difference between a bacterium position and the reference position. J(i, j, k, l) = abs(θ r − θ(i, j, k, l)) (11)

Swarming
E. coli bacteria can communicate about their current position whether it is a good or a bad direction to converge. To emulate this swarming phenomenon, the cost function needs to be modified as detailed in (12) and (13).
where d a , w a , h r , and w r represent the depth and width of the attractant signal, the height, and width of the repellant effect, respectively. In (12) the notations are simplified, θ represents the bacterium understudy, and θ i represents the bacteria that already moved.

Reproduction
Once all the bacteria have moved and computed their new cost function, a classification is made based on their cost function value. Then, the half with the higher cost function values dies while the other half splits in two, at the same position. So that the number of bacteria is constant, and the population is healthier.

Elimination and Dispersal
E. coli bacteria sometimes die or get dispersed in the environment without any reason. In our application, this phenomenon helps the chemotactic process because it reduces the chances to be trapped in a premature local solution. A probability coefficient (P ed ) is defined, and each bacterium is subjected to elimination and dispersal with this probability. When a bacterium is eliminated it is replaced with a new one with a random position to keep constant the population.

DC-DC Buck-Boost Converter Predictive Control
The predictive-based control is also employed to control the DC-DC buck-boost converter. The three same steps are needed as, (1) the current predictive model, (2) the current reference estimation, and (3) a cost function as demonstrated in Figure 5.

Elimination and Dispersal
E. coli bacteria sometimes die or get dispersed in the environment without any reason. In our application, this phenomenon helps the chemotactic process because it reduces the chances to be trapped in a premature local solution. A probability coefficient (Ped) is defined, and each bacterium is subjected to elimination and dispersal with this probability. When a bacterium is eliminated it is replaced with a new one with a random position to keep constant the population.

DC-DC Buck-Boost Converter Predictive Control
The predictive-based control is also employed to control the DC-DC buck-boost converter. The three same steps are needed as, (1) the current predictive model, (2) the current reference estimation, and (3) a cost function as demonstrated in Figure 5.

Current Predictive Model
Using Kirchhoff's laws, the mathematical model of the DC-DC buck-boost converter is developed. Equation (14) is obtained when S1 is closed and S2 is open and, Equation (15) is obtained when S1 and S2 are respectively open and closed. As the voltage regulation is achieved by controlling the BES current, only the current equations are needed. Again, the forward Euler method (6) is used to convert the system into a discrete-time model. Finally, the predictions (16) are obtained as

BES Reference Current Estimation
As the DC-DC buck-boost controller aims to regulate the DC-link voltage by controlling the BES current, two components need to be considered. (1) The amount of current coming from the AC side of the microgrid, which is computed using the active power of the inverter and the DC voltage reference; and (2) the amount of current needed to regulate the voltage, which is calculated using the error between the DC-link voltage and its

Current Predictive Model
Using Kirchhoff's laws, the mathematical model of the DC-DC buck-boost converter is developed. Equation (14) is obtained when S 1 is closed and S 2 is open and, Equation (15) is obtained when S 1 and S 2 are respectively open and closed. As the voltage regulation is achieved by controlling the BES current, only the current equations are needed. Again, the forward Euler method (6) is used to convert the system into a discrete-time model. Finally, the predictions (16) are obtained as

BES Reference Current Estimation
As the DC-DC buck-boost controller aims to regulate the DC-link voltage by controlling the BES current, two components need to be considered. (1) The amount of current coming from the AC side of the microgrid, which is computed using the active power of the inverter and the DC voltage reference; and (2) the amount of current needed to regulate the voltage, which is calculated using the error between the DC-link voltage and its reference. Finally, this value represents the amount of current going through the inverter and it needs to be adjusted to represent the amount of current the BES needs to store.

Cost Function
The cost function (18) is employed to evaluate which of the two predictions is closer to the reference. It uses the absolute value of the error between the reference and the prediction as presented in (18). The prediction with the smaller cost function is closer to the reference. Therefore, if I bat(k + 1)1 possesses the smallest cost function value, S 1 is closed and S 2 open on the next sampling time and if I bat(k + 1)2 possesses the smallest cost function, S 1 is open and S 2 is closed.

Results
To validate the proposed control strategies for the DC-DC buck-boost converter and three-phase inverter, simulation and experimental tests are realized in presence of a different types of loads. The simulation tests are performed using Matlab/Simulink. Figure 6 shows the PCC voltage (V pcc ), the load current (I load ), the DG current (I dg ), the inverter current (I inv ), the frequency of the system, the BES current (I bat ), the state of charge of the BES (SOC), and the voltage of the DC-link (V dc ). In Figure 7, the active and reactive power of the load (P load and Q load ), the DG (P dg and Q dg ), and the inverter (P inv and Q inv ) are demonstrated. Then, in Figure 8, the power references generated using BFO estimation technique (P ref and Q ref ) and the active and reactive power of the inverter (P inv and Q inv ), are presented. It is observed that three different loads are connected at the system at different times as (1) a constant 8 kW resistive load and from t = 1 s to t = 2 s additional resistive load of 3 kW, (2) from t = 3 s to t = 4 s a 2 kVAr capacitive load is connected, and (3) from t = 5 s to t = 6 s an inductive load of 2 kVAr is connected. One sees clearly in Figure 6 that the PCC voltage, the frequency of the system as well as the DC-link voltage are well regulated during the transitions. One sees that the overshoot and undershoot in DC-link voltage is minimized, which confirms the developed predictive-based controller. In addition, the DG current is kept constant during all times, but the inverter current varies with the variation of loads, which confirms that the balance in power is ensured by the BES for our application. One observes that BES current from t = 1 s to t = 2 s is increased but for the rest of the simulation is kept constant and is with a negative sign, which means that BES is charging. In Figure 7, the same phenomena are shown, the active power generated from the DG is constant and the inverter active power varies with the variation of load power demand. Regarding, the reactive power, one can see that the DG reactive power is almost zero and the inverter reactive power varies with the variation of load reactive power demand. In Figure 8, the performance of the inverter power references is presented, one observes that the estimated active and reactive power using predictive based control follows their references generated using the BFO optimization technique, which confirms the good operation of both techniques used to control the two-level three-phase inverter to supply the load with constant voltage and frequency and mitigate the harmonics.            Figure 9 shows the waveform of the PCC voltage (Vpcc), the load current (Iload), the DG current (Idg) and the inverter current (Iinv) in presence of a non-linear load. One can see  that the waveforms of the PCC voltage and DG current are balanced and sinusoidal. In this case, the inverter acts as an active shunt filter, it compensates harmonics created by the nonlinear loads and balance the DG currents. One sees in Figure 10 that the total harmonic distortion (THD) of the PCC voltage is 3.28% and the THD of the DG current is 3.99% and that the THD of the load current is 23%. Therefore, the PCC voltage and DG current are below the limit of 5% and respects IEEE Std 519-1992, IEEE recommended practices and requirement for harmonic control in the electrical power system. ies 2021, 14, 1723 11 of 15 that the waveforms of the PCC voltage and DG current are balanced and sinusoidal. In this case, the inverter acts as an active shunt filter, it compensates harmonics created by the nonlinear loads and balance the DG currents. One sees in Figure 10 that the total harmonic distortion (THD) of the PCC voltage is 3.28% and the THD of the DG current is 3.99% and that the THD of the load current is 23%. Therefore, the PCC voltage and DG current are below the limit of 5% and respects IEEE Std 519-1992, IEEE recommended practices and requirement for harmonic control in the electrical power system.   that the waveforms of the PCC voltage and DG current are balanced and sinusoidal. In this case, the inverter acts as an active shunt filter, it compensates harmonics created by the nonlinear loads and balance the DG currents. One sees in Figure 10 that the total harmonic distortion (THD) of the PCC voltage is 3.28% and the THD of the DG current is 3.99% and that the THD of the load current is 23%. Therefore, the PCC voltage and DG current are below the limit of 5% and respects IEEE Std 519-1992, IEEE recommended practices and requirement for harmonic control in the electrical power system.     Experimental results of the DC-link voltage (Vdc), DG current (Idg), inverter current (Iinv), and load current (Iload) are presented in Figure 12a,b. Figure 12c shows the DC-link voltage (Vdc), DG current (Idg), BES current (Ibat), and load current (Iload). Figure 12d shows the PCC voltage (Vpcc), DG current (Idg), inverter current (Iinv), and load current (Iload). It is observed in Figure 12a,b, that the load increases and decreases, respectively, at t = 0.5 ms, but the DG current stays constant and the inverter current varies with the variation of the load, it decreases and increases with increasing and decreasing of loads. One can see in Figure 12c that the load is increased at t = 0.6 s and decreased at t = 1.2 s, the DG current stays constant and the BES current is increased and decreased with the load variations. The BES current is of the negative sign which means that the battery is being charged by the DG. Indeed, the balance of power in the system is ensured by the BES. One observes that DC-link voltage varies slightly, which confirms the robustness of the developed predictive-based control for the DC-DC buck-boost converter. From Figure 12d, one observes that the inverter acts as an active filter, it compensates the harmonics current created by the non-linear load and balance the DG current and PCC voltage, these results can be compared to the simulation results presented in Figure 9. In Figure 13, the harmonic spectrum of the PCC voltage, load current, and DG current are presented. One sees that THD of the PCC voltage (a) and DG current (b), are less than 5%, which respects the IEEE-Std 519-1992. This confirms that the predictive-based control operates well under the presence of nonlinear loads. Experimental results of the DC-link voltage (V dc ), DG current (I dg ), inverter current (I inv ), and load current (I load ) are presented in Figure 12a,b. Figure 12c shows the DC-link voltage (V dc ), DG current (I dg ), BES current (I bat ), and load current (I load ). Figure 12d shows the PCC voltage (V pcc ), DG current (I dg ), inverter current (I inv ), and load current (I load ). It is observed in Figure 12a,b, that the load increases and decreases, respectively, at t = 0.5 ms, but the DG current stays constant and the inverter current varies with the variation of the load, it decreases and increases with increasing and decreasing of loads. One can see in Figure 12c that the load is increased at t = 0.6 s and decreased at t = 1.2 s, the DG current stays constant and the BES current is increased and decreased with the load variations. The BES current is of the negative sign which means that the battery is being charged by the DG. Indeed, the balance of power in the system is ensured by the BES. One observes that DC-link voltage varies slightly, which confirms the robustness of the developed predictive-based control for the DC-DC buck-boost converter. From Figure 12d, one observes that the inverter acts as an active filter, it compensates the harmonics current created by the non-linear load and balance the DG current and PCC voltage, these results can be compared to the simulation results presented in Figure 9. In Figure 13, the harmonic spectrum of the PCC voltage, load current, and DG current are presented. One sees that THD of the PCC voltage (a) and DG current (b), are less than 5%, which respects the IEEE-Std 519-1992. This confirms that the predictive-based control operates well under the presence of nonlinear loads.

Conclusions
In this paper, the implementation of predictive-based control with the BFO technique for a standalone microgrid has been investigated. The two-level configuration is controlled to regulate the DC-link voltage, the voltage, and the frequency, and to improve the power quality at the PCC. For the AC side, the power references obtained with the BFO method are used as inputs to the predictive control so that it can control the power exchanges while regulating the PCC voltage and frequency but also improve the power quality. For the DC side, the predictive control is used to regulate the DC-link voltage by

Conclusions
In this paper, the implementation of predictive-based control with the BFO technique for a standalone microgrid has been investigated. The two-level configuration is controlled to regulate the DC-link voltage, the voltage, and the frequency, and to improve the power quality at the PCC. For the AC side, the power references obtained with the BFO method are used as inputs to the predictive control so that it can control the power exchanges while regulating the PCC voltage and frequency but also improve the power quality. For the DC side, the predictive control is used to regulate the DC-link voltage by

Conclusions
In this paper, the implementation of predictive-based control with the BFO technique for a standalone microgrid has been investigated. The two-level configuration is controlled to regulate the DC-link voltage, the voltage, and the frequency, and to improve the power quality at the PCC. For the AC side, the power references obtained with the BFO method are used as inputs to the predictive control so that it can control the power exchanges while regulating the PCC voltage and frequency but also improve the power quality. For the DC side, the predictive control is used to regulate the DC-link voltage by controlling the DC-DC buck-boost converter. The obtained simulation and experimental results are satisfactory under the presence of all conditions. The power quality, voltage, frequency, and power exchanges are achieved without any overshoot nor undershoot of the DC-link voltage. The DG is kept always operating at its rated power and the reactive power is supplied by the BES, which confirms the robustness, accuracy, and precision of the developed BFO technique-based for standalone microgrid application. The integration of other energy sources such as RES should be considered in future studies which would modify the objectives of the microgrid. The BFO algorithm should be modified to include theses new objectives and to make the power management more efficient.
Author Contributions: This paper was a collaborative work between the four authors. F.D. contributed to the design of the proposed control strategies, simulation, and experimental results, and drafted the manuscript. M.R. performed in the design of system elements, experiments, and revision of the manuscript. H.I. and A.C. supervised the work, provided advice on methodology and results. All authors have read and agreed to the published version of the manuscript.

Conflicts of Interest:
The authors declare no conflict of interest. Table A1. Parameters of the System.