A Stochastic Approach to Designing Plug-In Electric Vehicle Charging Controller for Residential Applications

The increase of Plug-in Electric Vehicles (PEVs) penetration in distribution systems necessitates processing strategic assets in order to deal with their energy needs. A careful investigation into matters related to PEV charging management under actual circumstances can be regarded as the critical step towards enabling this process. Accordingly, this paper intends to design a practical controller capable of performing charging scheduling under uncertainties related to the lack of access to crucial PEV information accounting for departure time, energy requirement, and power demand nonlinearity. Although such an issue can be encountered when developing charging models for real-world conditions, it has not been adequately taken into consideration. The proposed controller carries out charging scheduling through a procedure with a set of effective straightforward algorithms, essential for actual applications. Particularly, it takes advantage of a Bayesian forecasting model that is able to efficiently predict charging energy demand according to car owner’s behavior. In addition, it employs a stochastic optimization framework to schedule PEV charging based on the dynamic electricity price and user preference. Several case studies are conducted to examine the performance of suggested controller in optimal scheduling by exploiting real data. The evaluation process is executed through a comparative analysis by using a deterministic method, as the ideal case, which exploits a full-information space. The results show that the proposed procedure can offer competitive charging schedules, which can minimize the cost while satisfying user desires. The designed controller can successfully manage PEV charging in the presence of stochastic phenomena with limited information access, and thus, enable physical implementations.

INDEX TERMS Plug-in electric vehicle, energy management, charging scheduling, load modeling, uncertainty.  Over the last decade, Plug-in Electric Vehicles (PEVs), spurred by ambitious political announcements and technological advances, have expanded significantly [1]. Total sales of PEVs have reached an annual increase of 40% [2]. In the fist trimester of 2021, the global fleet of these cars made a record by surpassing 10 millions, 3 millions more than the previous year [2]. In the long run, the rapid integration of PEVs into the distribution network can dramatically increase grid peak demand and cause uncertainty and instability in the operation of existing electric power systems [3]. Several investigations have shown that PEV charging is most often performed at home [4]- [6]. Therefore, PEV is progressively becoming a new major residential electrical appliance.

A. PEV CHARGING SCHEDULING CONTEXT
Similar to other domestic appliances with flexible energy usage such as dishwashers, the charging of PEVs can be managed by the Home Energy Management System (HEMS) to avoid demand during peak periods with relatively high prices [7], [8]. PEV charging is typically scheduled to reduce the cost considering the price signal and the user comfort preference. The scheduling is performed through an optimization problem, formulated based on PEV charging parameters. Arrival time, departure time, charging energy requirements (initial and desired State Of Charge (SOC)), battery capacity, charging power, and conversion efficiency are the main parameters of the optimization procedure. A PEV charging controller that is aimed at practical implementations must be able to handle uncertainties related to the lack of access to specific parameters. These factors account for departure time, energy requirement, and power demand non-linearity, which are essential for an effective charging management. Although the lack of such information can be encountered under real conditions, it has not been adequately taken into consideration. From a general viewpoint, research studies have neglected to address the charging scheduling problem considering the above issue. For instances, most analyses have considered a perfect knowledge about the departure time [9], [10] that is not feasible especially in a long run. In addition, other works have neglected the nonlinear behavior of PEV charging power. Besides, several studies have assumed automatic access to either the battery SOC or travelled distance. However, PEV manufactures seem to be reluctant to provide this information in near future. Therefore, charging stations are not able to communicate with PEV on-board charging controller in order to receive relevant information. It should be also added that some of these assumptions can lead to further challenges. For example, exploiting the travelled distance to estimate the initial SOC, as a common strategy, can be unreliable for PEVs that utilize external (home-away) charging sessions.
On the other side, few research works have investigated the aforementioned concern. They have normally employed Model Predictive Control (MPC) and stochastic optimization methods to address the PEV charging uncertainties [11]. The biggest challenge of the former is the need of an accurate and viable predictive model in order to perform efficiently. Nevertheless, the related literature does not provide sufficient details about utilized predictive models. On the other hand, studies on the latter have not examined the effect of unreliable decisions due to the existing uncertainties on user satisfaction, particularly with the final SOC. In fact, the lack of such an examination has brought about scenarios under which, their proposed methods have led to insufficient charging regarding mobility constrains [12]. More importantly, the relevant research is limited in scope due to concentrating on specific matters. Accordingly, it cannot enable actual applications that should be performed under the entire circumstance, i.e., the lack of information on essential parameters, which are interconnected. Accordingly, this study focuses on the development of a PEV charging scheduling system with the aim of addressing the aforementioned challenges.

