{'fraction_non_alphanumeric': 0.030455801104972376, 'fraction_numerical': 0.005870165745856353, 'mean_word_length': 4.576930483342962, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
QoS guaranteed online management of battery swapping station under dynamic energy pricing

Further popularisation of electric vehicles (EVs) is hindered by their relatively short driving distance and long battery charging time. To overcome these shortcomings, the battery swapping station (BSS) has been proposed as a means of satisfying the increasing demands for fast EV battery recharging. At a BSS, (partially) depleted batteries from EVs can be replaced with partially or fully charged ones almost instantaneously. Recharging scheduling and maintenance of batteries are done by the operator of BSS, with the target of minimising electrical energy costs while satisfying customer demands. In this study, the authors consider a realistic BSS framework in which EVs can arrive at BSS with time of day dependent rates having different battery state-of-charges. They investigate the battery charging scheduling problem in the BSS under a dynamic energy pricing. They solve (i) an online optimal BSS control problem to minimise the energy cost with a quality-of-service (QoS) guarantee, and (ii) an offline optimal BSS design problem to determine the optimal number of stored batteries so as to achieve a desirable tradeoff between flexibility in charging and amortised battery costs. The experimental results show that the total charging energy cost can be reduced significantly under different traffic scenarios.


Introduction
Electric vehicles (EVs) have long been considered as one of the potential alternatives for fossil fuel-based vehicles in order to alleviate the energy efficiency and environmental concerns. Relatively high oil prices caused by the depletion of oil reserve and large greenhouse emissions have been strong impetus for the wide penetration of EVs. However, relatively short driving distances and long battery charging time in battery charging stations hinder the rapid popularisation of EVs. EVs still have a number of disadvantages which hinder their further prevalence. A well-known shortcoming of EVs is their short driving range and long battery charging time, which can greatly affect the driving experience. AC Level 1 and AC Level 2 charging as commonly seen in EV charging stations can add around 2-5 and 10-20 miles of driving range per hour of charging [1], respectively, which are far more time consuming than refuelling a car using gasoline. Even the state-of-the-art DC Level 2 fast charging technology can achieve no more than 150-200 miles of range per hour of charging [1], which is still about ten times slower than adding the same driving range to a conventional car with a gas pump. A new business model of building a network of fast battery swapping station (BSS) has been proposed to address this challenge and is supported by major EV manufacturers such as Tesla [2], Mitsubishi [3], and so on. In a BSS, depleted or partially depleted batteries can be easily replaced by fully or partially charged batteries [4,5]. Drivers only need to wait for a short period of time for dismounting and loading batteries. By adopting the battery swapping strategy, customers are released from the time-and energy-consuming recharging operations and the maintenance of batteries, which are implemented in the BSS. Charge scheduling of batteries is managed by the operator of the BSS, targeting minimisation of the energy cost and satisfying customer demands at the same time, with the potential of enhancing grid stability by properly responding to the dynamic energy pricing policies [6,7].
Different from the traditional 'park and charge' scenario, the battery swapping concept is a relatively new idea with only a history of a few research investigations. Zheng et al. [8] and Yang and Hao [9] focused on the optimal installation location problems of BSS. In [8], the battery charging/swapping station models are developed to compare the revenue of rapid-charging stations and BSSs using life-cycle cost analysis. Yang and Hao [9] proposed a heuristic to determine the location strategy of BSS and the routing plan for a fleet of EVs under battery driving range limitation. Sun et al. [10] formulated the battery charging scheduling problem in a BSS as a stochastic control problem using the queueing network model, and derived the optimal solution using dynamic programming. In [11], Yang et al. compared the BSS and the traditional battery charging stations and analysed the market strategy of BSS to increase the profit from the energy price fluctuation, but only fully charged batteries could be swapped in their model, which is not practical. These previous works are based on stationary models and have not effectively integrated battery charging scheduling with the time-varying EV arrival rate, the dynamic energy price fluctuation, which limits their practicality in actual implementations. EVs may arrive at the BSS requesting for swapping service with different rates at different times-of-day, and the state-of-charges (SoCs) of the batteries for replacement may also vary. The BSS operator needs to make online adaptive decisions about the charging scheduling of (partially) depleted batteries based on the battery SoCs, the dynamic energy pricing policy, and estimated EV arrival rates.
Different from the aforementioned works, we consider a realistic BSS framework in which EVs can arrive at BSS with time-of-day arrival rates, different battery SoCs, and different requested battery qualities. With a prediction of the future EV arrival rate, the BSS will determine the optimal charging schedule, i.e. charging speeds and charging deadlines, of its stored batteries. We formulate (i) an online optimal BSS control problem in order to minimise the energy cost with quality-of-service (QoS) guarantee for EVs under dynamic energy pricing scheme, as well as (ii) an offline optimal BSS design problem to determine the optimal number of stored batteries in the BSS to achieve a desirable tradeoff between the higher flexibility in battery charging and swapping services to EVs (when there are more stored batteries) with the lower amortised battery degradation cost (when there are fewer stored batteries). We solve the online BSS control problem using the proposed battery swapping charging algorithm (BSCA), and solve the offline BSS design problem using heuristic search techniques. In this work, (i) we consider the differentiation of requested batteries for QoS purpose. The batteries to be swapped do not need to be fully charged ones. More general, differentiating batteries with different quality levels can be extended to the case in The rest of paper is organised as follows. The detailed system model and problem formulation are described in Section 2. Section 3 presents the solution methods of both BSS control problem and BSS design problem. Experimental results are followed in Section 4.

BSS system model
The general BSS system multilevel design architecture is proposed in Fig. 1. The swapping centre at the bottom level is the interface for delivering swapping services to the incoming EV traffic. The battery coordinator manages all stored batteries inside the BSS and has the ability to set target SOCs and appropriate charging deadlines for batteries based on a probabilistic prediction of the near future EV traffic. A target QoS must be provided. The battery charging scheduler aims at deriving optimal charging rates for batteries in response to energy price fluctuations, and meeting constraints, such as battery characteristics, desired QoS levels.
In order to fulfil the swapping requests from the incoming EV traffic, the BSS should be equipped with a sufficient number of batteries. Let N denote the total number of batteries in the BSS of interest, and let T = 24 h denote the optimisation time horizon of the BSS management problem. Obviously, the number N, which is the count of batteries stored in the BSS at any time t, will remain fixed during the whole day. In a realistic BSS system, each battery + could be either fully charged or (partially) depleted, i.e. its charging demand D j ≥ 0 can be an arbitrary value according to the target SOC for that battery. Finally, the number of batteries N in the BSS needs to be optimised since storing more batteries than needed will incur a more significant capital cost and battery maintenance cost.
Suppose the ith EV arrives at time t with the battery state-ofcharge SoC i , the battery nominal capacity C i , the maximum battery charging rate V i , and the requested battery SOC i r . If there is a stored battery with a SOC at least SOC i r , the battery on the EV will be replaced by the stored battery j (SOC j ≥ SOC i r ) in the BSS based on a swapping policy, supposing that each stored battery in the BSS has a unique index (ID) j ∈ {1, 2, …, N}. The information of stored battery j should be updated with the dismounted battery, i.e. the starting time t j s = t, SoC i , and R j . With the updated information of all stored batteries, the battery coordinator determines target SOC j t and charging deadlines t j d for all batteries j ∈ {1, 2, …, N} according to a prediction of future traffic and a desirable QoS level. At the battery charging scheduler level, optimal charging rates s jt for the jth battery at time t can be determined so as to minimise charging costs while considering battery characteristics and charging deadlines.
Similar to previous works [10,12], the instantaneous power consumption of BSS satisfies a general quadratic function of the total charging rate of batteries at time t, i.e. S t = α ∑ j ∈ J t s jt 2 + β ∑ j ∈ J t s jt , where J t is the set of batteries being charged in the BSS at time t, α and β are parameters accounting for various aspects of energy loss such as the battery's rate capacity effect, the loss inside batteries, the energy loss in DC-DC converters and other conversion circuitry, and so on [13,14]. We derive α and β parameters from our actual measurement results for a number of different batteries and the requisite conversion circuitry. In our BSS charging scheduling model, the dynamic energy pricing scheme from the utility grid is considered. Dynamic energy pricing programs allow customers to pay a temporally fluctuating market rate for their electricity [15][16][17]. Price is higher during the peak hours than off-peak periods, encouraging users to shift loads to off-peak hours to lower their electric energy cost, thereby relieving the stress on the utility grid [18]. Let ξ(t) denote the energy price at time t.

Battery charging scheduler
Based on the above definitions and system modelling accounting for the energy price fluctuation, the static version of the battery charging problem at the battery charging scheduler level for energy cost minimisation is described as follows.

Static version of battery charging problem for energy cost minimisation.
Given: the charging starting time t j s , deadline t j d , maximum charging rate R j , charging target SOC j t and current SOC j for each battery j at time t, 1 ≤ j ≤ N. Find: the optimal charging rate s jt for j battery at time t. Minimise: Subject to: where constraint (1b) ensures that the charging demands of all batteries are satisfied during the time interval between the starting time and the deadline. Constraint (1c) ensures that the charging rate cannot be negative or exceed the maximum charging rate for each battery. The charging demand is zero if target SOC j t ≤ SOC j , which is described by constraint (1d). For the static version with charging demands, (t j s , t j d , D j , R j ) of all batteries are given to the BSS battery charging scheduler. The problem is thus a convex optimisation problem with a convex objective function and linear constraints, and therefore can be solved optimally with a polynomial time complexity [19]. However, in reality, the BSS management problem is essentially an online adaptive problem, in that EVs can arrive at the BSS at random times during a day, and a dismounted battery along with all other stored batteries can have arbitrary charging demands and deadlines that are determined by the BSS battery coordinator. Therefore, the BSS battery coordinator should adaptively provide appropriate inputs to the battery charging scheduler based on the current status and prediction of future arrival of EVs, in order to satisfy the QoS constraint. Details of the BSS battery coordinator are described in the next subsection.

Battery coordinator
In our proposed multilevel architecture, the objective of battery coordinator is to determine the charging target SOC and deadlines for a batch of batteries in the BSS with the guarantee of QoS levels based on the EV traffic prediction.

QoS guarantee:
The swapping service request of an EV can only be fulfilled if the BSS has at least one battery at the requested quality level in stock (i.e. N L t ≥ 1, L indicates the quality level). Please note that only the SOC of battery is considered as the requesting quality level. However, the quality level can be generalised to the case in which manufactures, capabilities, and other battery metrics can also be included. In reality, the customer might request a partially charged or a fully charged battery depending on his/her specific road trip plan. Battery options with varied qualities should be provided by the BSS. Similar to the work [20,21], we model the EV arrival process as a time-variant Poisson process. Let λ L (t) denote the arrival rate of EV requesting a battery with a quality level L at time t. Then the probability of k EVs arriving during time interval [t, t + Δt] is given by At time t + Δt, the number of quality level L batteries is N L t + Δt and thus a total number of ∑ L m N L m t + Δt EVs can be served, where m is the discrete quality level index. From (2), the probability that the quality level L requirement of EVs can be satisfied is given by which equals the probability that no more than N L m t + Δt EVs will arrive in the prediction sliding time window [t, t + Δt]. Let ρ denote the QoS tolerance level for the BSS, then P L m QoS should satisfy the constraint P L m QoS ≥ ρ.

Battery coordination:
Given the time window [t, t + Δt], predicted arrival rates λ L (t) and QoS tolerance value ρ, we can calculate the least number N L m t + Δt of level L m batteries which should be ready for swapping at time t + Δt, i.e. the charging deadlines. The prediction time window should be varied in an appropriate range, which should consider both the short term and relatively long term. The short-term prediction can help determine more precise deadlines, however, it cannot deploy batteries effectively and would suffer from the short horizon. The long-term prediction would neglect the bursting traffic, which may result in the failure to serve swapping requests. Among all stored batteries, the BSS battery coordinator should select which batteries are swapping candidates for quality level L m requests at time t + Δt, aiming at satisfying QoS and minimising the total charging energy. Let the binary variable x jm ∈ [0, 1] denote whether the battery coordinator sets the charging target of the battery j be L m (1) or not (0). In our work, the quality level L m belongs to a discrete set, for m ∈ [0, M].
Based on the above description, we formulate the BSS battery coordinating problem as follows.
Given: the QoS tolerance ρ, the prediction time window [t, t + Δt], the arriving rate λ L (t), stored batteries SOC j , charging target SOC L m , maximum charging rate R j .
Find: the optimal mapping of a battery j to a charging target SOC L m , which is denoted as the value of x jm , j ∈ [0, N], m ∈ [0, M]. Minimise: Subject to: In the objective function (4a), D jm is the charging demand by setting the target of battery j as L m . The BSS battery coordinator tries to minimise the total charging demand for all batteries. Constraint (4b) captures the fact that the x jm is a binary variable. Constraint (4c) ensures that a battery can be assigned only one target level. Constraint (4d) captures the relation that the number of batteries at level L m should be at least N L m t + Δt in order to satisfy swapping requests at time t + Δt. Constraint (4e) is the charging demand for SOC j targeting at SOC L m . Constraint (4f) ensures that fulfilling the charging demand is feasible considering the maximum charging rate. Constraint (4g) ensures the QoS is guaranteed. Based on the above description and formulation, the minimum number of L m batteries at time t + Δt, N L m t + Δt can be calculated by (3). Therefore, the BSS battery coordination problem is an integer linear programming (ILP) problem, which can be solved in standard solvers.

Online optimal BSS control problem
Based on the discussion before, we describe the online optimal BSS control problem for energy cost minimisation. Given the total number of batteries N of the offline design problem and battery information, the BSS battery coordinator and battery charging scheduler adaptively make deployment decisions and set charging schedules when each EV arrives considering the dynamic energy pricing. An example of the online BSS control problem is illustrated in Fig. 2. The hourly dynamic energy prices are denoted by ξ(1), ξ (2) . . . ξ (24) for the price during each hour The online BSS control problem is described as follows. Online BSS control problem for energy cost minimisation at time t.
Given: Stored batteries information SOC j , the maximum charging rate R j , the battery nominal capacity C j , and the QoS tolerance ρ, the prediction time window [t, t + Δt], the predicted arriving rate λ L m (t), m ∈ [0, M].
Find: the optimal charging rate s j (k) for j ∈ J(t, k) at kth time interval, k ∈ K(t), which is the union of all K(t, j) for all j ∈ J(t, k), given the number of batteries N. Minimise: Subject to: where this online BSS control problem is a discrete-time-based optimisation problem. When a new EV comes and the battery is swapped at time t, the sets K(t, j), J(t, k), and D j (t) are updated. D t is the charging demand for j at time t.The battery coordinator first maps batteries to the target SOC and sets the charging deadlines by solving charging levels in (4). Then, the new charging schedules will be decided by the BSS battery charging scheduler solving (5). Note that the problem described in (1) is a static version of battery charging problem for energy cost minimisation and the charging deadlines of all EVs' batteries are prior known to BSS in (1). The problem of (1) can be optimally solved using convex optimisation but it is not a realistic setting. Here, the problem described in (5) is an online problem involving battery swapping and has QoS constraint. Note that the owners of BSSs can be a third-party company which provides battery swapping service or EV manufactures aiming to improve QoS and concerning about the operation costs. In this case, the formulation would be still reasonable. In Section 3, we will present details of proposed solutions to this problem.

Offline optimal BSS design problem
For a profitable BSS, the infrastructure must be provided at a low cost. In the BSS business model, batteries are owned by BSS instead of EV drivers. It is critical for the BSS to determine an appropriate number of batteries in circulation because the equipment purchasing, maintenance cost, and amortised battery degradation cost will increase when more batteries are in store. The optimal number of batteries is influenced by several key factors, such as the EV traffic, charging demands, and charging rates. A low number of batteries at the BSS can reduce the battery degradation and maintenance cost, but will restrict the freedom of BSS scheduler on charging scheduling exploiting the energy price fluctuation. The optimal number of stored batteries should be derived to achieve a desirable trade-off of the above two factors. Let γ denote the cost per stored battery in a unit time, which includes the maintenance cost and the amortised degradation cost, i.e. the state-of-health degradation. Let Γ denote the capital cost per stored battery. For simplicity, we assume that γ will be constant during a day. Therefore, the fixed cost associated with N batteries during time Δt is N ⋅ γ ⋅ Δt. Given the traffic data for a whole day, the offline BSS design aims at finding the optimal number of stored batteries and charging policies for minimising the total cost. The offline BSS design problem is described as follows.
Offline BSS design problem.
Given: The EV traffic information within a day. Find: the optimal number of batteries N at the design time. Minimise: Subject to: The EV traffic information should be given to the BSS, and the optimal number of stored batteries can be found by a local search procedure. The state of all stored batteries could be initialised based on a proportional rule in the offline design problem to reflect the adjustment of battery number. However, in the online control problem, the initial batteries could be in random states. Notice that the offline BSS design problem requires the solution of the BSS control problem, i.e. the BSS control problem must be solved and the optimal s j (k) profile derived for each possible N value.

Solution method
Based on the aforementioned formulation, a framework for solving the online BSS control and offline BSS design problem, named the battery swapping charging algorithm (BSCA), is proposed in this section to effectively minimise the overall cost. The BSCA algorithm comprises of two parts: (i) solution to the online optimal BSS control for optimal battery coordinating and charging policies in order to minimise the energy cost with QoS guarantee, (ii) offline BSS design for searching the optimal number of stored batteries.

Online optimal BSS control
In the online optimal BSS control problem, the number of batteries N is given by the offline design. At each time t with an EV arriving, a battery having finished its charging process or the dynamic energy price period changing, the stored battery information is updated. Then, charging deadlines and charging SOC targets for all stored batteries are calculated by the BSS battery coordinator with the QoS guarantee. As described in Section 2, the future arrival of EVs is assumed to follow a time-variant Poisson process. Based on the key prediction parameter, the future arrival rate λ L m (t) at time t, the minimum number of batteries N L m t that should be at SOC L m at time t is calculated by using (2) and (3) satisfying the QoS tolerance'. The optimal mapping of the current stored batteries to charging targets SOC L m at time t + Δt is calculated by solving (4). We find the appropriate deadline t j d by searching the prediction time window [t, t + Δt] with increasing Δt at each prediction step. The described problem can be solved using a kernel ILP solver within a loop which increases the prediction window at each iteration.
After determining appropriate deadlines and SOC target levels, information about all batteries B info is updated, and the optimal charging rates of all batteries that minimise the energy cost are derived by solving (5). A package for specifying and solving convex programs, such as CVX [22], or the fmincon function in Matlab, is used in this paper.

Offline BSS design
The offline BSS design problem is solved by a local search method, where searching range is specified as [N min , N max ]. For each number in the searching range, the starting time t j s , deadlines t j d and target SOC levels of all stored batteries and the batteries that can be swapped in the future are calculated by solving (4). Next, the minimum total cost is obtained by solving (6). Using the EV traffic information offline, the optimal number of stored batteries satisfying the QoS constraint is found.
The pseudo-code of proposed online BSCA is provided in Algorithm 1 (see Fig. 3). The input data include the initial N batteries information B init , consisting of the battery profiles (V j , t j s , SoC j , C j ), predicted EV arriving rate λ L m (t), and QoS tolerance level ρ. The output data include the optimal mapping of batteries to certain target SOCs and deadlines, charging rates profile for all batteries. The algorithm is executed when an EV arrives, a battery has finished its charging process, or the dynamic energy price period changes. When a swapping service is requested, the algorithm checks if the BSS has batteries at least at the requested level. The battery can be swapped only if batteries above the requested are available and the stored battery information B info is then updated. Given each Δt within the prediction time window (here, 2 h is default), (2)-(4) are solved for obtaining the optimal mapping of batteries to target SOC levels and deadlines at time t + Δt satisfying the P QoS constraint. The battery coordinator updates the battery mapping results and sends them to the battery charging scheduler for calculating optimal charging rates achieving the energy minimisation under dynamic energy prices. At each decision time epoch, B info is updated based on previous charging rate profiles. In addition, the real-time energy cost from the last decision time epoch until the current time is calculated. Finally, the overall cost for the whole time horizon is calculated.

Experimental results
In this section, we evaluate the proposed BSCA in real-time scenarios. Typical market prices are obtained by averaging dayahead LMP prices from the period August 2015 in the PJM market [23]. The coefficients of the charging cost function are set to α = 0.225/kW and β = 0.13. The battery cost γ = 1.7 $/h, Γ = $3000. According to state-of-art battery charging parameters [24], the requested levels battery swapping can be divided into four groups [25, 50, 75, 100] kWh. For QoS tolerance probability, ρ is set to 95%.
Three scenarios are simulated: (i) light traffic, (ii) moderate traffic, (iii) heavy traffic. First, the offline design problem for the moderate traffic is shown in Fig. 4. From the result, we know that increasing the total number of batteries will gain more flexibility result in reducing the charging cost at the expense of increasing the amortised and capital cost. In order to maximise the avenue of BSS, a carefully offline design is needed considering possible economical parameters.
Three baselines are developed for the comparison of charging cost: (A1) the battery coordinator satisfies the larger target SoC first by randomly choosing feasible batteries, while the deadlines and charging rates are decided the same as the BCSA; (A2) the battery coordinator randomly chooses batteries for charging at an average rate D j / t j d − t j s ; (A3) the battery coordinator manages battery following the same policy as the BSCA, but charges the battery at average rates. For all baselines, a same QoS is ensured. The cumulative charging costs using the BSCA, A1, A2, and A3 are plotted in Fig. 5: light traffic (Fig. 5a), moderate traffic (Fig. 5b), heavy traffic (Fig. 5c). Only the charging costs are considered for comparison. As shown in Table 1, charging costs can be reduced by 45, 92, and 90%, respectively, comparing with A1, A2, and A3 methods under the heavy traffic scenario. By comparing the (A2, A3) or (A1, BSCA), in which charging rates are determined by an identical policy, we can see that the battery coordinator can reduce the charging cost. The reason of the battery charging scheduler in BSCA reducing a significant amount of charging cost is that the charging is shifted to 'off peak' hours when energy prices are lower. This shifting can reduce total charging costs at the end of a day. For the moderate and the heavy traffic scenario, the charging costs are more significantly reduced by adopting the BSCA. For the method A1, especially at the lighter traffic, the charging cost is closed to the BSCA because charging some batteries at lower SOC at the 'off peak' will have the chance to save costs in the future under the condition that the charging rates are optimised as the BSCA. However, this is not guaranteed. Implementing the proposed BSCA in multi design levels in the BSS reduces the charging cost significantly.

Conclusion
The BSS strategy is promising for meeting fast recharging demands in the future. In this work, the battery charging scheduling and design problem are investigated under dynamic energy pricing. An online QoS-aware algorithm, BSCA, is proposed to minimise the charging energy costs and to satisfy swapping requests with a service tolerance probability at the same time. In addition, an offline optimal BSS design problem is solved to find the optimal number of batteries. Realistic EVs swapping and charging experiments are implemented to evaluate the performance of proposed BSCA under three traffic scenarios. The results show that the charging energy costs can be reduced significantly comparing with three other baselines.