## 3 Dynamic Algorithm of Resource Re-allocation
### Lyapunov Optimization  
In this study, the Lyapunov function, denoted as \(L(t)\), is defined as follows:  
\[L(t)=\sum_{n=1}^{N}\left(z_{n}(t)Q_{n}(t)\right)^{2}+\left(R(t)\right)^{2}. \tag{28}\]  
The Lyapunov drift is \(\Delta L(t)=L\left(t+1\right)-L(t)\), which represents the trend of the change in the data queues of the service-guaranteed user \(Q^{n}(t)\) and the virtual cost queue \(R(t)\). To guarantee the stability of the data queues and the virtual cost queue, the drift has to be decreased. That means that the platoon leader needs to decrease the number of active users to increase the service rate of the active users; the backlogs of the active users are decreased and there is no need for frequent re-allocation among the users. However, this is contrary to the objective of the optimization problem. Therefore, to stabilize the queues and optimize the objective of \(P\) simultaneously, the drift-plus-penalty function is defined as follows:  
\[\text{Min}\ \Delta L(t)-Vf(t),\]  
where \(V\) is a control parameter that determines the trade-off between the drift of the queues and the objective of \(P\) in Equation (25). As in the lemma presented in Reference [32], if there are four nonnegative real members-\(A\), \(B\), \(\omega\),\(\eta\), and \(A\leq\max\left[B-\omega,\;0\right]+\eta\)-then \(A^{2}\leq B^{2}+\omega^{2}+\eta^{2}-2B\left(\omega-\eta\right)\). Thus, the drift-plus-penalty function can be derived as:  
\[\Delta L(t)-Vf(t) = L\left(t+1\right)-L(t)-Vf(t) \tag{29}\] \[= \sum_{n=1}^{N}\left(z_{n}\left(t+1\right)Q_{n}\left(t+1\right) \right)^{2}+\left(R\left(t+1\right)\right)^{2}-\sum_{n=1}^{N}\left(z_{n}(t)Q_{ n}(t)\right)^{2}-\left(R(t)\right)^{2}\] \[-V\sum_{n=1}^{N}z_{n}(t)\] \[\leq \sum_{n=1}^{N}z_{n}(t)\left(\left(\mu_{n}(t)\right)^{2}+\left(a_{ n}(t)\right)^{2}-2Q_{n}(t)\left(\mu_{n}(t)-a_{n}(t)\right)\right)+\gamma^{2}\] \[+\left(r(t)\right)^{2}-2R(t)\left(\gamma-r(t)\right)-V\sum_{n=1} ^{N}z_{n}(t).\]  
Therefore, to minimize the upper bound of the drift-plus-penalty function in Equation (29), the channel allocation scheme is proposed as follows:  
\[\underset{\mathbf{X}}{\text{max}} \sum_{n=1}^{N}z_{n}(t)\left(2Q_{n}(t)\left(\mu_{n}(t)-a_{n}(t) \right)+V\right)-2R(t)r(t) \tag{30}\]  
under the constraints (25b)\(\sim\)(25e). By minimizing Equation (30), we obtain the following:  
\[\mathbb{E}\left\{\Delta L(t)-Vf(t)\right\} \leq \Theta+\mathbb{E}\left\{\sum_{n=1}^{N}z_{n}^{*}(t)\left(-2Q_{n}(t )\left(\mu_{n}^{*}(t)-a_{n}(t)\right)\right)\right\} \tag{31}\] \[-2\mathbb{E}\left\{R(t)\left(\gamma-r^{*}(t)\right)\right\}-V \mathbb{E}\left\{f^{*}(t)\right\},\]  
where \(\Theta\) is a constant that satisfies the following inequation:  
\[\text{Min}\ \Delta L(t)-Vf(t),\]0  
Furthermore, we use the time-average of Equation (31) and rearrange the equation to obtain:  
\[\text{Min}\ \Delta L(t)-Vf(t),\]1 \[\text{Min}\ \Delta L(t)-Vf(t),\]2  
where \(\varepsilon\) is a small constant such that \(\overline{a_{n}(t)}+\varepsilon\leq\overline{\mu_{n}(t)}\) for each VU that \(z_{n}(t)=1\). Due to \(\lim_{T\rightarrow\infty}\frac{1}{T}\mathbb{E}\left\{L(t)-L(1)\right\}=0\) and \(\lim_{T\rightarrow\infty}\frac{1}{T}\sum_{t=1}^{T}\mathbb{E}\left\{R(t)\left( \gamma-r^{*}(t)\right)\right\}\geq 0\), the lower bound of the expectations of the number of service-guaranteed users can be guaranteed as follows:  
\[\text{Min}\ \Delta L(t)-Vf(t),\]3 \[\text{Min}\ \Delta L(t)-Vf(t),\]4\[\text{Min}\ \Delta L(t)-Vf(t),\]5  
where \(z_{n}^{*}(t)\) and \(Q_{n}^{*}(t)\) are the set of the service-guaranteed users and the queue of user \(n\) corresponding to \(f^{*}(t)\) and \(r^{*}(t)\):  
\[\text{Min}\ \Delta L(t)-Vf(t),\]6  
From Equations (33) and (34), it is found that the constant \(V\) determines the lower bound of the number of service-guaranteed users and the upper bound of the length of the queue.