B. CONTRIBUTION
The main contribution of this paper is designing a practical PEV controller that is able to perform charging scheduling under uncertainties related to the lack of access to critical charging parameters. The novelty of the proposed approach can be detailed in terms of: 1) A charging management strategy that unlike other similar methods, does not rely on departure time and SOC information from PEV on-board controller at the plugin time; 2) A stochastic optimization framework that can offer the optimal horizon and control actions for PEV charging considering a monetary value for customer dissatisfaction related to final energy state and electricity price; 3) An online control algorithm that is able to deal with the non-linearity of charging power profile as well as the uncertainties of energy demand and departure time.
It should be added that the charging scheduling procedure utilizes a forecasting model to estimate charging energy requirement based on driver habits. The performance of this process is assessed across multiple charging sessions within almost one year regarding real-world conditions. In addition, a comparative study is used to demonstrate the efficiency of the designed controller, which can be easily integrated into existing charging infrastructures. The rest of the paper is organized as follows. Section II provides the literature review. The PEV charging problem formulation is presented in Section III. The stochastic predictive model of PEV charging demand and the PEV charging control process are also detailed in this section. The evaluation framework of the proposed system is described in Section IV. The results of case studies and comparative analysis are discussed in Section V, followed by conclusion in Section VI.

II. BACKGROUND
The literature provides a variety of studies about charging scheduling of PEVs in the context of smart grids. This subject has been examined for various objectives on different scales of individual to fleets of PEVs. Energy cost minimization [11], [13], ancillary services provision [14]- [18], integration with renewable energy systems [19]- [21], power grid planning [22], [23], and investment decision in the transportation sector [24] are among PEVs popular matters. Particularly, PEVs charging cost reduction has been intended through scheduling methods due to the flexibility of their energy demand. Individual and coordinated Charging are general approaches to scheduling with regard to the electricity market design [25].
PEV charging scheduling is normally formulated in terms of an optimization problem. Accordingly, existing methods can be classified into deterministic and stochastic techniques [26], [27]. The former assumes a full accurate access to PEV critical parameters such as on-board SOC measurement data, arrival and departure time, user preference, charging power, and future driving needs [27]. On the other hand, the latter takes into account these factors along with their uncertainties. A large portion of relevant studies in the literature is based on the deterministic approach [27]. Ref [9] developed a real-time home energy management algorithm to control multiple home appliances and a PEV with the aim of minimizing overall electricity bill. The proposed system utilized a fuzzy logic controller that was supplied by exact information of PEV parameters. An energy management algorithm for PEV smart home charging was proposed in [10] to minimize the cost. The smart charging was carried out in both 'vehicle-to-home' and 'vehicle-to-grid' modes by means of linear programming. Similarly, it exploited accurate values of PEV parameters. Ref [28] explored a long-term electricity bill minimization problem based on an online HEMS that controlled the energy demand of a PEV along with other appliances. The developed method employed a stochastic optimization based on the Lyapunov technique to handle uncertainties related to electricity price, outdoor temperature, renewable energy generation, electricity demand, comfort level, and occupancy status. However, it did not take into account uncertain parameters related to PEV charging demand. Furthermore, the suggested HEMS was assumed to receive charging request details including arrival time, departure time, and energy requirements directly from the PEV owner. A coordinated, centralized framework for PEV charging and HVAC control in a neighborhood area was explored in [29]. The PEV charging was modeled by using users' travel patterns, which must be communicated with the aggregator before the performing day. Ref [30] assessed the potential of PEV and four other domestic loads for peak shaving. Unlike [29], it developed a decentralized control system whose performance was evaluated over 100 households based on different price signals. The above studies have not taken into account a practical examination of their propositions under real-world conditions. In fact, in real cases, the PEV controller should consider uncertainty sources for effective scheduling regarding charging flexibility and battery storage (vehicle-to-grid) potentials. Nonetheless, some studies have attempted to investigate the stochastic nature of PEV charging parameters. Ref [26] explored the stochastic modeling of PEVs arrival time, departure time, and travelled distance by means of Probability Density Functions (PDFs). It aimed to improve power system planning by predicting PEVs aggregated power profile. Likewise, PEV demand was modeled by using the PDF of its parameters in [31], [32]. The proposed model was evaluated through different cost and energy management strategies in a power grid with photovoltaic and wind turbines generation. It accounted for realworld scenarios by dealing with the stochastic behavior of PEV demand. However, these studies did not integrate uncertainties associated with PEV modeling parameters into their decision-making process. Indeed, the uncertainty parameters should be incorporated into the PEV charging optimization problem for practical implementations.
Ref [33] presented an energy management strategy for controlling PEV and other home appliances according to the future vehicle state and household energy demand predictions. It utilized an MPC to minimize the impact of PEV state prediction uncertainty on charging and discharging. A multi-level, day-ahead, real-time optimization framework for PEVs charging management in a commercial building was proposed in [25]. The Building Energy Management System (BEMS) was equipped with solar production. It was intended to regulate PEVs charging within two steps in a transactive market. First, the BEMS practiced a profit maximization by estimating building energy demand regarding charging requirements and PV generation. Afterwards, it performed a real-time optimization problem by use of MPC to minimize the difference between the actual and pre-scheduled energy use. However, the BEMS did not aim to schedule PEVs charging since it assumed that owners were either unwilling or unable to interact their detailed information. In fact, the BEMS was focused to provide PEV owners with incentives based on their flexibility potentials for charging power in every market period. The performance of the suggested system was evaluated by using simulated PEV charging behavior, provided by the Danish National Travel Survey data. [12] proposed a Stochastic Dynamic Programming (SDP) framework for optimal energy management of a smart home with PEV. The SDP problem was formulated to minimize the instantaneous energy cost of the home at each time interval considering the expected charging demand. The charging request was managed based on a Markov chain model of PEV parking status, captured from its historical data. Different charging strategies comprising vehicle-to-grid, vehicleto-home, and grid-to-vehicle were carried out to evaluate cost saving potentials of PEV. Although the proposed SDP considered the uncertainty of departure time, it did not deal with its impact on user satisfaction in terms of final energy state adequacy in the decision process. Besides, it was acknowledged that charging optimization practice could lack to meet PEV mobility constraints under certain electricity prices.

