## 3 AGC Power Allocation Strategy of Charging Stations Based on Consensus Algorithm
### Charging Power Station AGC Power Allocation Based on Cost Consensus Algorithm  
In order to make the charging station with lower adjustment cost bear with more power disturbance, the cost is selected as the consentaneous state variable. Hence, the adjustment cost \(r_{i}\) of the \(i\)th charging station can be written as follows:  
\[r_{i}=C_{i}\cdot\Delta P_{i}, \tag{8}\]  
where \(C_{i}\) represents the adjustment cost coefficient of the \(i\)th charging station.  
For the purpose of ensuring the power balance and guaranteeing that all the EV charging stations can share the power deviation, the cost consensus variable \(r_{i}\) need to be updated as follows:  
\[r_{i}[k+1]\left\{\begin{array}{ll}\sum\limits_{j=1}^{n}d_{ij}[k]x_{j}[k]+ \frac{\gamma\Delta P_{\text{error}}}{n},&\Delta P_{\text{EV}\,\sum\limits_{j} }>0\\ \sum\limits_{j=1}^{n}d_{ij}[k]x_{j}[k]-\frac{\gamma\Delta P_{\text{error}}}{n},&\Delta P_{\text{EV}\,\sum\limits_{j}}<0\end{array}\right., \tag{9}\]  
where \(\gamma\) denotes the error adjustment factor, with \(\gamma>0\); and \(\Delta P_{\text{error}}\) is the deviation between the total power instruction of EV centralized control center and the total power instruction of all EV charging stations, which can be defined by the following:\[\Delta P_{\text{error}}=\Delta P_{\text{EV}\sum}-\sum_{i=1}^{n}\Delta P_{i}. \tag{10}\]  
During the update of the consensus state variable, in order to gradually reduce the absolute value of power deviation, the adjustment cost consensus variable \(r_{i}\) should increase gradually if \(\Delta P_{\text{EV}\sum}\) is positive. On the contrary, if \(\Delta P_{\text{EV}\sum}\) is negative, the adjustment cost consensus variable \(r_{i}\) should decrease gradually.  
After several iterations of Equation (9), the adjustment cost of each EV charging station tends to be consentaneous, while the convergence criteria can be given as follows:  
\[\Delta P_{\text{error}}\leq\varepsilon. \tag{11}\]  
During the optimization process, the power instruction assigned to an EV charging station may exceeds its reserve capacity limit. To guarantee that the generation command of each charging station can be limited within their lower and upper bounds, the following operation is designed into the optimization process:  
\[\Delta P_{i}=\left\{\begin{array}{ll}\Delta P_{i}^{\text{max}}=\sum\limits_{ i=1}^{M_{i}}\Delta P_{iw}^{\text{max}},&\Delta P_{i}>\Delta P_{i}^{\text{max}}\\ \Delta P_{i}^{\text{min}}=\sum\limits_{i=1}^{M_{i}}\Delta P_{i\text{{}_{i}}}^ {\text{min}},&\Delta P_{i}<\Delta P_{i}^{\text{min}}\end{array}\right., \tag{12}\]  
where \(\Delta P_{i}^{\text{max}}\) and \(\Delta P_{i}^{\text{min}}\) represent the maximum and minimum standby capacity of the \(i\)th EV charging station, respectively.  
Under such circumstances, the adjustment cost of the EV charging station also reaches the limits, as follows:  
\[r_{i}=r_{i}^{\text{max}}=\left\{\begin{array}{ll}C_{i}\text{-}\left|\Delta P _{i}^{\text{max}}\right|\text{,}&\Delta P_{i}>\Delta P_{i}^{\text{max}}\\ C_{i}\text{-}\left|\Delta P_{i}^{\text{min}}\right|\text{,}&\Delta P_{i}<\Delta P _{i}^{\text{min}}\end{array}\right.\text{.} \tag{13}\]