Research on Economic Optimal Dispatching of Microgrid Based on an Improved Bacteria Foraging Optimization

This paper proposes an improved Bacterial Foraging Optimization for economically optimal dispatching of the microgrid. Three optimized steps are presented to solve the slow convergence, poor precision, and low efficiency of traditional Bacterial Foraging Optimization. First, the self-adaptive step size equation in the chemotaxis process is present, and the particle swarm velocity equation is used to improve the convergence speed and precision of the algorithm. Second, the crisscross algorithm is used to enrich the replication population and improve the global search performance of the algorithm in the replication process. Finally, the dynamic probability and sine-cosine algorithm are used to solve the problem of easy loss of high-quality individuals in dispersal. Quantitative analysis and experiments demonstrated the superiority of the algorithm in the benchmark function. In addition, this study built a multi-objective microgrid dynamic economic dispatch model and dealt with the uncertainty of wind and solar using the Monte Carlo method in the model. Experiments show that this model can effectively reduce the operating cost of the microgrid, improve economic benefits, and reduce environmental pollution. The economic cost is reduced by 3.79% compared to the widely used PSO, and the economic cost is reduced by 5.23% compared to the traditional BFO.


Introduction
The electricity demand continues to expand with social science and technology development. It is challenging to meet electricity demand using only traditional thermal power generation methods. Distributed generation (DG) is widely used in microgrid systems and supplies power to regional users because of its flexible control, self-protection, and schedulability. The energy consumption problems caused by traditional power generation methods can be alleviated, and the environmental pollution caused by thermal power generation can be reduced. Wind and photovoltaics are clean and renewable energy sources in microgrids. However, the intermittence and fluctuations caused by wind speed and light intensity will challenge the stable operation of the grid system with a large-scale grid connection of wind turbines and photovoltaic panels. Therefore, it is necessary to first deal with the uncertainty of wind photovoltaics and then use DG, which can operate flexibly and cooperate with renewable energy generation technologies to build a microgrid and optimize its scheduling. This model effectively reduces economic costs and improves power supply quality and stability.
Many scholars have studied the uncertainty treatment of wind and light. Ref. [1] proposed a Latin hypercube sampling method to process the uncertainty of wind and solar data, effectively reducing the impact of wind and light on power grid peak shaving [2]. Combining the roulette wheel mechanism and Monte Carlo thinking to process wind and light data, using randomly generated scenes to simulate the uncertain process of scenery, this method can effectively reduce the economic cost of hydrothermal unit scheduling.
Linear programming [3][4][5], dynamic programming [6,7], Lagrangian relaxation [8], and nonlinear programming [9,10] have many problems with large-scale power systems, Biomimetics 2023, 8,150 2 of 23 such as traditional microgrid dispatching optimization methods. Various electrical constraints also increase the complexity and difficulty of microgrid dispatching optimization. These problems mainly focus on accuracy and computational efficiency. An increasing number of swarm intelligence algorithms have been applied to microgrid dispatching optimization to overcome such problems. Some mature swarm intelligence algorithms, such as PSO [11], GA [12], and WOA [13] are widely used in microgrid dispatching optimization due to their advantages of fast convergence and simple processes. However, these traditional algorithms also easily fall into local optima, have low efficiency, premature convergence results, and low precision. Many optimization methods have been encountered in the process of microgrid dispatching optimization. Reference [14] introduced a simulated annealing algorithm and chaos optimization into the PSO algorithm, enriching the population diversity, and enhancing the global search ability. Reference [15] presented a differential evolution algorithm (ED) into the quantum particle swarm optimization algorithm (QPSO), which improved the ability to jump out of the optimal local solution in the later stage. Reference [16] proposed using tabu search to optimize particle swarm optimization compared with CLQPSO and short-term microgrid scheduling results. The IPSO is better than the traditional PSO and Tabu Search (TS) in the two-level energy optimization scheduling strategy. Reference [17] proposed a BPSO method for scheduling household energy management systems with distributed power sources. This method can effectively reduce economic costs, energy consumption, and environmental pollution. Reference [18] used an adaptive strategy to optimize the GA to improve its convergence accuracy of the GA algorithm.
Moreover, Reference [19] combined the advantages of the GA and PSO algorithms. The microgrid dispatching optimization was modeled as a quadratic programming problem, and the improved GA-PSO algorithm was used. The WOA has a higher solution quality than the PSO and GA. However, WOA also needs help with problems, such as premature convergence and low accuracy of the results. To improve the performance of WOA, Reference [20] uses adaptive inertia weight, spiral search method, and generalized inverse learning to improve and optimize WOA. The results of multiregion interconnected microgrid system scheduling prove that this optimization method can effectively improve the performance of the WOA and reduce the cost of microgrid operation. New swarm intelligence algorithms have been gradually developed and applied to microgrid economic dispatch models. Reference [21] proposed an economic dispatch model using the cuckoo algorithm to optimize multiple microgrids and determined the power supply strategy by predicting the best state of charge of the battery. This method has a significant improvement over PSO. Reference [22] utilized a mixture of bacterial foraging algorithms and genetic algorithms to achieve minimum cost load management [23]. The bacterial foraging algorithm is also used to achieve the scheduling of isolated microgrids, and a large number of experiments have proven the effectiveness of the proposed method, which can reduce economic cost. Reference [24] proposed a bald eagle search optimization algorithm (BE-SOA) to control the scheduling between demand and power supply, which can effectively reduce energy costs and microgrid emissions costs. Reference [25] proposed applying the butterfly algorithm to the microgrid scheduling solution. Aiming at the problem of poor convergence accuracy of the butterfly algorithm and easy falling into a local optimum, they used Cauchy mutation to improve the position information of the butterfly and expand the global search performance of the algorithm by using chaotic mapping enriched species diversity. The method's effectiveness is proven by scheduling a microgrid cluster system composed of multiple microgrids. An improved crow algorithm [26] is proposed for microgrid scheduling with distributed power sources. By introducing a Levy flight strategy, the convergence speed and result accuracy of the algorithm can be effectively improved. Most swarm intelligence research focuses on solving the performance of algorithms in the microgrid dispatching process. (2) The main contributions of this study are as follows: (1) This study improved the algorithm's speed and considered its accuracy in chemotaxis.
The adaptive step size formula replaces the standard fixed step size, and the PSO speed formula is introduced to improve the random direction vector (PHI). (2) The crisscross algorithm is used to improve the population of the algorithm and global search performance in the replication part. (3) The dynamic dispersal equation and sine-cosine algorithm were used to improve the loss of high-quality results and the algorithm's efficiency for the dispersal part.
The remainder of this paper is organized as follows: the first section builds a microgrid model with multiple objective cost functions; the second section describes the improvement of the BFO, quantitatively analyzes the impact of each part of the improvement, and conducts a comparative test; the third section deals with the uncertain processes of wind and solar, applies the BFO to the microgrid dispatching model to solve it, and gives the comparative experimental results; and the fourth section is a summary of the full text.

