## 3 Dataset Processing Based on Simulated Annealing Algorithm  
In this section, we use the traditional Simulated Annealing (SA) algorithm to construct an optimization model for a building energy management system (BEMS). This model aims to optimize power costs and improve energy efficiency by reasonably scheduling the charging and discharging behaviors of electric vehicles (EVs) and managing power exchanges with the grid. Additionally, the dataset generated by this model will serve as training samples and reference data for subsequent machine learning methods, ensuring that the machine learning model can make forecasts and decisions based on reliable historical data. The Simulated Annealing algorithm is a heuristic global optimization method inspired by the physical annealing process of solids. By controlling the simulated \"temperature\", the algorithm initially accepts suboptimal solutions to avoid getting trapped in local optima. As the \"temperature\" gradually decreases, the algorithm reduces the acceptance probability for suboptimal solutions, ultimately converging toward a global optimum in [11; 12; 13; 14; 15]. Furthermore, this model introduces an \"attack system\", which randomly omits portions of the mall's load data at each time step. This setup simulates the impact of data loss or network attacks on system data transmission in real-world scenarios, increasing the model's robustness requirements. By handling these incomplete datasets, the model can maintain effective scheduling even in the presence of missing information, further enhancing its practical applicability. Equation (2) represents the objective function of this model, which is the minimization of the total electricity cost for each vehicle. In this Equation, \(C_{\text{goal}}\) represents the total target price; \(C(t)\) represents the real-time electricity price; \(P_{\text{EVI}}\) represents the power of charge and discharge; \(R(t)\) stands for reactive power expense rate; \(Q_{\text{EVI}}\) stands for reactive power. Reactive power refers to the power component generated due to the phase difference between voltage and current during the charging and discharging processes of electric vehicles. It is primarily used to maintain the stability of the electromagnetic field in the power grid. The consumption of reactive power reflects the energy exchange characteristics between electric vehicles and the grid. Excessive reactive power consumption can reduce the efficiency of the power grid and increase the difficulty of dispatching. Therefore, it is necessary to incorporate reactive power calculation and optimization into the model. However, reactive power does not directly calculate electricity bills, so the value of \(R(t)\) in this formula is 0  
\[C_{\text{goal}}=\text{min}\sum_{i=1}^{N}\sum_{t=1}^{t\text{max}}\left(C(t)P_{ \text{EVI}}(t)+R(t)Q_{\text{EVI}}(t)\right)+C_{\text{PF}}+C_{\text{THD}} \tag{2}\]  
Equation (3) indicates the power factor fine, and if the power factor PF is too low, the grid will impose a fine. And Equation (4) indicates the harmonic pollution fine, and if the total harmonic distortion THD exceeds the standard, a fine will be imposed. \[C_{\text{PF}}=\alpha\cdot(0.95-\text{PF})\cdot P_{\text{max}} \tag{3}\]  
\[C_{\text{THD}}=\beta\cdot(\text{THD}_{\text{actual}}-\text{THD}_{\text{threshold }}) \tag{4}\]  
Equation (5) is the time-of-use electricity price formula, which shows the difference in electricity charges at different times, where \(C_{1}\) represents 0.8 ($), \(C_{2}\) represents 0.75 ($), \(C_{3}\) represents 0.9 ($), and \(C_{4}\) represents 1.05 ($). \(T_{1}\) is 0.00; \(T_{2}\) is 10:00; \(T_{3}\) at 16:00; 19:00 on \(T_{4}\); \(T_{5}\) is 24:00. \[C(t)= \begin{cases}C_{1},t_{1}\leq t<t_{2}\\ C_{2},t_{2}\leq t<t_{3}\\ C_{3},t_{3}\leq t<t_{4}\\ C_{4},t_{4}\leq t<t_{5}\end{cases}  \tag{5}\]  
Equation (6) is the range of the arrival time of each vehicle: 8:00 for \(T_{6}\); \(T_{7}\) is 9:00.