III. PROBLEM FORMULATION A. DETERMINISTIC APPROACH
PEVs charging scheduling is generally formulated as a shortterm optimization problem considering HEMS needs.

1) Deterministic-based PEV charging problem formulation
The main objective of PEV charging system is to find optimal control actions, u * k that minimize charging cost while satisfying system constraints. Let SOC k be the PEV battery SOC at the time step k and u k be the decision variable that controls the ON/OFF status of its charging. Considering the departure time, T , the deterministic optimization problem of PEV charging can be formulated as, where λ k stands for the price of electricity at k in ¢/kWh, b nom is the rated charging power in kW, and ∆t represents the time step. Additionally, γ E is the charging efficiency and E cap is the PEV battery capacity in kWh. SOC pi is the battery initial SOC at the plug-in time, t pi . SOC min T and SOC max T represent the minimum and maximum battery SOC, required at the departure time.

2) Main hypothesis
The deterministic approach assumes that all modeling parameters are perfectly known and accessible by the controller in an automated way within each charging session. As discussed, this assumption can hinder real implementations since PEV charging scheduling can be subject to uncertainties related to the lack of critical charging parameters. Particularly, this method neglects the nonlinear behavior of PEV charging power, which is governed by two modes of operation comprising constant current mode and constant voltage mode (CCCV). However, the aforementioned matters are crucial to PEV charging services. This has been demonstrated in Figure 1 that presents a PEV charging session based on the CCCV modes, switched at t CC . In this figure, the variance of the charging profile (grey boundary) is attributed to uncertainty in charging duration due to external factors such as ambient temperature, and the accuracy of the battery SOC estimate.

