Overarching Sustainable Energy Management of PV Integrated EV Parking Lots in Reconfigurable Microgrids Using Generative Adversarial Networks

In recent years, environmental issues have motivated the wide usage of electric vehicles (EVs) due to their zero tailpipe emission. However, this trend can pose severe challenges to power systems, such as decreasing equipment lifetime. Moreover, the CO2 emission of EVs is closer to that of internal combustion engine vehicles in some cases due to the carbon footprint of EV charging. Modeling the uncertain nature of EV users’ behavior is another obstacle due to the complex dynamics of these uncertainties. To overcome these problems, an overarching day-ahead smart charging method is proposed in this paper from the perspective of distribution system operators (DSOs), EV users, and governments simultaneously. The aim of the proposed method is to minimize the operating cost of microgrids, the degradation cost of EV batteries, and emission cost by scheduling the active and reactive power of EV parking lots integrated with photovoltaic (PV) systems as well as finding the optimum network configuration. Previous model-based methods cannot appropriately model uncertainties in EV users’ behavior because of some statistical assumptions. Nevertheless, this paper employs data-driven methods based on generative adversarial networks (GAN) to represent these uncertainties. The performance of the proposed method is evaluated by implementing it on a real reconfigurable microgrid. The results show that using the proposed method, the DSO and emission costs can reduce by 11.96% and 3.37% compared to the uncoordinated charging of EVs, respectively. Furthermore, the share of sustainable energy in EV charging increases by 9% using the proposed method.

C ONTINUOUS increases in greenhouse gas (GHG) emissions and the high price of fossil fuels have raised the interest of people and governments in using electric vehicles (EVs) [1]. In 2016, more than a quarter of the total CO 2 production was in the transportation sector, while more than three-quarters of which is related to fossil fuel vehicles [2]. Currently, EVs are recognized as one of the most efficient modes of transportation with zero tailpipe emission. It is predicted that by 2030, due to the enactment of new laws by governments, the number of EVs will exceed 250 million units in the world [3]. Although EVs are considered a clean resource, the CO 2 emission value of EVs is closer to that of internal combustion engine vehicles in some cases due to the carbon footprint of the battery production and charging process of EVs [4]. Therefore, in order to reduce pollution, it is essential to charge EVs with sustainable energy [5]. The increasing growth of EVs has also faced power systems with some challenges. Some of the major challenges are the emergence of a new peak in load profile [6], increase in power grid losses [7], damage to power system equipment such as transformers and cables [8], and uncertainties in EV users' behavior (e.g., the arrival and departure time of EVs) [9].

B. Background and Related Works
Previous studies have attempted to cope with EV charging challenges. In [10], the effect of various types of plug-in hybrid electric vehicle charging on the optimal operation of reconfigurable microgrids has been investigated under the dynamic line rating security constraint. In this article, the arrival time of EVs has been modeled based on uniform and normal distributions and a normal distribution has been used to model the daily mileage of EVs. In [11], a two-stage optimization framework has been proposed. In the first stage, the charging of EVs has been scheduled to fill valleys and minimize the charging and battery degradation cost of EVs. In the second stage, the distribution feeder reconfiguration problem has been solved. This reference assumes that the arrival and departure time of EVs have normal distributions and the daily mileage of EVs follows a lognormal distribution. The authors in [12] have proposed a bi-objective optimization model for an EV parking lot integrated with a photovoltaic (PV) system in order to improve the economic and environmental performance of the parking lot. The initial state of charge (SoC) and present time of EVs in parking lots have been randomly considered. Article [13] has presented a multi-objective optimization framework to demonstrate a conflict between the cost and emission minimization of EV charging. Authors in [14] have proposed a transactive energy management system for EV parking lots equipped with rooftop PV systems to balance the charging demand of EVs with supply. In this paper, the distribution of the arrival and departure time, and SoC of EVs have been assumed to be normally distributed. In [15] a co-optimization algorithm has been proposed to schedule the charging of EVs from the distribution system operator's (DSO) point of view by managing the active and reactive power of EVs simultaneously. Authors in this article have modeled the arrival and departure time, and daily mileage of EVs based on normal distribution functions. In [16], the active and reactive power of EVs have been scheduled by considering the simultaneous benefit of their users and DSO. Moreover, in this article, a method called Route Mapping has been used to model the arrival time and SoC of EVs and the departure time of EVs has been modeled using a normal distribution. In [17], an operational planning model has been proposed for centralized charging stations integrated with PV systems and an echelon battery system. A multiobjective optimization model has been employed to minimize the electricity purchase cost, load fluctuation, and the battery system life-cycle loss cost. In this reference, EVs' daily driving mileage has been represented by a log-normal distribution. The authors in [18] have introduced a bi-level optimization method to schedule EV charging. At the upper level, the price optimization model of EV charging and at the lower level, the load optimization model of EV charging have been established. In this paper, the behavioral modeling of EV users has been determined based on mathematical relationships. In [19], an optimal charging model has been proposed to minimize the volatility of renewable energy sources (RES) as well as the charging cost of EVs. In this article, EV users' behavior has been modeled by normal distribution functions.

