Bacterial Foraging-Based Algorithm for Optimizing the Power Generation of an Isolated Microgrid

An Isolated Microgrid (IMG) is an electrical distribution network combined with modern information technologies aiming at reducing costs and pollution to the environment. In this article, we implement the Bacterial Foraging Optimization Algorithm (BFOA) to optimize an IMG model, which includes renewable energy sources, such as wind and solar, as well as a conventional generation unit based on diesel fuel. Two novel versions of the BFOA were implemented and tested: Two-Swim Modified BFOA (TS-MBFOA), and Normalized TS-MBFOA (NTS-MBFOA). In a first experiment, the TS-MBFOA parameters were calibrated through a set of 87 independent runs. In a second experiment, 30 independent runs of both TS-MBFOA and NTS-MBFOA were conducted to compare their performance on minimizing the IMG using the best parameter tuning. Results showed that TS-MBFOA obtained better numerical solutions compared to NTS-MBFOA and LSHADE-CV, an Evolutionary Algorithm, found in the literature. However, the best solution found by NTS-MBFOA is better from a mechatronic point of view because it favors the lifetime of the IMG, resulting in economic savings in the long term.


Introduction
Currently, one of the most critical issues is the efficient use of available energy sources.Therefore, in rural or remote geographic locations, the generation and distribution of energy is a significant challenge for many areas of engineering such as control, power electronics or planning, among others.In recent years, microgrids (MGs) have been a reliable solution for the power supply in separate areas, provided that there is adequate operational planning of the MG energy sources [1].
In general, an MG is composed of energy storage systems (ESS),hybrid power generation systems (HPGS) from renewable energy sources (RES) and conventional generation systems (CGS); with all elements working in a coordinated way for the power generation.It is important to highlight that CGSs have a high operating cost due to the materials and transportation logistics.Moreover, ESSs are integrated by costly devices requiring a safe manner operation, thus guaranteeing a long service life.Finally, uncertainty in the appropriate operation of the RES due to the origin of wind and sunlight must take into account.These theoretical considerations are some of the reasons why optimal management of power generation resources for the appropriate operation of the MG is required.
In isolated microgrids (IMGs), a hybrid power generation system (HPGS) is responsible for the generation of reliable energy.This is done by integrating into the IMG at least one of the RES, CGS, and ESS systems such as a wind turbine generator, solar generator, diesel generator, or battery storage systems.However, due to the RES generation intermittency, the ESS become the main factor in the steady performance of the IMGs [2][3][4].When a steady state is reached, the best performance of the whole system is obtained.HPGSs have been studied by several authors [5][6][7], describing conditions of remote localities having variable demand and power dispatch by generators minimizing the cost of generation, while maintaining a balance between the generation of energy and the load.
Usually, the power supply to the load in an IMG can be calculated as an economic dispatch function for generators at a large-scale power level [8].This cost function should be minimized, subject to constraints related to the generator's capacity and the energy balance between generation and load demand.The load demand must be computed for a 24 h period in an IMG, and several scenarios can be presented in the HPGS such as: (1) RESs cannot produce energy for 24 h; (2) all the RES in the IMG can always dispatch energy, but not the total demand capacity of the load; (3) the main costs are the fuel costs and the generation of the diesel generator; and (4) the operation cost of the HPGSs are non-linear, generally due to the cost of the diesel generator.
On the other hand, there is a kind of problems, specifically in real-world applications, where it is impossible to find an optimal solution using a viable amount of resources employing traditional techniques such as numerical methods or graphic analysis.These cases correspond to the hard optimization category and have a similar nature to the NP (nondeterministic polynomial time) decision problems since they can not be solved in an optimal way or up to a guaranteed point using deterministic methods in polynomial time.
Metaheuristics are an alternative to find feasible and optimal solutions to NP problems, where any problem modeled as a constrained numerical optimization problem (CNOP) can have at least one optimal feasible solution.A CNOP also known as a general problem of non-linear programming can be defined as: minimize f ( x) subject to: g i ( x) ≤ 0, i = 1, . . ., m or h j ( x) = 0, j = 1, . . ., p. Here, x ∈ R n such that n ≥ 1, is the solution vector x = [x 1 , x 2 , . . ., x n ] T , where each x i , i = 1, . . ., n is delimited by the lower and upper limit L i ≤ x i ≤ U i ; m is the number of inequality constraints and p is the number of equality constraints (in both cases, the constraints can be linear or non-linear).If we denote by F the feasible region (where all the solutions that satisfy the problem are found) and by S the entire search space, then F ⊆ S.
Metaheuristics are well-known algorithms, most of them are inspired by nature, that have successfully solved CNOPs.Metaheuristics are divided into two broad groups: (1) evolutionary algorithms (EAs), whose operation is based on emulating the process of natural evolution and survival of the fittest [9], and (2) swarm intelligence algorithms (SIAs) that base their operation on social and cooperative behaviors of simple organisms such as insects, birds, and bacteria [10].
From the initial ideas of Bremermann [11], in 2002 Passino proposed a novel SIA called Bacterial Foraging Optimization Algorithm (BFOA) [12], based on E.Coli bacteria foraging.In BFOA, each bacterium E. Coli tries to maximize the energy obtained per unit of time spent on the foraging process, while avoiding harmful substances.Moreover, bacteria can communicate with each other by segregating certain substances.There are four main processes in BFOA: (1) chemotaxis (swim-tumble movements), (2) swarming (communication between bacteria), (3) reproduction (cloning of the best bacteria), and (4) elimination-dispersal (replacement of the worst bacteria).Bacteria are potential solutions to the problem and their location represents the values of the problem decision variables.Bacteria can move (generate new solutions) through the chemotaxis cycle; additionally, a movement through the attraction of solutions in promising areas of the search space is generated (as it allows the reproduction of the best solutions).Finally, those bacteria located in areas of low quality are deleted.
In 2009, a simplified BFOA version was proposed, called modified bacterial foraging optimization algorithm (MBFOA) [13], which implements fewer parameters with respect to the original BFOA.MBFOA includes a mechanism for the management of constraints based on feasibility rules, consisting of (a) between two feasible solutions, that with the best value in the objective function is selected, (b) between a feasible solution and a non-feasible solution, the feasible one is selected, and (c) between two non-feasible solutions, the one with the smallest amount of constraint violations is selected [14].MBFOA has been used to solve a number of problems of a different nature.For example, solving a set of chemical and mechanical engineering design problems, obtaining competitive results [13], and the solution of a bi-objective mechanical design problem with constraints [15].
In 2016, a recent algorithm based on MBFOA, called two-swim MBFOA (TS-MBFOA) [16], was proposed.This version includes an operation similar to the mutation operator, used in EAs, as a swimming operator within the chemotaxis process.It also implements a random swim in the chemotaxis process, along with a skew mechanism for the initial population based on the variables range.TS-MBFOA has been used to solve real-world problems of mechatronic design and also in the nutrition field by generating successful healthy menus [17].
There is a number of proposals in the specialized literature using metaheuristics algorithms to optimize particular mathematical models minimizing or maximizing an MG.Some of the EAs employed are Differential Evolution and Genetic Algorithms.SIAs employed are limited to particle swarm optimization (PSO) and BFOA.Other paradigms such as artificial neural networks, harmony search, and hybridizations between harmony search and differential evolution have also been used [18][19][20].A common factor in this works is the management of constraints using the penalty technique, which implies adding more parameters to be defined by the end user.
In Table 1, main proposals based on BFOA were grouped according to particular characteristics.Moreover, other proposals were added-each proposal derived in several contributions.In the first row, representing this work, BFOA is implemented in order to optimize a mathematical model minimizing an IMG, including renewable energy sources such as wind and solar, as well as a conventional generation unit based on diesel fuel.Two novel versions of the BFOA are implemented and tested: TS-MBFOA, and a new proposal called NTS-MBFOA.Results showed that TS-MBFOA obtained better numerical solutions compared to NTS-MBFOA and compared to LSHADE-CV, an EA found in the literature solving the same problem.However, the best solution found by NTS-MBFOA is better from a mechatronic point of view because it favors the lifetime of the IMG and therefore resulting in economic savings in the long term.
In the second row of Table 1, Ahmad and others [21] proposed the bacterial foraging tabu search (BFTS) technique, a hybridization of BFOA and tabu search (TS) using different operational time interval (OTI) to schedule appliances while balancing user comfort (UC).His goal was to reduce both the waiting time and electricity cost simultaneously.Real-time pricing (RTP) scheme was used to get the total cost of electricity consumed.For simulations, they studied an average size modern home with 11 appliances.The simulation results of BFTS-based scheduled clearly shows that the proposed technique is better as compared to BFOA, TS, and unscheduled electricity consumption.The electricity cost and waiting time were minimized thus increasing UC.
In the third row of Table 1, Hasan and others [22] implemented two algorithms aimed at minimizing electricity cost and peak to average ratio (PAR) in a smartgrid by using BFOA and strawberry algorithm (SBA).Real-time pricing (RTP) pricing scheme was used to calculate the electricity cost.A single home with three types of appliances; fixed, shiftable and elastic appliances composed the simulated model.Authors found that these optimization schemes reduce the total electricity cost and peak to the average ratio by shifting the load from on-peak hours to off-peak hours.BFOA performed better than SBA regarding electricity cost minimization.However, the authors concluded that trade-off always exists between cost and user comfort.
In the fourth row of Table 1, Saadia and others [23] gained electricity cost reduction up to 40% in a home energy management system (HEMS) with a single home using BFOA and pigeon inspired optimization (PIO).Cost, PAR and waiting time of the appliances were calculated on the bases of a 120 h time slot.Two types of appliances were used: interruptible and non-interruptible.Critical peak pricing (CPP) was used as a pricing signal to calculate the electricity bills.Simulation results showed that PIO was identified as the best technique as it performs well in reducing cost.PIO gives 37% more waiting time than BFOA; it has 60% less cost by BFOA and PAR is 3% less by BFOA.In the fifth row of Table 1, Wang and others [24] implemented a genetic algorithm to optimize a micro-grid operation considering distributed generation, environmental factors and demand response (DR).Experiments were conducted on a smart micro-grid from Tianjin, China.The building micro-grid system mainly includes distributed generation, energy storage device, electric vehicle, and various load resources.Two prices mechanisms were used, fixed price and DR prices.The main finding of this model is to optimize the cost in the context of considering demand response and system operation without reducing user comfort.Also, the authors found that the natural gas price dramatically influences both the operation cost of the micro-grid and demand response.
In the sixth row of Table 1, Ma and others [25] focus on minimizing the overall system generating cost, including the depreciation cost, the operation cost, the pollutant emission cost, and economic subsidies available for renewable energy source (RES) over the entire dispatch period of an IMG.For experimentation, they use an actual IMG in Dongao Island, China.Authors applied a modified PSO algorithm to solve this optimization problem.Results showed that this algorithm was able to minimize both the fuel consumption cost and pollution emission cost.
In the seventh row of Table 1, Wang and others [26] proposed a distributed locational marginal pricing (DLMP)-based unified energy management system (uEMS) model, which considers both increasing profit benefits for distribution generations (DGs) and increasing stability of the distributed power system (DPS).The model contains two parts: (1) a game theory-based loss reduction allocation (LRA); and (2) a load feedback control (LFC) with price elasticity.Simulation results based on a modified IEEE 37-bus system show that uEMS can lead to a more fairly competitive environment for DGs, where the model can increase DGs' benefits, reduce system losses, and improve stability.
In the last row of Table 1, Zhu and others [27] aimed to find the optimal placement and control parameter settings of multiple battery energy storage System (BESS) units to improve oscillation damping in a power transmission system.They formulated a mixed-integer optimization problem and solved it using PSO.Experiments were conducted on two power systems, the New England 39-bus system, and a Nordic test system.This optimization design can be adapted to seasonal load changes and the minimum number of BESS units to be placed.The superiority of the proposed model was validated with another typical type of controllers in the existing literature.
On the other hand, Aziz and others [28] investigated the techno-economic and environmental performance of a hybrid energy system (HES) under the load following (LF) and cycle charging (CC) strategies using HOMER software as a tool for optimization analysis.Experiments were conducted in a photovoltaic (PV)-diesel-battery configuration.Results show that variations in critical parameters, such as battery minimum state of charge, time step, solar radiation, diesel price, and load growth have considerable effects on the performance of the proposed system.
In summary, the problem of optimal management of energy sources in an IMG can be solved as a dispatch control problem, which deals with the energy flow management from the various sources to load for cost minimization.
This document is organized as follows: Section 2 presents the mathematical modeling of the Isolated Microgrid proposed.Sections 3 and 4 briefly describe TS-MBFOA and the normalized version called NTS-MBFOA.In Section 5, results obtained and the discussion of these are presented.Finally, in Section 6, the conclusions and future works are presented.

