A Heuristic Charging Cost Optimization Algorithm for Residential Charging of Electric Vehicles

: The charging loads of electric vehicles (EVs) at residential premises are controlled through a tariff system based on ﬁxed timing. The conventional tariff system presents the herding issue, such as with many connected EVs, all of them are directed to charge during the same off-peak period, which results in overloading the power grid and high charging costs. Besides, the random nature of EV users restricts them from following ﬁxed charging times. Consequently, the real-time pricing scenarios are natural and can support optimizing the charging load and cost for EV users. This paper aims to develop charging cost optimization algorithm (CCOA) for residential charging of EVs. The proposed CCOA coordinates the charging of EVs by heuristically learning the real-time price pattern and the EV’s information, such as the battery size, current state-of-charge, and arrival & departure times. In contrast to the holistic price, the CCOA determines a threshold price value for each arrival and departure sequence of EVs and accordingly coordinates the charging process with optimizing the cost at each scheduling period. The charging cost is captured at the end of each charging activity and the cumulative cost is calculated until the battery’s desired capacity. Various charging scenarios for individual and aggregated EVs with random arrival sequences of EVs against the real-time price pattern are simulated through MATLAB. The simulation results show that the proposed algorithm outperforms with a low charging cost while avoiding the overloading of the grid compared to the conventional uncoordinated, ﬂat-rate, and time-of-use systems.


Introduction
Global warming affects human life in various ways, such as increasing temperature, rising sea levels, and severe floods. It is mainly caused by the massive CO 2 emission from petroleum, natural gas, coal, geothermal, and automobile industries due to internal combustion engines (ICEs) automobiles discharging unhealthy CO 2 . Cars and trucks emit almost 26%, while other transportation methods account for about 12% of carbon dioxide emissions [1]. In the USA, transportation is the second-largest source (34%) of CO 2 emission, • We developed a charging cost optimization algorithm that learns the characteristics of EVs and real-time price patterns and computes a threshold value of price for each arrival and departure sequence of EVs. The threshold value is utilized to schedule the charging operation of EVs with minimizing the charging cost and respecting the operational constraints of the power grid. • We show how the different schemes influence the charging cost and grid overloading by developing charging scenarios for individual and aggregated EVs with fixed and random arrival and departure sequences against the real-time electricity price patterns.
• We evaluated the performance of the proposed CCOA against the uncoordinated, flat-rate, and time-of-use systems in terms of charging cost and grid overloading.
The rest of this paper is organized as follows. Section 2 discusses the literature survey. Section 3 presents the proposed algorithm. The simulation results and discussion are presented in Sections 4 and 5 concludes the paper with related future work.

