# Stochastic Predictive Energy Management of Multi-Microgrid Systems
## 5 Efficient Cost Allocation Strategy  
In this paper, it is assumed that MGs in a neighborhood area desire to represent the whole MMG system as a predictable entity to the main grid. In other words, the final goal is to minimize the net value of unexpected power transactions with the main grid. According to (3), the net exchanged energy of the MMG network with the main grid is equal to the summation of the flow of lines that connect MGs to the main grid. It is assumed that the network of MGs will be penalized according to the real-time power deviation from the scheduled plan as represented in (29) where \(PCost\) stands for the penalty cost and \(\lambda\) represents the cost factor (\(\frac{\xi}{kWh}\)) imposed to the MMG system for one kWh energy deviation. \[PCost=(\hat{I}_{M}(t)-I_{M}(t))\lambda. \tag{29}\]  
In this paper, it is proposed that the final penalty cost could be distributed among MGs (\(\lambda=\sum_{i=1}^{M-1}\lambda_{i}\)) by following their participation level. In other words, one should calculate the effect of power deviation in different MGs in the change of \(I_{M}(t)\) from the reference value. Considering an exemplary system diagram for \(M=4\) as represented in Figure 2, changes in \(I_{M}(t)\) is equal to the summation of the line flow changes in different lines that connect the MGs to the main grid as shown below. \[\Delta I_{M}(t)=\Delta f_{1-M}+\Delta f_{2-M}+...+\Delta f_{(M-1)-M}. \tag{30}\]In (30), \(\Delta f_{n-m}\) represents the change in power flow of the line \(n-m\), which connects the \(n\)th bus to the \(m\)th bus. According to [34], it is assumed that any power changes \(\Delta P_{i}\) at the \(i\)th bus of the system will be compensated through an exact opposite change in the reference bus, which is assumed to be the main grid in this study while the power generation in other buses remains fixed. Since power changes in the generation of different MGs do not have the same effect on the power flow of the intended line, the line flow sensitivity factors are used to measure different MGs effect and to share the penalty cost fairly. Difference between the expected line power flow (\(f_{n-m}(t)\)) and the realized line power flow (\(\hat{f}_{n-m}(t)\)) can be represented as follows:  
\[\Delta f_{n-m}(t)=\hat{f}_{n-m}(t)-f_{n-m}(t). \tag{31}\]  
Considering the effects of power changes in different MGs on the line \(n-m\) and defining \(\alpha_{(n-m),i}\) as the sensitivity of line \(n-m\) power flow to a change of \(\Delta P_{i}\) in the \(i\)th MG, \(\Delta f_{n-m}(t)\) could be written as below. \[\Delta f_{n-m}(t)=\sum_{i=1}^{M-1}\alpha_{(n-m),i}\Delta P_{i}(t). \tag{32}\]  
Utilizing (30), the change in power flow of the reference line concerning different MGs can be calculated as follows:  
\[\Delta I_{M}(t)=\sum_{i=1}^{M-1}\Delta f_{M-i}(t), \tag{33}\]  
\[\Delta I_{M}(t)=\sum_{i=1}^{M-1}\alpha_{(M-i),1}\Delta P_{1}(t)+...+\sum_{i=1 }^{M-1}\alpha_{(M-i),M-1}\Delta P_{M-1}(t). \tag{34}\]  
According to (35), the change in the flow of a line can be written using the phase angle change in the two buses \(n\) and \(m\) where the line is connected [34]. In (35), \(x_{n-m}\) represents the line reactance. Figure 2: An illustrative four-bus network example. Moreover, using the linear power flow equations, the phase angles and power change of buses are related according to (36) where \([X]\) is derived from the admittance matrix [34]. \[\Delta f_{n-m}=\frac{1}{x_{n-m}}(\Delta\theta_{n}-\Delta\theta_{m}), \tag{35}\]  
\[\Delta\theta=[X]\Delta P. \tag{36}\]  
Hence, the line flow sensitivity factors are derived as follows:  
\[\alpha_{(n-m),i}=\frac{df_{n-m}}{dP_{i}}=\frac{d}{dP_{i}}[\frac{1}{x_{n-m}}( \theta_{n}-\theta_{m})]=\frac{1}{x_{n-m}}(X_{n-i}-X_{m-i}). \tag{37}\]  
It should be noted that if the \(l\)th bus is the reference bus, then \(X_{l-i}=0\), \(X_{i-l}=0\). Utilizing (34) and (37), the penalty cost coefficient of each MG can be considered as the normalized value of the line flow sensitivity factors.