Description of the Isolated MicroGrid
An IMG is composed of a set of AC loads and an HPGS.In this work, the HPGS is integrated by a solar photovoltaic generator (PV), a wind turbine generator (WT), a diesel generator (DG) and a battery storage system (BS), as shown in Figure 1.The aim of the optimal management of energy sources in an IMG is to assign the load demands among its distributed generation units securely and reliably, to minimize the overall system generating cost, subject to a set of constraints.Thus, it is essential to compute the operation cost of each of such generation units.In this work, the cost function and data for the BS, PV and WT generators were taken from [29] (2014 prices).In that work, the authors computed the corresponding cost function of the BS, PV, and WT considering the rate of return of the initial investment using a factor of capital recovery in a regular series of equal annual payments.Figure 2 depicts the overall optimization process proposed.

DG Generation Cost
The mathematical relationship associated with this kind of systems is related to the generator power.Without loss of generality, we established the cost function as: where F i and P i are the i-th generation source and its output power, respectively.Also, α, β and γ are the cost coefficients.Therefore, in this work the cost function for the DG systems is given by: Diesel Generator (DSτ) using Eq. 2 Battery Storage System (BSτ) using Eq. 5 Solar Generator (PVτ) using Eq.6 Wind Turbine Generator (WTτ) using Eq.7 Implement TSMBFOA Implement NTSMBFOA

