Optimal Operation of Microgrids Comprising Large Building Prosumers and Plug-in Electric Vehicles Integrated into Active Distribution Networks

: Active distribution networks and microgrids will be powerful tools for future power systems in their endeavor to integrate more renewable energy sources, increase distributed generation and optimize their operation. In this paper, a method for the coordinated optimal operation scheduling of active distribution networks that are hosting complex microgrids comprising large building prosumers and plug-in electric vehicle aggregators is proposed. The electrical and thermal power systems of the microgrid are modelled in detail while the examined active distribution network is assumed to be able to optimally shift part of its loads in time and comprises renewable energy sources as part of its local generation. Moreover, the microgrid is assumed to be able to shift part of its load in order to assist the active distribution network in order to satisfy all of the network constraints when this is required. The proposed method was developed in such a way that allows both the microgrid and the active distribution network to optimize their operations without exchanging the internal information comprising their technical characteristics and parameters. To this end, the method is organized into ﬁve levels wherein only the absolutely necessary information is exchanged, i


Introduction
Future electric power systems will be characterized by the increased penetration of renewable energy sources (RES).Distributed generation will pave the way to this end; however, it will increase the current level of complexity and pose several technical problems and challenges.Active distribution networks are a characteristic network paradigm that is suitable to host distributed generation, RES and flexible loads providing demand response capacity to the power grid.Moreover, the organization of parts of active distribution networks in microgrids will provide reliable solutions to problems resulting from the increased complexity of these networks while also provide more degrees of freedom in their control and optimal operation.In this paper, many of the above-mentioned issues are covered as the coordinated optimal operation scheduling of active distribution networks hosting complex microgrids comprising large building prosumers and plug-in electric vehicle aggregators is studied.
Buildings' energy management systems (EMS) often place more emphasis on the optimization and control of individual buildings [1,2] instead of the control of microgrids of building complexes.Energy management algorithms have focused more heavily on residential buildings [3,4] or residential microgrids [5] than commercial buildings and microgrids, which are more complicated and difficult to optimize.An effective energy management strategy for a microgrid in both grid-connected and islanded modes is presented in [6][7][8], in contrast to [9,10] wherein the autonomous operation of the microgrid is not taken into consideration.Specifically, as is featured in [8], when the microgrid is connected with the main electric grid, the grid regulates the system frequency and voltage.In the case of a significant load variation in the island mode operation of the microgrid, a diesel generator controls the system frequency and voltage.An optimal energy management method for HVAC systems' control of commercial buildings is proposed in [11][12][13].Thermal zones are used to describe the building's thermal system, ensuring that the occupants have a comfortable indoor environment.Additionally, the EMS that is suggested in [14] divides the electrical loads into dispatchable and non-dispatchable categories and takes into account the thermal behavior of a commercial building, in contrast to [15], wherein the various building load types that were employed in this study were not independently modeled.Moreover, the majority of the existing works do not consider the Vehicle-to-Grid( V2G) operation [16,17] of electric vehicles, in contrast to [18] wherein Plug-in Electric Vehicles(PEVs) were used as an energy storage system by absorbing or injecting active power from or into the electric grid.Even though many studies do not include any distributed power generation or energy storage units, the energy management systems that are proposed in [19][20][21] comprise various RES and energy storage systems.In [22], an integrated buildings and microgrid system with different renewable energy resources and controllable loads that is based on multiagent energy management system was monitored and optimally controlled.The proposed algorithm has the capability to minimize a system's operational cost and meet user demands in a variety of weather-related scenarios and pricing models.In [23], the proposed optimization method was applied in an office building microgrid, comprising EVs and batteries, that was connected to the main electric grid.Batteries were utilized as static energy storage, while EVs were employed as dynamic energy storage in order to maximize the overall profit of the microgrid and balance the fluctuations of demand, electricity price and RES generation.Moreover, the EVs' behavior and driving patterns have been taken into consideration.In [24], a two-level optimization strategy is suggested for the optimally distributed generation planning for active distribution networks taking into account the incorporation of energy storage systems.A method for allocating energy storage systems into active distribution networks is suggested in [25].The Energy Storage Systems (ESSs) were properly modelled so as to support the electric network in terms of network losses and voltage variations.Moreover, the proposed method takes into consideration of the stochastic behavior of both loads and renewable energy source generation.In [26], a model-based robust control method was developed in order to manage tracking control and to take advantage of statistical identification for learning to model parametric and nonlinear environmental uncertainties.Parameter identification techniques could be applied especially to the building model as its parameters are characterized by their stochastic behavior and constant change.
The innovative characteristics of this work are listed next.
-The innovative edge of the method is that it requires very short computation times (of the order of a few minutes) for extremely complex systems consisting of very largescale building complexes with a number of decision variables that can reach a few thousand and operational constraints of a multiple of this number.In order to achieve this, a simple way to dispatch the total needs, in terms of thermal power, of a building to its thermal zones is used.The thermal power that is required to be provided to each thermal zone is a function of the total thermal power that is required by the building, its thermal zone volume and its estimated internal temperature together with its upper and lower limits.As a result, the required computation time is kept very low, since the total required thermal power of the building is optimized and then dispatched to the thermal zones.Moreover, an effective aggregation technique is applied to the plug-in electric vehicles that are hosted by the microgrid.-To the best of the authors' knowledge, there are very few works studying the coordinated optimal operation of active distribution networks and microgrids (and especially microgrids comprising large building prosumers).
-The electrical and thermal power systems of complex large building prosumers, the equivalent battery of the hosted electric vehicles and the auxiliary diesel generators were modelled in detail and jointly optimized in both an active distribution networkconnected scenario and that of the autonomous operation of the microgrid.-Another advantage of the algorithm is that, during time periods of the day when the electric grid is not available, the microgrid is able to meet the electricity demand of the building itself with the interconnected electric vehicles and the integrated RES and this same provision of electricity may also be called upon if there is a need or it is economically optimal by the use of the building's auxiliary generators.

