# Mean-Field Stackelberg Game-Based Security Defense and Resource Optimization in Edge Computing
## 4 Mean-Field Games Equilibrium and Optimal Strategies
### Local Optimal Control Problem for the Defenders  
Due to the heterogeneity of the edge devices, we replace \(x^{N}(t)\) with \(z(t)\), which can be viewed as the mass behavior of the defenders when \(N\rightarrow\infty\), in which the individual influence of each defender will be negligible. We will obtain the optimal strategies of the defenders under this consideration. **Proposition 1**. : _Corresponding to system models (1) and (3), we consider the local optimal strategy problem for each defender. There exists a unique optimal defense strategy \(u_{i}^{*}(t)\) if and only if_  
\[u_{i}^{*}(t)=\beta_{i}^{-1}p_{i}(t)b_{i}-\beta_{i}^{-1}\lambda_{i}u_{0}(t) \tag{5}\]  
_where the adjoint process and the optimal trajectory satisfy the following equations_:  
\[dx_{i}^{*}(t)=\Big{(}a_{i}x_{i}^{*}(t)+c_{i}\|x_{i}^{*}(t)-Ax^{N}(t)\|^{2}-b_ {i}^{-1}\alpha_{i}^{-1}b_{i}p_{i}(t)+\Big{(}c-\beta_{i}b_{i}\alpha_{i}^{-1} \Big{)}u_{0}(t)\Big{)}dt \tag{6}\]  
\[dp_{i}(t)=\Big{[}-p_{i}(t)\Big{(}a_{i}+c_{i}\Big{(}x_{i}(t)-Ax^{N}(t)\Big{)} \Big{)}+\alpha_{i}\Big{(}x_{i}(t)-Ax^{N}(t)\Big{)}\Big{]}dt \tag{7}\]  
_where \(x_{i}^{*}(0)=x_{i0}\), \(p_{i}(T)=0\)._  
Proof. : Consider the variation of defense strategy \(\delta u_{i}(t)\) for each \(i\), which is the control process, such as \(u_{i}(t)=\delta\cdot\delta u_{i}(t)+u_{i}^{*}(t)\). The variational equation is as follows:  
\[\left\{ \begin{array}{l}d\delta x_{i}(t)=\Big{(}a_{i}\delta x_{i}(t)+b_{i} \delta u_{i}(t)+c_{i}\|\delta x_{i}(t)-Ax^{N}(t)\|^{2}+c\delta u_{0}(t)\Big{)} dt\\ \delta x_{i}(0)=0\end{array} \right. \tag{8}\]  
where \(\delta x_{i}(0)=0\). \(\square\)Since the cost function is convex, Equation (5) is the optimal defense strategy if and only if the first-order cost function case  
\[ \begin{split} 0&=\delta I_{i}^{*}\big{(}u_{i}^{*}(t) \big{)}:=\tfrac{d}{dx}J_{i}^{*}\big{(}\delta\cdot\delta u_{i}(t)+u_{i}^{*}(t) \big{)}\Big{|}_{\delta=0}\\ &=E\int_{0}^{T}\big{[}a_{i}\delta x_{i}(t)\big{(}x_{i}(t)-Ax^{N}( t)\big{)}+\delta u_{i}^{*}(t)\beta_{i}u_{i}(t)+\lambda_{i}\delta u_{i}(t)u_{0}(t) \big{]}dt\end{split}  \tag{9}\]  
Next, we use the Ito formula:  
\[d\delta x_{i}(t)p_{i}(t)=\delta b_{i}u_{i}(t)p_{i}(t)dt+\delta x_{i}(t)\Big{(}x _{i}(t)-Ax^{N}(t)\Big{)}dt \tag{10}\]  
Since \(\delta x_{i}(0)=0\), and \(p_{i}(T)=0\), we obtain the optimal control. We now obtain the local optimal strategy for the defender and the corresponding state trajectory. The purpose of this analysis is to determine the mean-field approximation and the \(\varepsilon\)-Stackelberg equilibrium problem. It can be seen from Proposition 1 that the optimal defense strategy is determined by the threat level of the attackers and the adjoint operator, whereas the defense strategy also depends on the state because of the limited resources of edge devices. Hence, we can refine the adjoint operator \(p_{i}(t)\). To obtain the feedback representation of the defenders in (5) and (6), let \(p_{i}(t)=-V_{i}(t)x_{i}^{*}(t)+\varphi_{i}(t)\), where \(V_{i}(t)\) is the value function, and \(\varphi_{i}(t)\) is the continuously differentiable function satisfying \(\varphi_{i}(T)=0\) and  
\[-\frac{dV_{i}(t)}{dt}=-\beta_{i}^{-1}b_{i}^{2}V_{i}^{2}(t)+2a_{i}V_{i}(t)+ \varphi_{i} \tag{11}\]  
\[V_{i}(T)=0 \tag{12}\]  
By using the above transformation, the corresponding optimal state equation and the optimal defense strategy can be re-written as follows:  
\[dx_{i}^{*}(t)=\Big{[}\Big{(}a_{i}-\beta_{i}^{-1}b_{i}^{2}V_{i}(t)\Big{)}x_{i}^ {*}(t)+\beta_{i}^{-1}b_{i}^{2}\varphi_{i}(t)+c_{i}\|x_{i}^{*}(t)-Ax^{N}(t)\|^ {2}+\Big{(}c-\beta_{i}^{-1}\lambda_{i}\Big{)}V_{i}(t)\Big{]}dt \tag{13}\]  
\[d\varphi_{i}(t)=\Big{[}\Big{(}a_{i}-\beta_{i}^{-1}b_{i}^{2}V_{i}(t)\Big{)} \varphi_{i}(t)-\varphi_{i}Az(t)-V_{i}(t)\Big{(}\beta_{i}^{-1}\lambda-c\Big{)} u_{0}(t)\Big{]}dt \tag{14}\]  
where \(z(t)=\lim\limits_{N\to\infty}x^{N}(t)\), \(x_{i}^{*}(0)=x_{i}(0)\), \(\varphi_{i}(T)=0\).