B. PROPOSED STOCHASTIC OPTIMIZATION PRINCIPLES
In the proposed stochastic optimization, the departure time is assumed to be unknown or at least unavailable across the charging session. Once the PEV plugs in, the connection time is identified. However, the charging controller can be unaware of PEV leaving time. Notwithstanding, it needs to operate such a way that minimizes the cost and the user dissatisfaction considering the final battery SOC. In order to achieve this aim, the controller requires to manage the uncertainty of departure time, charging duration, and energy requirements when operating in real-world conditions i.e. the absence of complementary information [12], [34], [35]. On the other side, HEMS is presumed to be unable to directly retrieve battery SOC information from the vehicle. This is due to insufficient communication protocols between third-party systems such as HEMS and PEV on-board controller. Therefore, HEMS only utilizes exchanging information between PEV and charging station, particularly charging power measurements. In fact, such information, provided by the controller, allows HEMS to effectively manage PEV charging in the lack of their direct communication. In fact, measurement data from charging station is accessible to PEV controller without any specific communication protocol. Moreover, this charging data is the richest information that can be used to capture PEV behavior, specifically the non-linear nature of charging power profile. Such statistics, collected from station services, are more accurate than travel distance information that is affected by charging sessions, performed outside the house [36].
Due to the lack of SOC information, the Coulomb Counting (CC) method, used to compute this variable in (1c), should be reformulated. In this regard, the alternative equation of CC to determine energy state dynamic of the PEV by exploiting charging power as the only available information is defined by [37], where at discrete time, k, y denotes accumulated charging energy in the battery with an initial value of zero in the plugin time and b is the actual charging power. It should be noted that previous studies have mostly used the rated charging power to estimate SOC dynamics. However, this is not the case in real conditions where charging time is more due to the CCCV charging mode of the PEV battery as shown in Fig. 1.
Considering departure time uncertainty, charging duration, and energy requirement, PEV charging can be formulated in terms of a stochastic problem [12], [38] through, is the total cost of overall charging energy at the departure time, y T , according to the departure uncertainty parameter, ξ. The problem subject is a chance constraint to meet user preference for charging amount, y pref . η is the user satisfaction probability considering the final state of energy with normally a large value. Accordingly, η closer to one conveys that the user tolerates y T < y pref by less probability (1 − η). The objective function in (3a) is determined by, where based on uncertain departure time, C (y T , ξ) and D (y T , ξ) are charging cost and dissatisfaction level functions related to the final state of energy. In this manner, the optimal control actions, u * k must minimize both C (y T , ξ) and D (y T , ξ) considering ξ. In the developed stochastic problem, the departure time, T and the control actions, u k are the decision variables.
The formulated problem can be solved by the Monte Carlo simulation and Sample Average Approximation (SAA), described by Algorithm 1 [39]. In this Algorithm, the decision space to select the departure time, T is defined according to its distribution. To be specific, the decision is made based on a limited number of samples by dividing the departure time distribution into N larger intervals as illustrated in Figure 2. This is due to the fact that searching the main distribution can be computationally expensive for shorter time steps, k. The method to capture departure time distribution is detailed in Subsection III-C.
Subsequently, the controller solves the optimization problem for a decided T through, Step Description 1.
Define the decision space T ∈ Ω T from the distribution ; 2.
Store the expected value of Q(y T , ξ) by using the SAA method in (8); 7.
Select the decision T that leads to the minimum value of total Q(y T , ξ).
that b av is the average charging power. The chance constraint in (3b) is realized by (5d) whereŷ min is the minimum estimated energy, required by the charging session to meet η level of satisfaction. This constraint aims to ensure that the final energy state at the departure time satisfies user energy needs. It can be deduced that rated power, b nom , is not a practical choice for PEV charging according to its time-variant behavior, presented in Figure 1. Considering this value leads to shorter charging duration that is not the case of actual situations. Nevertheless, the relevant literature has mainly utilized the rated value for charging scheduling. In order to relieve this issue, the formulated problem in (5a) has considered average power, b av , which is more sensible. Additionally, this decision results in a time-invariant estimation of charging state dynamic, (5b), that consequently, facilitates classic optimization problem solving. The process to determine y min and b av is explained in Subsections III-D and III-E.
Afterwards, the solution of the deterministic optimization problem is assessed under different departure scenarios by the controller. These cases are provided by sampling the conditional probability distribution over the departure time, captured based on the plug-in time. Figure 2 exemplifies such a distribution where T min and T max are the earliest and latest departure time, respectively, according to the historical data. ξ s is a sample from this range. Consequently, the examination of the solution y T is carried out by calculating the charging and dissatisfaction costs through (6) and (7), respectively, considering the departure scenario, ξ s , FIGURE 2: Exemplified conditional probability distribution of the departure time with respect to the plug-in time.
where κ 1 and κ 2 are the amplitude and shape parameters of the dissatisfaction function, respectively, and y ξ s is the energy state, defined by This function has been exemplified in Figure 3. In this figure, two regions can be distinguished that have been separated by a grey dashed line. The hardly tolerable zone presents user's highest dissatisfaction to depart due to lower energy amounts. On the other hand, the highly tolerable zone corresponds to energy levels where user's willingness to depart start increasing proportionally. The parameters of the dissatisfaction function are defined in such a way that a trade-off between both types of costs is realized. To be specific, the amplitude of the dissatisfaction function is decided with regard to the energy price to avoid the dominance of charging cost. The significance of user's desire can be justified by κ 1 values for which the final charging energy is selected within the tolerable area. Furthermore, κ 2 manipulates the steep decrease of the dissatisfaction curve. In order to choose the shape parameter, additional source of information related to user behavior is required, which is not in the scope of this study. Therefore, a value that ensures a smooth decreasing rate of the curve is considered. Indeed, the properties of the dissatisfaction function should be investigated through adequate information to improve the HEMS convenience.
Finally, the expectation value of the total cost can be calculated by SAA based on, The above process is carried out for all the decided horizons, T , in Ω T . Subsequently, the solution of the pro- posed stochastic optimization, applied to the current charging session, is the horizon whose corresponding control action results in the minimum overall cost.

2) Implementation of the proposed PEV charging controller
The PEV charging controller uses only data from residential Electric Vehicle Supply Equipment (EVSE) as assumed. Particularly, it exploits historical power measurement information as an alternative for charging demand prediction and scheduling. For each charging session, the controller, presented in Fig. 4, performs the following three steps at the plug-in time.

1)
Forecasting: A predictive model estimates the charging demand,ŷ s , according to predictor variables, x s . Subsequently, the energy demand estimate,ŷ s , is used to model the charging power profile for the prediction horizon, T . 2) Optimization: The stochastic optimization problem is solved in order to define the best charging policy based on the actual electricity price signal and the predicted charging demand across T . At this stage, the controller assumes that the estimates of the charging demand and departure time are precise. 3) Execution: The PEV charging system implements the control actions, resulted from the previous step.