Literature Survey
In the EVs research, various studies considered the power and daily commute distance patterns with the objective functions of minimizing the power losses, voltage deviation, and fleet consumption for aggregated EVs [15][16][17]. A charging load optimization algorithm for a fleet of EVs based on dynamic programming with the assumption of arrival and departure sequence of 8:00 AM and 6:00 PM was studied in [9]. Their proposed scheme showed approximately, a 17% reduction in the daily load profile compared to the conventional dumb charging scheme. The authors in [18] studied the charging load optimization of aggregated households through V2G technology. The study considered 63 households, such that each household was assigned a random electric load profile obtained from Belgian households, and the EV's SoC was approximated, between 20% and 60% through uniform distribution. The authors in [19] considered various factors (i.e., transformer's load, voltage limits, and parking availability) and employed a genetic algorithm (GA) for computing an optimal load pattern for the aggregated EVs. The study investigated various uncontrolled and controlled charging case studies with different penetration ratios of EVs and concluded, that about 85% and 5% were allowed to charge at the valley and peak periods, while in the remaining hours, 10% EVs were charged. The study in [20] suggested a Monte Carlo-based charging control method for aggregated EVs by utilizing the available data on the distribution of departure time, commuting distance, and average power consumption. The work in [21] analyzed the stochastic characteristics of EVs by obtaining the datasets from the Netherlands transportation network. The time of each trip and the traveling distance were considered stochastic variables, and the battery SoC was obtained using the traveled history. Then the power demand of EVs based on the real commuting distance for domestic charging was modeled using a Monte Carlo simulation approach. The authors in [22] developed a multi-location charging scheme for EVs using their travel distances. In this work, the national household travel survey (NHTS) driving dataset was used to derive statistical distributions of travel patterns. Then a simulation was performed to generate trip chains using start time, end time, driving distance, and the end location from the NHTS dataset. The work in [23] presented a data-driven stochastic optimization algorithm for reducing the energy cost of commercial buildings in the Southern California region. The work considered the uncertainty associated with the availability of plug-in electric vehicles (PEVs) for charge and discharge and modeled the energy cost optimization problem using mixed integer linear programming (MILP). The study in [24] considered the local electricity market to develop an energy trading mechanism for consumers and prosumers to reduce congestion, energy cost, and intermediate players, such as retailers. In our previous works [25][26][27], we highlighted the requirements of the power grid, parking lot operators, and developed charging and discharging algorithms based on fuzzy inference systems. The developed fuzzy inference system was able to incorporate the uncertain available power, the SoC, and the dwell time of EVs into an aggregated control variable. The developed algorithm utilized the aggregated control variable to coordinate the charging and discharging of EVs in each sampling period. The authors in [28] considered the driving cycles from traffic information for optimal management of EV charging. The proposed scheme was simulated with several standard driving cycles, and the results showed significant improvement in comparison to rule-based control and a depletion sustenance control scheme. A game-theoretic with a non-cooperative strategy coupled with the electricity prices for minimizing the charging cost of PEVs was proposed in [29].
In contrast to the electricity prices profiles, these papers mostly studied the power consumption pattern while optimizing the charging and discharging of a load of EVs.
The study in [30] introduces three different tariff systems (i.e., electricity rates) for coordinating the charging operations of EVs at residential premises. These tariff systems correspond to fixed electricity rates (i.e., constant rates), time-of-use electricity rates (i.e., dual rates, according to off-peak and on-peak periods), and real-time rates (i.e., the rates which vary according to the time of day). The work combined the electricity tariff systems, the vehicle commuting distances, and the battery types to approximate the charging start time and the overall duration of the charging for each type of battery. The proposed method is applied to a 38-node distribution system from the U.K. and compared with four different charging scenarios (i.e., uncontrolled domestic charging, uncontrolled off-peak domestic charging, smart domestic charging, and uncontrolled public charging). The performance was measured through electric load profiles for different penetration levels of EVs.
However, this work assumed a long stay time of EVs while ignoring the dwell time of EVs, and thereby the computed charging schedule may not be feasible for EVs with different dwell times. To fill the gap, we develop a charging CCOA that utilizes the battery size, current SoC, arrival departure times, and the real-time price profile for coordinating the charging schedules within the dwell times of the EVs with optimizing the cost at each scheduling period. The developed CCOA captures the charging cost of each charging activity and aggregates the holistic cost until the battery's desired capacity of each EV.

Proposed Charging Cost Optimization Algorithm
The charging process of EVs can be performed via either uncoordinated or coordinated charging. The former case depends on the connection and starts charging immediately once the EVs are plugged into the CSs. In contrast, the latter case coordinates the charging of EVs by considering some external factors such as the power system requirements, the driving behavior, the charging time and cost, and the power demand of EVs. This section provides a detailed discussion on the two charging categories and presents the underlying mechanism of the proposed CCOA.

Uncoordinated Charging
The uncoordinated charging is generally based on the EV user's energy requirements and the availability of the CS. For instance, the EVs need a recharge to fulfill the charging need for their next trip journey. The uncoordinated charging begins the charging process as soon as an EV is plugged into a CS. By modeling the uncoordinated charging method, it is possible to find the consequences of the charging behavior on the grid side, such as the electric load and the charging cost at the customer's premises. In this work, we are interested in modeling the charging activities of EVs for analyzing the cogent effect on the charging cost. A detailed procedure of the uncoordinated charging process is illustrated in the flowchart in Figure 1. At any t, the algorithm checks whether an EV is plugged or not. If no connection is detected, the algorithm increments the t and repeats the checking process again. However, if an EV is connected, it collects the data from the EVs and checks the SoC against the BC, and calculates the electric load and cost for each charging activity. This process continues until the battery is fully charged. Then it checks the time against the maximum time limit and accordingly increments the time step to either repeat the procedure or terminate the algorithm.

Coordinated Charging
In contrast to uncoordinated charging, the coordinated charging algorithms aim to determine the time moments (i.e., charging schedule) that represent the start or stop of the battery charging process. Therefore, the algorithms are modeled based on external factors such as electric load profile, vehicle trip distance, electricity tariff-based system, and real-time electric load and price profiles. This section presents a detailed discussion concerning the TOU tariff systems and the proposed CCOA algorithms.

