## 4 BILSTM-Transformer Based Bems Model
### Offline Training Based on the BiLSTM-Transformer System Architecture
#### 4.3.3 Data Feature Extraction and Network Parameter Optimization  
In general, the data series in the time-series-forecasting problem tend to have significant time-correlation features, so these sequences can be fed into the neural network for modeling. However, in the task of EV-charging and -discharging scheduling and load forecasting in shopping malls, there is the complexity of several data features, which increases the difficulty of model fitting. If these unprocessed data sequences are used directly for training, it can lead to the model overfitting historical data and failing to learn effective forecasting patterns. In this case, even if the model performs well on the training set, it will not perform well in the real world because it cannot handle discrete data with no temporal correlation.  
In order to solve the above problems, the steps of data preprocessing and feature recognition are introduced into the network architecture. First, to solve the problem of diversity and discreteness of data, we use a fully connected layer and a one-dimensional convolutional layer to preprocess the original data. This step can extract locally important features by performing convolution operations on the input data, and at the same time filter out possible invalid information or noisy data, ensuring that the model can focus on the key information that really affects the change of \(P_{\text{gird}}\).  
Next, the network adopts stacked N attention-BiLSTM modules, and the attention mechanism enhances the model's ability to pay attention to the global features of the input sequence. The attention mechanism can dynamically assign weights to ensure that the model can capture the important information of \(P_{\text{gird}}\) at different time steps when processing time series. Combined with the time series modeling capability of bidirectional long short-term memory (BiLSTM) network, the module further improves the capture of bidirectional time dependencies in the model, so that it can effectively cope with the complex time correlation in the charging and discharging scheduling of electric vehicles.  
In particular, the Transformer network is used to extract global data features, and captures long-range dependencies through the multi-head self-attention mechanism to ensure that the system can fully understand the overall structure of the input data, so as to further eliminate the interference of invalid information. The introduction of the Transformer module enables the system to show stronger computational efficiency and global modeling capabilities when processing large-scale data, and avoids the common local optimal problems in traditional time series models.  
Finally, after feature extraction by BiLSTM, the network uses a fully connected layer to output the final \(P_{\text{gird}}\) forecasts. The fully connected layer aggregates all the information after feature extraction to generate a \(P_{\text{gird}}\) forecasting value for the small at the next time step. This deep model architecture, which combines feature extraction, attention mechanism, and BiLSTM network, ensures the robustness and accuracy of the system in the face of complex charging and discharging scheduling problems.