C. DEPARTURE TIME MODELING
The departure time (parking duration) information is one of the critical inputs that the controller needs to optimally schedule the PEV charging since it defines the time-horizon of the optimization. Uncertainty in this factor can lead to insufficient charging at the plug-out time and, in turn, user dissatisfaction. Therefore, it should be addressed for real applications since it is an inherent component of the charging practice. As a random variable, departure time is unknown to the controller at the plug-in time unless the PEV owner specifies it. Nevertheless, the latter situation is uncommon due to either users' ignorance of the true leaving time or their unwillingness to share such information on a regular basis. The Markov chain [12] and Semi-Markov [33] models are the most popular methods that have been used to represent PEV parking status in the literature. Since Markov chain-based models process the probability of parking status change (through state transition matrix) at each time step, their integration in stochastic optimization leads to a complex decision space especially for large number of PEVs. This, in turn, makes the optimization problem complicated to solve [11]. The Semi-Markov-based designs, which employ a similar procedure, are also complex. They capture the vehicle state by modeling the duration of all possible PEV travels. Generally, incorporating an uncertain parameter into a stochastic decision process can result in model complexity, high computational cost, and convergence issues regarding the optimization problem. These matters can bring challenges to both PEV controller software and hardware designs. For example, they can simply increase the equipment cost and avoid customer adoption. Since dealing with these circumstances is the primary step towards feasibility, utilizing efficient straightforward methods in the analytical process is stimulated. Accordingly, the PEV parking status modeling can be simplified while maintaining its significance for charging scheduling. Our analysis using actual data evidences that the parking duration can be decided based on the plug-in time. As a result, a clustering method is utilized to classify the PEVs according their arrival time. Afterwards, the Kernel Density Estimation (KDE) technique is used to model the departure time distribution of each group of PEVs by exploiting their corresponding historical data through [40], where N s is the total number of samples, h > 0 is the bandwidth parameter, T (j) is the jth observation data, and K is the Gaussian Kernel function. As a non-parametric method, KDE is a perfect fit for modeling departure time patterns through estimating their densities. It is a reliable choice for uncertain conditions since it can effectively describe timeseries with unknown underlying distributions [41].

D. PEV ENERGY DEMAND FORECASTING
Considering the objective of the controller, a forecasting system is developed that is not only able to estimate charging demand but also capable of quantifying its relevant uncertainty. This mechanism examines the stochastic behavior of PEV energy demand in the beginning of every charging session. Accordingly, letŷ s be the estimated energy demand for charging the PEV in the s th charging session, and x s and y s be the input vectors of exogenous and historical endogenous variables, respectively. The goal is to define the forecasting model, f , that predictsŷ s with minimum error. The general mathematical formulation of this model is described by (10), where θ x and θ y are model parameters associated with x s and y s , respectively. The vector of exogenous variables, x s is composed of calendar and weather components as the predictors. The calendar factor contains the plug-in time in decimal hours, the day of the week, w d s , and the number of the week, w k s . The weather factor comprises the average temperature,T s , in • C, the average sunlight,Ŝ l s , in kJ/m 2 , the average wind speed,v w s , in m/s, and the precipitation, p r s , in mm during the day of charging session. The vector of autoregressive variables, y s encompasses the history of charging energy requirements during the last l home charging sessions.
The proposed strategy considers all the predictors and employs the Sequential Forward Selection method to select the best ones based on their forecasting performance [36]. Different predictive models can be used to create the function f . Here, a linear modeling approach is used as, y s = x s θ x + y s θ y (11) where θ x and θ y are the vectors of coefficients. Given n number of observations, the objective is to estimate {θ x ; θ y } in order to have an efficient prediction of the current PEV charging demand. The model parameters are estimated by a Bayesian inference technique. The Bayesian inference expresses the regression parameters in terms of probability distributions [42]. It uses the Bayes' theorem to provide the posterior distribution of the model parameters instead of their single best estimations as for Frequentist methods [43]. Accordingly, this approach is able to quantify model uncertainties. The Bayesian learning process begins by defining the prior probability distribution of the model parameters, as the initial belief, before observing any data. The prior distribution is updated by using the observed data based on the Bayes' theorem to construct the posterior distribution, explained by [43], where θ = [θ x , θ y ] T and σ stand for the model parameters, and X and Y are the historical observations of the predic-tors as the input and the charging demand as the output, respectively. P (Y |θ, X, σ) is the observation likelihood, and P (θ) and P (σ) are the prior distributions over θ and σ, respectively. The likelihood P (Y |θ, X) can be computed through, From the Bayesian perspective, it can be assumed that y i is a univariate random variable that follows a Gaussian distribution based on [44], that N presents the Gaussian function, f (x i , y i , θ), as the model prediction, is the mean, and σ 2 stands for the variance. Due to its unknown value, it is assumed that σ can be explained by an inverse-Gamma prior distribution according to, where α and β are the shape and scale parameters, respectively. The prior probability distribution of θ can be also considered as a Gaussian distribution, explained by [43], where υ is a hyperparameter and Z(υ) denotes a normalizing constant. The equations (14)- (16) are used to derive the posterior distributions of the model parameteres in (12). Subsequently, the charging demand of the current session can be estimated by calculating the expectation of the posterior distribution of the predictive model, defined by [45] , whereθ MAP is the maximum a posteriori estimation of θ given byθ MAP = arg max θ (P (Y |θ, X) P (θ)). To be specific, the expectation in (17) is estimated by sampling the posterior distribution of θ based on the Markov Chain Monte Carlo (MCMC) technique [45]. Afterwards, the expectation value is used to quantify the minimum charging energy requirement of the corresponding session considering η level of user satisfaction through, where δ η is a positive constant. This value is chosen so that the right side of (18) offers the upper bound of η level of confidence.