BS Generation Cost
The general cost function, proposed in [29], is given by: where P is the generator output power, a is the rate of return of the initial investment, I p is the inversion cost per installed unit and G E is the operation and maintenance costs per unit of generated power.Also, the rate of return of the initial investment is computed by: where r the interest rate (we set a value of 0.09 for the base case) and N the useful life (we propose 20 years), respectively.In this work, we set a 2 kWh battery storage bank as the ESS system of the IMG.Therefore, the inversion cost per storage unit installed is established as [I p = 1000 $/kW].Also, the operation and maintenance costs per unit is given by [G E =¢1.6/kW].Finally, the cost function is given by: (5)

PV Generation Cost
The PV generation cost was computed using a inversion cost per installed unit of [I p = 5000 $/kW] and the operation and maintenance costs per unit given by [G E =¢1.6/kW].Therefore, the PV generation cost is computed by:

WT Generation Cost
To compute the cost function of the WT generator we use an inversion cost per installed unit given by [I p = 5000 $/kW], and an operation and maintenance costs per unit given by [G E =¢1.6/kW].Thus, the cost function is computed by:

Optimization Strategy
In order to obtain an optimal power generation in an IMG, an economic dispatch problem must be solved.In this problem, the output power of each one of the IMG's sources must be computed at every hour of the day, so that the generation cost is the lowest possible.In this study, the vector of design variables is related to the sources, therefore: where P i with i = 1, . . ., 4 is the output power of the i-th generation source.

