## 4 Models and Algorithm Design
### Algorithm Development  
The proposed algorithm is based on the algorithm presented in [8] utilizing the Lagrangian dual problem for EDP and further improves it. The designed algorithm derives a distributed EDP solution using local \(\lambda\) estimation using only local communication for each generator [8,49]. Initially, it is also necessary to state some assumptions that will be considered for the entire algorithm operation. **Assumption 2**. : _All considered price functions \(C_{i}:P_{i}\to R^{+}\) are convex and continuously differentiable._  
This assumption is not violated even in the case of the considered shapes of the price functions for renewable resources given in Equations (13), (16), (17), and (19). That is because they are linear or constant functions. Linear functions and constant functions are both concave and convex. **Assumption 2**, along with the condition described in Equation (11), which is affine, meets the Slater condition. The Slater condition is essential for ensuring strong duality in a convex optimization problem and requires the feasible region to contain an interior point. In this context, an affine function comprises a linear function plus a constant, and its graph forms a straight line. This implies a zero duality gap, allowing the original problem outlined in Section 3 to be transformed into a Lagrange dual problem. Similarly, it can be argued that the condition (3) for the extended problem is also affine, and therefore, along with **Assumption 2**, it satisfies the Slater condition in this case as well. As mentioned in the previous chapters, the communication topology of the network between \(N\) agents is represented using an unbalanced directed graph \(\mathcal{G}\). **Remark 2**. : _The proper functioning of the algorithm relies on the graph \(\mathcal{G}\) being strongly connected, primarily due to the need for information exchange among agents. The distributed solution would not operate appropriately if any network part were informationally isolated from the rest._  
Before the algorithm itself, it is necessary to define the set of all renewable resources as \(O_{s,w}=O_{s}\cup O_{w}\) to shorten the notation. Term \(O_{c}\) and \(O_{b}\) represent a set of conventional units and BESS. In each agent in the network, the following three equations are calculated, which thus define the entire iterative algorithm:  
\[\lambda_{i}(k+1) =\sum_{j=1}^{N}w_{ij}\lambda_{j}(k)- \begin{cases}\gamma_{i}(k) \frac{\
abla\Phi_{i}(\lambda_{c_{i}}(k))}{y_{i}(k)},&\text{if}\,i\in O_{c},\\ \\ \gamma_{i}(k)\frac{\
abla\Phi_{i}(\lambda_{c_{i}}(k))}{y_{i}(k)},&\text{if}\,i \in O_{s,w},\\ \\ \gamma_{i}(k)\frac{\
abla\Phi_{i}(\lambda_{b_{i}}(k))}{y_{i}(k)},&\text{if}\,i \in O_{b},\\ \end{cases}  \tag{22}\] \[P_{i}(k+1) = \begin{cases}\varphi_{c_{i}}\big{(}\
abla C_{c_{i}}^{-1}(\lambda_ {c_{i}}(k+1)\cdot\mu_{c_{i}}^{-1}(k))\big{)},&\text{if}\,i\in O_{c},\\ \\ \varphi_{s,w_{i}}\big{(}P_{s,w_{i}}\cdot\mu_{s,w_{i}}(k)\big{)},&\text{if}\,i \in O_{s,w},\\ \\ \varphi_{b_{i}}\Big{(}\mathrm{Y}\big{(}E_{b_{i}}(t)\big{)}\cdot\mu_{b_{i}}(k) \Big{)},&\text{if}\,i\in O_{b},\\ \end{cases} \] (23) \[y_{i}(k+1) =\sum_{j=1}^{N}w_{ij}y_{j}(k). \tag{24}\]  
For the first two equations, three distinct calculations can occur, depending on whether the agent represents a conventional power plant (index \(c\)), renewable resources (index \(w\), \(s\)), or a BESS (index \(b\)) with price functions \(C_{c_{i}}\), \(C_{s,w_{i}}\), or \(C_{b_{i}}\). Variable \(\lambda_{i}(k+1)\) represents the\(i\)-th generator estimation of the optimal incremental cost. The calculations for all three options are nearly identical, differing only in the price function used and, consequently, the form of the gradient calculation \(\
abla\Phi_{i}(\lambda_{i}(k))\). Term \(P_{i}(k+1)\) expresses the corresponding power generation and has three calculation options. The first option calculates for all conventional controllable power plants belonging to the set \(O_{c}\).