Microgrid Economic Dispatch Model
The microgrid example comprises distributed power sources, such as wind generators, photovoltaic power generation panels, diesel engines, micro steam turbines, and fuel cells shown in Figure 1.
in the microgrid dispatching process. (2) The main contributions of this study are lows: (1) This study improved the algorithm's speed and considered its accuracy in chem The adaptive step size formula replaces the standard fixed step size, and th speed formula is introduced to improve the random direction vector (PHI). (2) The crisscross algorithm is used to improve the population of the algorithm and search performance in the replication part. (3) The dynamic dispersal equation and sine-cosine algorithm were used to impr loss of high-quality results and the algorithm's efficiency for the dispersal part The remainder of this paper is organized as follows: the first section build crogrid model with multiple objective cost functions; the second section describes provement of the BFO, quantitatively analyzes the impact of each part of the im ment, and conducts a comparative test; the third section deals with the uncertain pr of wind and solar, applies the BFO to the microgrid dispatching model to solve gives the comparative experimental results; and the fourth section is a summary full text.

Microgrid Economic Dispatch Model
The microgrid example comprises distributed power sources, such as wind g tors, photovoltaic power generation panels, diesel engines, micro steam turbines, a cells shown in Figure 1.

The Model of DG
As energy generation forms, wind and photovoltaic power have significant vo and are affected by many meteorological factors, such as wind speed, wind directio intensity, and temperature. Therefore, the power balance brought by wind power ation has great uncertainty. A model of a wind turbine follows:

The Model of DG
As energy generation forms, wind and photovoltaic power have significant volatility and are affected by many meteorological factors, such as wind speed, wind direction, light intensity, and temperature. Therefore, the power balance brought by wind power generation has great uncertainty. A model of a wind turbine follows: (1) In Equation (1), (Explain the specific meaning of the formula) P W represents the output of wind power, P n represents rated power, and the output of wind power generation is related to the actual wind speed, where v represents actual wind speed, v in , v out and v n represent the cut-in wind speed, cut-out wind speed, and rated wind speed, respectively. When the wind speed is less than the cut-in wind speed or greater than the cut-out wind speed, the fan is not working. The output power is zero. If the wind speed is between the rated wind speed and the cut-out wind speed, the fan output is at the rated power output. When the wind speed is between, the output power of the fan is reflected by the empirical equation.
Photovoltaic panel model: Photovoltaic output is positively correlated with light intensity. In Equation (2), P V represents the output power of solar energy, r represents the light intensity, s represents the total radiation area of the photovoltaic module, and η V represents the photoelectric conversion efficiency of the photovoltaic panel.
Diesel generator model: The mathematical model of diesel generators is like that of coal-fired units in thermal power generation, and it has a particular peak-shaving effect in microgrids. The formula is as follows: In Equation (3), a i , b i , and c i are the cost coefficients of diesel generators; C DE represents the cost of power generation; P DE represents the output of generators; N represents the number of diesel generators.
Micro Turbine Model: The stand-alone power of a microturbine is small, generally between 20 and 300 KW, and its formula is as follows: In Equation (4), Price and L represent the price and calorific value of natural gas, respectively; P MG (t) represents the output power of the microturbine at time t; η MG (t) represents the power generation efficiency at this time, and the efficiencies of different types of micro-turbines can be obtained by polynomial curve fitting. The model of the micro turbine is C65; ∆t indicates the operating hours.
Fuel cell model: Fuel cells are known as the fourth-generation power generation device technology. Proton exchange membrane fuel cells are selected, and their cost formula is similar to that of microturbines: In Equations (5), P FC (t) and η FC represent the fuel cell's output power and power generation efficiency, respectively, where the power generation efficiency can also be obtained by polynomial curve fitting.
The traditional neural network prediction method for wind and solar output prediction is unsuitable because wind and solar have volatility and randomness and are affected by many factors. Traditional wind and solar output forecasting use a neural network to make regression predictions on historical power. However, the predicted value often needs to reflect the influence of uncertain weather conditions on wind and solar output. Aiming at the uncertainty processing of wind and solar, Ref. [27] proposed a two-stage optimization model of the microgrid from the two stages of day ahead and real time. This method can effectively reduce the prediction error and improve the stability of the power supply. Ref. [28] proposed a microgrid interval optimization method based on affine arithmetic and used the non-dominated sorting genetic algorithm to solve the framework. The results show that this method can effectively alleviate the uncertainty brought by renewable energy, such as wind and solar. Ref. [29] considered the meteorological conditions comprehensively, using a data-driven Bayesian non-parametric method, modified column, and constraint generation (CC) to solve the uncertainty problem of the scenery further. This paper uses the Monte Carlo sampling method to reduce the scene of wind and solar generation. The uncertain process of wind power and photovoltaic output is simulated by randomly optimized scenario generation and reduction. The core idea of Monte Carlo is to use the frequency of events to approximate the probability of event occurrence and use the Euclidean distance as the basis for scene reduction to iterate. The method is mainly divided into three parts: building a probability model, sampling, and valuation.
Weibull distribution of wind speed: In Equation (6), v represents the actual wind speed, and c and k are Weibull's model parameters.
Beta distribution of light intensity: In Equation (7), s represents the light intensity α and β is the shape parameter of the Beta distribution. The wind speed and light intensity data fitted by Weibull and Beta distributions are, respectively, substituted into the wind turbine output model and the photovoltaic power generation output model. The wind and solar output prediction is obtained by using Monte Carlo scene reduction.