E. CHARGING PROFILE ESTIMATION
The CCCV charging mode causes the PEV charging power to have a non-linear behavior. The PEV charging controller should consider this behavior to minimize its effect specifically on the final state of charge constraint. Unlike other similar works, the proposed controller estimates the PEV charging power profile by using both its estimated energy requirement at the plug-in time and historical charging pattern. Particularly, it exploits the duration information of the constant voltage (CV) and constant current (CC) phases to construct this profile. This information is obtained from charging demand behavior across these phases. The length and energy needs of the CV stage are taken from a complete historical charging session since the PEV battery behavior within this stage is similar [46]. Subsequently, the charging requirement of the CC stage can be computed by, (19) where in the current session s, y CC s and y CV l are the energy demand in the CC and CV phases. Additionally, the duration of this phase,t CC , i.e. the switching time as shown in Fig. 1 (20) that b 0 is the actual charging power measurement at the plug-in time. Subsequently, the charging profile can be created through, where b l j is the actual charging power of the CV phase during the last full charge. As a result, the average of the constructed power profile provides b av in (5b) in order to facilitate the provision of an optimal solution by the proposed optimization problem, as mentioned.

IV. EVALUATION FRAMEWORK
The controller continuously monitors the actual output signal, b s k , to detect the connection time. Once the PEV is plugged in, it solves the optimization problem over the decided control horizon, T , based on the predicted energy demand. At this point, the controller performs the PEV charging by utilizing the control actions as the solution of the optimization process.

A. POTENTIAL SAVINGS CALCULATION
After each charging session, the performance of the controller is evaluated by analyzing the saving that is obtained from the controlled charging through, where CU C and CCC denote the cost of the uncontrolled and controlled charging, respectively.

B. INTERACTION WITH THE CAR OWNER
The proposed controller eases the incorporation of the PEV owners in the charging scheduling by providing them with the choice of approving or modifying its decision. Information that can be communicated with the owners includes the amount of required charging energy, the potential savings, the estimated driving range, and the charging schedule. The rough range corresponding to the estimated energy requirement can be obtained by using [47], where RDR represents the rough range estimate and d EP A expresses the EPA-rated combined fuel economy. For example, for the Nissan leaf 2016 (30 kWh), the d EP A is 19.1 kWh/100 km [48].

V. RESULTS AND DISCUSSION
The performance of the proposed online PEV charging controller is extensively discussed in this section. Two scenarios based on two types of electricity price signals are considered. Herein, actual charging data and electricity price signals are used to demonstrate a realistic perception of the controller performance.

A. CASE STUDY PREPARATION
The performance of the proposed controller for managing PEV home charging is evaluated by using actual charging data. This data has been collected from a level-2 local charging station (240V), located in an institutional center in Trois-Rivières, Quebec as shown in Fig. 5. A National Instruments acquisition system has been connected to each EVSE to measure charging voltage and current data. The PEV, considered in this case study, is a Nissan Leaf 2016 whose specifications are detailed in Table 2. The charging data has been collected from March 27, 2017, to January 15, 2018. The total number of charging sessions, performed by the PEV, during this period is 112. Since the controller is intended for home charging applications, a preprocessing step is applied to the collected data from local EVSE in order to advertise a pertinent attribute. This step is mainly executed by shifting the time index (charging time) of charging demand. Accordingly, the charging station arrival (departure) time is interpreted as household   . It is worth mentioning that this procedure has been carried out due to difficulties in supplying adequate data from homes, which can enable feasible investigations. Nevertheless, the values of the resultant charging power profile remain unchanged. Fig. 6 depicts the KDE applied to arrival and departure time according to home charging scenario i.e. shifted profiles. It can be observed that the plug-out normally occurs around 7:40AM while the plug-in happens around 6:40PM, which is consistent with NHS information. Besides, two types of actual price signals are considered as illustrated in Fig. 7. Both signals are based on time-variant prices. The first profile corresponds to Ontario actual TOU pricing. The second one is a modified version of the first signal that has the same average value but higher variations to reflect other possible dynamics.

B. DEPARTURE TIME DISTRIBUTION
The clustering procedure, explained in III-C, is applied to the data, resulted from the preparation phase. In the first step, this process yields three different arrival time clusters. These groups account for evening and night (5pm to 5am), afternoon (1pm to 5pm), as well as morning (5am to 1pm) regarding the descending order of their density values. Such classification is manifested by the overall plug-in time distribution, presented in Fig. 6. In the second stage, the clustering method provides the controller with three different departure time distributions corresponding to the plug-in time classes as depicted in Fig. 8  updated based on new observations after each charging session. In fact, the charging database is gradually enriched by new measurements. This, in turn, assists with capturing the seasonality of data and improves departure-time inferences. It is noted that efficiency in modeling conditional departure time is a result of differentiating between charging sessions according to their plug-in time. Such an approach can be useful for other charging locations.

