## 4 BILSTM-Transformer Based Bems Model
### The Preliminary Description of the Method  
As described in Section 2, the main task of BEMS is to dispatch the charge and discharge of numerous electric vehicles parked in the parking lots of commercial buildings.  
Since the load change in the mall shows a significant time dependence, its forecasting can be regarded as a typical time-series-forecasting problem. In general, the main purpose of a time-series-forecasting problem is to predict a future state or value based on trends, periodicity, and other relevant characteristics in the time series by analyzing the historical data of the system. In this study, the complexity of the historical data of the system is mainly due to the dynamic changes in time of the charging and discharging needs of electric vehicles, the electricity prices of the upper and lower grids, and environmental factors.  
In order to deal with the complexity of multimodal historical data in the system, effectively capture the temporal correlation of \(P_{\text{grid}}\), and manage the charging and discharging operations of a large number of electric vehicles in the parking lot of commercial buildings, we chose BiLSTM (bidirectional long short-term memory network) as the infrastructure. Combined with the multi-head self-attention mechanism of Transformer to further improve the modeling ability of remote time dependence, a scheduling method based on BiLSTM-Transformer short-term load-forecasting model was proposed.  
When processing time series data, long short-term memory networks (LSTMs) have become a classic choice in time series forecasting due to their powerful time-dependent modeling capabilities in [16; 17; 18; 19]. By introducing the forgetting gate, input gate, and output gate, LSTM effectively solves the gradient vanishing and gradient explosion problems encountered by traditional recurrent neural networks (RNNs) in long-term sequences in [20; 21; 22]. Its unique cell structure allows it to retain important information in time series data while ignoring extraneous or unnecessary features.  
However, the load variation of the mall is not only affected by the historical state but also by the future state. For example, relying solely on traditional LSTMs for one-way time series modeling has limitations for such complex scheduling problems.  
To solve this problem, we introduce a bidirectional long short-term memory network (BiLSTM). Unlike traditional LSTMs, BiLSTMs are able to comprehensively consider past and future state information at each time step of the series by simultaneously processing both forward and backward information of the time series.  
At the same time, with the exponential growth of the number of electric vehicles, the generalization time of the traditional model also increases exponentially, and the Transformer network enhances the system's ability to model the dependence between remote time steps through the global attention mechanism. Especially for high-dimensional time series data, Transformer can process the input of each time step in parallel, thus reducing the time overhead required by BILSTM when processing large-scale data. Through the combination of BiLSTM and Transformer, we can capture both local and global time dependence, so that our method can not only predict the trend in load in shopping malls but also deal with the complexity and uncertainty in large-scale EV scheduling.  
The structure of the model consists of an input layer, a convolutional layer, a Transformer encoder layer, a bidirectional LSTM layer, and a fully connected output layer. In the process of model training, we use the convolutional layer, Transformer encoder layer, and BiLSTM layer to extract features according to the historical \(P_{\text{grid}}\) state of the mall, and finally output the predicted \(P_{\text{grid}}\) value through the fully connected layer. By repeating this forecasting process at each time step, we can generate a \(P_{\text{grid}}\) forecasting for the mall in the future to guide its parking-lot charging and discharging scheduling.