Microgrid Economic Dispatching Model
There are multiple objective functions and constraints in the microgrid dispatching optimization problem, and most of the research on microgrid scheduling only considers the cost target of the DG output of the microgrid and the cost of electricity purchase and sale. In this paper's microgrid economic dispatching model, there are traditional power generation, such as microturbines and diesel generators, so the three objective functions of DG cost, environmental impact cost, and power purchase cost are considered comprehensively.
Power Generation Cost: In Equation (8), T represents the scheduling cycle; N represents the total number of distributed power sources; C i, f and C i,m ￼ respectively, P i,t cost and equipment maintenance cost of distributed power sources; ￼ represents the output result of the i-th power source at time t. The installation and maintenance costs of wind turbines and photovoltaic power generation panels are not considered here.
Environmental Impact Costs: In the microgrid of this example, there is a distributed power source that uses natural gas, diesel, and other energy supplies as raw materials for power generation. It is also necessary to include the environmental impact cost in the objective function of microgrid dispatching optimization to consider the environmental gas pollution caused by the consumption of these raw materials (mainly refers to CO 2 , SO 2 , NO X , etc.): Equation (9), C i,e represents the pollution gas environmental cost coefficient corresponding to each distributed power supply.
Electricity price cost: To reflect intuitively the consumption and utilization of the microgrid, consider the cost of electricity price as the objective optimization function: In Equation (10), C grid,t represents the real-time electricity price (24 h system); P grid,t represents the power exchange result between the microgrid and the enormous power grid after considering the user load.
In summary, the objective function of microgrid dispatching optimization can be expressed as Micro Turbine Constraints: In Equation (12), P min MG represents the minimum output constraint of the microturbine; P max MG represents the maximum power of the microturbine unit output; some studies use the rated power here.
Diesel Constraints: Fuel Cell Constraints: Power exchange constraints between the microgrid and main grid: In the above equation, P min grid P max grid ￼ represent the minimum and maximum power allowed for power exchange between the microgrid and the primary grid.
Microgrid supply and demand balance constraints: In Equation (16), P L,t represents the total power demanded by the load during the t period.

