# MADDPG-Based Security Situational Awareness for Smart Grid with Intelligent Edge
## 4 Problem Formulation
In particular, at time slot \(t\), define \(\mathcal{A}_{bk}^{p(t)}=1\) to indicate that the anomaly traffic is detected for port \(p(t)\), and \(\mathcal{A}_{bk}^{p(t)}=0\) otherwise; \(\mathcal{A}_{bk}^{e(t)}=1\) toindicate that anomalous event \(e(t)\) is detected, and \(\mathcal{A}_{bb}^{e(t)}=0\) otherwise; \(\mathcal{A}_{bb}^{n(t)}=1\) to indicate that vulnerable node \(n(t)\) is detected, and \(\mathcal{A}_{bb}^{n(t)}=0\) otherwise; and \(\mathcal{A}_{bb}^{a(t)}=1\) to indicate that the possible attack's category \(a(t)\) is detected, and \(\mathcal{A}_{bb}^{a(t)}=0\) otherwise. Then, the cost of the SSA's processing under the edge agent \(k\) at time slot \(t\) is  
\[\mathcal{C}(t)=\sum_{p(t)=1}^{P(t)}\mathcal{A}_{bb}^{p(t)}C_{kp(t)}^{exPot}(t )+\sum_{e(t)=1}^{E(t)}\mathcal{A}_{bb}^{e(t)}C_{ke(t)}^{exLog}(t)+\sum_{n(t)=1} ^{N(t)}\mathcal{A}_{bb}^{n(t)}C_{kn(t)}^{in}(t)+\sum_{a(t)=1}^{A(t)}\mathcal{A }_{bb}^{a(t)}C_{kn(t)}^{At}(t). \tag{5}\]  
Assume that in the power terminals under the jurisdiction of time slot \(t\), edge agent \(k\), the actual case of port \(p^{\prime}(t)\), if the traffic information is abnormal, \(\mathcal{N}_{k}^{p^{\prime}(t)}(t)=1\), and otherwise \(0\); similarly, \(\mathcal{N}_{k}^{p^{\prime}(t)}(t)=1\), \(\mathcal{N}_{k}^{p^{\prime\prime}(t)}(t)=1\), and \(\mathcal{N}_{k}^{p^{\prime}(t)}(t)=1\) denote the alarm event \(e^{\prime}(t)\), vulnerable node \(n^{\prime}(t)\), and the possible attack \(a^{\prime}(t)\) is existing in the actual case, respectively. Then, the error rate of anomaly traffic port detection for external environment information is expressed as  
\[\mathcal{E}_{k}^{exPot}=1-\frac{\sum_{p(t)=1}^{P(t)}\Delta_{p(t)}}{P(t)}. \tag{6}\]  
If \(\mathcal{A}_{bb}^{p(t)}=\mathcal{N}_{k}^{p^{\prime}(t)}(t)\), then \(\Delta_{p(t)}=1\), and inversely, \(\Delta_{p(t)}=0\). The detection error rate of alarm events for external environment information is expressed as  
\[\mathcal{E}_{k}^{exLog}=1-\frac{\sum_{v(t)=1}^{E(t)}\Delta_{e(t)}}{E(t)}. \tag{7}\]  
If \(\mathcal{A}_{bb}^{e(t)}=\mathcal{N}_{k}^{p^{\prime}(t)}(t)\), then \(\Delta_{n(t)}=1\), and inversely, \(\Delta_{n(t)}=0\). The detection error rate of vulnerable nodes in the internal environment is expressed as  
\[\mathcal{E}_{k}^{in}=1-\frac{\sum_{n(t)=1}^{N(t)}\Delta_{n(t)}}{N(t)}. \tag{8}\]  
If \(\mathcal{A}_{bb}^{n(t)}=\mathcal{N}_{k}^{p^{\prime\prime}(t)}(t)\), then \(\Delta_{n(t)}=1\), and inversely, \(\Delta_{n(t)}=0\). The detection error rate of the possible attack is expressed as  
\[\mathcal{E}_{k}^{At}=1-\frac{\sum_{a(t)=1}^{A(t)}\Delta_{a(t)}}{A(t)}. \tag{9}\]  
Similarly, if \(\mathcal{A}_{bb}^{a(t)}=\mathcal{N}_{k}^{a^{\prime}(t)}(t)\), then \(\Delta_{a(t)}=1\), and inversely, \(\Delta_{a(t)}=0\). The security situational awareness for smart grids under edge computing (SSASGEC) problem to minimize the processing cost under low-error rate by combining situational elements in different dimensions is as follows:  
\[\underset{t\in[0,T]}{\text{min}}\mathcal{C}(t) \tag{10}\] \[O_{k(t)}^{exLog}(t)\in\{0,1\},\ e(t)=\{1,2,\ldots,E(t)\}. \tag{2}\]0 (10a) \[\left\{ \begin{array}{l}\mathcal{A}_{bb}^{p(t)},\mathcal{A}_{bb}^{e(t)}, \mathcal{A}_{bb}^{n(t)},\mathcal{A}_{bb}^{a(t)}\in\{0,1\},\forall\ k\in\{1,2, \dots,K\}\\ \mathcal{E}_{k}^{exPot}<\epsilon_{kexp}^{exPot},\forall\ k\in\{1,2,\dots,K\}\\ \mathcal{E}_{k}^{exLog}<\epsilon_{kexp}^{exLog},\forall\ k\in\{1,2,\dots,K\} \\ \mathcal{E}_{k}^{in}<\epsilon_{kexp}^{in},\forall\ k\in\{1,2,\dots,K\}\\ \mathcal{E}_{k}^{At}<\epsilon_{kexp}^{At},\forall\ k\in\{1,2,\dots,K\}\end{array}  \right., \tag{10f}\]where \(\epsilon^{extPol}_{k,\exp},\epsilon^{exLog}_{k,\exp},\epsilon^{in}_{k,\exp}\), and \(\epsilon^{At}_{k,\exp}\) denote the expectation detection error rate, respectively. (10a) represents the information of the current moment of the situational elements. (10b) indicates the situation awareness variables. (10c), (10d), (10e), and (10f) denote the four threat detections' error rates under the three situational dimensions that should not surpass our expectation.