# Optimal Scheduling of Microgrids Based on an Improved Dung Beetle Optimization Algorithm
## 5 Case Simulation
### Case Simulation with DR and Uncertainty of Wind and Solar Power  
The output of wind and solar energy is highly random, necessitating appropriate modeling to enhance the efficiency of scheduling optimization. The K-means clustering algorithm effectively reduces computational complexity by categorizing different generation scenarios, thereby shortening running time. The clustered scenarios enable MG operators to predict and respond to various generation fluctuations based on historical data, leading to more accurate scheduling decisions. This approach not only increases scheduling efficiency but also enhances the MG's adaptability to sudden changes. Based on the reduction scenarios as proposed in Section 3.3, a simulation analysis was conducted, considering DR. It can be observed from Figure 10 that after the DR, the distribution of load exhibits a pronounced optimization effect. Specifically, the load during the valley and normal time increases, whereas the load during the peak time significantly decreases. This change indicates that the DR effectively guides users to reduce electricity demand during peak time while encouraging increased consumption during valley time, thereby smoothing the load curve. This adjustment in load distribution not only helps alleviate the pressure on the grid during peak time, reducing over-reliance on DG units, but also enhances the overall operational efficiency and stability of the grid. Furthermore, through its peak load shifting, the DR promotes the rational allocation of electricity resources, reduces operational costs of the power system, and provides greater flexibility for the integration of renewable energy sources. Five scenarios obtained after K-means clustering reduction in Section 3.3 and the load curve considering DR were selected for scheduling simulation, and the data are shown in Figure 11. Figure 11a-e represent the solar and wind power of five scenarios. Additionally, the most typical scenario with the highest probability (Scenario 1) obtained through K-means clustering was selected for comparison simulation with a scenario that does not consider DR and the uncertainty of wind and solar power, using IDBO for optimization. Table 10 shows the results comparison of minimal total cost in different scenarios. Table 10 shows that IDBO still demonstrates its outstanding global optimization capability and stability. The final value is significantly lower than the other two comparison \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Scenario** & **IDBO/CNY** & **DBO/CNY** & **GWO/CNY** \\ \hline
1 & 954.24 & 1302.04 & 1420.69 \\
2 & 997.48 & 1402.99 & 1426.54 \\
3 & 996.01 & 1325.97 & 1411.65 \\
4 & 963.95 & 1370.78 & 1425.76 \\
5 & 986.61 & 1438.19 & 1459.79 \\ \hline \hline \end{tabular}
\end{table} 
Table 10: Results comparison of minimal total cost in different scenarios. algorithms. This result not only confirms the efficacy of IDBO in solving complex optimization problems but also validates the results in Sections 5.1 and 5.2, further proving the unique advantages of IDBO in microgrid optimization scheduling. IDBO is better at handling nonlinear, multi-constraint optimization problems, especially in complex scenarios like microgrids that involve coordination of various energy sources and uncertainties, where its performance is particularly remarkable. Table 11 compares the average final value after running the algorithms 100 times in five different scenarios. IDBO performs well across all five scenarios, with lower average total costs compared to other algorithms. Additionally, while achieving lower final values, IDBO also maintains lower standard deviations, indicating more stable results. This shows that IDBO is more reliable when handling different datasets, exhibiting higher stability and robustness. It effectively reduces operational uncertainty, validating its superior performance in MG optimal scheduling. Figure 11: Cont. Figure 10: Load curves with or without DR.