Objective Function
The classical economic dispatch problem is established with: subject to the following constraints: where n is the number of generation sources, P min i and P max i are the minimum and maximum values of the output power of the i-th generation source, P L is the total load demanded by the system, and F i is the generation cost of the i-th generation source.
In this work, the objective function at τ-hour is given by: where ω 1 , ω 2 , ω 3 and ω 4 are the weights related with each one of the sources generation.These weights were fixed to 0.25 while the fuel cost was set to USD $1. Finally, considering that the generation cost must be computed at every hour of the day, the total objective function for all the day is:

Design Constraints
In order to produce a proper management of the power generation in the IMG, we considered some design constraints.
• Power Balance: The sum of the generation power of all sources must be equal to the total load demanded by the system: • BS Model: The output power of the solar PV generator and the load demanded at time t by the system, determine the state of charge (SOC) of the battery storage system BS.On the other hand, the SOC of the BS system at hour t, SOC(t), is related to the previous hour SOC, SOC(t − 1) [6]: where , in which η D and η D are the battery charging efficiency and the battery discharging efficiency, respectively.Also, B max C is the maximum battery capacity.
Using Equation (15), a general mathematical equation by the battery dynamics can be established as: where SOC(0) is the initial state of charge of the battery, α C ∑ t τ=1 P 3 (τ) + α C ∑ t τ=1 P 4 (τ) is the input power by the battery and α D ∑ t τ=1 P 2 (τ) is the power discharged by the battery at time t, respectively.Finally, at time t the state of charge of the battery must be between the minimum (SOC min ) and maximum (SOC max ) possible capacity: In this work, the BS parameters are shown in Table 2.