Time-of-Use Tariff Systems
The tariff system defines electricity rate structures concerning different periods, thus called TOU [31]. These systems are adopted to encourage the EV owners to recharge vehicles during off-peak time. Three different tariff system such as flat, single, and multitariff systems are discussed in [30]. According to their work, the standard tariff system uses a fixed electricity rate. In the presence of TOU, the C for i-th is a function of the E consumption with the P in that particular time of use period. Considering the following example with discrete time steps, we deduce the formulation for the charging cost C of an i-th EV. Let us consider the scheduled EV1 ( Figure 2b) discussed in [32] having a battery capacity of 40 kWh. The EV1 has an t a and t d such that (t a = 3, t d = 12) and has a SoC of 25% (10 kWh). Considering the arrival and departure sequence, the S t is computed to be 10 time steps i.e., (S t = t d − t a +1) such that the arrival is at the start while the departure is at the end of time steps t a = 3 and t d = 12. It is envisioned that each time step is 15 min with delivering energy E = 5 kW/t) and thereby requires 6 time steps to complete the charging requirements. The coordinated charging considers a decision variable D for EV1 (i.e., D EV 1 ) to control the charging process according to the three tariff systems as illustrated in Figure 2. First is the flat-rate tariff in which the EV is charged with an average fixed price P for every kWh, as shown in Figure 2a. In this case, each of the time steps costs the same price, and thereby the charging cost is proportional to the energy consumption. Second is the TOU tariff, in which the prices are based on the time of use of energy consumption and remain constant until a certain period. Usually, the prices are average prices linked to the day-ahead spot price. Depending on the TOU, there can be three different possible prices, the P1, P2, and P3 [33]. The charging cost of EV1 can be computed according to the sum of the product of charging power (charging energy), charging price, and the decision variable at each time. Let C EV 1 denote the charging cost of EV1 for the consumed energy E with the charging price P in each time step t. The charging cost based on a flat rate tariff can be computed as ). This implies that with constant energy consumption E in each time step t, the charging cost C EV i for the i-th EV is computed for each of the tariff systems using Equation (1).
where the flat prices are the average constant charging cost in each time step and are usually computed for 24 h. Similarly, the tariff system corresponds to different prices according to the off-peak, mid-peak, and on-peak time steps, with a constant average cost for four h (i.e., 00:00-04:00, 01:00-05:00, 02:00-06:00, 03:00-07:00, and 04:00-08:00) [28]. However, the dynamic nature of EV owner's behavior on arrival, departure & stay time, and their distinct energy requirements are the major obstacles in following the TOU tariff systems. The real-time prices are a more natural option for optimizing the charging cost but present complexity and challenges when dealing with the multiple inputs from both the EVs and the power grid in each time step [34].

The Proposed Charging Cost Optimization Algorithm
The proposed CCOA optimizes the charging cost of EVs through real-time prices following the system model, as shown in Figure 3. It consists of several functional components including, the power grid, grid operators (i.e., TSO, DSO, and the utility grid operators), the LV distribution network, CCOA, and the households with EVs. The power grid is the power generation source from various sources such as coal, natural gas, nuclear, and renewable energies sources (i.e., solar and wind) [35]. The TSO is responsible for the smooth operations and reliable transmission of power from generation (power grid) to the given area (i.e., DSO) by a high voltage transmission, as well as robust and cost-efficient network [36]. In coordination with the TSO, the DSO facilitates the end-users by managing and distributing the energy from the power grid to the consumers through the LV-distribution network [37]. The utility company deals with the economic aspect of electricity in the wholesale and retail markets. The wholesale and retail markets correspond to the electricity trade between the utility company, the power grid, and consumers [38]. The CCOA deals with the retail market prices and coordinates the charging operation of EVs according to the real-time price within their stay time. The stay time S t of an i-th EV (i.e., S t i ) is a function of the arrival-departure sequence (t a i , t d i ), and the E r is the function of SoC and BC as given by Equations (2) and (3): Considering a constant C r at each time step t, the RT and i-th EV (i.e., RT i ) depend upon the amount of energy demanded as computed in Equation (4). The P h can thus be computed according to price vector P and the stay time S t , for each arrival and departure sequence (t a , t d ) as given in Equation (5): The energy consumption E at each time step t is a function of SoC, BC, and the C r as computed in Equation (6). We define the objective function of minimizing the charging cost C for the i-th EV, which is defined as the sum of the product of the energy consumption E and the charging price P, as computed in Equation (7).
subject to: SoC min (t) ≤ SoC i (t) ≤ SoC max (t) (11) where D is the binary decision control variable with values [0, 1] representing postpone and charge operations. The objective function Equation (7) is subject to several linear constraints, for example the required time RT to charge should be less than the stay time S t and the price P at any time step t, and should be less than the computed threshold price values P h as given in Equations (8) and (9). Similarly, the charging rate C r should be within C min r and C min r while the SoC should follow the SoC min and SoC max boundaries as defined by Equations (10) and (11) [39,40]. To resolve the objective function for optimizing the charging cost, we present two algorithms given in Algorithms 1 and 2 with the following details.

