# Mean Square Consensus of Nonlinear Multi-Agent Systems under Markovian Impulsive Attacks
## 4 Numerical Examples  
In this section, a numerical example with four different cases corresponding to the results established in the previous section is presented, and the last one is given to illustrate the case when gains of attacks \(|\eta_{k}|\leq 1,k\in\mathbb{N}\). Consider the NMASs with four agents, for which the communication topology is described as Figure 2. The dynamics of each agent can be described as follows:  
\[\dot{x}_{i}(t)=Ax_{i}(t)+Bf(x_{i}(t))+Cu_{i}(t). \tag{22}\]where the system states \(x_{i}(t)=[x_{i1}^{T}(t),x_{i2}^{T}(t)]^{T}\in\mathbb{R}^{2}\). \(u_{i}(t)\) is shown in (2), and the nonlinear function \(f(x_{i}(t))=(\tanh(x_{i1}(t)),\tanh(x_{i2}(t)))^{T}\). The constant matrices \(A,B,\) and \(C\) are given as follows:  
\[A= \begin{bmatrix}0.1&0\\ 0&0.1\end{bmatrix} ,B= \begin{bmatrix}0.4&-0.02\\ -1&0.6\end{bmatrix} ,C= \begin{bmatrix}0.2&0.1\\ 0&0.2\end{bmatrix} .\]  
which implies \(\kappa=0.505\) and \(\beta=1.234\) with \(K=0.1\). Choose \(P=I_{2}\); then \(\rho=1\) and \(\gamma=\rho\beta=1.234\). Suppose a generator of the considered Markovian chain is given as the matrix \(\Lambda\)  
\[\Lambda= \begin{bmatrix}-4&2&1&1\\ 1&-5&2&2\\ 2&1&-4&1\\ 2&2&1&-5\end{bmatrix} ,\]  
from which we know that \(\gamma=1.234<\min_{j\in\Gamma}\{\lambda_{j}\}=4\), from which the transition probability matrix \(Q\) can also be derived as  
\[Q= \begin{bmatrix}0&0.5&0.25&0.25\\ 0.2&0&0.4&0.4\\ 0.5&0.25&0&0.25\\ 0.4&0.4&0.2&0\end{bmatrix} ,\]  
and for which the Markovian chain is described in Figure 3, where we only present a local part of the whole Markovian chain. Figure 3: The Markovian chain generated by the probability transition matrix \(Q\). Figure 2: The communication topology of the NMASs (22). In addition, set the initial values of system state  
\[x(t_{0}) =\left[x_{1}^{T}(t_{0}),x_{2}^{T}(t_{0}),x_{3}^{T}(t_{0}),x_{4}^{T}( t_{0})\right]^{T}\] \[=\left[1.5\quad 0.6\quad 0.5\quad-1.2\quad-1.5\quad-0.6\quad-0.5 \quad 1.2\right]^{T}\]  
which can also be randomly generated. Moreover, we can verify that the average values of \(x(t_{0})\) is \(x_{ave}=0\). Let the error state defined as \(|e_{i}(t)|=\sqrt{x_{i1}^{2}(t)+x_{i2}^{2}(t)}\). As shown in Figure 4, the error trajectories of agents do not reach an agreement in the absence of a controller, in other words, system (22) is unstable without control. In the following, we consider four cases of stochastic attacks, in which the first three examples are given to illustrate some results proposed in the previous section and the last example is given to illustrate the case in which gains of attacks are below the defined threshold, i.e., \(|\eta_{k}|\leq 1,k\in\mathbb{N}\). Let the time step of all the simulations in this section be \(step=0.01\). **Remark 6**. : _As we know, the Markovian process can reflect the random jump phenomenon in the real world well and is widely used in many production activities. The cases given here are used to simulate different kinds of malicious human-made network attacks in reality as well as possible attack phenomena in engineering applications such as some transformers that suffer from cyber attacks and result in functional failure in the power grid._  
_Case 1: Stochastic gains and instants._  
In this case, based on the condition that \(|\eta_{k}|>1,k\in\mathbb{N}\), we assume that gains of the impulsive deception attacks \(\mu_{1}=1.1\xi_{1}^{\intercal},\mu_{2}=-1.2\xi_{2},\mu_{3}=-1.1\xi_{3}^{\intercal}\), and \(\mu_{4}=1.2\xi_{4}\), where \(\xi_{i},i=1,2,3,4\) satisfy the Bernoulli distribution with expectations \(\mathbb{E}[\xi_{1}]=0.5,\mathbb{E}[\xi_{2}]=0.1,\mathbb{E}[\xi_{3}]=0.2\), and \(\mathbb{E}[\xi_{4}]=0.1\), respectively. Then, we can verify that \(v_{1}=0.605,v_{2}=0.144,v_{3}=0.242\), and \(v_{4}=0.144\). In addition, instants of attacks obey the Markovian chain, for which  
_Case 2: The Markovian chain is a stationary distribution._  
From the given generator, the stationary distribution \(\bar{\epsilon}=(0.273,0.227,0.273,0.227)\) can be obtained.