# Optimal Scheduling of Microgrids Based on an Improved Dung Beetle Optimization Algorithm
## 4 Improved Dung Beetle Optimization Algorithm
### Algorithm Solution Process
```
23: Update the ball-rolling beetle by \(x_{i}^{t+1}=x_{i}^{t}+\tan(\theta)\left|x_{i}^{t}-x_{worst}^{t}\right|\)
24:end if
25:end if
26:if\(i==\) Egg-laying Beetles then
27: Update the egg-laying beetles by \(B_{i}^{t+1}=x_{gbest}^{t}+b_{1}\times\left(B_{i}^{t}-Lb^{*}\right)+b_{2}\times \left(B_{i}^{t}-Ub^{*}\right)\)
28:end if
29:if\(i==\) Small Beetles then
30: Update the small beetles by \(x_{i}^{t+1}=x_{i}^{t}+C_{1}\left(x_{i}^{t}-Lb^{\prime}\right)+C_{2}\left(x_{i }^{t}-Ub^{\prime}\right)\)
31:end if
32:if\(i==\) Thief Beetles then
33: Update the thief beetles by \(x_{i}^{t+1}=x_{lbest}^{t}+Sg\left(\left|x_{i}^{t}-x_{gbest}^{t}\right|+\left| x_{i}^{t}-x_{lbest}^{t}\right)\)
34:end if
35:end for
36:if the newly generated position is better than before then
37: Update it
38:end if
39: Non-dominated Sorting of the Current Population
40:function Reverse Learning for Elite Individuals
41: Select elite individuals
42: Calculate the boundaries of elite individuals
43: Generate reverse solution X\({}^{\prime}\) = rand() \(\times\) (T\({}_{\text{LB}}\) + T\({}_{\text{UB}}\)) - X
44:end function
45:\(t=t+1\)
46:end while
47:return
```  
**Algorithm 1**_Cont._  
In this study, the optimization scheduling of the MG is achieved through the IDBO. Each beetle's position represents the power output of various DG units and energy storage systems within the MG. The movement of the beetles simulates the exploration behavior of the algorithm in the process of searching for the optimal solution. The beetles \"movement\" is limited by several constraints, such as power balance, output power range, and climb rate constraints. In this metaphor, the beetles' behavior can be seen as traversing the solution space by following specific rules, avoiding infeasible regions, and utilizing the reverse learning strategy to escape local optima, ultimately searching for the global optimal solution. Therefore, the IDBO provides an efficient solution for optimization scheduling of MGs. It is worth mentioning that the main reason for choosing the DBO is its unique exploration and exploitation mechanisms, which can effectively solve complex optimization problems, rather than simply due to its novelty or natural metaphor. Many nature-inspired algorithms rely solely on superficial metaphors, lacking substantive scientific contributions, and even obscuring underlying mathematical principles through obscure terminology [36]. In contrast, the core mechanisms of DBO (such as rolling, dancing, and foraging behaviors) have been carefully designed and transformed into mathematically rigorous optimization strategies, making a clear scientific contribution. Supported by both empirical and theoretical evidence, DBO performs excellently in search efficiency and in handling multimodal problems, avoiding the \"just another nature-inspired algorithm\" trap. The selection of DBO is justified by its dual merits: as a novel algorithm, it not only contributes significant scientific value to the optimization domain but also exhibits remarkable potential in addressing complex problem-solving challenges.