-
The operation of the active distribution network comprising RES, flexible loads and a hosted microgrid is optimally jointly scheduled without requiring the microgrid and the active distribution network to disclose to each other their respective internal technical characteristics and information.- The proposed algorithm fully satisfies the active distribution network's operational constraints regarding power flows, voltage amplitudes and angles in both microgridconnected and islanded operation.
The rest of the paper is organized as follows.A brief description of the proposed EMS is given in Section 2. Section 3 presents the models of the components of the examined microgrid.In Section 4, the objective functions and the constraints that were used in the adopted optimization levels are presented.Finally, Section 5 provides the results that were obtained by the simulation of the examined system and analyzes them, while general conclusions are given in Section 6.

Brief Description of the Proposed Energy Management System
The proposed energy management system is structured in the five optimization levels that are described next in this section.Before the application of the optimization levels of the method, the forecasts of occupancy, human activity levels, ambient temperature, PEVs' arrival/dwell times, solar radiation, wind speed and electricity price must be performed for the upcoming 24 h.The examined system is depicted in Figure 1.

Optimization Level 1
The first level of optimization is to be applied to each building prosumer of the microgrid in order to provide the optimal electric power demand of the HVAC systems of the building's thermal zones and optimally shift the non-critical electrical loads within the optimization period, while maintaining the internal temperature of any thermal zone within a predefined comfort zone and the total building electric power demand under its nominal value.
Moreover, this level optimally schedules the output power of the hosted cluster of PEVs, the operation of the building's diesel generator set and the power that the microgrid exchanges with the active distribution network based on the RES generation, electricity price forecasting and auxiliary diesel generators' economic models.At the same time, all of the operational and technical constraints of the above-mentioned components should be satisfied.For instance, a hard requirement should be set according to the PEV aggregate model so as to ensure that each PEV can reach the target of stored energy at its disconnection time without violating any technical constraint.PEVs not only absorb power from the network and charge their battery packs but they also have the ability to operate in V2G mode i.e., PEVs can inject power into the grid during specific time periods.
The goal of this optimization level is to minimize the daily operational cost of the microgrid.

Optimization Level 1
The first level of optimization is to be applied to each building prosumer of crogrid in order to provide the optimal electric power demand of the HVAC sy the building's thermal zones and optimally shift the non-critical electrical loads w optimization period, while maintaining the internal temperature of any therm within a predefined comfort zone and the total building electric power demand u nominal value.
Moreover, this level optimally schedules the output power of the hosted c PEVs, the operation of the building's diesel generator set and the power that the m exchanges with the active distribution network based on the RES generation, el price forecasting and auxiliary diesel generators' economic models.At the same of the operational and technical constraints of the above-mentioned component be satisfied.For instance, a hard requirement should be set according to the PEV ag model so as to ensure that each PEV can reach the target of stored energy at its dis tion time without violating any technical constraint.PEVs not only absorb power network and charge their battery packs but they also have the ability to operate mode i.e., PEVs can inject power into the grid during specific time periods.
The goal of this optimization level is to minimize the daily operational co microgrid.

Optimization Level 2
In the second optimization level, the algorithm aims to minimize the operatio

Optimization Level 2
In the second optimization level, the algorithm aims to minimize the operational cost of the active distribution network by appropriately choosing the adjustment coefficient of the flexible electrical loads of the distribution network at each time interval.Network constraints are not considered in this stage.If the network constraints are not violated then the energy management process stops.Otherwise, time periods wherein the network constraints are violated are identified and sent to the microgrid in order to assess the minimum and maximum possible deviations of its power exchange that will contribute to the elimination of the network constraints' violation.

Optimization Level 3
If the distribution network constraints that result from the second level of optimization are out of their permissible ranges, the third optimization level is performed.In this level, the algorithm determines the maximum feasible variation of the power that is transferred between the microgrid and the active distribution network.

Optimization Level 4
In the fourth optimization level, the algorithm aims to maintain the distribution network's voltages and the currents of the power lines within their permissible limits by suitably shifting the flexible electrical loads in time and regulating the power that is exchanged between the distribution network and the microgrid within the limits that were determined in optimization level 3.

Optimization Level 5
In this optimization level, the algorithm aims to minimize the overall cost of the operation of the microgrid over a 24 h period, taking into consideration the power that the microgrid should exchange with the active distribution network (this was estimated in the fourth optimization level).