Optimization Problem
We defined the mono-objective optimization problem associated with the optimal power generation as: subject to the constraints: with the bounds: where DG nominal is the nominal capacity of the DG system and B cmax is the maximum capacity of the battery system; with proposed values of 5000 kW and 2000 kW, respectively.Values of P pv and P wind were taken from [30].Indeed, values of P pv (τ) and P wind (τ) (where P pv is the photovoltaic output power and P wind is the wind output power) are based on studies conducted on real data.For the photovoltaic resource, two-day solar irradiation data collected in Celestún (México) was used.For the wind resource, data collected in Celestún (México), Ambewela (Sri Lanka), and Madrid (Spain) for several heights was used.In this study, these ranks are used as input values for the TS-MBFOA and NTS-MBFOA at each run to find the minimum value optimizing the IMG.Table 3 summarizes the initial power in Watts (W) and percentages (for the ESS) of each resource in the IMG per hour.

Two-Swim Modified Bacterial Foraging Optimization Algorithm (TS-MBFOA)
TS-MBFOA is an algorithm derived from MBFOA proposed to solve CNOPs [16].In this metaheuristic, a bacterium i represents a potential solution to the CNOP (i.e., a n-dimensional real-value vector identified as x), and it is defined as θ i (j, G), into a population of bacteria (S b ), where j is the chemotaxis loop (N c ). G is the generational loop that ends up reaching a maximum number of generations (GMAX) or using a number of evaluations, defined by the user, calculated as: A generation includes the following processes: (1) a chemotaxis process with N c loops; (2) a swarming towards the best bacterium of the swarm θ B (G); (3) a reproduction process, if the frequency parameter RepCycle (defined by the user) allows it, with the best bacteria of the swarm S r ; and finally (4) an elimination-dispersal process that eliminates the worst bacterium of the swarm.
Chemotaxis: In this process, two swims are interleaved in each generation: either the exploitation swim or exploration swim is performed.The process starts with the exploitation swim (classical swim).Yet, a bacterium will not necessarily interleave exploration and exploitation swims, because if the new position of a given swim θ i (j + 1, G) has better fitness (based on the feasibility rules) than the original position θ i (j, G), another swim at the same direction will take place in the next loop.Otherwise, a new tumble is computed.The process stops after N c attempts.
The exploration swim uses the mutation between bacteria and is calculated by: where θ r 1 (j, G) and θ r 2 (j, G) are two different randomly selected bacteria from the population.Additionally, σ is a parameter defined by the user used in the swarming operator, which defines the proximity of the new position of a bacterium with respect to the position of the best bacteria in the population θ B (G).In this operator, σ is a positive control parameter for scaling the different vectors in (0,1), i.e., scales of the area where a bacterium can move.
The exploitation swim is calculated as: where φ(i) is calculated with the original tumble operator of BFOA: where ∆(i) T is a random vector with elements within the range [−1, 1].C(i, G) is the random step size of each bacterium updated by: where Θ(i) is a randomly generated vector of size n with elements within the range of each decision variable: [U x , L x ], x = 1, . . ., n, and R is a user-defined parameter for scaling the step size (this value must be close to zero, for example 5.00E-04).The initial C(i, 0) is generated using θ(i).This random step size allows bacteria to move in different directions within the search space and prevents premature convergence, as suggested in [31].
Step size R can be randomly, statically, and dynamically adjusted [32].Swarming: At the half number of the chemotaxis process, the swarming operator is applied with (where σ is a user-defined positive parameter between (0,1)): where θ i (j + 1, G) is the new position of the bacterium i, θ B (G) is the current position of the best generational bacterium and σ, is a parameter called scaling factor, which regulates how close the bacterium i will be from the best bacterium θ B .In this proposal, if a solution violates the boundary of decision variables then a new solution of x i is randomly generated between the lower and upper limits L i ≤ x i ≤ U i of the decision variables.The swarming operator movement applies twice in a chemotaxis loop, while in the remaining steps the tumble-swim movement is carried out.Reproduction: In this process, bacteria are ordered based on the handling constraint technique, duplicating the best bacteria S r , and eliminating the same number of worst bacteria to maintain the size of the population.The process is carried out once every certain number of cycles which is a user-defined parameter 1 ≤ RepCycle ≤ GMAX, it aims to allow the diversity in the swarm.
Elimination-dispersal: Finally, the worst bacterium of the population θ w (j, G) is eliminated based on the feasibility rules, and a new one is randomly generated.
The original proposal of TS-MBFOA includes a skew mechanism to generate the random initial population and a local search engine.However, in this study we did not include this mechanism in order to reduce computational cost.The pseudocode of TS-MBFOA is presented in Algorithm 1.
Algorithm 1: TS-MBFOA pseudocode.S b is the number of bacteria, N c is the number of chemotaxis cycles, σ is the scaling factor, R is the stepsize, S r is the number of bacteria to reproduce, Repcycle is the reproduction frequency and GMAX is the number of generations.