C. Research Gaps
In the day-ahead charging scheduling of EVs, the key step is accurately modeling uncertainties in the generation of sustainable energy and EV users' behavior. Most previous studies have used Monte Carlo simulation and probability distribution fitting methods to model uncertainties in the driving behavior and arrival and departure time of EVs. However, because of the time-varying and dynamic nature of these uncertainties, these model-based methods, which are based on some statistical assumptions (e.g., Gaussian), cannot accurately represent these uncertainties. To the best of the authors' knowledge, this is the first paper that uses a data-driven method to represent uncertainties in EV users' behavior. Furthermore, the profits of all stakeholders should be considered in the charging planning of EVs. The purpose of DSO is to reduce the operating cost of distribution networks, including decreasing energy losses and the operating cost of power grid components [20]. In order to persuade EV users to participate in the day-ahead charging algorithm, the benefits of EV users (such as the battery degradation cost of EVs) must be taken into account. Furthermore, from the point of view of governments, they should follow pathways to reduce GHG emissions. For this purpose, life cycle assessment (LCA) of power system equipment and electric vehicles can be considered in the charging of EVs. LCA method assesses the environmental impacts of a product throughout its entire life cycle, i.e., from production and operating to final disposal [21]. Limited research studies have managed EV charging from the perspective of all DSO, EV users, and governments. None of the previous articles has managed the charging of EVs by considering the operating cost of both distribution transformers and cables as well as the effects of harmonics produced by PV systems and the charger of EVs on the thermal model of distribution transformers. Moreover, managing the reactive power of EVs can decrease the operating cost of distribution networks by reducing energy losses and the loading of transformers and cables [16]. However, the management of both active and reactive power has rarely been performed in the literature.
Shortcomings and weaknesses in the previous research studies regarding the smart charging of EVs can be divided into the following categories: Sh1: In the charging scheduling of EVs, uncertainties in the generation of sustainable energy and EV users' behavior are represented based on model-based methods along with some statistical assumptions [10]- [16].
Sh3: The operating cost and environmental cost of power grid components in the presence of harmonics have never been considered simultaneously [10]- [16].
Sh4: Only the active power of EVs has been managed and the reactive power exchange between EVs and the network has not been considered [10]- [14].

D. Contributions
In this paper, a new day-ahead method for EV parking lots integrated with PV systems is proposed in order to schedule the charging of EVs from EV users', DSO's, and governments' perspectives. From DSO's perspective, energy losses cost and the operating cost of distribution transformers and cables are considered in the proposed method. From EV users' perspective, the degradation cost of batteries is taken into account. From the governments' perspective, the environmental cost of EVs, transformers, and cables are incorporated in the proposed method. To deal with modeling uncertainties in EV users' behavior and the generation of PV systems, a data-driven method based on generative adversarial networks (GAN) is employed. In the proposed method, both active and reactive power of EVs are managed to make more profits for DSO. Due to the harmonic injection of PV systems and EVs, the effect of harmonics on the thermal model of transformers is modeled. In order to reduce energy losses, a reconfiguration technique is used in the proposed method. The robustness of the proposed method is shown by changing the penetration level of PV systems.
The main contributions of this paper are summarized as follows: • This paper introduces an overarching framework for the charging of EVs in parking lots integrated with PV systems, which aims to reduce the costs of DSO and EV users as well as decrease GHG emissions (tackling Sh2 and Sh3) • A data-driven method based on GAN is used to predict EV users' behavior (initial SoC, arrival and departure to/from parking lots, etc.) and the production of PV systems (tackling Sh1). • The management of active and reactive power, as well as a reconfiguration technique, are employed to minimize the operating cost of DSO. (tackling Sh2 and Sh4).