Building Thermal Model
In this work, each building is divided into thermal zones.Using the following thermal equilibrium equation, a mathematical relationship between the internal temperature, thermal gains, thermal loads and ambient temperature can be developed in order to analyze the thermal behavior of each thermal zone [27].
The heat exchange between a thermal zone and its outdoor environment is described by Equations ( 2)-( 5), while Equation (6) estimates the heat exchange between a thermal zone and its neighboring zones. . . . . .
Equations ( 1)-( 6) can be written for each building thermal zone and integrated in state space form as is seen in the following equations.
The tables A b , B b , C b and D b correspond to each building of the microgrid with dimensions (N Z × N Z ), N Z × (2N Z + 2), (N Z × N Z ) and (N Z × N Z ), respectively.The input vector U is of dimensions (2N Z + 2) × 1 and contains the thermal cooling power and the thermal gains of each thermal zone, the ambient temperature and the total solar radiation.The state vector T in is of dimensions (N Z × 1) and contains the internal temperatures of all of the thermal zones of the building.

Building Electrical Loads
There are different types of electrical loads in each thermal zone of the building that can be classified as either critical or non-critical loads.Critical loads correspond to those of devices whose power consumption is specific and cannot be changed.Non-critical loads correspond to those of devices that have a certain flexibility to shift their electricity consumption into different timeslots of the day or to operate at lower power levels than their nominal power.
The power that is consumed by the electrical loads of the zth building's thermal zone P el,z is calculated by taking into account the forecasted number of people that will be performing activity in the thermal zone and each type of device that they will use [28], as follows.
The total electric power consumption of the building is calculated as follows: In this work, it is considered that the electrical power consumption of the non-critical loads constitutes a percentage (n non_cr ) of the total power that is consumed by the electrical loads of the building.
The optimal load shifting algorithm transfers a specific percentage of the non-critical load of one timeslot to a different one, provided that the energy that is consumed before and after the load shifting remains the same as is formulated in Equation (12).

Parking Dynamic Aggregate Battery Model
A dynamic equivalent battery model was developed for the PEVs that are hosted by a microgrid's parking lots.It is based on the forecasts of the PEVs' plug-in and dwell times, their initial stored energy and their batteries' technical characteristics.The permissible operation area of an individual PEV is shown in Figure 2.
Energies 2022, 15, 6182 The times that the EV is plugged into the network and unplugged from it are with  and  , respectively. and  are the maximum and the minimum v a PEV's battery stored energy (in kWh). is the initial stored energy (kWh) of ea  and  are the maximum and minimum power levels that the PEV's bat exchange with the network, respectively. is the stored energy target that th has requested that their PEV should reach at its disconnection time.The dynam and upper bounds of the PEV's stored energy, E and E , are generally de The times that the EV is plugged into the network and unplugged from it are denoted with t 0 and t f , respectively.E max and E min are the maximum and the minimum values of a PEV's battery stored energy (in kWh).E 0 is the initial stored energy (kWh) of each PEV.P max and P min are the maximum and minimum power levels that the PEV's battery can exchange with the network, respectively.E target is the stored energy target that the driver has requested that their PEV should reach at its disconnection time.The dynamic lower and upper bounds of the PEV's stored energy, E low and E high , are generally defined by four points at which they start to decrease or increase with a constant rate of change P min or P max .These points are (t 0 , E 0 ), (t L 1 , E min ), (t L 2 , E min ) and (t f , E target ) for E low and (t 0 , E 0 ), (t H 1 , E max ), (t H 2 , E max ) and (t f , E target ) for E high and they are shown in Figure 2.
The variables t L 1 , t H 1 , t L 2 and t H 2 are estimated as follows [29]: The E high and E low limits of the ith PEV are estimated at time t as: The main goal of the PEV aggregation model is to obtain the dynamic upper and lower limits of the total amount of stored energy in their battery packs and the total active power that they can exchange with the electric network.The time varying technical limits of the equivalent aggregate battery are calculated by applying the following equations: It should also be noted that the stored energy of the parking-equivalent battery changes continuously due to the continuous plugging and unplugging of the EVs.This change is denoted by E di f f and it is calculated by applying the following equations: Let us assume that P opt (t) is the optimal active power that the equivalent aggregate battery exchanges with the electric network.By adopting generator convention, the resulting stored energy (in kWh) at the end of the next time interval is calculated as it follows:

Operation Scheduling of the Diesel Generator Set
The optimal operation scheduling of the diesel generators of the buildings can further decrease the operational cost of the microgrid of building prosumers.The generator fuel cost function FC depends on the power that is produced by the generator P g and it may be accurately approximated by the use of second-order polynomials [30].Thus, the fuel cost of the gth diesel generator at time t is given as,

Optimization Concept
In this work, particle swarm optimization (PSO) has been used in order to optimally schedule the operation of the examined system.It is one of the most highly efficient heuristic methods and it is remarkably simple to implement.PSO has proved very robust and efficient for application to complex optimization problems as it does not depend on the selected initial starting point and leads to a global optimum with a high rate of success.

First Stage of Optimization
In the first stage of optimization, the algorithm aims to minimize the total operational cost of the microgrid while satisfying all of the associated technical and operation constraints.The decision variables of the examined optimization problem are the following: 1.
The total HVAC power consumption of each building at every timeslot of the optimization period, P EC,total,b .

2.
The adjustment coefficient of the non-critical electrical loads of each building at each time interval, n shi f t.

3.
The state of operation of the gth diesel generator, st g .4.
The active power that is exchanged by each PEV parking lot and the microgrid, P opt (t).

5.
The active power that is exchanged by the microgrid and the electric grid, P MG .
The objective function that is used in this optimization stage and all of the associated constraints is provided next. with • Building Thermal Load Constraints P EC,total,min ≤ P EC,total (t) ≤ P EC,total,max with Considering a summer cooling scenario, the power dispatch to the thermal zones is formulated in (35).

