## 4 BILSTM-Transformer Based Bems Model
### Microgrid Optimization Method Based on Cognitive Control
#### 4.5.3 Quantification of Information Gap
In the process of data collection and model evaluation, we selected partial days of data as the key sample source for the test set, which covers the time series changes in all key variables. The selection of testing equipment takes into account the different charging and discharging behaviors of electric vehicles, as well as load of buildings at different time periods. The remaining time is used for training. In order to verify the forecasting effect of the model and the control ability of the system, we compare five different methods:

1. BiLSTM-Transformer: This is the core model proposed in this paper, which combines bidirectional long short-term memory network (BiLSTM) and Transformer architecture to effectively capture complex patterns and remote dependencies in time series. The model was trained and predicted using a complete and correct dataset. 2. BiLSTM-Transformer + data loss: This model is based on BiLSTM-Transformer for prediction, but data loss is introduced in the test set to evaluate the performance of the model in the environment with incomplete data. 3. BiLSTM-Transformer + cognitive control system + data loss: The model adds a cognitive control system on the basis of BiLSTM-Transformer to deal with incomplete data or transmission failure. Both the training set and the test set contain data loss scenarios to verify the robustness of the cognitive control system in complex environments. 4. LSTM-Transformer: The combination of traditional long short-term memory (LSTM) network and Transformer is used to compare the prediction accuracy with BiLSTM-Transformer. This model provides a benchmark for evaluating the advantages of the new model. 5. CNN-LSTM: The CNN-LSTM model combines convolutional neural networks (CNN) and long short-term memory networks (LSTM), aiming to fully utilize the advantages of both. CNN excels at extracting local features from input data, especially when processing time series data, and can effectively identify and capture short-term changes in signals. LSTM, on the other hand, can handle long-term dependencies and maintain the flow of information through memory and forgetting mechanisms. Therefore, the CNN-LSTM model can simultaneously focus on local features and long-term trends in time series prediction, thereby improving the accuracy and stability of the prediction. 6. RNN (Recurrent Neural Network) is a traditional model for processing sequential data, and its structure can effectively capture dependencies in time series. RNN processes

Figure 4: Load include 100 Days. each time step in the input sequence through cyclic connections, allowing the model to remember previous input information. However, RNNs may face the problem of vanishing or exploding gradients when dealing with long-term dependencies, which limits their performance in complex time series prediction tasks. Therefore, RNN is often used as a benchmark model to compare with more advanced models such as BiLSTM-Transformer and CNN-LSTM, in order to evaluate the advantages of the new model in load forecasting. 7. True value of annealing algorithm run: The real value generated by the simulated annealing algorithm is used as a benchmark for comparison. The algorithm uses a complete dataset, ensuring accurate raw-state forecasts. ### Learning Performance of BiLSTM Transformer Network

Firstly, the learning performance of the BiLSTM-Transformer network was evaluated. During training, we use the mean-squared error (MSE) as a loss function to measure the deviation between the network output and the target value in the training dataset. The change in the loss function during training is shown in Figure 5. In this study, the BiLSTM-Transformer network was trained on a dataset containing complete information, using high-resolution data of 720 time steps. In the first 30 iterations of the initial training phase, the loss function drops rapidly, indicating that the network quickly captures the dominant patterns in the data. After 80 iterations, the loss function gradually stabilizes and falls to a level below \(10^{-4}\).