7
Apply the swarming operator using Equation ( 26) and σ for the bacteria θ i (j, G).Duplicate the best bacteria S r and the same number of worst bacteria are eliminated to maintain the size of the population.

end 14
Perform the elimination-dispersal process eliminating the worst bacterium θ w (j, G) from the current population considering the technique of handling constraint.
15 Update the step size vector using Equation (25).

Normalized Two-Swim Modified Bacterial Foraging Optimization Algorithm (NTS-MBFOA)
Normalization is the operation in which a set of values of a certain magnitude are transformed into another one, on a predetermined scale.In this work, normalization represents a change of magnitude at a fixed scale to map the search space of the TS-MBFOA to a range of [−1, 1], and so obtain a better performance of the algorithm solving the IMG problem [33].We employ the following to normalize the bacterial population, as proposed in [34]: where x i is a decision variable, θ i x (j, 0) is the value to normalize the bacterium's current position, and U x is the upper limit of the variable x i .
Denormalization of results consists of the inverse operation, which is a simple multiplication as is defined in: The pseudocode of NTS-MBFOA is presented in Algorithm 2. The new bacterium generated in the elimination-dispersal process is also normalized using Equation (27).The best and worst bacterium are selected according to the feasibility rules of Deb [14], using the objective function value and the sum of violated constraints.In this algorithm, bacteria are ordered from best to worst.First, bacteria are denormalized and evaluated both in the objective function and the problem constraints.Subsequently, bacteria are ordered.The set of ordered bacteria is again normalized to continue with the following algorithm processes.Figure 3 describes the TS-MBFOA operation.Algorithm 2: NTS-MBFOA pseudocode.S b is the number of bacteria, N c is the number of chemotaxis cycles, σ is the scaling factor, R is the step size, S r is the number of bacteria to reproduce, Repcycle is the reproduction frequency and GMAX is the number of generations.

8
Apply the swarming operator using Equation ( 26) and σ for the bacteria θ i (j, G).Perform the reproduction process by ordering the population according to the feasibility rules.

13
Duplicate the best bacteria S r and the same number of worst bacteria are eliminated to maintain the size of the population.

end 15
Perform the elimination-dispersal process eliminating the worst bacterium θ w (j, G) from the current population considering the technique of handling constraint.The new bacterium generated is normalized with Equation ( 27).

Results
We implemented TS-BFOA and NTS-MBFOA to solve the IMG problem on three computers with the following characteristics: a PC with 4 GB RAM, 2.3 Ghz processor; and two PCs with 8.0 GB RAM, 2.4 GHz processor.We use the Matlab R2018b development platform over a 64 bit Windows operating system.

