## 3 Adaptive Task Traffic-Shaping Algorithm
### Task Request Queueing Theory Model
#### 3.2.2 Adaptive Traffic Shaping Based on Resource Load  
This study establishes a Hidden Markov Model (HMM) to characterize the relationship between the system's overall load levels and the expected token fill rate levels, based on the comprehensive load conditions of the system. Both the system's overall load and the expected token fill rate are categorized into discrete levels. The parameters of the HMM are initialized to predict the state of the expected token fill rate level at the next time step, given the observed sequence of the system's overall load levels. Specifically, this study categorizes the system's overall load into five levels, denoted as _LoadRank_, which represents the observable states. These levels are defined as follows: _L_([0, 0.35]): Low load; _LM_((0.35, 0.5]): Low-Medium load; _M_((0.5, 0.75]): Medium load; _HM_((0.75, 0.9]): High-Medium load; _H_((0.9, 1.0]): High load. Similarly, the expected token fill rate is categorized into three levels, denoted as _RateRank_, which represents the hidden states. These levels are defined as: _Rank1_, _Rank2_, _Rank3_. A HMM is established to model the relationship between the observable _LoadRank_ and the hidden _RateRank_. The HMM parameters are initialized as follows: hidden states (Equation (3)); initial probability distribution of hidden states ({\(P_{Rank1}^{0},P_{Rank2}^{0}\), \(P_{Rank3}^{0}\)} = {0.4,0.3, 0.3}); transition probability matrix of hidden states (Equation (4)); emission probability matrix (Equation (5)). Based on the observed sequence of _LoadRank_ (calculated in real-time), the HMM predicts the state of _RateRank_ at the next time step. Additionally, two rate adjustment parameters, \(\alpha\) and \(\beta\) are introduced. Let \(f(Rank)=f(\alpha,\ \beta)\):  
\[f(Rank)=\left\{ \begin{array}{ll}\alpha=1,\beta=1\,\ \ if\ RateRank=\ Rank1\\ \alpha=0.5,\beta=1,\ \ if\ RateRank=\ Rank2\\ \alpha=0,\beta=0.8,\ \ if\ RateRank=\ Rank3\end{array} \right. \tag{3}\]  
The transition probability matrix \(T_{raterank,raterank}\) and the emission probability matrix \(E_{loadrank,raterank}\) for _RateRank_ are defined as follows. \[T_{raterank,raterank}=\left[ \begin{array}{ccc}0.7&0.3&0\\ 0.15&0.7&0.15\\ 0&0.3&0.7\end{array} \right] \tag{4}\]\[E_{loadrank\_raterank}= \begin{bmatrix}0.750&0.050&0.005\\ 0.150&0.200&0.020\\ 0.075&0.500&0.075\\ 0.020&0.200&0.150\\ 0.005&0.050&0.750\end{bmatrix}  \tag{5}\]  
Based on the inverse relationship between the comprehensive load of the system and the task processing capability of the system [38], Equation (6) is defined to take the current comprehensive complex computing task processing rate of the system as  
\[\mu=\left(1-\frac{Load}{MaxLoad}\right)\times N \tag{6}\]  
In the formula, Load is the current comprehensive load of the server, which has been defined previously. \(MaxLoad\) is the load value when the server is fully loaded (ideal state). \(N\) indicates the number of tasks that can be executed per second when the server is idle. This value can be obtained by multiple experiments. From \(L=\frac{\lambda}{\mu-\lambda}\), vecanger :  
\[\lambda=\frac{l\times\mu}{1+L}=\frac{L}{1+L}\times\frac{(MaxLoad-Load)}{ MaxLoad}\times N \tag{7}\]  
It can be seen that Equation (7) describes the relationship between the expected task arrival rate \(\lambda\) of the system and the current system Load. If the system load is calculated in real time, the task arrival rate \(\lambda\) can be obtained. Furthermore, based on the relationship model between the expected task arrival rate and the system's comprehensive load, in combination with the maximum token fill rate of the GIS system (Equation (8)), the minimum token fill rate (Equation (9)), and the expected token fill rate levels, a relationship model is established between the system's expected average task arrival rate and the expected token fill rate. The token fill rate of the token bucket is then adjusted according to the obtained expected token fill rate, thereby achieving adaptive task traffic shaping.