E. Paper Structure
The rest of the paper is organized as follows. Section II provides an outline of the proposed method. In section III, the modeling of uncertainties is explained in detail. In section IV, the proposed method is presented in detail. Section V discusses the case study, experimental protocols for modeling uncertainties, and simulation results. Ultimately, the paper is concluded in section VI. Power system equipment modeling, and the LCA of power system components and EVs are described in the Appendix, shown in the supplementary material.
II. PROPOSED METHOD OVERVIEW In this paper, a new method for the day-ahead charging scheduling of EVs is proposed, taking into account the benefits of EV users, DSO and governments simultaneously. The overview of the proposed method is illustrated in Fig. 1. Home chargers could be installed only at 40% of garages in the US [22]. For this reason, in this method, EV parking lots, which are integrated with PV systems, are located in commercial workplaces. The main difference between residential charging stations and commercial parking lots is in the hours of the day that EVs are available for being charged. The purpose of integrating EV parking lots with PV systems is to supply the part of the energy needed for charging EVs with sustainable energy in order to mitigate the carbon footprint of EVs. Planning for the next day is based on forecasting some uncertainties regarding EV charging, including the arrival and departure time of EVs to/from parking lots, the SoC of EVs when they arrive at parking lots, and the power production of PV panels. In this method, charging demand for each parking lot, the number of available EVs at each parking lot at each time step, the initial SoC of EVs, and meteorological data are predicted by GAN models and sent to the aggregator as the historical data of the mentioned uncertainties. The historical data can be stored on a cloud server due to a huge virtual space for storing data provided by the cloud environment. In cloud storing, a shared pool of configurable computing resources can be easily and quickly accessed with minimal management or service provider interaction [16]. The stored data on the cloud server are accessible via an internet connection.
At the aggregator level, the charging of EVs is scheduled with the aim of reducing GHG emissions and operating costs of the power grid and EVs. The proposed objective function consists of 3 sections. The first section is related to the carbon footprint of EVs and the daily environmental cost of distribution transformers and underground cables. In the microgrid operation section, energy losses cost and the daily operating cost of distribution transformers and cables are considered. The last section is related to the battery degradation cost of EVs. Furthermore, a reconfiguration technique is employed to provide more profits for DSO. Optimization variables in this method are distribution line status, and active and reactive power exchanged between the EVs and the network at each time step. Finally, scheduled active and reactive power exchanged between EVs and the grid for each time interval are sent to the parking lots and the optimum network configuration for each time interval is sent to the DSO.

III. UNCERTAINTIES MODELLING
As uncertainties can affect the accuracy of day-ahead scheduling, they must be properly modeled. The arrival and departure time, daily driving, and initial SoC of EVs as well as the generation of PV systems are the main uncertainties in the proposed method. In this section, the stochastic and uncertain behaviors of EVs and weather are modeled.

A. Generative Adversarial Network
GAN was firstly introduced in 2014 by Goodfellow and since then has been widely used in image processing and data generation [23]. GAN models include two deep neural networks called generator and discriminator. The responsibility of the generator is to try to generate fake data in a way that fools the discriminator. The discriminator aims to distinguish between generated data by the generator and true historical data. For this reason, the generator and discriminator are similar to two players that play a game. At the end of the training procedure, the generator and discriminator reach an equilibrium. At this stage, the discriminator cannot distinguish between the true historical data and generated data. It means that the generator can exactly follow the distribution of historical data. In Fig. 2, the structure of the GAN model is shown.
The loss function of the discriminator and generator are respectively represented as follows [24]  where G and D are the generator and discriminator functions, p data is the distribution of true historical data, and p z is the generated distribution. By combining (1) and (2), a twoplayer minimax game can be formulated with value function The training process of GAN has two stages performed iteratively: updating generator parameters with fixed discriminator parameters and updating discriminator parameters with fixed generator parameters. Since G and D are completely independent functions, any standard gradient-based learning rule can be used to optimize the performance of the generator and discriminator. In this paper, the Adam algorithm is applied. Adam algorithm is an efficient algorithm for stochastic optimization based on calculating individual adaptive learning rates for each parameter [25].