An Improved Bacterial Foraging Optimization and Its Application
The BFO [30][31][32] is a new swarm intelligence algorithm mainly divided into chemotaxis, replication, and dispersal. (BFO's Short Insights) Traditional BFOs will face problems, such as slow convergence speed, poor accuracy of results, easy to fall into local optimization, and low efficiency of algorithms. The schematic diagram of E. coli is shown in Figure 2, Figure 2a represents the forward swimming process of E. coli, and Figure 2b represents the overturning process of E. coli.

An Improved Bacterial Foraging Optimization and Its Application
The BFO [30][31][32] is a new swarm intelligence algorithm mainly divide taxis, replication, and dispersal. (BFO's Short Insights) Traditional BFOs w lems, such as slow convergence speed, poor accuracy of results, easy to fal timization, and low efficiency of algorithms. The schematic diagram of E. c Figure 2, Figure 2a represents the forward swimming process of E. coli, represents the overturning process of E. coli.

Chemotaxis Process
Chemotaxis is a significant part of the BFO algorithm. It simulates th reverse of Escherichia coli in the foraging process, as shown in the above pict This is used as the primary means of optimization. The following formul mate the process of flipping forward: In Equation (17)

Chemotaxis Process
Chemotaxis is a significant part of the BFO algorithm. It simulates the forward and reverse of Escherichia coli in the foraging process, as shown in the above picture ( Figure 2). This is used as the primary means of optimization. The following formula can approximate the process of flipping forward: In Equation (17), θ(i, j, k, l) represents the position of the i-th bacterium at the j-th chemotaxis, k-th replication, and l-th dispersal; C(i) represents the step size of the i-th bacterium, and the traditional Bacterial Foraging Optimization adopts a fixed step size formula to find the Optimal solution; PHI represents the random direction of bacteria forward; ∆i is the defined random direction vector.
Step size C has a significant impact on the convergence speed and accuracy of the algorithm. Although a more significant step size can increase the convergence speed, it reduces the accuracy. Although a too-small step size can improve the solution accuracy, it will cause the algorithm to converge slowly. The fixed step size in the traditional BFO is a fundamental reason for the slow convergence of the algorithm because it cannot balance the convergence speed and accuracy. Ref. [33] introduced the step size search formula of the fish swarm algorithm into the BFO and used an adaptive function to improve the step size. The speed of this function is very slow at the beginning of the iteration, and the speed suddenly increases at the end of the iteration. Although this method can improve the convergence speed to a certain extent, its impact on the global search performance of the algorithm remains to be verified. For this reason, this paper proposes to use the dynamic step size formula instead of the traditional fixed value. In Equation (18), (We rewrote the correlation equation) N c , N re , and N ed , respectively, denote the number of chemotaxis restriction, replication restriction, and dispersal restriction in the α 1 ￼ expressed as the step length coefficient. The above equation makes it possible to search with a more significant step size in the early stage of the algorithm iteration and speed up the algorithm's convergence speed. As the number of iterations increases, a refined search is performed with a small step size in the later stage of the iteration to improve the algorithm's accuracy.
Another factor that plays a crucial role in the convergence speed is the random direction vector PHI. Due to the random process being included in the definition of the random direction vector, the convergence speed of the algorithm is limited [34]. For this reason, this paper proposes a particle swarm algorithm speed formula using dynamic inertia weight factors to replace the traditional random direction vector.
In Equation (19), V represents the velocity; c 1 and c 2 represent the weight coefficient; r 1 and r 2 represent random number; Pbest i Gbest i ￼ represent the current optimal solution and the optimal global solution, respectively w_now ￼ represents the dynamic inertia weight coefficient. The advantages of the fast solution speed of the particle swarm optimization algorithm are mainly reflected in the speed and population update formula. The update of velocity V depends on the optimal solution, which is very different from random optimization. Many invalid searches are avoided, which is also the main reason for the fast iteration of the particle swarm optimization algorithm. Replacing the traditional PHI with the speed formula can speed up the chemotaxis speed of bacteria foraging and significantly improve the convergence speed and efficiency of the algorithm (Algorithm 1). Calculate the influence of bacterial clustering behavior on fitness value and save as Jl 5 Replacing PHI with Particle Swarm Velocity Formula 6 P(i,j + 1) = P(j) + C * PHI 7 Update fitness value J 8 while (m < Ns) 9 if (J < Jl) 10 Update

Replication Process
The replication process is the process of simulating the biological elimination competition of bacteria. After the chemotaxis is completed, the replication operation is performed according to the accumulated health value of the bacteria, namely: In Equation (21), J i Health represents the cumulative health value of bacteria i; N c which represents the total number of chemotaxis. The BFO algorithm uses the binary replication method. The cumulative health value is sorted in ascending order, and the first half of highquality bacterial individuals are copied to keep the overall number of bacteria unchanged.
The traditional binary replication method has certain disadvantages. Although the algorithm's complexity is reduced, the diversity of the population is also significantly reduced. Currently, the improvement of the BFO replication process mainly focuses on the hybridization of the population, and the commonly used methods include mixed GA. Ref. [35] proposed the method of crossing bacterial individuals to improve the population. However, this paper proposes to use the crisscross algorithm [36][37][38] to replace the binary replication method to improve the replication process and ensure the diversity of the population. The crisscross algorithm has been an emerging swarm intelligence algorithm in recent years. Each crossover iteration of the crisscross has a comparison process with the previous generation different from Ref. [35]. The horizontal crossover process is as follows: This equation is expressed as the intersection of X(x, d) and X(y, d) in the d dimension, which r 1 represents a random number between [0, 1] and c 1 represents a random number between [−1, 1]. Two individuals can be crossed to produce two offspring, which can be decided by updating the health value. High-quality individuals enter the next step of the vertical crossover process.
The vertical cross process is: This formula is expressed as crossing bacteria x in two dimensions. The vertical crossing is a random process. The vertical crossing will be performed only when the satisfaction probability is less than the crossing probability. This is also the difference from the horizontal crossing. At the same time, it is only better than the parent generation. The cross children will be retained for the next iteration. Relying on the CSO to update the population in different dimensions can effectively broaden the population's diversity and enhance the algorithm's global search performance (Algorithm 2).

Dispersal Process
Dispersion is significant to ensure that the algorithm jumps out of the optimal local solution. The algorithm is designed to regenerate a bacterium i according to the initial population generation formula if the random probability r is less than the fixed dispersal probability P ed . This method simulates the influence of the external environment on E. coli. The traditional fixed dispersal probability will bring certain disadvantages. Some highquality bacterial individuals will be eliminated, thereby reducing the algorithm's efficiency under the fixed probability to satisfy the algorithm's general nature. This paper introduces a dynamic probability formula to replace the traditional fixed dispersal probability through: The probability can be adjusted to a dynamic probability that changes with the health value. In Equations (25), J worst represents the worst value of the health degree, J best represents the optimal value of the health degree, and J x represents the real-time health value of the x-th bacteria. The probability of individuals with excellent health values being dispersed decreases while the probability of bacterial individuals with poor health values being dispersed increases in this way. Thus, the high-quality individuals avoid loss and ensure the efficiency and performance of the algorithm. Although, the dynamic dispersal probability can avoid the loss of high-quality solutions as much as possible. This paper proposes the Sine-Cosine algorithm (SCA) to improve the dispersal process.
SCA is a new swarm intelligence algorithm proposed by Australian scholar Mirjalili in 2016 [39]. The algorithm utilizes sine and cosine functions inspired by the fluctuating optimization of sine and cosine functions to fluctuate the initial random candidate solution toward the optimal solution or vice versa to complete the optimization process.
The above equation X t i represents the position of the i-th dimension of the current solution in the t-th iteration, the value of r 1 to r 4 means a random number, indicating the end position of the i-th dimension. r 4 is a random number that represents the determination of the probability of a search strategy. Taking 0.5 allows the two strategies to be performed with equal probability. When the random number is less than 0.5, a sinusoidal oscillation search is performed, and when the random number is greater than 0.5, a cosine oscillation search is performed. Ref. [40] applies the SCA to the process of chemotaxis and uses the sine-cosine search formula to optimize the random direction vector PHI so that the step size can be reduced linearly from a to 0. The speed of BFO improves in this model. This paper proposes using the SCA to improve population generation in dispersal. After satisfying the dynamic dispersal probability, it is judged again to perform the sine-cosine search. The terminal position is set as the optimal bacterial position, and the above formula generates dispersed populations of bacteria that meet the requirements. The dispersed bacteria will change with the optimization process of the algorithm. Thus, the loss of the optimal value caused by the randomness of traditional methods is avoided, and the algorithm's efficiency is improved (Algorithm 3).

Test Analysis
To quantitatively analyze the impact of each improved part on the performance of the algorithm, this paper uses six test functions to test BFO and BFO with CSO and BFO with SCA and BFO with CSO and SCA, BFO with PSO, IBFO with PSO, and CSO and SCA. Moreover, this paper compared BFO with PSO and some improved bacterial foraging algorithms. The number of iterations is 400, the number of bacteria s is 50, the number of chemotaxis Nc is 50, the maximum number of steps Ns of one-way movement is 4, the number of copy operations Nre is 4, the number of dispersal Ned is 2, the traditional dispersal probability Ped is 0.25, the number of attractants d attract is 0.1, the release rate of the attractant ommiga attract is 0.2, the number of repellants h repellant is 0.1, and the release rate ommiga repellant of the repellant is 0.1. Each group of test functions is carried out in 20 experiments, and the test results are as follows (Table 1, Figures 3-8). Ackley Alpine Schwefel                  The ordinate in the figure above represents the function value, and the abscissa represents the iteration number. By combining the algorithm's test results and convergence curve, SCA comprehensively improves the convergence speed and accuracy of the algorithm. The CSO improves the algorithm's accuracy more significantly but at the expense of convergence speed. Mixing the two will improve the accuracy due to SCA's efficient population dispersal during the dispersal process. It reduces the algorithm speed slightly simultaneously because mixing crisscross takes some time. However, the CSO enriches the replication population and improves the search performance of the algorithm. The convergence result will change abruptly due to the influence of dispersal on population initialization when iteration is 200 times. Improving the dispersal process can effectively alleviate this situation and make the whole process of algorithm convergence relatively smooth. Mixing PSO can significantly improve the convergence rate of BFO because PSO can improve the process of E. coli rollover swimming and avoid a lot of invalid random searches. The speed update formula of the particle swarm optimization algorithm can quickly search for iteration. The BFO integrated with various optimization parts has the highest search accuracy and the fastest iteration speed. This paper also compares some other algorithms for BFO optimization, such as the Hormone Regulation based Emotional Bacterial Foraging Algorithm (HR-EBFA) [41], Bacterial Foraging reinforcement Learning Optimization Algorithm (RL-BFA) [42], the improved Quantum Bacterial Foraging Algorithm (MQBFA) [44], and Distribution Estimation based adaptive Bacterial Foraging Algorithm (BFOED) [43]. The improved bacterial foraging algorithm presented in this paper has better results than the above methods.

Algorithm Application and Experimental Analysis
In this paper, microgrid dispatching optimization is designed as the behavior of bacteria foraging. The flow chart is as follows: Among them, in Figure 9 ,the bacterial population is initialized as a six-dimensional array:  The ordinate in the figure above represents the function value, and the abscissa represents the iteration number. By combining the algorithm's test results and convergence curve, SCA comprehensively improves the convergence speed and accuracy of the algorithm. The CSO improves the algorithm's accuracy more significantly but at the expense of convergence speed. Mixing the two will improve the accuracy due to SCA's efficient population dispersal during the dispersal process. It reduces the algorithm speed slightly simultaneously because mixing crisscross takes some time. However, the CSO enriches the replication population and improves the search performance of the algorithm. The convergence result will change abruptly due to the influence of dispersal on population initialization when iteration is 200 times. Improving the dispersal process can effectively alleviate this situation and make the whole process of algorithm convergence relatively smooth. Mixing PSO can significantly improve the convergence rate of BFO because PSO can improve the process of E. coli rollover swimming and avoid a lot of invalid random searches. The speed update formula of the particle swarm optimization algorithm can quickly search for iteration. The BFO integrated with various optimization parts has the highest search accuracy and the fastest iteration speed. This paper also compares some other algorithms for BFO optimization, such as the Hormone Regulation based Emotional Bacterial Foraging Algorithm (HR-EBFA) [41], Bacterial Foraging reinforcement Learning Optimization Algorithm (RL-BFA) [42], the improved Quantum Bacterial Foraging Algorithm (MQBFA) [44], and Distribution Estimation based adaptive Bacterial Foraging Algorithm (BFOED) [43]. The improved bacterial foraging algorithm presented in this paper has better results than the above methods.

Algorithm Application and Experimental Analysis
In this paper, microgrid dispatching optimization is designed as the behavior of bacteria foraging. The flow chart is as follows: Among them, in Figure 9, the bacterial population is initialized as a six-dimensional array: P = zeros(N, T, popsize, N c , N re , N ed ). The first to sixth dimensions correspond to the distributed power supply, the microgrid operating period, the number of bacteria, the number of chemotaxes, the number of replications, and the number of dispersals.

Uncertainty Treatment of Wind Power and Photovoltaic
Given the uncertain influence of wind power and solar, this paper uses meteo cal data from a particular place in Inner Mongolia to predict wind and solar output. the MC's idea to generate 100 scenery scenes and then cut them back randomly. T output scenes and their probabilities after reduction are shown in the figure below According to Figure 10, Scenario 5 has the highest probability. Figure 11 show random scenarios for simulating wind power output, and Figure 12 shows 100 ra scenarios for simulating photovoltaic output. Figures 13 and 14 show the output aft nario reduction. The uncertainty process of wind and photovoltaic output are sim by using the probability of scenario occurrence. Therefore, this paper uses the fo data of the reduced wind and photovoltaic output of Scenario 5, and the reduced power output is shown in Figure 15.

Uncertainty Treatment of Wind Power and Photovoltaic
Given the uncertain influence of wind power and solar, this paper uses meteorological data from a particular place in Inner Mongolia to predict wind and solar output. It uses the MC's idea to generate 100 scenery scenes and then cut them back randomly. The five output scenes and their probabilities after reduction are shown in the figure below.
According to Figure 10, Scenario 5 has the highest probability. Figure 11 shows 100 random scenarios for simulating wind power output, and Figure 12 shows 100 random scenarios for simulating photovoltaic output. Figures 13 and 14 show the output after scenario reduction. The uncertainty process of wind and photovoltaic output are simulated by using the probability of scenario occurrence. Therefore, this paper uses the forecast data of the reduced wind and photovoltaic output of Scenario 5, and the reduced wind power output is shown in Figure 15.

Examples of Microgrid Dispatching
The basic parameters of the controllable distributed power generation in Table 2 and typical daily load and real-time electricity price in Table 3 in this example are as follows:

Examples of Microgrid Dispatching
The basic parameters of the controllable distributed power generation in Table 2 and typical daily load and real-time electricity price in Table 3 in this example are as follows:

Examples of Microgrid Dispatching
The basic parameters of the controllable distributed power generation in Table 2 and typical daily load and real-time electricity price in Table 3 in this example are as follows:

Examples of Microgrid Dispatching
The basic parameters of the controllable distributed power generation in Table 2 and typical daily load and real-time electricity price in Table 3 in this example are as follows: The typical daily load [45] and real-time electricity price [46] are as follows: Considering the environmental cost, the emission coefficients of each pollutant, and the corresponding cost coefficients [47] are as follows (Table 4):  Figure 16 shows the scheduling results of the microgrid. Wind and photovoltaic are clean and renewable energy that will be fully output in the microgrid dispatching, and other distributed power sources will fill the shortage of unmet load demand. It is necessary to purchase power from the enormous power grid if the combined output of each distributed power source under the constraint of the upper limit of the maximum power fails to meet the load demand. Fuel cells are prioritized for most of the operation period, followed by micro steam turbines and diesel generators because of their low operating costs and environmental impact. The overflow will be sold to the grid according to the selling price between hours three and six; the overflow occurs at hours nineteen and twenty-two. This study will consider adding energy storage equipment into the subsequent research to improve the absorption capacity of the power grid. It can be seen from Figure 17 that the Total cost (T-cost) includes various parts of the cost, including the operation cost of distributed power supply (O-cost), Environmental pollution cost (E-cost), and the cost of electricity purchase and sale (P and S-cost). The operation cost of distributed power supply gradually increases after the start-up of each distributed power supply and then fluctuates within a specific range; during the stop phase, the operation cost will gradually decrease. O-cost accounts for a large proportion of T-cost, followed by E-cost and P-and S-cost. The negative value of the P-and S-cost represents the profit from electricity sales, and the positive value represents the electricity purchase expenditure.
The following Table 5 shows the detailed data of each distributed power source and power grid output in the optimal scheduling results of the microgrid.  It can be seen from Figure 17 that the Total cost (T-cost) includes various parts of the cost, including the operation cost of distributed power supply (O-cost), Environmental pollution cost (E-cost), and the cost of electricity purchase and sale (P and S-cost). The operation cost of distributed power supply gradually increases after the start-up of each distributed power supply and then fluctuates within a specific range; during the stop phase, the operation cost will gradually decrease. O-cost accounts for a large proportion of T-cost, followed by E-cost and P-and S-cost. The negative value of the P-and S-cost represents the profit from electricity sales, and the positive value represents the electricity purchase expenditure.
The following Table 5 shows the detailed data of each distributed power source and power grid output in the optimal scheduling results of the microgrid. It can be seen from Figure 17 that the Total cost (T-cost) includes various parts of the cost, including the operation cost of distributed power supply (O-cost), Environmental pollution cost (E-cost), and the cost of electricity purchase and sale (P and S-cost). The operation cost of distributed power supply gradually increases after the start-up of each distributed power supply and then fluctuates within a specific range; during the stop phase, the operation cost will gradually decrease. O-cost accounts for a large proportion of T-cost, followed by E-cost and P-and S-cost. The negative value of the P-and S-cost represents the profit from electricity sales, and the positive value represents the electricity purchase expenditure.
The following Table 5 shows the detailed data of each distributed power source and power grid output in the optimal scheduling results of the microgrid.   This paper applies IBFO, BFO, and PSO to the microgrid economic dispatching problem to verify the improved method's excellence. The number of experiments is 30, and the experimental results are averaged. In Table 5, the experimental result of IBFO is the best, which is CNY 1653.4, the experimental result of BFO is CNY 1739.9, and the experimental result of PSO is CNY 1716.0. The microgrid dispatching cost of IBFO is reduced by 3.79% compared with PSO. The scheduling cost of the improved bacterial foraging algorithm is reduced by 5.23% compared with the traditional BFO. The experimental results show that the improved bacterial foraging algorithm can effectively reduce the cost of economic dispatching optimization of the microgrid.

Conclusions
This paper refines the three main steps of BFO. This study introduced the speed formula of PSO in the chemotaxis stage to improve the search accuracy and speed. The adaptive step size is used to modify the standard fixed step size, which made the algorithm search at high speed in the early iteration. The improvements reduce the step size in the late iteration. The CrissCross Algorithm is used to enrich the population diversity in the replication stage. The global search performance of the algorithm is further enhanced. This research proposes the dynamic dispersal equation to improve the survival of highquality individuals' probability to solve the low efficiency caused by the loss of highquality individuals in the dispersal process. This research also proposed SCA to improve the population generation and further improve the search efficiency of the algorithm. The influence of each improved part on the algorithm's performance was quantitatively analyzed by multiple test functions and compared with many other improved algorithms for bacterial foraging. The results show that the improved Bacterial Foraging Algorithm proposed has the best results. This study applied the improved BFO to a microgrid economic scheduling model considering multiple optimization objectives to prove the excellent performance. MC is used to reduce the scene by aiming at the uncertainty processing of scenery force in the model. Finally, the experimental results prove that the method proposed can effectively reduce the operating cost of the microgrid, improve economic benefits, reduce environmental pollution, and ensure the stability of power consumption for users. In the future, we can study the accommodation of microgrids and the dispatching of microgrids with multiple energy storage devices.

Conflicts of Interest:
The authors declare that the research was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.

Abbreviations
Abbreviations commonly used in articles and abbreviations used in bacterial foraging algorithms: