# Load Balancing Oriented Predictive Routing Algorithm for Data Center Networks
## 3 Algorithm Design
### Implementation of the Algorithm  
The ST-ResNet algorithm is a link frequency prediction algorithm that conforms to the characteristics of spatio-temporal data. Then, the LLBR algorithm is used to optimize the link load balancing scheduling strategy according to the prediction results. This section first describes the ST-ResNet algorithm and then introduces the LLBR. The prediction model based on the ST-ResNet algorithm is obtained through model training, and the link usage frequency in the network is subsequently predicted to ascertain the link occupation state in the next time period. The specific steps of the St-ResNet algorithm are as follows:  
1. The data is divided into three groups according to the network characteristics: long-term correlation characteristics \(S_{q}=[X_{t-l_{q}},X_{t-(l_{q}-1)},\cdots X_{t-q}]\), periodic characteristics \(S_{p}=[X_{t-l_{p}},X_{t-(l_{p}-1)},\cdots X_{t-p}]\) and self-similarity characteristic \(S_{c}=[X_{t-l_{c}},X_{t-(l_{c}-1)},\cdots X_{t-1}]\), and \(l_{c}\), \(l_{p}\), and \(l_{q}\) are the time intervals;
2. Through Equation (4), three groups of data are fused to obtain the input data \(X_{Res}\);
3. The input data \(X_{Res}\) is formatted by Equation (5), such that all values are between \(-1\) and \(1\) and the output value \(\hat{X}_{t}\) is obtained;
4. The above operation is repeated until the \(RMSE\) between the predicted value and the real value is small or remains unchanged;
5. The current model is saved as a prediction model. To ensure the accuracy and timeliness of the prediction model, the parameters of the model must be trained periodically and constantly updated. Then, the calculation method of the network route and the issuing of the route are performed according to the updated prediction model. The prediction algorithm is shown in Algorithm 1. The LLBR algorithm involves path calculation after the prediction model is obtained. First, the algorithm reads the predicted link usage times in HDF5 format into a two-dimensional array and then it evaluates whether each link has an odd number of uses. if so, the algorithm calculates the total estimated cost of the link, i.e., \(C_{ij}\). We can thus obtain Equation (7):  
\[C_{ij}=R_{ij}+L_{ij}+jump_{ij} \tag{7}\]  
where \(L_{ij}\) is the delay of the link, \(jump_{ij}\) is the number of hops from the network request source switch to the link, and \(R_{ij}\) is the predicted use times of the link. If the number of times the link is used is even, then the current link usage is disregarded. We can ascertain the cost of the link through Equation (8). \[C_{ij}=L_{ij}+jump_{ij} \tag{8}\]  
Meanwhile, the predicted situation of this sub-link is halved for the next use. Finally, the path with the least estimated cost is calculated by the Dijkstra algorithm [41]. The specific description of the LLBR algorithm is shown in Algorithm 2. ```
Input: Historical observations:\(X_{0},\cdots,X_{n-1}\);Lengths of characteristics sequences:\(l_{c},l_{p},l_{q}\);Period:\(p\); Trend span:\(q\); Prediction cycle:\(T\). Output: The result \(R\) of next \(T\) predict
1\(S\gets NULL,M\gets NULL\)
2 forall available time interval(\(1\leq t\leq n-1\))do
3\(S_{c}=[X_{t-l_{c}},X_{t-(l_{c}-1)},\cdots X_{t-1}]\);
4\(S_{p}=[X_{t-l_{p}},X_{t-(l_{p}-1)},\cdots X_{t-p}]\);
5\(S_{q}=[X_{t-l_{q}},X_{t-(l_{q}-1)},\cdots X_{t-q}]\);
6 Put an training instance \((S_{c},S_{p},S_{q},X_{t})\) into \(M\)
7 Initialize all learnable parameters \(\theta\) in ST-ResNet
8 whilestop criteria not metdo
9 Randomly select a batch of instances\(M_{b}\) from\(M\)
10 Find \(RMES\) by minimizing the Equation (6) with \(M_{b}\)
11 Use \(M\) to predict \(X_{T_{n}}=\left(X_{T_{n-1}},Y_{T_{n-1}}\right)\)
12 Put the result of change \(X_{T_{n}}\) into the original format into \(R\)
```  
**Algorithm 1**ST-ResNet Algorithm. The Dijkstra algorithm is the shortest path algorithm from one to the other vertices and solves the shortest path problem in the graph.