Algorithm 1 Main Algorithm of the proposed charging cost optimization algorithm (CCOA)
Input: Arrival and departure times, battery capacity, state-of-charge, and price profile Output: Optimal charging cost and electric load profiles 1: Initialize the system local and global variables 2: Load the electric load (L) and price (P) vectors 3: for t ← 1 to |T| do 4: for i ← 1 to |N| do 5: Compute S t and E r According to Equations (2) and (3) 6: Compute RT and P h According to Equations (4) and (5) 7: Validate constraint defined in Equation (9) 8: for j ← 1 to |P| do 9: if P[j] ≤ P h [i] then Validate constraint defined in Equation (8) 10:

FTS[i] ← P[j]
Feasible time steps for charging 11: end if 12: j ← j + Print the updated results 29: end for 30: t ← t + 1 31: end for Step 1. Initialize all the system local and global variables (i.e., N, t, i, j, k, and the arrays) and load L and price P vectors.
Step 2. Collect the input data and compute the stay time S t , required energy E r , required time steps RT, and the threshold price P h value for each of the i-th EVs, using Equations (2)- (5). Moreover, for each EV, validate the constraint defined in Equation (9). Step 3. Collect the FTS for charging each of the i-th EVs according the threshold price value defined within their arrival and departure sequence in lines 7 to 12.
Step 4. Get the first price value from the feasible time steps FTS a.k.a. the feasible solution set and compute the OTS by setting the decision D variable for each of the i-th EV in lines 15 to 25.
Step 5. Call the subroutine Charge_Control (i.e., Algorithm 2). First, it validates constraints defined by Equations (10) and (11). Then, it checks the optimal charging steps, the decision variable, and the energy requirements and thereby controls the charging process of EVs according to their optimal schedules. For each charging, the activity updates the charging cost and the electric load vectors in lines 6 to 12. Finally, it returns the updated SoC, charging cost C, and electric load L vectors to Algorithm 1. Step 6. Print the updated results. Increment the time step t and repeat the process for the remaining intervals. Validate constraint defined in Equations (10) and (11) 5:

Simulation Results and Discussion
The simulation is based on three types of price profiles, including real-time, flatrate, and time-of-use TOU [41], as illustrated in Figure 4. Moreover, we conduct charging scenarios for individual and aggregated EVs with fixed and random arrival and departure sequences to evaluate the efficiency of the proposed CCOA against UCC, CFR, and CTOU, respectively. For all these scenarios, we assume a η = 0.95 [42], charging rate (C r = 6.6 kWh) [43], and time step (t = 15 min), while the rest of their details are presented as follows.

Individual Charging Scenario
In this scenario, we consider a single household with the baseload (i.e., electric load) profile shown in Figure 5. Moreover, it assumes the EV with known parameters such as arrival & departure time sequence, SoC, V, and i, as given in Table 1. The battery charging process with different charging schemes is shown, in Figure 6. The battery charges in different time steps according to the different schemes. Depending on the connection and flat charging cost, the charging process starts immediately with UCC and CFR charging schemes. The CTOU delays charging until the off-peak period, while the proposed CCOA finds the most optimal time steps and controls the charging process according to the realtime price pattern. Following the charging process, each charging scheme has a different charging load, as shown in Figure 7. All three schemes, except the CCOA, result in a new peak load. The new peak with UCC and CFR is 3.56 kW, while it is 3.27 kW with the CTOU scheme.    The efficiency of CTOU depends on the required time RT steps for charging and thereby exceeding the RT from the TOU period results in overloading the grid load. However, the CCOA learns the real-time prices to find the most optimal time steps for charging such that it avoids grid overload. Following the charging schedules and the grid load, a comparison of charging cost with UCC, CFR, CTOU, and CCOA is illustrated in Figure 8. Compared to all three schemes, the CCOA results in optimal charging cost, and thereby the accumulated charging cost is 265. 10, 151.50, 137.27, and 131.90 cents concerning the UCC, CFR, CTOU, and CCOA, respectively. This implies that for an EV, the proposed CCOA reduces the charging cost by 133.20, 19.60, and 5.37 cents compared to the UCC, CFR, and CTOU methods.