B. Output Power of PV Systems
In order to obtain the output power of PV systems, 24-hour ambient temperature and irradiation must be determined. For this purpose, daily ambient temperature and irradiation of the specific month over the last four years must be gathered with a resolution of 15 minutes. The configuration of the GAN models, used to model uncertainties in weather, is illustrated in Fig. 3. Both the generator and discriminator of the GAN models are built by stacking two fully connected layers. The output of the generator is a vector of dimension 96. The output of the discriminator is a single scalar that represents the probability that the input data belong to the historical data.
The power generation of PV systems can be calculated as follows [26], [27]  where T c is obtained as

C. EV Users' Behavior
By modeling the arrival and departure time of EVs, the number of EVs at parking lots at each time step and the staying duration time of each EV at parking lots can be modeled. Since a high level of correlation exists between the arrival time and departure time of EVs, the independent modeling of these parameters is unrealistic. Independent modeling refers to the probabilistic modeling of parameters by ignoring stochastic dependence between them. Fig. 3 shows the architecture of the GAN model applied to model uncertainty in the arrival and departure time of EVs. In the GAN model, the generator and discriminator include six fully connected layers. The output of the generator is a vector of dimension 2 that the elements of this vector represent the arrival time and departure time of an EV. The output of the discriminator is similar to that of the GAN models for modeling uncertainties in weather.
The SoC of EVs can be calculated as follows To increase the lifetime of batteries, upper and lower limits are considered SoC. In this paper, the upper and lower limits are assumed 80% and 10%, respectively. The characteristics of EVs, such as their electrical energy consumption (E c ), battery capacity (B E V ), types of EVs, etc., are modeled similarly to [15]. The daily distance traveled by an EV (D E ) is modeled by GAN. To represent uncertainty in the daily distance traveled by EVs, a GAN model is employed in which both of the generator and discriminator are built by stacking eight fully connected layers. The output of the generator is a continuous value that indicates the daily distance traveled by an EV. The output of the discriminator is similar to that of the GAN models for modeling uncertainties in weather. The historical data of the proposed GAN models for representing uncertainties in EV users' behavior is the data collected in the specific month over the last year.
Three AC and DC charging levels exist based on SAE J1772 standard [28]. In this paper, a single-phase connection to the grid with the maximum charging current of 32A and the maximum power of 7.4kW is used to charge EVs. In other words, AC level 2 charging is adopted for charging EVs.

IV. PROBLEM FORMULATION
As mentioned earlier, the aim of this paper is to manage the charging of EVs from the perspective of EV users, DSO, and governments. The objective function of the problem is formulated as follows where DLC Grid is obtained as The first section of the objective function represents the cost of DSO that includes the daily cost of energy losses and the daily operating cost of transformers and power cables. The calculation of the daily operating cost of transformers and power cables is explained in detail in appendix. The second section of the objective function is related to the cost of GHG emissions that contains the daily environmental cost of transformers, power cables, and EVs. The daily environmental cost calculation is described in detail in appendix. The last section of the objective function indicates the cost of EV users that is the battery degradation cost of EVs. The constraints of the problem are described below.

A. Power Flow Equations and Voltage Constraints
Load flow equations are represented in the constraints (9)- (11). The injected active and reactive power at time t and node x of the grid ( p x t and q x t ) are obtained by (11). According to (11), the apparent power of a node in which a parking lot is located, equals the sum of the apparent power of the parking lot and other loads on the node minus the generation of the PV array installed at the parking lot.
Constraint (12) indicates the limitation of the voltage of buses in which parking lots are connected to them. The voltage of the buses should be in the range V L to V U during the charging time.
In this study, V L and V U are set to 0.95 and 1.05 per unit (p.u.), respectively.