C. FORECASTING OUTCOMES
In this section, the performance of the designed predictive model is assessed. Accordingly, a comparative study is carried out by using the Ridge Regression (RR) method. As a frequentist-based technique, the RR is an appropriate choice considering the suggested scheme, which is based on the Bayesian inference. To be specific, RR uses the Ordinary Least Squares (OLS) to estimate the model parameters while the Bayesian method infers the posterior probability distribution of those parameters by utilizing a set of priors. In addition, a sensitivity analysis is performed prior to this comparison in order to evaluate the most important predictive variables.

1) Sensitivity analysis
Although the predictors, x s , defined in Subsection III-D, are typical components of time series forecasting methods, only a few of them are significant for PEV energy requirement prediction. Therefore, it is important to perform a sensitivity analysis to examine the degree of predictability of each predictor and consequently select the most relevant ones. In order to avoid the computational complexity of Bayesian algorithm for the feature selection, this procedure is carried out by the Ridge regression model. For this purpose, a portion of data is divided into the training set comprising 56 data samples (28 charging sessions), and the test set containing 100 data samples (56 charging sessions). The result of the sensitivity analysis is presented in Fig. 9. This figure shows the coefficient of determination score, R 2 , for the combination of the most effective predictors, which are selected sequentially by starting from the best one. It can be observed that the most important predictor is the connection time, t pi , which is responsible for about 50% of R 2 . The result accuracy increases to around 64 % for the combination of five best predictors, x 1−5 . Afterwards, the value of R 2 slightly increases by adding new predictors.

2) Comparative study
In order to exercise the comparative analysis, both predictive models are trained with data from March 27 to May 30, 2017. The total number of charging sessions is 29 during this period. Afterwards, the methods are tested by exploiting data from May 31 to January 8, 2018 in an on-line manner. It should be mentioned that the training phase is processed over a window that is expanded with the arrival of new charging session data. Bayesian model is performed by using the PyMC3 Python package. A Gamma distribution with the shape and scale parameters equal to 3 is considered as the prior for σ according to (15). Furthermore, a Normal distribution with the mean and variance of zero and 20 is used as the prior for θ in accordance with (16). These priors have provided the best results based on an extensive number of tests.  Table 3 and Fig. 10 show the results of both models, applied to the test data. The outcomes are evaluated by R 2 , Root Mean Square Error (RMSE), and Mean Absolute Error (MAE) as the accuracy metrics. Regarding the forecasting precision, the Bayesian approach operates efficiently, and its performance is relatively higher than the RR technique for a different number of predictors, as presented in the Table  3. More importantly, the Bayesian inference is superior to the RR due to its ability to offer a means for quantifying the model uncertainty, as shown in Fig. 10 (light-orange regions). This advantage can result in a robust control over PEV charging by decreasing the risk of missing energy storage, essential for user satisfaction. In fact, the upper bound of the quantified uncertainty is exploited to characterize y min in (18). However, this is not the case for RR that estimates only the expected value of charging demand. Only the five best predictors consisting of t pi , y s−7 ,T s , w k s , and y s−6 are used in the rest of the analysis considering the outcomes similarity, implied by Table 3. It should be added that y s−l refers to the last l th charging session.

D. ONLINE CONTROL PROCESS
The performance of the proposed controller is evaluated over the entire database, which contains the information of all possible daily trips. The evaluation is carried out within the following steps by exploiting the data of Dtest.

1) Proposed controller operation
As depicted in Fig. 11, the charging scheduling is performed within two main phases. The series of events within the first stage is illustrated in Fig. 11.a. In this step, the controller detects the PEV connection time (blue dashed line) by observing the actual power measurement, b k , and estimates the required amount of energy to charge its battery,ŷ min s , by using the forecasting model. Subsequently, it constructs the charging power profile by using the estimated energy demand and the charging session history. Afterwards, the optimization problem is solved in order to define the best control action according to the price signal and the decided horizon in terms of parking duration (blue line). At this point, the controller informs the user about the optimal charging policy, especially the likely driving range (RDR). For example, the RDR corresponding to the PEV charging case in Fig. 11 is 81 km. In the second stage, the on-line charging is implemented based on the decided control action as indicated in Fig. 11.b. It can be observed that in the implementation step, the estimated charging needs are managed by the binary control signal. The controller allows for charging the battery only at the ON state according to this signal (control action = 1). This can lead to situations in which the minimum demand is not satisfied because of the lack of an accurate estimation of the initial energy requirement. As illustrated in Fig. 11.b, this case is likely to occur where the expected charging power is exploited (orange-dashed line). A control action that relies on the single best estimate (exact expectation) by employing non-Bayesian methods like RR can notably deteriorate this issue. However, a design that integrates parameters uncertainties into the controller's decision can offer a robust process. Therefore, it can relieve this concern by using parameters' posterior distributions to satisfy the user preference through a confidence level. This has been achieved by the proposed design as depicted by Fig. 11.b (greendashed line). Figure 10 clarifies this matter by demonstrating single point and posterior distribution estimations of PEV charging demand as the key difference between RR and Bayesian techniques, respectively. It should be highlighted that the on-line decision making process can be perceived from the actual charging profile following the current time across the decided horizon in Figs. 11.a and 11.b.
Regarding the operation time, the controller takes less than 2 minutes to provide the decision on charging scheduling. This time mainly belongs to the forecasting process and optimization problem, which generally take 40 seconds and 30 seconds, respectively. The controller operates every 10 minutes (time step), and thus, its decision needs are not violated by the computational time. It should be noted that the simulations are run on an Intel i7-9700 CPU@3 GHz processor with 16 GB of RAM.