Aggregated Charging Scenario
To investigate the impact of aggregated EVs on the distribution level, we considered a LV distributed network connecting 102 houses, as shown in Figure 9 [25]. The electric load on the LV distributed network is the sum of all the baseloads of the connected houses and the EVs energy consumption. In realistic situations, the LV distribution network supports EVs with different battery types and capacities. Consequently, EVs with battery capacities of 40 kWh and 53 kWh with a 50% penetration level for each battery type are considered in an aggregated scenario [42,45]. To realize the distinct behavior of the EV users, we generate a random arrival and departure sequences using Gaussian distribution with µ = 6:00 PM, σ = 3 h and µ = 10:00 AM, σ = 2.5 h, obtained from the PDF of NHTS [46], respectively as given in Figure 10. The arrival time SoC for the EVs are distributed through uniform distribution between 20% to 50% of their battery capacities, as given in Figure 11. The different charging methods correspond to different charging loads. A comparison of the charging load concerning the UCC, CFR, CTOU, and CCOA is shown as a violin graph in Figure 12. The average load is about 213.76 kW with the UCC and CFR methods, while it is 185.51 kW and 178.68 kW with the CTOU and CCOA methods. Thus, the CCOA reduces the average charging load by 35.08 kW and 6.83 kW compared to the UCC and CFR, and CTOU methods. The proposed CCOA efficiently handles the charging that helps to maintain the load, while the UCC and CFR, and the CTOU result in new peak loads. The charging cost for the UCC, CFR, CTOU, and CCOA is compared in Figure 13. The figure shows that the UCC has the highest charging cost followed by the CFR and CTOU, while the proposed CCOA has the least cost. The average charging cost is 66.25, 47.65, 38.86, and 29.93 cents with respect to UCC, CFR, CTOU, and CCOA methods, respectively. This implies that the CCOA reduces the average charging cost by 60.00%, 43.00%, and 35.00% cents/kW compared to the UCC, CFR, and CTOU methods, respectively.

Conclusions
In this paper, we developed charging cost optimization algorithms CCOA based on real-time prices for the residential charging of EVs. The proposed CCOA computes a threshold price value for each arrival and departure sequence of EVs and accordingly coordinates the charging process with optimizing the cost while avoiding gird overloading at each scheduling period. The CCOA computes the holistic charging cost until the battery's desired capacity by capturing the cost of each charging activity. Various charging scenarios with individual and aggregated EVs against the real-time price pattern are simulated through MATLAB. The simulation results are verified against the UCC, CFR, and CTOU methods. In the case of individual charging scenarios, the CCOA reduced the charging cost by 133.20, 19.60, and 5.37 cents/kW while avoiding grid overloading compared to the UCC, CFR, and CTOU methods. Considering the aggregated scenario, the CCOA reduced the average load by 35.08 kW and 6.83 kW compared to the UCC and CFR, and CTOU methods. The average charging cost is minimized by 60.00%, 43.00%, and 35.00% cents compared to the UCC, CFR, and CTOU methods, respectively.
This work utilized the day-ahead electric load and price profiles assuming similar household consumption and prices patterns; however, forecasting the electric load and price profiles using neural network algorithms will result in more accurate and realistic analysis. Consequently, in future, the proposed work will focus on incorporating the electric load and prices historical data and neural network-based models. Funding: This publication has emanated from research supported in part by a grant from Cooperative Energy Trading System (CENTS) under grant number REI1633, and also by grants from Science Foundation Ireland under Grant Numbers 12/RC/2289_P2 (Insight), 16/RC/3918 and 16/RC/3835 co-funded by the European Regional Development Fund. For the purpose of Open Access, the author has applied a CC BY public copyright licence to any Author Accepted Manuscript version arising from this submission.

Conflicts of Interest:
The authors declare no conflict of interest.