B. EVs and Parking Lots Constraints
Constraint (13) represents that the total energy demand of a parking lot (E n G2V ) is equal to the total energy required for the charging of EVs during their appearance time in the parking lot.
P EV c,n t t, n = 1, . . . , N P L (13) According to (14), the SoC of EVs at each time step should be lower than SOC U and upper than SOC L , respectively.
Constraint (15) guarantees that when EVs leave parking lots, they are fully charged. In some cases, meeting this constraint is impossible due to staying in parking lots for a limited time or a very low level of SoC. Thus, these EVs will not be incorporated in the proposed method and they must be charged with a constant charging rate. In other words, EVs that have the potential to meet the fully charged constraint will participate in the proposed method.

C. Transformers and Power Cables Constraints
The operating limits of transformers are explained in constraints (17) and (18). The maximum allowed hottest-spot temperature of transformers is 120 • C and the loading of transformers beyond the nameplate rating is constrained to 50% under normal cyclic loading conditions by IEC 60076-7 standard [29], [30]. Constraints (17) and (18) express that the hottest-spot temperature and loading of transformers should not exceed the maximum permitted amounts.
Constraints (19) and (20) are associated with the operating constraints of underground power cables. According to (19), the current of cables should be limited to their maximum rating. Constraint (20) represents that the temperature of cables should not surpass the maximum permissible temperature of cables that is 90 • C [31].
A node-branch incidence matrix is an oriented matrix that its columns are branches and its rows are nodes. In order for the matrix to be square, the generator located in the slack bus is added to branches (columns). According to (21), if the determinant of matrix M is ±1, there is no loop in the microgrid and a path exists between every two buses.
Constraints (22) is switching constraint. The number of daily switching actions for each cable should not violate the maximum permissible value that is 4 [33]. Because of the non-linear objective function and constraints, a mixed-integer non-linear programming (MINLP) solver is employed. For this purpose, the basic open-source non-linear mixed-integer programming (BONMIN) optimization framework is used to optimize (7) due to the superior performance compared with metaheuristic optimization methods. The BON-MIN solver combines the interior-point optimization approach and the coin-or branch and cut method to solve MINLP optimization problems [34].

V. SIMULATION RESULTS
In this section, the performance of the proposed method is evaluated through simulations in MATLAB R2019a. To validate the robustness of the proposed method, a sensitivity analysis is carried out on the maximum output power of PV systems. The numerical simulations are conducted on a 64-bit computer with an Intel Core i3 CPU of 2.13 GHz and 4 GB RAM.

A. Case Study
The proposed method is implemented on the feeder of the modified Sirjan (a city located in Iran) city center's distribution network illustrated in Fig. 5. More details about the benchmark system can be found in [35]. It is assumed that three parking lots equipped with PV arrays are sited in commercial workplaces with the capacity of 160, 160, and 480 vehicles. The maximum output power of PV arrays and the characteristics of transformers, which are installed on parking lot buses, are tabulated in Table I [36]. The thermal data of used transformers in this paper are shown in Table II. The purchase price of transformers is 166.1 $/kVA [37]. The types of used underground cables in this study are XLPE-insulated cables with aluminum conductors and the cross-section of 150, 70, and 50 mm 2 . The power cable data and prices are shown  I   PARKING LOTS DATA   TABLE II   TRANSFORMERS THERMAL DATA   TABLE III THERMAL AND ELECTRICAL PARAMETERS OF CABLES in [38]. The thermal and electrical data of cables and soil are indicated in Table III. The purchase price of EV batteries is considered 176 $/kWh [39]. The value of GHG emission cost (π emi ) is equal to 0.156 $/kg. The amount of GHG emissions in the production and end-of-life phases of transformers, power cables, and EVs are extracted from [40]- [42]. The microgrid is traditionally supplied by natural gas power plants that the amount of their GHG emissions is presented.