•
Building Electrical Load Constraints P PB,min (t) ≤ P opt (t) • Diesel Generator Set Constraints st g (t)•P g,min ≤ P g (t) ≤ st g (t)•P g,max , ∀t, g t OFF,g − t ON,g ≥ T ON_min,g , ∀g t ON,g − t OFF,g ≥ T OFF_min,g , ∀g

Second Stage of Optimization
In the second optimization stage, the algorithm aims to minimize the total operational cost of the active distribution network by appropriately choosing the adjustment coefficient n DN_sh .The optimal load shifting algorithm is permitted to transfer a certain percentage of the flexible load of one timeslot to a different one, provided that the energy that is consumed before and after the load shifting remains the same.
It is considered that the electrical power consumption of the flexible loads constitutes a percentage of the overall power that is consumed by the electrical loads of the distribution network (P DN,load ).
The objective function that is used in this optimization stage is formulated in (44).It aims to minimize the operational cost of the active distribution network by suitable load shifting.Network constraints are not considered in this stage.

Third Stage of Optimization
In this optimization stage, the deviations of the building's electric consumption ∆P buildings , diesel generator power ∆P diesel and PEV parking lot power ∆P PEVs,aggr from their optimal values are estimated.These optimal values are those that lead to the maximum deviations of the power that the microgrid exchanges with the active distribution network that contributes to all of the network constraint violation elimination processes and ensures satisfaction of all of the microgrid constraints.The objective function that is used in the third stage of optimization is provided in (52), followed by its respective constraints.

max
where V and θ are vectors representing the amplitudes and the angles of the distribution network voltages and Y is the network admittance matrix.The variable |V(k)| is the voltage amplitude at the kth node, θ(k) is voltage angle at the kth node and I max (k, l) is the maximum current flowing in the electric line connecting the kth and lth node.The S inj vector comprises the apparent power injections at the nodes of the network while P inj and Q inj comprise the active and reactive power injections at all of the network nodes, respectively.
MatPower was used to solve the optimal power flow (OPF) problem with the constraints that are defined in (64)-(69) [31].MatPower uses the solvers of non-linear constrained optimization problems that are provided in the Matlab Optimization Toolbox in order to solve the AC OPF problem and it can deal with the most constraints that are associated with the electrical network's operation.

Fifth Stage of Optimization
The decision variables in this stage are the first four that are described in the first optimization level.The objective function that is used in this optimization stage is provided in (70).
The power that is exchanged by the microgrid and the active distribution network is required to be equal to that which was obtained in the fourth optimization level.

