# Double-Consensus Based Distributed Optimal Energy Management for Multiple Energy Hubs
## Appendix B Consensus Algorithm, Initializations and Projection Conditions  
1. The two different discrete-time systems considered are as follows: \[\left(\mathrm{P1}\right)\ \ \ \chi_{i}(k+1)\ =\ \sum\limits_{j\in N_{i}^{ \epsilon}}r_{ij}\chi_{j}(k)\] (14)\[(\text{P2})\quad\widetilde{\chi}_{i}(k+1)\ =\ \sum_{j\in N_{i}^{+}}s_{i,j} \widetilde{\chi}_{j}(k)\] (A9) Since R is row stochastic, P1 forms the first-order consensus protocol. Each node reaches the final common value \(\chi_{i}(\infty)\ =\ w^{T}\chi(0)\). Since \(S\) is column stochastic, the summation of all state variables is a constant, i.e., \(\sum\widetilde{\chi}_{i}(k)\ =\ \sum\widetilde{\chi}_{i}(0)\). 2. We let \(u_{i}^{e,min}\ =\ u_{i}^{e,max}\ =\ u_{i,m}^{g}\ =\ 0\). Then, according to the first three equations of Equation (12), the optimal solution of \(E_{i}^{e}\), \(E_{i}^{g,p}\) and \(E_{i}^{g,1-p}\) of each energy hub can be determined by the unique Lagrange multipliers \(\lambda_{e}\) and \(\lambda_{e}\), given by \[\left\{ \begin{array}{l}E_{i}^{e}\ =\ \overline{a}_{i}^{p}\lambda_{e}- \overline{b}_{i}^{p}\\ E_{i}^{g,p}\ =\ \overline{a}_{i}^{p,c}\lambda_{e}-\overline{a}_{i}^{p,c} \lambda_{g}-\overline{b}_{i}^{p,c}\\ E_{i}^{g,1-p}\ =\ \overline{a}_{i}^{h,c}\lambda_{g}-\overline{a}_{i}^{h,c} \lambda_{e}-\overline{b}_{i}^{h,c}\\ \end{array} \right.\] (A10) where \(\overline{a}_{i}^{p}\ =\ \eta_{i}^{ee}/2a_{i}^{e}\), \(\overline{b}_{i}^{p}\ =\ b_{i}^{e}/2a_{i}^{e}\), \(\overline{a}_{i}^{p,c}\ =\ 2\beta_{i}^{g}\eta_{i}^{e,chp}/\vartheta\), \(\overline{a}_{i}^{p,c}\ =\ (\gamma_{i}^{g}\eta_{i}^{boill}-2\beta_{i}^{g}\eta_{i}^{h, chp})/\vartheta\), \(\overline{b}_{i}^{p,c}\ =\ (2\beta_{i}^{g}\eta_{i}^{g}-\gamma_{i}^{g}b_{i}^{g})/\vartheta\), \(\overline{a}_{i}^{h,c}\ =\ \gamma_{i}^{g}\eta_{i}^{e,chp}/\vartheta\), \(\overline{a}_{i}^{h,c}\ =\ \gamma_{i}^{g}\eta_{i}^{boill}-\gamma_{i}^{g}\eta_{i}^{h, chp})/\vartheta\), \(\overline{b}_{i}^{h,c}\ =\ (2\alpha_{i}^{g}\eta_{i}^{g}-\gamma_{i}^{g}\eta_{i}^{ b})/\vartheta\), and \(\vartheta\ =\ 4\alpha_{i}^{g}\beta_{i}^{g}-(\gamma_{i}^{g})^{2}\). 3. \(E_{i}^{e}(0)\), \(E_{i}^{g,\varphi}(0)\) and \(E_{i}^{g,1-\rho}(0)\) can be designed as any admissible values, and the other variables are initialized as \[\left\{ \begin{array}{l}y_{i,e,p}(0)\ =\ l_{i}^{e}/2-E_{i}^{g}(0)\\ y_{i,e,c}(0)\ =\ l_{i}^{e}/2-E_{i}^{g,\varphi}(0)\\ y_{i,g,c}(0)\ =\ l_{i}^{h}-E_{i}^{g,1-\rho}(0)\\ \lambda_{i,e,p}(0)\ =\ \lambda_{i,e,c}(0)\ =\ \lambda_{i,g,c}(0)\ =\ 0\end{array} \right.\] (A11)
4. To map the infeasible values into the feasible operating region, the cases for no active constraints, one active constraint and two active constraints are separately discussed to further give the corresponding identification conditions as follows:  
1. None of the constraints are active constraints, i.e., the optimal solutions before and after considering the inequality constraints have the same values. The identification condition of this case is if \(x_{i}^{g,\varphi}(k)\) and \(x_{i}^{g,1-\rho}(k)\) satisfy \[\widetilde{\lambda}_{i,m}x_{i}^{g,\rho}(k)+\widetilde{e}_{i,m}x_{i}^{g,1-\rho} (k)+\widetilde{f}_{i,m}>0\] (A12) then there are no active constraints; otherwise, the optimal solution belongs to another case. 2. Only one inequality constraint is an active constraint. Let \(\hbar\) represent any one inequality equation. The identification condition of this case is that if there exist solutions \(x_{i,\hbar,}^{g,\rho}\), \(x_{i,\hbar,}^{g,1-\rho}\) and \(u_{i,\hbar}^{g}\geq 0\) satisfying \[\left\{