B. Experimental Protocol for Uncertainties Modeling
The uncertainties in EV users' behavior and the output power of PV systems are modeled according to section III. For modeling the output power of PV systems, daily ambient temperature and irradiation of Sirjan during May from 2016 to 2020 with a resolution of 15 minutes are collected. The historical data related to the years from 2016 to 2019 are considered as the training data and the historical data related to 2020 are used as the test data. The historical data for the arrival and departure time of EVs are provided by the EVnetNL dataset [43]. This dataset includes 10000 transactions in 2019 from public charging stations operated by EVnetNL. The data of transactions during May have been extracted and considered as historical data. The historical dataset consists of 1668 samples. In order to model the driving pattern of EVs, daily distance traveled by vehicles has been extracted from CBS open data StatLine dataset [44]. The historical dataset contains 1755 samples.
In order to prevent generating random results by the GAN models, 5-fold cross-validation has been employed. For each GAN model, the related historical data have been divided into 5 folds in a way that each fold includes almost 20% of total samples. Four of the folds have been selected as the training set and the remaining fold as the testing set. All GAN models are optimized by Adam optimizer with a learning rate of 0.001. All weights of neurons in neural networks are initialized by the Glorot uniform initializer. The number of training iteration is set to 20,000. The proposed GAN models are implemented in Python using the Tensorflow platform [45]. The average execution time for training the proposed GAN models is tabulated in Table IV.