Case Study
In the examined case study, the microgrid was assumed to comprise three large office buildings, three large EV parking lots, two auxiliary diesel generators, two PV parks and one wind turbine park.The IEEE 33-node radial distribution network has been used as the electric network in the proposed system.The single-line diagram of the examined electric distribution network is shown in Figure 3.The model parameters that are related to the buildings of the microgrid are ta in Tables 1-4.Four types of PEV batteries were considered in this article with th nical characteristics given in Table 5.All of the necessary technical parameters of th generators are presented in Table 6.The model parameters that are related to the buildings of the microgrid are tabulated in Tables 1-4.Four types of PEV batteries were considered in this article with their technical characteristics given in Table 5.All of the necessary technical parameters of the diesel generators are presented in Table 6.The ambient temperature that was used in this case study is shown in Figure 4 and it is a typical daily temperature time series from late summer in Greece.The time series of the electricity price forecast that was used in the examined scenario is shown in Figure 5.It was assumed that the electricity price that was forecast was carried out by the power system operator and provided to the microgrid and the active distribution network.Provided that the computation time that is required by the proposed method is small (of the scale of a few minutes), it was assumed that the electricity price forecast would be provided to the local electricity market participants after the day-ahead electricity market was carried out.
Energies 2022, 15, 6182 15 of 27 The ambient temperature that was used in this case study is shown in Figure 4 and it is a typical daily temperature time series from late summer in Greece.The time series of the electricity price forecast that was used in the examined scenario is shown in Figure 5.It was assumed that the electricity price that was forecast was carried out by the power system operator and provided to the microgrid and the active distribution network.Provided that the computation time that is required by the proposed method is small (of the scale of a few minutes), it was assumed that the electricity price forecast would be provided to the local electricity market participants after the day-ahead electricity market was carried out.The number of people conducting activity in each building of the microgrid is shown in Figure 6.As can be seen in this figure, the maximum number of active people in each building were present from 13:00-14:00.The ambient temperature that was used in this case study is shown in Figure 4 and it is a typical daily temperature time series from late summer in Greece.The time series of the electricity price forecast that was used in the examined scenario is shown in Figure 5.It was assumed that the electricity price that was forecast was carried out by the power system operator and provided to the microgrid and the active distribution network.Provided that the computation time that is required by the proposed method is small (of the scale of a few minutes), it was assumed that the electricity price forecast would be provided to the local electricity market participants after the day-ahead electricity market was carried out.The number of people conducting activity in each building of the microgrid is shown in Figure 6.As can be seen in this figure, the maximum number of active people in each building were present from 13:00-14:00.The number of people conducting activity in each building of the microgrid is shown in Figure 6.As can be seen in this figure, the maximum number of active people in each building were present from 13:00-14:00.The connection and the dwell periods of the PEVs rely on the different types tivities (being at home, being at work, shopping and social engagements) that their d partake in and they are calculated using their respective probability density fun (PDFs) [32], as are shown in Figure 7a and Figure 7b, respectively.For instance, as it observed, the connection rate for the PEVs of citizens who are at work peaked at 7:3 whereas their dwell time peaked at approximately 8.5 h.The obtained total number connected EVs that were found during the examined time period is shown in  The connection and the dwell periods of the PEVs rely on the different types of activities (being at home, being at work, shopping and social engagements) that their drivers partake in and they are calculated using their respective probability density functions (PDFs) [32], as are shown in Figures 7a and 7b, respectively.For instance, as it can be observed, the connection rate for the PEVs of citizens who are at work peaked at 7:30 a.m., whereas their dwell time peaked at approximately 8.5 h.The obtained total number of the connected EVs that were found during the examined time period is shown in Figure 8.The connection and the dwell periods of the PEVs rely on the different types of activities (being at home, being at work, shopping and social engagements) that their drivers partake in and they are calculated using their respective probability density functions (PDFs) [32], as are shown in Figure 7a and Figure 7b, respectively.For instance, as it can be observed, the connection rate for the PEVs of citizens who are at work peaked at 7:30 a.m., whereas their dwell time peaked at approximately 8.5 h.The obtained total number of the connected EVs that were found during the examined time period is shown in Figure 8.The time series of the power generation of Photovoltaics (PVs) and Wind Tur WTs) are shown in Figure 9.The internal temperatures of all of the buildings' thermal zones that are obtai the first optimization level, with their upper and lower bounds, are given in Figur was observed that the internal temperatures of all of the thermal zones of each bu were consistently well-maintained between the comfortable temperature range 27.5°C and they all tended to behave in the same way.The internal temperatures of all of the buildings' thermal zones that are obtai the first optimization level, with their upper and lower bounds, are given in Figure was observed that the internal temperatures of all of the thermal zones of each bu were consistently well-maintained between the comfortable temperature range 27.5°C and they all tended to behave in the same way.The internal temperatures of all of the buildings' thermal zones that are obtained in the first optimization level, with their upper and lower bounds, are given in Figure 10.It was observed that the internal temperatures of all of the thermal zones of each building were consistently well-maintained between the comfortable temperature range of 19-27.5 • C and they all tended to behave in the same way.The electric power consumptions of the HVAC systems of the buildings are shown in Figure 11.As anticipated, each building's total cooling power changed according to the ambient temperature and the predicted pattern of occupant activity.Obviously, the largest building had the biggest cooling needs.The algorithm aims to reduce the power demand when the electricity price is quite high.The total non-critical electrical demand of the buildings of the microgrid is shown in Figure 12, before and after the first level of optimization was implemented.It can be noted that the algorithm optimally shifted the non-critical electrical loads from the high electricity time period to the time period from 13:00-16:00, when the electricity price was low.The electric power consumptions of the HVAC systems of the buildings are shown in Figure 11.As anticipated, each building's total cooling power changed according to the ambient temperature and the predicted pattern of occupant activity.Obviously, the largest building had the biggest cooling needs.The algorithm aims to reduce the power demand when the electricity price is quite high.The electric power consumptions of the HVAC systems of the buildings are shown in Figure 11.As anticipated, each building's total cooling power changed according to the ambient temperature and the predicted pattern of occupant activity.Obviously, the largest building had the biggest cooling needs.The algorithm aims to reduce the power demand when the electricity price is quite high.The total non-critical electrical demand of the buildings of the microgrid is shown in Figure 12, before and after the first level of optimization was implemented.It can be noted that the algorithm optimally shifted the non-critical electrical loads from the high electricity time period to the time period from 13:00-16:00, when the electricity price was low.The total non-critical electrical demand of the buildings of the microgrid is shown in Figure 12, before and after the first level of optimization was implemented.It can be noted that the algorithm optimally shifted the non-critical electrical loads from the high electricity time period to the time period from 13:00-16:00, when the electricity price was low.The total active power of the PEV parking lot, together with its respective upp lower limits, is shown in Figure 14.Generator convention was used, hence the n values indicate that the aggregate battery absorbed power from the grid (i.e., it was ing), while positive values indicate that the battery injected power to the grid (i.e.discharging).The total energy that was stored in the equivalent aggregate battery microgrid's parking lot, as well as its respective upper and the lower limits, is sh Figure 15.These limits changed over time as a result of the fluctuating number nected EVs and electricity price variations.The algorithm effectively covered t crogrid's energy demand with internal power sources during its autonomous op and, at the same time, it reduced its daily operational cost.It was observed that al PEVs managed to reach their energy targets while satisfying all of the operation   The total active power of the PEV parking lot, together with its respective upp lower limits, is shown in Figure 14.Generator convention was used, hence the n values indicate that the aggregate battery absorbed power from the grid (i.e., it was ing), while positive values indicate that the battery injected power to the grid (i.e.discharging).The total energy that was stored in the equivalent aggregate battery microgrid's parking lot, as well as its respective upper and the lower limits, is sh Figure 15.These limits changed over time as a result of the fluctuating number nected EVs and electricity price variations.The algorithm effectively covered t crogrid's energy demand with internal power sources during its autonomous op and, at the same time, it reduced its daily operational cost.It was observed that al PEVs managed to reach their energy targets while satisfying all of the operation technical constraints.In order to guarantee that the necessary energy was stored the microgrid's island operation, the PEVs were compelled to store extra energy fr The total active power of the PEV parking lot, together with its respective upper and lower limits, is shown in Figure 14.Generator convention was used, hence the negative values indicate that the aggregate battery absorbed power from the grid (i.e., it was charging), while positive values indicate that the battery injected power to the grid (i.e., it was discharging).The total energy that was stored in the equivalent aggregate battery of the microgrid's parking lot, as well as its respective upper and the lower limits, is shown in Figure 15.These limits changed over time as a result of the fluctuating number of connected EVs and electricity price variations.The algorithm effectively covered the microgrid's energy demand with internal power sources during its autonomous operation and, at the same time, it reduced its daily operational cost.It was observed that all of the PEVs managed to reach their energy targets while satisfying all of the operational and technical constraints.In order to guarantee that the necessary energy was stored during the microgrid's island operation, the PEVs were compelled to store extra energy from the electric grid before the grid's power supply was interrupted.The time series of all of the node voltages after the execution of optimization are shown in Figure 16.The upper and lower voltage limits were set to 1.1 and 0 respectively.According to Figure 16, the voltages of the network buses were ou predefined limits during the time period from 19:00-22:00.The time series of all of the node voltages after the execution of optimization st are shown in Figure 16.The upper and lower voltage limits were set to 1.1 and 0.9 respectively.According to Figure 16, the voltages of the network buses were out o predefined limits during the time period from 19:00-22:00.The time series of all of the node voltages after the execution of optimization stage 2 are shown in Figure 16.The upper and lower voltage limits were set to 1.1 and 0.9 p.u., respectively.According to Figure 16, the voltages of the network buses were out of the predefined limits during the time period from 19:00-22:00.Therefore, it was necessary to identify the time periods during which the network constraints were violated and provide them to the microgrid in order to evaluate the minimum and maximum possible deviations of its power exchange in optimization stage 3, as is shown in Figure 17.It was considered that the maximum permitted fluctuations of the power of the buildings, parking lots' aggregate battery and diesel generators were up to 20% of their installed power capacity.At the same time, as can be observed in Figure 18, the internal temperatures of all of the thermal zones of the buildings were well-maintained between their minimum and maximum limits.Therefore, it was necessary to identify the time periods during which the network constraints were violated and provide them to the microgrid in order to evaluate the minimum and maximum possible deviations of its power exchange in optimization stage 3, as is shown in Figure 17.It was considered that the maximum permitted fluctuations of the power of the buildings, parking lots' aggregate battery and diesel generators were up to 20% of their installed power capacity.At the same time, as can be observed in Figure 18, the internal temperatures of all of the thermal zones of the buildings were well-maintained between their minimum and maximum limits.Therefore, it was necessary to identify the time periods during which the n constraints were violated and provide them to the microgrid in order to evaluate t imum and maximum possible deviations of its power exchange in optimization as is shown in Figure 17.It was considered that the maximum permitted fluctua the power of the buildings, parking lots' aggregate battery and diesel generators w to 20% of their installed power capacity.At the same time, as can be observed in 18, the internal temperatures of all of the thermal zones of the buildings were wel tained between their minimum and maximum limits.In the time period from 19:00-22:00, when the voltages of the distribution net nodes dropped, the cooling power of the buildings was required to be reduced shown in Figure 17) and, therefore, the indoor temperatures of the buildings increas Moreover, Figure 17 exhibits the optimal deviation of the power that was excha between the microgrid and the active distribution network as was obtained from op zation stage 4. It is obvious that it was within its predefined bounds.Figure 19 exh the active distribution network load before and after optimization stages 2 and 4 implemented.In the second optimization stage, it was observed that the flexible elec loads were shifted to time periods of low electricity price (13:00-15:00) in order to con ute to the minimization of the active distribution network's total operational cost w satisfying all of the operational constraints at the same time.The time series of all o node voltages after the execution of optimization stage 2 are shown in Figure 20.It c seen that the distribution network voltages were well-maintained within their permis limits.In the time period from 19:00-22:00, when the voltages of the distribution network nodes dropped, the cooling power of the buildings was required to be reduced (as is shown in Figure 17) and, therefore, the indoor temperatures of the buildings increased.
Moreover, Figure 17 exhibits the optimal deviation of the power that was exchanged between the microgrid and the active distribution network as was obtained from optimization stage 4. It is obvious that it was within its predefined bounds.Figure 19 exhibits the active distribution network load before and after optimization stages 2 and 4 were implemented.In the second optimization stage, it was observed that the flexible electrical loads were shifted to time periods of low electricity price (13:00-15:00) in order to contribute to the minimization of the active distribution network's total operational cost while satisfying all of the operational constraints at the same time.The time series of all of the node voltages after the execution of optimization stage 2 are shown in Figure 20.It can be seen that the distribution network voltages were well-maintained within their permissible limits.In the time period from 19:00-22:00, when the voltages of the distribution netw nodes dropped, the cooling power of the buildings was required to be reduced ( shown in Figure 17) and, therefore, the indoor temperatures of the buildings increas Moreover, Figure 17 exhibits the optimal deviation of the power that was excha between the microgrid and the active distribution network as was obtained from op zation stage 4. It is obvious that it was within its predefined bounds.Figure 19 exh the active distribution network load before and after optimization stages 2 and 4 implemented.In the second optimization stage, it was observed that the flexible elec loads were shifted to time periods of low electricity price (13:00-15:00) in order to con ute to the minimization of the active distribution network's total operational cost w satisfying all of the operational constraints at the same time.The time series of all o node voltages after the execution of optimization stage 2 are shown in Figure 20.It ca seen that the distribution network voltages were well-maintained within their permis limits.