First Experiment
First, we calibrate the parameters for TSM-BFOA and NTS-MBFOA via 87 independent runs with a diverse combination of parameters and 15,000 generations.The ranges tested for each parameter were: S b between [10,200], N c between [5,100], S r between [1, S b /2], RepCycle between [10,200], R, B between [0,1] and GMAX between [5000,15,000].The best result obtained from all the independent runs was the value −564,959.112.During the calibration phase, we noticed that the higher the number of bacteria and chemotaxis cycles, the execution time of both algorithms increased from an order of seconds to minutes, due to the number of evaluations needed (number of times that a solution is evaluated in the objective function and constraints), which is calculated by S b × N c × GMAX.TS-MBFOA takes ∼14 min, on average, using the best combination of parameters.In the case of NTS-MBFOA, the algorithm takes ∼16 min on average.This time can be improved using a computer with a better processor.
We found that, by increasing the reproduction frequency (RepCycle) to values greater than 60, the results quality of the algorithm decreased, that is, the population of bacteria loses diversity.Therefore, a lower number of bacteria S r favors the performance of the algorithm.
Finally, values close to zero for the step size R and scaling factor B allow a better balance between exploitation and exploration of the search space and have a positive impact on the performance of the algorithm when generating higher quality solutions according to the objective function.
From these experiments, the best parameter calibration is presented in Table 4.

Second Experiment
We ran independently both TS-MBFOA and NTS-MBFOA 30 times with the parameter configuration obtained in the previous experiment.The statistical results of both algorithms are shown in Table 5.The standard deviation is calculated using the best solution found in each of the 30 independent runs, where the best solution is the sum of the 24 objective functions in a run.TS-MBFOA obtained the best solution with a value of −551,960.121followed by NTS-MBFOA with a value −549,369.785 in the objective function.Values are negative because they represent an economic saving when operating with RES, instead of using only the diesel generator and the ESS (battery).The more energy supplied by the RES and the less supplied by the DG and the ESS, the higher the savings.
A convergence graph was generated for TS-MBFOA and NTS-MBFOA using the data of the independent run number 15 (representing the median).In Figure 4, we can observe the behavior of each algorithm during the 24 h, both algorithms starting with infeasible solutions.For the NTS-MBFOA, feasible solutions arise in the first ∼10 generations, except for hours 16:00, 17:00, and 23:00, where the algorithm requires more generations.For the TS-MBFOA, solutions are found beyond 200 generations.As can be observed in Figure 4, the NTS-MBFOA converges more quickly on feasible solutions, which indicates a lower computational cost than TS-BFOA.
With respect to the quality of the solutions found by the algorithms in each of the 24 h, the convergence graphs indicate that both algorithms behave differently along the day, but in hours 00:00, 02:00-04:00, 06:00-07:00, 13:00-14:00, 16:00-18:00 and 22:00-23:00 the TS-MBFOA algorithm generates better feasible solutions.In the rest of the hours, NTS-MBFOA generates a better solution to the objective function.In run number 15, the TS-MBFOA obtained a value of −525,869.49in the objective function, in the case of NTS-MBFOA the value found was −422,989.41.Results of bacterial foraging-based algorithms are better when compared against the LSHADE-CV algorithm.However, a higher number of evaluations is required.Parameters reported by the authors of LSHADE-CV algorithm are presented in Table 6.LSHADE-CV dynamically tuned the parameters using operators such as parameter memory and linear population reduction [35].The best numeric solution was −532,508.057.Besides, BFOAs obtained a better median, average, standard deviation and the worst value found is close to the average.Analyzing the results of the TS-MBFOA and the NTS-MBFOA, we observed that NTS-MBFOA has a lower standard deviation than the TS-MBFOA because it finds the better among the worst results, that is, results closer to the average.To know if there is a significant difference between the NTS-MBFOA and TS-MBFOA algorithms, we conducted the non-parametric Wilcoxon Signed Rank Test, with a confidence level of 95% to the set of the 30 best solutions obtained of the 30 independent runs of each algorithm.The result obtained by this test was a p value of 0.00112, which implies that there is a significant difference between the results of both algorithms.
To analyze results from the mechatronic point of view, we used the values of the best solution generated by TS-MBFOA, NTS-MBFOA, and LSHADE-CV, respectively, for the IMG during the 24 h.
Values presented in Tables 7-9 were used to generate the IMG behavior graphs shown in Figure 5, respectively.In these graphs, each resource is marked with different lines.In the case of the BFOAs, it is important to highlight that the conditions established for the use of solar and wind energy favor the high demand for diesel consumption (see Table 3).Analyzing the behavior graphs of the TS-MBFOA and the NTS-MBFOA, we can observe that both algorithms produce similar results, i.e., both allow the consumption of solar and wind energy while decreasing the use of the diesel generator and the intervention of the battery (ESS).
Specifically, the use of solar power increases from 07:00 h onwards and decreases after 17:00 h, when the sun begins to hide.Concerning the wind power, both graphs show variations of peaks in the first hours, reaching a maximum production of energy close to 1250 watts between the 13:00 and 19:00 h.The ESS operates in a considerable and constant way between 13:00 h and 18:00 h.However, in the early hours of the day, the solution generated by TS-MBFOA presents several peaks (state transitions of the battery operation) that fall and rise abruptly, which decreases the battery's lifetime.
The behavior of the solar and wind power, as well as ESS, tends to reduce the diesel demand from 12:00 h.Moreover, diesel is even not used for one hour, between 14:00 and 15:00 h, in both algorithms.However, when solar power is depleted, diesel power begins to rapidly increase.Analyzing the behavior of the use of diesel in the early hours of the day, it is evident that the NTS-MBFOA solution allows less diesel generator starts by having fewer peaks during the first hours of the day, which increases the lifetime of the diesel generator.
TS-MBFOA obtained a better solution in numbers, with −551 960.121 in the objective function value, compared to NTS-MBFOA, that obtained a value of −549, 369.785 in the objective function.The behavior of the graph lines, which correspond to the resources used in the IMG, favors the NTS-MBFOA because this solution increases the useful lifetime of the ESS and the DG, allowing economic savings on the long term.
Comparing the behavior graphs of the NTS-MBFOA and LSHADE-CV, we observe similar behavior in all the components of the IMG.Only from the hour 15:00 to 16:00 h it is evident how the EA delays the start of the diesel generator.On the other hand, from the hour 21:00 to 22:00 h, this algorithm starts the diesel generator slightly, something that does not happen in NTS-MBFOA.Since the graphs are very similar, we can take the numerical values as a point of comparison, where the best results of both algorithms were −549,369.785and 532,508.057,respectively.We can conclude that