C. Results and Discussion
For testing the performance of the GAN models related to modeling the output power of PV systems, they have generated the daily ambient temperature and irradiation of 31 days. Fig. 6a, Fig. 6b, and Fig. 6c illustrate the average daily ambient temperature, irradiation, and the output power of PV systems generated by the GAN models, respectively. The GAN model related to modeling the arrival and departure time has generated 800 pairs of the arrival and departure time (because the total number of EVs in this research is 800). In other words, the GAN model has generated the arrival and departure time of 800 EVs. As the number of test samples is not equal to 800, the percentage distribution of EVs has been calculated to be able to compare the generated data with test data. The GAN model related to representing the driving pattern has generated the daily distance traveled by 800 EVs. The generated arrival and departure time of EVs and the generated daily driving distance of EVs by the GAN model are demonstrated in Fig. 6d, Fig. 6e, and Fig. 6f, respectively.
To assess the performance of the GAN models, R-squared and normalized root mean square error (NRMSE) are calculated as follows The amount of R squared and N RM SE for GAN models are indicated in Table IV. As the value of the statistical measures and figures show, the GAN models can successfully follow the distribution of historical data and can accurately model uncertainties.
The case study is studied under four scenarios that are listed as follows • Base scenario: The uncoordinated charging of EVs.   Table V shows the results of different scenarios. In the base scenario, most EVs are charged in the early hours of the day when the electricity price is high and the production of PV arrays is low. As a result, the DSO and environmental costs in this scenario are higher than in other scenarios. In Scenario 1, where EVs only exchange active power with the microgrid, charging is mainly performed during hours when the price of electricity is low, which reduces the cost of energy losses. Moreover, due to charging EVs during off-peak times, the lifespan of power grid components increases. The operating cost of equipment in this scenario reduces by 14.07% compared to that of the base scenario. In the first scenario, in order to decrease the emission cost of EVs, EVs are charged more when the generation of PV arrays is high. The environmental cost decrease by 2.53% compared with that of the base scenario. The value of the objective function in this scenario gets better 1.95% compared to that of the base scenario. In Scenario 2, since the environmental cost is not considered in the objective function, the total emission cost in this scenario increases by 1.34% compared with that in scenario 1. On the other hand, due to the injection of reactive power from EVs into the microgrid, the total cost of DSO in this scenario declines by 11.72% and 9.25% compared to that of the base and first scenarios, respectively. In scenario 3, the DSO cost, environmental cost, and objective function decrease by 11.02%, 3.3%, and 4.02% compared to those in the base scenario, respectively. Reconfiguring the microgrid, as shown in the results, reduces the cost of DSO and increases the lifetime of power network components. The optimal configuration of the microgrid is presented in Table VI. In this  TABLE VI RECONFIGURATION SWITCHING ACTIONS scenario, the total cost of DSO decreases by 11.96%, 8.72%, 0.27%, and 1.06% compared to the base, first, second, and third scenarios, respectively. The total environmental cost in this scenario reduces by 3.37%, 0.86%, 2.17%, and 0.08%, respectively, compared to the mentioned scenarios. Finally, the objective function in this scenario improves 4.82%, 2.93%, 0.84%, and 0.33% compared with the mentioned scenarios, respectively. Because of considering the battery degradation cost of EVs in all scenarios, none of the EVs operates in the V2G mode. For this reason, the total cost of EV users in all scenarios is constant.
The daily active power of EVs for parking lot 2 is shown in Fig. 7. The uncoordinated charging of EVs causes emerging a new morning peak because a large number of EVs are charged at a constant charging rate when they arrive at the parking lot in the morning. In the final hours of the presence of EVs in the parking lot, the exchange of active power between the EVs and the network decreases. The active power consumption of the parking lot after 10 reduces significantly because most EVs are fully charged before that time. In scenarios 1 to 4, two charging peaks can be seen, one from 6:30 to 7:30 and the other one from 12:30 to 14:30. From 6:30 to 7:30, although the output power of PV systems is low, the electricity price, the power consumption in the grid, and the loading of transformers and power cables are low. As a result, EVs in all scenarios are charged during this period of time. Charging EVs in this period gains the environmental cost of EVs due to low PV system production. Thus, EVs in scenarios 1, 3, and 4 are charged less than scenario 2. From 12:30 to 14:30, the electricity price and the power consumption in the grid are low and the generation of PV systems is high. Consequently, EVs are charged in all scenarios during this period. In all scenarios, the second charging peak is greater than the first charging peak due to cheaper electricity tariffs and larger PV system generation during the second charging peak time. From 9:00 to 12:00, EVs in scenario 2 are not charged because the electricity price and power consumption are high. Moreover, EVs in this scenario are not discharged because it will expand the wear cost of EVs. In the other scenarios, due to an increase in the production of PV arrays during this period, EVs are charged to reduce the total environmental cost. The daily active and reactive power of the microgrid and EVs are illustrated in Fig. 8a, Fig. 8b, and Fig. 8c. In the base scenario, the peak value in the morning is 1.12 times the peak value of the load profile without parking lots. Increasing the peak value can cause problems in demand-side management (DSM) and shorten the lifespan of power grid components. As the most generation of PV arrays is after 10, this scenario cannot efficiently use the capacity of sustainable energy. Consequently, the emission and carbon footprint of EVs and power system equipment rise in this scenario. In scenarios 1, 3, and 4, PV systems play a greater role in charging EVs. The maximum generation of PV systems occurs during peak time. On the one hand, charging EVs during peak times gains the energy losses cost and the operating cost of transformers and power cables. On the other hand, charging EVs during this period provides an opportunity to charge EVs using clean energy and zero-emission sources. For this reason, there is a trade-off between minimizing the DSO and environmental costs. The proposed method schedules the charging of EVs during peak time in a way that the power consumption of parking lots is equal to the generation of PV systems. Therefore, the peak value does not change in these   the lifespan of power grid components are in a better situation than the base scenario. Scenario 2 improves the quality of DSM compared to other scenarios because the load profile in this scenario has the lowest peak value among scenarios 1 to 4. This is because a few EVs are charged during peak time in this scenario compared with other scenarios. In this situation, the generation of PV systems is injected into the grid which causes peak shaving in the grid. The reactive power of EVs is managed in scenarios 2 to 4. In these scenarios, as shown in Fig. 8b, in the early hours, due to the low number of vehicles at parking lots, the reactive power exchange between EVs and the microgrid is low. Then, during hours when the electricity price and power consumption in the microgrid rises, the injection of reactive power from EVs into the microgrid increases. By compensating reactive power during peak time, the DSO cost can be significantly reduced without gaining the degradation cost of EVs. During off-peak times, since EVs are charged, the injection of reactive power decreases according to constraint (16). The daily power loss profile of the grid is shown in Fig. 9. In the base scenario and scenario 1, because the active power of EVs is only managed, the pattern of the power loss profile is exactly the same as the active power profile. In scenarios 2 to 4, the power loss significantly diminishes due to the compensation of reactive power. Scenario 4 has the lowest daily power loss because of employing the reconfiguration technique. The average power loss during the charging time enhances from 82.13 kW (in the base scenario) to 68.25 kW (in scenario 4).
In Fig. 10, the contribution of sustainable energy to the charging of EVs in scenarios 3 and 4 is demonstrated. In the base scenario, the portion of using PV systems for charging EVs is 29.32%. Nevertheless, the percentage of the participation of PV systems in the charging of EVs is 38.32% in scenarios 3 and 4.
A sensitivity analysis is carried out on the penetration level of PV systems to study the robustness of the proposed method. The cost of different stakeholders in scenario 4 is indicated for the different percentages of PV system penetration in Table VII. The results show that the DSO and environmental costs and the contribution of PV systems to the charging of EVs gain by increasing the penetration level of PV systems. The DSO, environmental, and total costs for the 140% penetration level of PV systems decrease by 5.34%, 6.45%, and 3.79% compared with that for the 60% penetration level of PV systems, respectively. The contribution of PV systems to the charging of EVs improves from 23.09% (for the 60% penetration level) to 53.42% (for the 140% penetration level). The daily active power of the microgrid and EVs for the various penetration levels of PV systems is demonstrated in Fig. 11a and Fig. 11b. As the penetration level of PV systems increases, the proposed method tends to charge more EVs using PV systems to reduce the DSO and environmental costs. Another noteworthy point is that in all cases, the peak value is constant and does not change, which has a beneficial effect on DSM. In other words, in all cases, the charging of EVs is scheduled in a way that the amount of energy needed for charging EVs equals the generation of PV systems during peak time.

