# A Decentralized Multi-Agent-Based Approach for Low Voltage Microgrid Restoration
## 4 Proposed Decentralized Approach
### Mathematical Background
#### 4.1.1 Distributed Averaging  
Let \(g=(N,E)\) be a graph with \(N\) nodes and \(E\) edges. In node set \(N=\{1,2,\ldots,n\}\), consider each edge \(\{i,j\}\in E\) is an unordered pair of distinct nodes. Let \(c_{i}^{0}\) be a real number associated to node \(i\) at time \(t=0\). The average consensus problem calculates iteratively the average \((1/n)\sum_{i=1}^{n}c_{i}^{0}\) in a distributed way at every node (see Figure 4). The following iterative law, known as ACA, is proposed in the literature to solve this averaging problem [44]:  
\[c_{i}^{k+1}=c_{i}^{k}+\sum\limits_{j\in N_{i}}w_{ij}(c_{j}^{k}-c_{i}^{k}), \tag{1}\]  
where \(i=1,2,\ldots,n;n\) is the number of nodes; \(c_{i}^{k}\), \(c_{i}^{k+1}\) are the values of node \(i\) at iteration \(k\) and \(k+1\), respectively, and \(w_{ij}\) is the weight coefficient that enables communication between neighboring nodes \(i\) and \(j\). If nodes \(i\) and \(j\) are connected together, \(0<w_{ij}<1\), otherwise, \(w_{ij}=0\). \(N_{i}\) is the index of nodes connected to node \(i\).  
By considering \(\mathbf{C}^{\mathbf{k}}=[c_{1}^{k},\ldots,c_{i}^{k},\ldots,c_{n}^{k}]^{\mathsf{ T}}\), Equation (1) can be expressed in matrix form as follows:  
\[\mathbf{C}_{\mathbf{i}}^{\mathbf{k+1}}\mathbf{=}\mathbf{C}_{\mathbf{i}}^{ \mathbf{k}}\mathbf{+AC}_{\mathbf{i}}^{\mathbf{k}}\mathbf{=}\left(\mathbf{I}+ \mathbf{A}\right)\mathbf{C}_{\mathbf{i}}^{\mathbf{k}}\mathbf{\rightarrow} \mathbf{C}_{\mathbf{i}}^{\mathbf{k+1}}\mathbf{=DC}_{\mathbf{i}}^{\mathbf{k}}, \tag{2}\]  
where \(\mathbf{I}\) is the identity matrix, and:  
\[\mathbf{D}=\left[\begin{array}{ccccc}1-\sum\limits_{j\in N_{1}}w_{1j}& \cdots&w_{1i}&\cdots&w_{1n}\\ \cdots&\cdots&\cdots&\cdots&\cdots\\ w_{1i}&\cdots&1-\sum\limits_{j\in N_{i}}w_{ij}&\cdots&w_{in}\\ \cdots&\cdots&\cdots&\cdots&\cdots\\ w_{n1}&\cdots&w_{ni}&\cdots&1-\sum\limits_{j\in N_{n}}w_{nj}\\ \end{array}\right]_{n\times n}. \tag{3}\]  
The square matrix \(\mathbf{D}\) is said to be _doubly stochastic_ if its elements are non-negative and sums of each row and each column are equal to ones, i.e., with \(\mathbf{I}_{1\times\mathbf{n}}=[1,1,\ldots,1]\), \(1\times\mathbf{D}=1\) and \(1\times\mathbf{D}^{\mathsf{T}}\mathbf{=1}\)[45]. Based on the Gerschgorin's Disks theorem, the eigenvalues of \(\mathbf{D}\) are lower than or equal to one. According to the _Perron Frobenius Lemma_[46], one can write:  
\[\lim\limits_{k\rightarrow\infty}\mathbf{D}^{k}=\frac{\mathbf{I}^{T}\ast 1}{n}, \tag{4}\]  
Figure 4: Principle of distributed averaging.  
where \(n\) is the dimension of matrix \(\mathbf{D}\). Combination of (2) and (4) leads to:  
\[\lim\limits_{k\rightarrow\infty}\mathbf{C}_{i}^{k}=\frac{\mathbf{I}^{T}*1}{n} \mathbf{C}_{i}^{0}. \tag{5}\]  
From Equation (5), one can see that the system reaches to consensus when \(k\) approaches infinity. The speed of convergence depends on the design of \(\mathbf{D}\). In practice, the exact equilibrium is not required, and the number of required steps for converging is approximately equal to:  
\[k=\frac{-1}{\log_{c}(\frac{1}{\lambda_{2}})}, \tag{6}\]  
where \(e\) is the error tolerance and \(\lambda_{2}\) is the second biggest eigenvalue of \(\mathbf{D}\)[44]. Equation (6) shows that \(\lambda_{2}\) determines the number of required steps to converge or equivalently the speed of the algorithm. To achieve the maximum speed and the optimal solution, the weight coefficients in matrix \(\mathbf{D}\) must be determined in such a way to minimize \(\lambda_{2}\).