# Optimal Scheduling of Microgrids Based on an Improved Dung Beetle Optimization Algorithm
## 3 Microgrid Multi-Objective Optimization Model
### Uncertainty of Wind and Solar Power
#### 3.4.2 Scenario Reduction  
Monte Carlo sampling can generate a large number of WT and PV time-series scenarios with equal probabilities. Whereas this effectively shows the uncertainty of wind and solar power, the large number of sample scenarios significantly increases the computational complexity of algorithms and reduces their efficiency. Therefore, scenario reduction methods are required to select a small number of representative scenarios and fit their occurrence probabilities. The proposed approach effectively addresses the inherent uncertainties associated with wind and solar power generation while simultaneously improving the computational efficiency of the algorithm. Common reduction techniques include PCA and DBSCAN, but they are not capable of addressing the uncertainty of wind and solar power in MGs. Firstly, PCA is a dimensionality reduction technique primarily used for data compression and feature extraction, rather than directly performing cluster analysis. While PCA can help simplify data, it cannot directly handle clustering problems in wind and solar power. Secondly, although DBSCAN excels at handling noise and clusters of complex shapes, in the analysis of MGs, the data typically have less noise, and the clusters are relatively regular, making DBSCAN's advantages less pronounced. In contrast, the backward scenario reduction and the K-means clustering algorithm are frequently used to address wind and solar scenario reduction in MGs. The backward scenario reduction method eliminates scenarios with minimal impact on the overall characteristics step by step until the desired number of scenarios is reached. This method is intuitive and simple to implement. The K-means clustering algorithm employs iterative optimization to automatically classify and aggregate similar scenarios, efficiently reducing a vast set of scenarios into a compact collection of representative ones. It is computationally efficient and more suitable for handling large-scale data. The number of clusters is important in scenario reduction algorithms. Too many clusters will reduce computational efficiency, whereas too few will fail to represent the uncertainty of wind and solar power. Based on an analysis of different cluster numbers, 1000 wind and solar output scenarios generated through Monte Carlo sampling are reduced to five scenarios using both methods, allowing for a comprehensive comparison of their advantages and disadvantages, as shown in Figures 3 and 4. The probabilities of the five scenarios after reduction are shown in Table 2.  
Figure 2: PV and WT output curve of simulated scenario. (**a**) WT output; (**b**) PV output. From Figures 3 and 4, it can be observed that the backward scenario reduction method performs poorly when dealing with a large sample size of 1000 scenarios. Its output exhibits excessive fluctuations and bad probability distribution, making it insufficient to describe the uncertainty of wind and solar power output. In contrast, the K-means clustering algorithm better captures the variability and uncertainty of wind and solar power \begin{table}
\begin{tabular}{c c c c c} \hline \hline \multirow{2}{*}{**Scenario**} & \multicolumn{2}{c}{**Backward Reduction**} & \multicolumn{2}{c}{**K-means Clustering Reduction**} \\ \cline{2-5}  & **WT** & **PV** & **WT** & **PV** \\ \hline Scenario 1 & 0.025 & 0.162 & 0.229 & 0.225 \\ Scenario 2 & 0.041 & 0.077 & 0.179 & 0.192 \\ Scenario 3 & 0.125 & 0.1 & 0.161 & 0.202 \\ Scenario 4 & 0.134 & 0.041 & 0.209 & 0.175 \\ Scenario 5 & 0.675 & 0.62 & 0.204 & 0.206 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: The probabilities of the five scenarios after reduction. Figure 4: PV and WT output data scenario after K-means clustering reduction. (**a**) WT output; (**b**) PV output. Figure 3: PV and WT output data scenario after backward reduction. (**a**) WT output; (**b**) PV output. output, providing more reliable and practical guidance for the optimization scheduling and economic operation of MGs incorporating WT and PV.