# Sustainable Operation of Active Distribution Networks
## 3 Agents' Modeling
### Active Distribution Network Management Agent (ADNM/A)
 \tag{39}\]  
where \(n_{ch},n_{disch}\) are the PEVs' charging (discharging) efficiency coefficients; \(SoC_{0}\) is the level of energy at the beginning of charging; \(SoC_{target}\) is the target level of the stored energy at the end of charging; \(SoC_{0,CEV}\) is the level of the stored energy of a cluster of PEVs at t\({}_{0}\); \(SoC_{T,CEV}\) is the target level of the stored energy of a cluster of PEVs at time t\({}_{0}\); \(SoC_{PB,high}\),\(SoC_{PB,low}\) are the maximum/minimum stored energy by the PEVs' aggregate battery, respectively; \(SoC_{CEV,high},SoC_{CEV,low}\) are the maximum/minimum stored energy by a cluster of PEVs; \(P_{CEV,max},P_{CEV,min}\) are the active power boundaries of a cluster of PEVs; and \(P_{PB,max},P_{PB,min}\) are the power boundaries of the PEVs' aggregate battery. Then, the ADN exploits an optimization technique for the optimal scheduling of its operation. Specifically, ADN uses particle swarm optimization (PSO), which is one of the most highly efficient heuristic methods and is remarkably simple to implement. PSO has been proven to be very robust and efficient for application in complex optimization problems as it does not depend on the selected initial point and leads to a global optimum with a high rate of success. However, it should be noted that no optimization method can guarantee convergence to the global optimum with a 100% rate of success. ADN provides the optimal total electric power consumption of the HVAC systems of all of the hosted residential buildings and the optimal active power of the PEVs' aggregate battery. The structure of each particle of the swarm with its different parts comprising the respective decision variables of the optimization of the ADN is given in Figure 5. Constrained OPF can be exploited to keep the voltages of the active distribution network and the currents of the power lines between the permissible boundaries. Then, the active and reactive power set-points that resulted from the OPF exploitation are forwarded back to the appropriate cluster agents to be suitably dispatched to the local agents they manage. The augmented cost function used by the PSO incorporating the imposed constraints is provided in Equation (40). The objective of the optimization procedure is to minimize the ADN's overall daily operational costs in accordance with the cost of electricity, while also fully satisfying all of the ADN components' constraints incorporated into the term (Penalty) of the objective function. \[TC_{ADN}=\min_{P_{PB,total},P_{HVAC,total}}\left\{\left(\sum_{t}P_{grid}(t) \cdot EP(t)\right)\cdot\Delta t+Penalty\right\} \tag{40}\]  
where EP denotes the variable price of electricity (m.u./MWh) and \(P_{grid}\) is the power of the main electric grid. Then, ADNM/A optimally dispatches the total HVAC electric consumption of residential buildings (\(P_{HVAC,total}\)) to the CBTL/As it supervises according to Equation (41) and the obtained active and reactive power set-points are delivered back to these clusters. Afterward, CBTLAs dispatch their power to the local agents BTL/As they supervise and control, as formulated in Equation (42). \[P_{HVAC,CB}(t)=\frac{FL_{CB}(t)\cdot\sum_{b}V_{b}}{\sum_{CB}\{FL_{CB}(t)\cdot V _{CB}\}}\cdot P_{HVAC,total}(t) \tag{41}\]  
\[P_{HVAC,b}(t)=\frac{FL_{b}(t)\cdot V_{b}}{\sum_{b}\{FL_{b}(t)\cdot V_{b}\}} \cdot P_{HVAC,CB}(t) \tag{42}\]  
where \(V_{CB}\) is the sum of the volumes of the buildings belonging to the respective cluster of buildings denoted by CB. The process of the HVAC system's optimal power dispatch to the CBTL/As and then to the local agents BTL/As and more specifically to each hosted residential building  
Figure 5: Particle structure used by the ADNM/A. is depicted in Figure 6. The average execution time of this process was 0.035 s for the examined system. A last optimization problem was solved for the optimal dispatch of the total power of the dynamic equivalent aggregate battery to CPEV/As and then to each PEV as formulated and described in detail in [25].