# Double-Consensus Based Distributed Optimal Energy Management for Multiple Energy Hubs
## 3 Distributed Algorithm
### DDC Algorithm with Inequality Constraints  
For variable \(E_{i}^{\epsilon}\), the corresponding inequality constraints in Equation (5a) can be taken into consideration by introducing the following well-known projection operations.  
\[E_{i}^{\epsilon}(k)\ =\ \ \left\{\begin{array}{l}E_{i,in}^{e,min},\ \text{if}\ x_{i}^{ \epsilon}(k)<E_{i,in}^{e,min}\\ x_{i}^{\epsilon}(k),\ \text{if}\ E_{i,in}^{e,min}\leq x_{i}^{\epsilon}(k)\leq E_{i,in}^{e,max} \\ E_{i,in}^{e,min},\ \text{if}\ x_{i}^{\epsilon}(k)>E_{i,in}^{e,max} \end{array}\right. \tag{11}\]  
Different from \(E_{i}^{\epsilon}\), \(E_{i}^{\delta\rho}\) and \(E_{i}^{\mathcal{S}1-\rho}\) are coupled by a set of linear inequality constraints, which greatly increases the solving difficulty. To address this issue, the basic concept is to establish a projection operation method that can map the solution without considering inequality constraints onto one point of the feasible operating region determined by Equation (6); meanwhile, the values of this point must satisfy the corresponding KKT conditions. Please note that the new solution may be inside the feasible operating region corresponding to no active constraints, on boundaries corresponding to one active constraint, or at the corner point of boundaries corresponding to two active constraints. Then, according to optimality conditions, we establish the identification conditions for the above three cases, which can be seen in Appendix B-(d).  
Furthermore, the projection operations for \(E_{i}^{g,\rho}\) and \(E_{i}^{g,1-\rho}\), to take Equation (6) into account, are given by  
\[E_{i}^{g,\rho}(k) = \left\{\begin{array}{ll}x_{i}^{g,\rho}(k),\text{ if }(24)\text{satisfied}\\ x_{i,h}^{g,\rho},\text{ if }(25)\text{satisfied}\\ x_{i,h\ell}^{g,\rho}\text{ if }(26)\text{satisfied}\end{array}\right. \tag{12}\] \[E_{i}^{g,1-\rho}(k) = \left\{\begin{array}{ll}x_{i}^{g,1-\rho}(k),\text{ if }(24)\text{satisfied}\\ x_{i,h}^{g,1-\rho},\text{ if }(25)\text{satisfied}\\ x_{i,h\ell}^{g,1-\rho},\text{ if }(26)\text{satisfied}\end{array}\right. \tag{13}\]  
Theorem 1 can be expanded to solve the problem Equations (3)-(6) by only replacing Equation (9), in Theorem 1, with Equations (11)-(13). For clarity, the flowchart of the proposed DDC algorithm is summarized in Figure 2.  
Figure 2: Flowchart of the proposed DDC algorithm.  
**Remark 3**.: _The coupled variables problem can be effectively solved by implementing the proposed DDC algorithm. Firstly, we express \(E_{i}^{\mathcal{S}\rho}\) and \(E_{i}^{\mathcal{S}1-\rho}\) without inequality constraints as the linear combination of \(\lambda_{e}\) and \(\lambda_{g}\). Then, the direct calculation of \(E_{i}^{\mathcal{S}\rho}\) and \(E_{i}^{\mathcal{S}1-\rho}\) can be transformed into the indirect calculation of \(\lambda_{p}\) and \(\lambda_{h}\), which can effectively handle the coupled variables existing in the objective function. Furthermore, along with the KKT conditions and the solution without inequality constraints, the proposed projection operation method maps infeasible values into the feasible operation region, which can further effectively handle the coupled variables existing within the inequality constraint limits._