Discussion
In this paper, a method for the coordinated optimal operation scheduling of active distribution networks hosting complex microgrids comprising large building prosumers and plug-in electric vehicle aggregators is proposed.The operational costs of both the microgrid and active distribution network were optimized while all of the associated constraints were fully satisfied.The proposed method is suitable to handle very complex microgrids comprising large building prosumers and a large number of PEVs.An aggregation technique was used to handle the large number of PEVs and a simple thermal power dispatch technique was used for the efficient modelling of the large building prosumers.A modified IEEE 33-bus test case system was used to test the efficiency of the proposed

Discussion
In this paper, a method for the coordinated optimal operation scheduling of active distribution networks hosting complex microgrids comprising large building prosumers and plug-in electric vehicle aggregators is proposed.The operational costs of both the microgrid and active distribution network were optimized while all of the associated constraints were fully satisfied.The proposed method is suitable to handle very complex microgrids comprising large building prosumers and a large number of PEVs.An aggregation technique was used to handle the large number of PEVs and a simple thermal power dispatch technique was used for the efficient modelling of the large building prosumers.A modified IEEE 33-bus test case system was used to test the efficiency of the proposed

Discussion
In this paper, a method for the coordinated optimal operation scheduling of active distribution networks hosting complex microgrids comprising large building prosumers and plug-in electric vehicle aggregators is proposed.The operational costs of both the microgrid and active distribution network were optimized while all of the associated constraints were fully satisfied.The proposed method is suitable to handle very complex microgrids comprising large building prosumers and a large number of PEVs.An aggregation technique was used to handle the large number of PEVs and a simple thermal power dispatch technique was used for the efficient modelling of the large building prosumers.A modified IEEE 33-bus test case system was used to test the efficiency of the proposed method.The obtained simulation results show that the proposed method led to the optimization of the operational costs of both the active distribution network and the microgrid while it ensured adherence to a large set of operation constraints of the microgrid and the active distribution network.As a future extension of this work, a method for the optimal real-time operation of the electrical and thermal energy systems of the buildings end energy storage facilities can be developed in order to effectively deal with the uncertainties arising from the predictions of stochastic variables, such as the price of electricity, the production of renewable energy sources and the activity of people and the hosted electric vehicles.the total solar radiation of the zth thermal zone n ch , n disch charging (discharging) efficiency coefficients of the PEV battery n DN_sh coefficient estimated by the distribution network optimal load shifting algorithm n shi f t coefficient estimated by the optimal load shifting algorithm N g number of the diesel generators of the microgrid N z total number of the thermal zones of a building p z the density of the zth thermal zone P * DN, f lex the optimal electric power consumed by the flexible loads of the distribution network P DN,load total distribution network load P EC,total,b electric power consumed by the EC (kW) P EC,total,min , P EC,total,max lower and upper limits of the electric power consumed by the EC (kW) P g power produced by the gth generator P g,min , P g,max minimum and maximum loading constraints of the gth diesel generator, respectively P * non_cr the optimal electric power consumed by the non-critical loads of a building P PB,max , P PB,min maximum/minimum power transfer rate of the equivalent battery of the EV parking lot Q EC,z cooling power generated by the EC of the zth thermal zone (kW)
Q ex,wall,z heat transfer through the external walls of the zth thermal zone (kW) .
Q in,wall,z heat transfer through the internal walls of the zth thermal zone (kW) Q in,z internal heat gains from people, appliances and lighting of the zth thermal zone (kW) .
Q sg,z the whole solar radiation transmitted across the windows of the zth thermal zone (kW) .
Q sw,z heat contribution due to the solar radiation on the surface of the external walls of the zth thermal zone (kW) .
Q win,z heat transfer across the windows of the zth thermal zone (kW) R se the external surface heat resistance for convection and radiation of the external wall st DN denotes if the distribution network is connected to the main electric grid (st DN = 1(0) if it is connected(disconnected)) st g denotes the operation state of the gth diesel generator (st g = 1(0) if it is on(off)) SC the shading coefficient of the windows T DN_sh,0 T DN_sh, f the beginning and the end of the time period where the distribution network flexible loads can be shifted in time T in,nz indoor temperature of the neighbor thermal zone T in,z indoor temperature ( • C) of the zth thermal zone T max,z , T min,z the maximum and minimum values of the indoor temperature of the zth thermal zone ( • C) t ON,g , t OFF,g time points that gth diesel generator starts/stops operating, respectively T ON_min,g , T OFF_min,g minimum allowable operation/nonoperation time of the gth diesel generator T out outdoor temperature ( • C) T shi f t,0 , T shi f t, f the beginning and the end of the time period where the buildings' non-critical loads can be shifted in time U wall , U win heat transfer coefficient of the external wall/window of the thermal zone V max(min) a vector comprising the upper (lower) bounds of the amplitude of node voltages V z volume of the air of the zth thermal zone