Figure 1 .
Figure 1.Hybrid power generation system components.
Output solution: Minimum cost per hour τ = 0 Solve the economic dispatch problem at time τ according to Eq. 18 s.t.Eq. 19 yes τ < 24 Compute the generation cost of the Hybrid Power Generation System:

4 for i=1 to S b do 5 for
j=1 to N c do6

11 Perform
the reproduction process by ordering the population according to the feasibility rules.

Figure 4 .
Figure 4. Convergence graph of TS-MBFOA and NTS-MBFOA in the independent run number 15.

Figure 5 .
Figure 5. Visualization of the power supply during the 24 h of the day for the operation of the NIR-MG, obtained by the TS-MBFOA, NTS-MBFOA and LSHADE-CV.

Table 1 .
Algorithms used for smartgrid optimization.

Table 2 .
Energy Storage System parameters.

Table 3 .
Starting conditions (in Watts and percentages) of the resources included in the IMG.L P = Load power, P 1 = Diesel power, P 2 = ESS, P 3 = Solar power and P 4 = Wind power.

Table 5 .
Basic Statistics of the results obtained by TS-MBFOA and NTS-MBFOA compared against an Evolutionary Algorithm.Std is the standard deviation.

Table 6 .
Parameters of LSHADE-CV.D is the number of decision variables of the problem, in this case D = 4.

Table 7 .
Details of the best solution found by the TS-MBFOA.

Table 8 .
Details of the best solution found by the NTS-MBFOA.

Table 9 .
Details of the best solution found by LSHADE-CV.