VI. CONCLUSION
In this paper, a new smart charging method for workplace EV parking lots integrated with PV arrays was introduced with the aim of optimizing the benefits of DSO, EV users, and governments simultaneously. In the proposed method, the active and reactive power of parking lots and the configuration of the microgrid were obtained to optimize the operating cost of power system components and energy losses cost (as the DSO profit), the environmental cost of power system components and EVs (as the governments profit), and the battery degradation cost of EVs (as the EV users profit). One of the salient parts of day-ahead EV charging scheduling is modeling uncertainties in EV users' behavior and the generation of PV systems. Due to the dynamic nature of these uncertainties, data-driven methods have superior performance to modelbased methods in modeling these uncertainties. In this paper, GAN-based models were used to capture uncertainties in the arrival and departure time of EVs, the daily driving distance of EVs, and the output power of PV systems. The evaluation of the proposed method was performed by implementing it on Sirjan's reconfigurable microgrid. The main conclusions and findings of the paper are summarized as follows: • The performance of GAN methods was evaluated by criteria R squared and N RM SE. The results demonstrated that the average amount of R squared and N RM SE for GAN models was 0.935 and 6.77 %, respectively. Accordingly, GAN models can appropriately represent the uncertainties. • From DSO's perspective, the DSO cost decreased by 11.96% using the proposed method in contrast with the uncoordinated charging of EVs. In addition, the improvement in the average power loss of the grid during the charging time was 16.9%. These enhancements are a consequence of managing the active power of EVs, injecting the reactive power of EVs into the grid, and employing the reconfiguration technique in the proposed method. From Government's perspective, the environmental cost was reduced by 3.37% compared with the uncoordinated charging of EVs due to participating sustainable energy in the charging of EVs. The contribution of PV systems to the charging of EVs improved from 29.32% (in the uncoordinated charging of EVs) to 38.32% (in the proposed method). From EV users' perspective, the usage of the proposed method did not influence the battery degradation cost of EVs because EVs were scheduled to operate only in G2V mode. Therefore, employing the proposed method can satisfy all the stakeholders. As the results showed, the amount of the objective function using the proposed method got better 4.82%. • The robustness of the proposed method was shown by considering the different penetration levels of PV systems. The sensitivity analysis results demonstrated that by increasing the percentage of the penetration of PV systems, the DSO and emission costs decreased. According to the results, the following policy recommendations are proposed for the stakeholders.
• Increasing the penetration of RES in distribution systems and integrating them with EV charging (DSOs and Governments). • Participating EVs in the reactive power support service market (EV users and DSOs). • Providing necessary historical data (the arrival and departure time, driving pattern of EVs, etc.) for parking lots and DSOs to be able to accurately model uncertainties (EV users and Governments). In this paper, it has been assumed that parking lots are located at commercial workplaces. For future research, the proposed method can be generalized by considering the possibility of residential EV charging. In the residential charging of EVs, since most EVs are connected to the grid from the afternoon to the next morning, PV systems must be equipped with battery storage. For this reason, battery energy management must be carried out along with the smart charging of EVs. Improving the accuracy of modeling uncertainties can be another future work. Standard GAN models have been used in this paper. However, using deep neural networks (such as long short-term memory neural networks, convolutional neural networks, etc.) instead of fully connected neural networks in the architecture of GAN models may enhance results.