Figure 1 .
Figure 1.Configuration of the proposed system.

Figure 1 .
Figure 1.Configuration of the proposed system.

Figure 3 .
Figure 3. Single-line diagram of the examined distribution network.

FigureFigure 7 .
Figure 7. (a) PDF of electric vehicles' connection time; (b) PDF of electric vehicles' dwell tim

Figure 6 .
Figure 6.Forecasted number of active people in microgrid's building.

Figure 7 .
Figure 7. (a) PDF of electric vehicles' connection time; (b) PDF of electric vehicles' dwell time.Figure 7. (a) PDF of electric vehicles' connection time; (b) PDF of electric vehicles' dwell time.

Figure 7 .
Figure 7. (a) PDF of electric vehicles' connection time; (b) PDF of electric vehicles' dwell time.Figure 7. (a) PDF of electric vehicles' connection time; (b) PDF of electric vehicles' dwell time.

Figure 9 .
Figure 9. Photovoltaic and wind power generation.

Figure 8 .Figure 8 .
Figure 8. Number of connected EVs.The time series of the power generation of Photovoltaics (PVs) and Wind Turbines (WTs) are shown in Figure 9.

Figure 9 .
Figure 9. Photovoltaic and wind power generation.

Figure 9 .
Figure 9. Photovoltaic and wind power generation.