2) Proposed controller performance
The performance of the proposed controller is evaluated over the test data, Dtest, which contains the information about different daily trips within around one year. The evaluation is carried out through a comparative study by using two other scenarios. The first case represents the uncontrolled charging where the PEV charging starts immediately after plug-in. The second case accounts for the controlled charging based on the deterministic approach. A controller based on this method has direct and complete access to PEV critical parameters comprising exact departure time, SOC (from the on-board controller), and charging power profile shape to perform charging scheduling. As a full information-based method, the deterministic scheme leads to the best result. Therefore, this scheme is a perfect choice for a benchmark to evaluate the performance of the stochastic technique, which does not utilize complete information. Fig. 12 presents the cumulative cost of charging. Throughout the charging sessions, the average saving of the proposed controller is about 29.1% and 45.4% more than the uncontrolled case for the dynamic and TOU pricing, respectively. In addition, the designed controller is very competitive with the deterministic scheme, which takes advantage of full information to provide the optimal charging schedule. To be specific, the slight difference between both methods can be attributed from one side to the high performance of the proposed stochastic process and from the other side to the influence rate of the uncertain parameters. Nevertheless, the latter does not justify the utilization of the deterministic approach since the full information modeling is not a feasible scenario due to inherent departure time uncertainty, charging power non-linearity, and on-board controller information inaccessibility, especially in a long run. In other words, real-world circumstances make a stochastic approach to PEV charging scheduling inevitable, as the main focus of this paper. In this regard, the suggested charging scheduling method achieves a remarkable efficiency despite the uncertainties related to the predictive model and the departure time. It significantly reduces the charging cost while ensuring that the PEV battery is sufficiently charged at the The results show that the proposed controller is capable of handling PEV charging under uncertainties of real practices. It can be deduced that the developed mechanism can significantly reduce users intervention in the decision-making process and facilitate owners' adoption. In addition, the proposed data-driven approach is able to learn different charging patterns if presented with sufficient data. This can be acknowledged from the forecasting model that is applied to historical observations with charging period diversity (day and season types). Moreover, the design takes advantage of a stochastic decision making mechanism based on robust optimization, which can assist with handling randomness of real-world circumstances.
Besides, the whole analysis provides important materials, in terms of data and methods, that can facilitate the development of efficient PEV charging systems for other practices. Additionally, it points out important remarks with regard to future investigations. Considering prerequisites for a useful modeling practice, this research suggests a comprehensive dataset that comprises the information related to plug-in/plug-out time, actual SOC from PEV on-board controller, and charging power of multiple charging sessions. Furthermore, it offers the development of a proper infrastructure to provide the PEV charging controller with the essential data in order to build relevant models for the charging scheduling analysis. Regarding car owners' role in realizing useful energy management systems, this investigation recommends exploring users' willingness to regularly share their information, especially departure time and charging desires (final SOC). This suggestion, in turn, promotes the study on customized charging models based on user preferences as an interesting subject. Such an analysis can be conducted in the context of power grid services where users' satisfaction rate, in terms of flexibility, is examined to benefit them with cost saving opportunities while maintaining the system operator interest.

VI. CONCLUSION
This study proposes a practical PEV controller to perform charging scheduling under uncertainties related to real-world circumstances. The suggested controller does not require significant resources and can be easily implemented by users. The utilized methodology comprises two main steps. The first step deals with predicting the required energy for charging at the plug-in time based on a predictive model. The second step involves utilizing a stochastic optimization to minimize the cost of charging considering the predictive model and departure time. The performance of the proposed approach has been evaluated by exploiting actual charging data. The designed stochastic framework carries out PEV charging scheduling with a remarkable efficiency, similar to deterministic scenarios with full information access. It ensures an adequate battery charge at the departure time while reducing the energy cost.

ACKNOWLEDGMENT
This work was supported in part by the Laboratoire des technologies de l'énergie (LTE) d'Hydro-Québec, the Natural Science and Engineering Research Council of Canada and the Fondation UQTR.