Figure 11 .
Figure 11.Total cooling power of each building of the microgrid (optimization level 1).

Figure 11 .
Figure 11.Total cooling power of each building of the microgrid (optimization level 1).

Figure 11 .
Figure 11.Total cooling power of each building of the microgrid (optimization level 1).

Figure 12 .
Figure 12.Total non-critical electrical loads before and after the execution of optimization le

Figure 12 .
Figure 12.Total non-critical electrical loads before and after the execution of optimization level 1.

Figure 13 Figure 12 .
Figure13exhibits the power that was produced by the diesel generators.The generators were scheduled to operate as close as possible to their optimal operation point.

Energies 2022, 15 , 6182 Figure 14 .
Figure 14.Active power of PEV aggregator and its upper and lower bounds.

Figure 15 .
Figure 15.Total stored energy of PEV aggregator and its upper and lower bound.

Figure 14 .
Figure 14.Active power of PEV aggregator and its upper and lower bounds.

Figure 14 .
Figure 14.Active power of PEV aggregator and its upper and lower bounds.

Figure 15 .
Figure 15.Total stored energy of PEV aggregator and its upper and lower bound.

Figure 15 .
Figure 15.Total stored energy of PEV aggregator and its upper and lower bound.

Figure 17 .
Figure 17.Optimal deviation of the power transferred between the microgrid and the active distribution network.

Figure 17 .
Figure 17.Optimal deviation of the power transferred between the microgrid and the activ bution network.

Figure 17 .
Figure 17.Optimal deviation of the power transferred between the microgrid and the active distribution network.

Figure 18 .
Figure 18.Internal temperatures of all building thermal zones (optimization level 3).

Figure 19 .
Figure 19.Active distribution network load before and after the execution of the optimization

Figure 18 .
Figure 18.Internal temperatures of all building thermal zones (optimization level 3).

Figure 18 .
Figure 18.Internal temperatures of all building thermal zones (optimization level 3).

Figure 19 .
Figure 19.Active distribution network load before and after the execution of the optimization 2 and 4.

Figure 19 .
Figure 19.Active distribution network load before and after the execution of the optimization levels 2 and 4.

Figure 21
Figure 21 exhibits the power that was exchanged between the microgrid and the active distribution network after the execution of optimization levels 1 and 4.

Figure 21 .
Figure 21.Active power exchanged between the microgrid and the active distribution network (optimization levels 1 and 4).

Figure 21
Figure 21 exhibits the power that was exchanged between the microgrid and the active distribution network after the execution of optimization levels 1 and 4.

Figure 21
Figure 21 exhibits the power that was exchanged between the microgrid and the active distribution network after the execution of optimization levels 1 and 4.

Figure 21 .
Figure 21.Active power exchanged between the microgrid and the active distribution network (optimization levels 1 and 4).

Figure 21 .
Figure 21.Active power exchanged between the microgrid and the active distribution network (optimization levels 1 and 4).
the upper(lower) bounds of voltage angles B, b set of the buildings of the microgrid, index indicating the number of the building E set of the external walls of each thermal zone G, g set of the generators of the microgrid, index indicating the number of the diesel generator k index indicating the type of electrical device I set of the internal walls of each thermal zone N set of the neighboring thermal zones x index indicating the xth internal wall orientation y index indicating the yth external wall/window orientation z denotes the zth thermal zone of the building Parameters, constants and variables τ win the glass transmission coefficient of the windows a 0g , a 1g , a 2g coefficients of the gth generator fuel cost function a w absorbance coefficient of the external surface of the wall ch state of operation (if ch = 1, the EV charges; else if ch = 0, EV discharges) C z the specific heat capacity of the zth thermal zone COP HVAC performance coefficient E PB stored energy of the equivalent battery (kWh) of the EV parking lot E PB,max , E PB,min max/min stored energy (kWh) of the equivalent battery of the EV parking lot E 0,PB initial stored energy (kWh) of the equivalent battery of the EV parking lot E t,PB target energy (kWh) of the equivalent battery of the EV parking lot F wall , F win the area of the total wall/window surface FC fuel cost function I T,z