원시데이터 수집 시스템
선정목록으로

Electric Bus Charging Schedules Relying on Real Data-Driven Targets Based on Hierarchical Deep Reinforcement Learning

관련 수소연료전지 · (5) 연료전지용 수분제어장치(가습기)

기본 정보

저자
  1. Jiaju Qi — School of Engineering, University of Guelph, Guelph, ON, Canada
  2. Lei Lei — School of Engineering, University of Guelph, Guelph, ON, Canada
  3. Thorsteinn Jonsson — EthicalAI, Waterloo, ON, Canada
  4. Lajos Hanzo — School of Electronics and Computer Science, University of Southampton, Southampton, U.K.
DOI
10.1109/access.2025.3571211
저널
IEEE Access
발행년도
2025
발행기관
Institute of Electrical and Electronics Engineers
피인용수
1
라이선스
cc-by
논문 유형
–
언어
–
원문 페이지
https://doi.org/10.1109/access.2025.3571211
토픽
Electric and Hybrid Vehicle Technologies
OpenAlex ID
W4410491837

평가 내용

관련도
관련
사업분야
수소연료전지 · (5) 연료전지용 수분제어장치(가습기)
부 분야
–
R&D 측면
–
확신도
–
근거 용어
–
판단 근거
임베딩 유사도 기반 평가로 '수소연료전지 > 연료전지용 수분제어장치(가습기)' 분야에 선정된 논문입니다.
R&D 활용 포인트
–
평가 입력
–

초록

The charging scheduling problem of Electric Buses (EBs) is investigated based on Deep Reinforcement Learning (DRL). A Markov Decision Process (MDP) is conceived, where the time horizon includes multiple charging and operating periods in a day, while each period is further divided into multiple time steps. To overcome the challenge of long-range multi-phase planning with sparse reward, we conceive Hierarchical DRL (HDRL) for decoupling the original MDP into a high-level Semi-MDP (SMDP) and multiple low-level MDPs. The Hierarchical Double Deep Q-Network (HDDQN)-Hindsight Experience Replay (HER) algorithm is proposed for simultaneously solving the decision problems arising at different temporal resolutions. As a result, the high-level agent learns an effective policy for prescribing the charging targets for every charging period, while the low-level agent learns an optimal policy for setting the charging power of every time step within a single charging period, with the aim of minimizing the charging costs while meeting the charging target. It is proved that the flat policy constructed by superimposing the optimal high-level policy and the optimal low-level policy performs as well as the optimal policy of the original MDP. Since jointly learning both levels of policies is challenging due to the non-stationarity of the high-level agent and the sampling inefficiency of the low-level agent, we divide the joint learning process into two phases and exploit our new HER algorithm to manipulate the experience replay buffers for both levels of agents. Numerical experiments are performed with the aid of real-world data to evaluate the performance of the proposed algorithm.

본문 126,876자

본문 펼치기
## Electric Bus Charging Schedules Relying on Real Data-Driven Targets Based on Hierarchical Deep Reinforcement Learning JIAJU QI <sup>1</sup>, STUDENT MEMBER, IEEE, LEI LEI <sup>1</sup>, SENIOR MEMBER, IEEE, THORSTEINN JONSSON <sup>2</sup>, AND LAJOS HANZO <sup>3</sup>, LIFE FELLOW, IEEE Abstract The charging scheduling problem of Electric Buses (EBs) is investigated based on Deep Reinforcement Learning (DRL). A Markov Decision Process (MDP) is conceived, where the time horizon includes multiple charging and operating periods in a day, while each period is further divided into multiple time steps. To overcome the challenge of long-range multi-phase planning with sparse reward, we conceive Hierarchical DRL (HDRL) for decoupling the original MDP into a high-level Semi-MDP (SMDP) and multiple low-level MDPs. The Hierarchical Double Deep Q-Network (HDDQN)-Hindsight Experience Replay (HER) algorithm is proposed for simultaneously solving the decision problems arising at different temporal resolutions. As a result, the high-level agent learns an effective policy for prescribing the charging targets for every charging period, while the low-level agent learns an optimal policy for setting the charging power of every time step within a single charging period, with the aim of minimizing the charging costs while meeting the charging target. It is proved that the flat policy constructed by superimposing the optimal high-level policy and the optimal low-level policy performs as well as the optimal policy of the original MDP. Since jointly learning both levels of policies is challenging due to the non-stationarity of the high-level agent and the sampling inefficiency of the low-level agent, we divide the joint learning process into two phases and exploit our new HER algorithm to manipulate the experience replay buffers for both levels of agents. Numerical experiments are performed with the aid of real-world data to evaluate the performance of the proposed algorithm. Index Terms Deep Reinforcement Learning; Electric Bus; Hierarchical Reinforcement learning; Charging Control ACRONYMS DDQN Double Deep Q Network DNN Deep Neural Network DQL Double Q-learning DQN Deep Q Network DRL Deep Reinforcement Learning EB Electric Bus EBCSP Electric Bus Charging Scheduling Problem GA Genetic Algorithm GHG GreenHouse Gas HAC Hierarchical Actor-Critic HDDQN Hierarchical Double Deep Q Network HDRL Hierarchical Deep Reinforcement Learning HER Hindsight Experience Replay HRL Hierarchical Reinforcement Learning IA Immune Algorithm MDP Markov Decision Process MILP Mixed Integer Linear Programming ML Machine Learning MRP Markov Reward Process RES Renewable Energy Source RL Reinforcement Learning RO Robust Optimization RTEM Real Time Energy Market 1J. Qi and L. Lei are with the School of Engineering, University of Guelph, Guelph, ON N1G 2W1, Canada, jiaju@uoguelph.ca; leil@uoguelph.ca 2T. Jonsson is with EthicalAI, Waterloo, ON N2L 0C7, Canada, thor@ethicalairesearch.com 3L. Hanzo is with the School of Electronics and Computer Science, University of Southampton, Southampton, SO17 1BJ, UK, hanzo@soton.ac.uk SAC Soft Actor-Critic SMDP Semi-Markov Decision Process SoC State of Charge TD-DDPG Twin Delayed-Deep Deterministic Policy Gradient TOU Time-of-Use V2G Vehicle-to-Grid I. INTRODUCTION N recent years, the adoption of Electric Buses (EBs) in public transportation fleets has been growing rapidly. Electrification of public transport reduces GreenHouse Gas (GHG) emissions, lowers maintenance and fuel costs, and provides the public # I with a more comfortable riding experience [1]. With the increasing penetration of EBs, the question of how the charging cost can be reduced has become a key concern for bus companies [2]. Concurrently, in an attempt to spread the demand for electricity and efficiently utilize the Renewable Energy Sources (RES), power utility companies have adopted real-time electricity prices. Consequently, bus companies are presented with an effective measure to reduce costs and participate in the grid services by implementing intelligent charging schedules. In order for EBs to fully take advantage of the time-varying electricity prices, intelligent strategies for charging scheduling are essential. Specifically, it is crucial to set an appropriate charging target, which is the target State of Charge (SoC) level at the end of a charging period. A high value may lead to unnecessary charging and high charging cost, while a low value could result in battery depletion during a trip. The optimization of EB charging schedules has been extensively explored, with existing contributions generally categorized into deterministic and stochastic schemes based on their system modeling approaches. Many studies, such as [3], [4], fall into the deterministic category. They consider system models where the parameter values are deterministic or constant, and typically derive optimal policies through solving Mixed Integer Linear Programming (MILP) problems. While deterministic models do simplify the problem formulation and solution processes, they struggle to address two significant types of uncertainties encountered in practical scenarios, i.e., uncertainties in EB operation, such as random variations in travel time and energy consumption; plus uncertainties in the smart grid, including fluctuations in electricity prices. Consequently, system models that incorporate these uncertainties and stochastic elements offer a more realistic and applicable representation of the real world, ultimately leading to more reliable and efficient charging schedules. However, the realistic consideration of uncertainties exacerbates the complexities of finding optimal charging targets. Firstly, since the amount of energy consumption during each trip depends on the time-varying traffic conditions along the bus route, the charging targets must be high enough to support the full trip taking into account these variations. For example, the charging targets have to be higher during rush hours, since it will take the EBs longer time and more energy to complete the trip. Secondly, the charging cost can be reduced by leveraging the real-time electricity prices. For example, EBs can create charging schedules that favor off-peak hours for charging, while discharging energy to the grid during peak hours in the Vehicle-to-Grid (V2G) mode [5]. In recent years, some studies within the stochastic category, such as [6]–[11], have explored the uncertainties in EB travel time and energy consumption, utilizing methodologies such as Robust Optimization (RO) [8]–[11], Immune Algorithms (IA) [6], and Genetic Algorithms (GA) [7]. These approaches aim to enhance adaptability to the variable nature of EB operations. However, existing studies generally do not account for the uncertainties in real-time electricity prices, limiting their ability to optimize charging targets for different charging periods. Additionally, many existing investigations assume a constant charging power throughout the entire charging period, restricting EBs from discharging to the power grid via V2G and adjusting charging power in real time based on fluctuating electricity prices—both of which could further reduce charging costs. To address the above limitations, this paper develops a charging strategy for EBs based on Deep Reinforcement Learning (DRL). DRL combines Reinforcement Learning (RL) with Deep Neural Networks (DNNs), and has shown significant potential to address uncertainties in operational environments in recent years. Compared with other techniques of dealing with uncertainty, such as RO, IA, and GA, DRL learns optimal policies directly from interactions with the environment, without relying on predefined stochastic models of the variables [12]. Moreover, DRL dynamically learns and updates policies in real time, allowing it to swiftly adapt to changes in dynamic environments. Despite its great potential, there is currently a scarcity of literature applying DRL to charging scheduling for EBs [13]–[17], mainly due to the difficulty in designing an efficient and stable learning process. Unlike existing DRL-based studies for EB charging, our work accounts for uncertainties in both electricity prices and traffic conditions while also incorporating flexible charging power decisions on a fine time-scale - such as every few minutes - to minimize the charging costs while ensuring sufficient battery energy for EB operations. Unfortunately, this task corresponds to a long-range multi-phase planning problem, which has not been addressed by the aforementioned DRL-based works. The solution to this problem is a key challenge in DRL, where the long action sequences give rise to issues such as slow convergence, high complexity, and insufficiently diverse exploration [18]. The situation further deteriorates when rewards are sparse, as in the EB charging problem when the penalty for running out of battery during trips occurs sporadically. As a result, learning from this undesirable outcome is challenging, because of its rare occurrence. To overcome the aforementioned challenges, we design a novel Hierarchical DRL (HDRL) algorithm [19] in this paper. The main contributions are summarized as follows. 1) _System_ _Model_ : Our system model extends beyond the bus transit system to include interactions with the electrical grid, embracing the uncertainties of electricity prices and integrating V2G capabilities. Furthermore, charging scheduling decisions at a finer time-scale are considered, which determine the amount of real-time charging power, rather than relying on fixed charging power levels. 2) _HDRL_ _Model_ : To address the challenges in solving the long-range multiple-phase planning problem with sparse reward, the charging target option is defined, which simultaneously serves as a temporally extended action and a closed-loop policy. By introducing options, the original MDP is decomposed into a novel two-level decision process including a high-level Semi-MDP (SMDP) and low-level MDPs. We demonstrate that effective policies can be learned from solving the high-level SMDP for prescribing data-driven charging targets. In order to learn a charging scheduling policy to realize the charging targets whenever possible with minimal charging cost, we define an intrinsic reward for the low-level MDPs. It is proved that the flat policy created by superimposing the optimal high-level policy and the optimal low-level policy performs as well as the optimal policy of the original MDP. Meanwhile, since the long-range effect is captured by the options, the low-level MDPs become isolated from each other, which can be trained over a shorter time horizon to improve the learning efficiency of long-range planning. 3) _HDRL_ _Solution_ : A novel algorithm, namely the so-called Hierarchical Double Deep Q Network (HDDQN)-Hindsight Experience Replay (HER) is proposed for simultaneously solving the high-level SMDP and low-level MDPs while capturing the interplay between them. Specifically, both the high-level and low-level agents adopt the DDQN framework [20], but along with separate experience replay buffers. Both agents observe the system states and rewards from the environment for constructing their own rewards. The high-level agent prescribes specific charging target options that are fed to the low-level agent, which decides on the charging powers that are implemented in the environment. Finally, novel approaches based on HER are applied in order to reduce the impact of non-stationarity on the high-level agent and sample inefficiency on the low-level agent brought about by simultaneously learning multiple levels of policies. This innovation enables the proposed algorithm to learn more efficiently and converge faster. The rest of the paper is organized as follows. Section II critically appraises the state-of-the-art. The system model and MDP model are introduced in Sections III and IV, respectively, while the two-level decision process with options is formulated in Section V. The HDDQN-HER algorithm is proposed in Section VI. Finally, our experiments are highlighted in Section VII, and conclusions are offered in Section VIII. II. STATE-OF-THE-ART _A._ _Research_ _on_ _EB_ _charging_ _scheduling_ _problem_ There are three major charging technologies for EBs: (i) conductive charging; (ii) battery swapping; and (iii) wireless charging. The studies on conductive charging scheduling can be further divided into plug-in charging and pantograph charging. Both types are classified into two distinct approaches: (i) depot charging which adopts normal or slow chargers to charge EBs at bus depots overnight; (ii) opportunistic charging <sup>1</sup> which utilizes fast chargers to charge EBs at terminal stations or stops [21]. In the following, we will primarily review the existing literature on the EB Charging Scheduling Problem (EBCSP) for plug-in charging and opportunistic charging, which constitutes the main focus of this paper. Broadly speaking, the EBCSP involves one or more EBs, a set of trips to be fulfilled by the EBs, and charging infrastructures. The objective is to optimize the charging schedule for minimizing costs, ensuring there is sufficient battery energy to support the EBs’ trips, while adhering to various operational constraints, primarily concerning the bus schedules, power grid, and charger availability. Traditionally, all the parameters in the EBCSP, such as the travel time and energy consumption for each trip, are assumed to be constant or known. Based on this deterministic information, the EBCSP is normally formulated as a MILP problem and solved by different methods such as Branch & Price (BP) [22], the column generation based algorithm [23], dynamic programming [24], and optimization solvers such as CPLIX [3], [4], [25]–[27]. There are different types of decisions on charging schedules. The simplest type is a binary variable indicating whether to charge or not, whenever an EB arrives at the terminal station after a trip. Most studies on binary charging decisions adopted a full charging policy, i.e., once an EB is assigned for charging, it must be fully charged before embarking on a new trip [3], [26]. Given the constraints imposed by bus schedules, which may not provide ample time for full charging, the studies in [22], [23], [28] opted for partial charging, and derived the achieved SoC level of battery based on factors including the energy consumption rate and the length of time until the next departure of the EB. Given that a simplistic binary decision could result in unnecessarily high SoC level and increased charging cost, most studies on partial charging made decisions on the charging duration while assuming a fixed charging power [24], [29], [30]. In order to further enhance the flexibility in making charging 1This terminology is synonymous with the “opportunity charging” in [21]. Fig. 1: Comparison of MILP, RO, GA, and DRL in terms of four key criteria: lower computational complexity, data independency, uncertainty handling, and adaptability to dynamic environments. scheduling decisions, [27] divided the charging period into smaller time intervals and optimized the charging power for each time interval. However, MILP-based methods have several limitations. First, MILP becomes intractable for large-scale problems, with computation time growing exponentially. Additionally, its adaptability to dynamic environments is poor, as any environment change requires re-modeling and re-solving, further exacerbated by its high computational cost. Most importantly, in realistic scenarios, the travel time and energy consumption are inherently stochastic due to factors such as traffic flow and intersection waiting time. Therefore, their exact values are unknown when solving the EBCSP in practice. Since MILP relies on deterministic modeling, it struggles to effectively handle these uncertainties. To address this issue, He _et al._ [3] estimated an EB’s travel time and energy consumption using the K-means clustering algorithm, and plugged in the predicted values in the MILP model to derive the charging schedule. However, it is impossible to completely eliminate the prediction errors given current technology limitations. In order to address the uncertainties associated with stochastic travel time and/or energy consumption, stochastic models have been formulated. These models inherently increase the complexity of the optimization algorithms designed for charging scheduling. For example, RO was widely used by the studies [8], [9], [10], and [11], to achieve the dual goals of reducing charging costs and improving system robustness. Both [8] and [9] considered a fixed charging power, with the former making binary charging decisions, while the latter optimizing the charging time. Conversely, both [10] and [11] optimized the charging power at smaller time-scales. Although RO can handle uncertainties and provide robust solutions within a predefined uncertainty set, it often leads to overly conservative policies, sacrificing performance to mitigate risks. RO requires modeling the uncertainty set and optimizing across multiple uncertain scenarios, resulting in high computational complexity, but its complexity is still lower than that of MILP. Additionally, RO lacks adaptability to dynamic environmental changes. Some studies opted for heuristic algorithms to address the uncertainties. For example, Liu _et al._ [6] employed the ant colony algorithm and IA to optimize charging plans under fixed and stochastic travel times, respectively, with a focus on charging time as the optimization variable. Bie _et_ _al._ [7] presented the probability distribution function of trip energy consumption and adopted GA to reduce the charging costs as well as the delay in trip departure times. Compared to MILP, heuristic algorithms represented by GA have lower computational costs. However, they require multiple iterative optimizations, resulting in slow convergence. Additionally, GA typically operates offline and requires the entire algorithm to be re-run to integrate new information or accommodate changes in the environment, limiting its adaptability to dynamic environments. This limitation underscores the suitability of DRL for solving EBCSP. Unlike traditional methods, DRL does not require precise modeling; instead, it learns directly from interactions with the environment, making it the most effective in handling uncertainty. It also demonstrates strong adaptability in dynamic environments. The training process of DRL requires a significant amount of time. However, once training is complete, DRL can make decisions quickly in real time during the deployment phase, as it only requires forward propagation through the trained neural network. However, a limitation of DRL is its heavy reliance on training data. Therefore, when designing new DRL algorithms, achieving higher sample efficiency is crucial. In Fig. 1, we visually present the comparison of MILP, RO, GA, and DRL. There is relatively little research on DRL-based solutions for EBCSP. Among these studies, Wang _et_ _al._ [15] combined clipped Double Q-learning (DQL) with Soft Actor-Critic (SAC) to simultaneously solve EB dispatching and charging scheduling problems, where the charging scheduling decision is a simple binary variable. Yan _et_ _al._ [14] adopted Q-Learning and Twin TABLE I: Contrasting this paper to the literature on EBCSP. [22]–[25] Features [3], [26] [27] [4] [6]–[9] [10], [11] [14], [15] [13] Our work <u>[28]–[30]</u> Charging cost ✓ ✓ ✓ ✓ ✓ ✓ ✓ <u>minimization</u> <u>Partial</u> <u>charging</u> ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ Uncertainties in energy consumption ✓ ✓ ✓ ✓ ✓ <u>and/or</u> <u>travel</u> <u>time</u> Adjustable ✓ ✓ ✓ ✓ <u>charging</u> <u>power</u> <u>DRL-based</u> <u>algorithm</u> ✓ ✓ ✓ <u>V2G</u> <u>mode</u> ✓ ✓ Uncertainty in ✓ <u>electricity</u> <u>price</u> Delayed Deep Deterministic Policy Gradient (TD-DDPG) to determine the EBs’ target SoC levels and their assigned service routes, while assuming fixed charging power. Chen _et_ _al._ [13] used DQL to make decisions regarding the charging power for EBs upon their arrivals at the terminal station. However, the charging power remains constant for each charging period. By contrast, our work considers more flexible charging power decisions at a smaller time-scale. In summary, while prior works apply various classical DRL techniques, they face challenges due to the inherent long-range multi-phase planning problem when applied to our system model. Therefore, our study aims to address this complexity by introducing a hierarchical framework with options. In addition to the parameters associated with the bus transit system, the characteristics of the smart grid have also been considered in some treatises. In order to reduce the charging cost, Manzolli _et al._ [4] explored the potential of the V2G scheme, which allows EBs to sell electricity back to the grid. Meanwhile, some studies [6], [10], [24], [28] examined the impact of Time-of-Use (TOU) electricity tariffs, which facilitate learning of optimal charging policies that exploit time-varying electricity prices. However, the electricity prices are typically assumed to be known and static for different periods of the day in all the above studies. In recent years, with the increasing penetration of RES into the electric grid, the adoption of the RealTime Energy Market (RTEM) [31] has been on the rise. This market allows participants to buy and sell wholesale electricity throughout the operating day, aiming to balance actual real-time demand with the fluctuating production of electricity [32]. We direct interested readers to [33], [34] for more information on how real-time electricity prices are determined and communicated to users. By transiting from static pricing contracts to real-time pricing contracts, the bus companies can potentially reduce their charging costs, while supporting the grid in achieving long-term stability in power supply [35]. However, the inherent randomness of real-time electricity prices poses an additional challenge in solving EBCSP, where a sequence of charging schedule decisions must be made to minimize the charging cost without knowing the fluctuating electricity prices for the rest of the day. This challenge has been rarely touched upon in previous research. This knowledge gap is addressed in our paper. Table I boldly contrasts our work to the existing literature on EBCSP in terms of key features. While most existing work aims for minimizing the charging cost and considers the more flexible partial charging option rather than full charging, only some of the studies take into account the uncertainties in energy consumption and/or travel time, and consider the charging power as an adjustable decision variable. In addition, existing treatises generally do not incorporate more advanced smart grid characteristics, such as the V2G mode and uncertainty in electricity price. Furthermore, the DRL-based algorithms are rarely adopted to solve the EBCSP, addressing the uncertainties in practical systems. As shown in Table I, our paper considers all the listed features, filling the corresponding gaps in this field. _B._ _Hierarchical_ _RL_ _(HRL)_ The existing approaches on HRL are mainly developed based on three basic frameworks [36], i.e., the option framework by Sutton _et_ _al._ [37], MAXQ by Dietterich _et_ _al._ [38], and the Hierarchy of Abstract Machines (HAMs) by Parr and Russell [39]. In the most widely-used option framework, an option is associated with a subtask and can be regarded as a high-level action. It is represented by three key components including the initiation condition, the low-level intra-option policy that is used for choosing actions, and the termination probability function. It can be proved that any MDP having a fixed set of options is an SMDP, and its solution leads to a high-level policy over options that is used for prescribing the options. In contrast to MAXQ, the individual intra-option policies cannot be learned as an independent unit in the option framework. They should be integrated into the original MDP and optimized as a whole [19]. Thus, the optimality of learning a hierarchical policy is theoretically guaranteed. The studies on the option framework can be categorized into the approaches with or without subtask discovery. The approaches with subtask discovery, such as those in [40], [41], do not predefine the subtasks for the options. By contrast, the approaches without subtask discovery, such as the H-DQN by Kulkarni _et_ _al._ [42], associate each option with a subgoal state for the Fig. 2: The contributions of this paper in contrast to the literature on HRL. low-level policy to achieve. In this case, some of the key components of option such as the termination function may not have to be learned, since an option may be deemed to be terminated, once the subgoal is achieved. In this paper, we adopt the option framework without subtask discovery and associate the options with the charging targets. In contrast to the existing HRL algorithms operating without subtask discovery [42]–[44], we formally formulate our problem associated with the options, providing a unified framework for both option learning and subgoal learning. An important challenge when simultaneously learning a hierarchy of policies is associated with the non-stationarity [19], since the low-level policy may change during the training process, which leads to non-stationary reward functions and transition probabilities of the high-level SMDP. To address this challenge, the Hierarchical Reinforcement Learning with Off-policy Correction (HIRO) by Nachum _et_ _al._ [43] adopted a mechanism of subgoal re-labeling. The Hierarchical Actor-Critic (HAC) regime of Levy _et al._ [44] integrates the ideas of Hindsight Experience Replay (HER) [45] with HIRO for further improvement. Since our objective in this paper involves not only achieving the charging target subgoals but also minimizing the charging cost, our problem is more challenging compared to the studies in [43] and [44]. Fig. 2 shows the contributions of this paper in contrast to the literature of HRL. III. SYSTEM MODEL The variables and parameters used in this paper are summarized in Table II. In general, we use cursive letters to represent a set, such as _S_ and _A_, uppercase letters to represent the total number of variables in a set, such as _T_ and _K_, and the corresponding lowercase letters to represent the variable indexes in a set, such as _t_ and _k_ . In addition, following the convention of reinforcement learning, we generally use the capital letters with subscript _t_ to denote random variables, such as _St_ and _At_, while the corresponding lowercase letters represent sample values of the random variables, such as _s_ and _a_ . We use uppercase letters to represent constant values, such as _E_ max and _E_ min. Finally, we use lowercase letters to represent the functions, such as _r_ ( _St, At_ ). In this paper, we consider an EB routinely traveling along a bus route that includes several bus stops and a terminal station. When the EB arrives at the terminal station, its battery pack can be charged. Therefore, the status of the EB can be divided into two alternating periods. One is the charging period, in which the EB stays at the terminal station for charging. The other is the operating period, in which the EB travels along the designated route. As shown in Fig. 3, consider that there are _K_ operating periods for the EB in a single day according to its bus schedule, where each operating period is indexed by _k_ _∈{_ 0 _, . . ., K_ _−_ 1 _}_ . Additionally, each operating period _k_ _∈{_ 0 _, . . ., K_ _−_ 2 _}_ is TABLE II: Notation used in this paper <u>Notations</u> <u>Description</u> Sets _A_ The action space _Iω_ The initiation set of states for option _ω_ _S_ <sup>+</sup>, _S_ <sup>T</sup> / _S_ The state space, the set of terminal/non-terminal states _Ω_ The option space Parameters _Bt_ The EB status at time step _t_, 0 for operating periods and 1 for charging periods _C_ <sup>end</sup> The penalty for EB to enter the terminal states _C_ max/ _D_ max The maximum absolute value of charging/discharging power of EBs _Et_ The SoC level of the battery at time step _t_ _E_ max/ _E_ min The maximum/minimum storage constraint of the battery _Ht_ The historical electricity prices in the period spanning from time step _t −_ _wp_ up to time step _t_ _K_ The number of operating periods in a day _k_ The index of an operating/charging period _kt_ The index of the current charging/operating period at the time step _t_ _Pt_ The electricity price at time step _t_ _St_ The system state at time step _t_ _tk_ The random time step at which the EB arrives at the terminal station from the operating period _k_ _Tk_ <sup>a</sup> The random number of time steps between two consecutive arrivals of the EB from operating _Tk_ <sup>a</sup> The random number of time steps between two consecutive arrivals of the EB from operating periods _k_ and _k_ + 1 at _tk_ and _tk_ +1, respectively _Tk_ <sup>d</sup> The fixed number of time steps between two consecutive departures of the EB for operating _Tk_ <sup>d</sup> The fixed number of time steps between two consecutive departures of the EB for operating periods _k_ and _k_ + 1 according to the bus schedule _Tk_ <sup>c/</sup> <sup>_T_</sup> <sup>o</sup> _k_ The random number of time steps in the charging/operating period _k_ _k_ <sup>c/</sup> <sup>_T_</sup> <sup>o</sup> _k_ _Tk_ <sup>c/</sup> <sup>_T_</sup> <sup>o</sup> _k_ The random number of time steps in the charging/operating period _k_ _wp_ The length of the time window to look into the past prices ∆ _t_ The duration of each time step _τt_ The number of remaining time steps from time step _t_ to the next departure time Decision Variables _At_ The action at time step _t_ _Ct_ The charging/discharging power of the battery at time step _t_ _ωt_ The charging target option at time step _t_ Functions _c_ <sup>tar</sup> ( _St, ωt_ ) The penalty of not realizing the charging target _r_ ( _St, At_ ) The reward function _r_ <sup>H</sup> ( _St, ωt_ ) The expected cumulative reward within one transition of SMDP _r_ <sup>L</sup> ( _St, ωt, At_ ) The intrinsic reward of the low-level MDPs _βω_ ( _St_ ) The termination condition of option _ω_ _Γt_ ( _Bt_ ) The probability that the current period is terminated at time step _t_ _πω_ ( _St_ ) The intra-option policy for option _ω_ _µ_ ( _St_ ) The policy over options followed by a charging period with the same index _k_ . Given our focus on opportunistic charging, which involves fast chargers at terminal stations, we exclude depot charging that typically occurs overnight after the last operating period _K −_ 1 of the day. Therefore, the time horizon considered in this paper starts and ends with an operating period, and there are _K_ _−_ 1 charging periods sandwiched between _K_ operating periods. The time in a full day is discretized into _T_ equal-length time steps, indexed by _{_ 0 _, . . ., T_ _−_ 1 _}_ . The duration of each time step is denoted as ∆ _t_ . Let _Tk_ <sup>o,</sup> <sup>_∀k_</sup> <sup>_∈{_</sup> <sup>0</sup> <sup>_, . . ., K_</sup> <sup>_−_</sup> <sup>1</sup> <sup>_}_</sup> <sup>and</sup> <sup>_T_</sup> <sup>c</sup> _k_ <sup>,</sup> <sup>_∀k_</sup> <sup>_∈{_</sup> <sup>0</sup> <sup>_, . . ., K_</sup> <sup>_−_</sup> <sup>2</sup> <sup>_}_</sup> <sup>be</sup> <sup>random</sup> <sup>variables</sup> <sup>that</sup> <sup>represent</sup> <sup>the</sup> number of time steps in the operating period _k_ and the charging period _k_, respectively. Note that the variables _Tk_ <sup>c</sup> <sup>and</sup> <sup>_T_</sup> <sup>o</sup> _k_ are random due to the uncertainty in the arrival times of the EBs at the terminal station, which is caused by the stochastic traffic conditions along the bus route. The random time step at which the EB arrives at the terminal station from the operating period _k_ is denoted by _tk_, where _k_ _∈{_ 0 _, . . ., K −_ 1 _}_ . Then, the EB enters the charging period _k_ upon its arrival at _tk_, where _k_ _∈{_ 0 _, . . ., K −_ 2 _}_ . Let _Tk_ <sup>d,</sup> <sup>_∀k_</sup> <sup>_∈{_</sup> <sup>0</sup> <sup>_, . . ., K_</sup> <sup>_−_</sup> <sup>2</sup> <sup>_}_</sup> <sup>denote</sup> <sup>the</sup> <sup>fixed</sup> <sup>number</sup> <sup>of</sup> <sup>time</sup> <sup>steps</sup> <sup>between</sup> <sup>two</sup> <sup>consecutive</sup> <sup>departures</sup> <sup>of</sup> <sup>the</sup> <sup>EB</sup> <sup>for</sup> operating periods _k_ and _k_ + 1 according to the bus schedule. This corresponds to the sum duration of a pair of consecutive _k_ <sup>o,</sup> <sup>_∀k_</sup> <sup>_∈{_</sup> <sup>0</sup> <sup>_, . . ., K_</sup> <sup>_−_</sup> <sup>1</sup> <sup>_}_</sup> <sup>and</sup> <sup>_T_</sup> <sup>c</sup> _k_ _k_ <sup>c</sup> <sup>and</sup> <sup>_T_</sup> <sup>o</sup> _k_ Let _Tk_ <sup>d</sup> Fig. 3: The schematic diagram of the system model for the EB charging problem. operating and charging periods, i.e., _Tk_ <sup>d</sup> _k_ <sup>d</sup> <sup>=</sup> <sup>_T_</sup> <sup>o</sup> _k_ <sup>o</sup> _k_ <sup>+</sup> <sup>_T_</sup> <sup>c</sup> _k_ <sup>c</sup> _k_ <sup>.</sup> <sup>Let</sup> <sup>_T_</sup> <sup>a</sup> _k_ operating and charging periods, i.e., _Tk_ <sup>d</sup> <sup>=</sup> <sup>_T_</sup> <sup>o</sup> _k_ <sup>+</sup> <sup>_T_</sup> <sup>c</sup> _k_ <sup>.</sup> <sup>Let</sup> <sup>_T_</sup> <sup>a</sup> _k_ <sup>,</sup> <sup>_∀k_</sup> <sup>_∈{_</sup> <sup>0</sup> <sup>_, . . ., K −_</sup> <sup>2</sup> <sup>_}_</sup> <sup>represent</sup> <sup>the</sup> <sup>random</sup> <sup>number</sup> <sup>of</sup> <sup>time</sup> <sup>steps</sup> between two consecutive arrivals of the EB from operating periods _k_ and _k_ + 1 at _tk_ and _tk_ +1, respectively. This corresponds to the sum duration of a pair of consecutive charging and operating periods, i.e., _Tk_ <sup>a</sup> <sup>=</sup> <sup>_tk_</sup> <sup>+1</sup> <sup>_−_</sup> <sup>_tk_</sup> <sup>=</sup> <sup>_T_</sup> <sup>c</sup> _k_ <sup>+</sup> <sup>_T_</sup> <sup>o</sup> _k_ +1 <sup>.</sup> We define _Bt_ as a random variable that represents the EB status at time step _t_, where _Bt_ = 1 and _Bt_ = 0 correspond to the charging and operating periods, respectively. In addition, let _kt_ denote the index of the current charging or operating period at time step _t_ <sup>2</sup> . Let _τt_ denote the number of remaining time steps from time step _t_ to the next departure time. The iterative calculation for _τt_ +1 is derived as _k_ <sup>a</sup> <sup>=</sup> <sup>_tk_</sup> <sup>+1</sup> <sup>_−_</sup> <sup>_tk_</sup> <sup>=</sup> <sup>_T_</sup> <sup>c</sup> _k_ <sup>c</sup> _k_ <sup>+</sup> <sup>_T_</sup> <sup>o</sup> _k_ _τt_ +1 = - _Tk_ <sup>d</sup> _Tk_ <sup>d</sup> _t_ +1 <sup>_,_</sup> if _Bt_ +1 = 0 and _Bt_ = 1 _,_ (1) _τt −_ 1 _,_ otherwise which means that _τt_ decreases by 1 at each time step until it reaches 0. When _τt_ = 0, the EB will depart for operating period _kt_ +1 at the next time step _t_ + 1. In this case, _τt_ +1 is set to a fixed value _Tk_ <sup>d</sup> _t_ +1 <sup>according</sup> <sup>to</sup> <sup>the</sup> <sup>bus</sup> <sup>schedule.</sup> We use _Γt_ ( _Bt_ ) to denote the conditional probability that the current period is terminated at time step _t_, given whether the current period is charging (i.e., _Bt_ = 1) or operating (i.e., _Bt_ = 0). Note that _Γt_ ( _Bt_ ) depends on _τt_ and _kt_ . Intuitively, in the operating period ( _Bt_ = 0), the probability of the EB returning to the terminal station increases as its traveling time elapses. Mathematically, we have _Γt_ ( _Bt_ = 0) = Pr( _Bt_ +1 = 1 _|Bt_ = 0 _, τt, kt_ ) Pr( _Tk_ <sup>o</sup> = _<u>k</u>_ <sup>o</sup> _<u>t</u>_ <sup>=</sup> <sup>_T_</sup> <sup>d</sup> _<u>kt</u>_ _,_ (2) Pr( _Tk_ <sup>o</sup> _<u>t</u>_ <sup>=</sup> <sup>_T_</sup> <sup>d</sup> _<u>kt</u>_ <sup>_−_</sup> <sup>_τt_</sup> <sup>)</sup> <u>�</u> _Tkt_ <sup>d</sup> <sup>_−τt−_</sup> <sup>1</sup> _x_ =0 [1 _−_ Pr( _Tk_ <sup>o</sup> _t_ _k_ <sup>o</sup> _t_ <sup>=</sup> <sup>_x_</sup> <sup>)]</sup> where the numerator represents the probability of the EB arriving at the terminal station at time step _t_, while the denominator represents the probability of the EB not arriving at the terminal station before time step _t_ . For the charging period ( _Bt_ = 1), we consider that the bus line works in accordance with a fixed schedule and the EBs must depart on time. Therefore, when the scheduled departure time is reached, i.e., _τt_ = 0, the charging period terminates with _Γt_ = 1. Meanwhile, we have _Γt_ = 0 in all the other time steps. Therefore, we have 2To avoid potential confusion, we would like to highlight that _tk_ is the index of a time step and _kt_ is the index of a charging/operating period. _Γt_ ( _Bt_ = 1) = Pr( _Bt_ +1 = 0 _|Bt_ = 1 _, τt_ ) = 1 _,_ if _τt_ = 0 (3) 0 _,_ otherwise <sup>_._</sup> The optimization objective is to determine the EB charging schedule in the charging period that minimizes the charging cost while keeping a sufficient SoC level in the battery to ensure reliable operation in the operating period. The charging cost depends on real-time electricity prices, which fluctuate over time. At each time step _t_, we use _Pt_ to denote the electricity price. Let _Et_ denote the SoC level of the battery for the EB at time step _t_, which is constrained by _E_ min ⩽ _Et_ ⩽ _E_ max _._ (4) Furthermore, let _Ct_ denote the charging/discharging power of the EB battery at time step _t_, which is positive when charging and negative when discharging. Note that the charging schedule _Ct_ only has to be determined in the charging period, where the EB can either draw energy from or return energy back to the electric grid in the V2G mode. On the other hand, the EB is always discharging in the operating period when the EB travels along the route, and thus _Ct_ is negative. Expressed mathematically, the constraint of _Ct_ can be written as: - _<u>E</u>_ <u>min</u> _∆t−Et_ _,_ <sup>_<u>E</u>_</sup> <sup><u>max</u></sup> _∆t_ <sup>_<u>−Et</u>_</sup> _∆t_ (5) - _,_ if _Bt_ = 0 <sup>_,_</sup> _∆t_ _Ct_ _∈_ [ _−D_ max _, C_ max] _∩_ [ _−D_ max _, C_ max] _∩_ - _<u>E</u>_ <u>min</u> _∆t−Et_ _,_ <sup>_<u>E</u>_</sup> <sup><u>max</u></sup> _∆t_ <sup>_<u>−Et</u>_</sup> - _,_ if _Bt_ = 1 [ _−D_ max _,_ 0] _∩_ - _<u>E</u>_ <u>min</u> _∆t−Et_ _,_ 0� _,_ if _Bt_ = 0 - _<u>E</u>_ <u>min</u> _∆t−Et_ _,_ 0 where _C_ max and _D_ max denote the maximum absolute value of charging and discharging power, respectively. In addition, [( _E_ min _−_ _Et_ ) _/∆t,_ ( _E_ max _−_ _Et_ ) _/∆t_ ] represents the value range due to the limitation of the EB battery capacity. Finally, the dynamics of the EB battery can be modeled as _Et_ +1 = _Et_ + _Ct_ ∆ _t._ (6) IV. MDP MODEL _A._ _State_ Let _St_ = ( _Et, Bt, τt, Ht, kt_ ) be the system state at time step _t_ . _Ht_ denotes the historical electricity prices in the period spanning from time step ( _t −_ _wp_ ) up to time step _t_, i.e., _Ht_ = - _Pt−wp, Pt−wp_ +1 _, ..., Pt−_ 1 _, Pt_ - _._ (7) Note that _wp_ is the length of the time window used for considering past prices. Let _S_ <sup>+</sup> denote the state space, which can be divided into the set of non-terminal states _S_ = _{St|Et_ _≥_ _E_ min _}_ and the set of terminal states _S_ <sup>T</sup> = _{St|Et_ _<_ _E_ min _}_ . When the SoC level in the EB’s battery is lower than the minimum battery capacity constraint, i.e., _Et_ _< E_ min, the agent will enter the terminal states and the current episode will end before the maximum time step _T_ is reached. _B._ _Action_ Let _At_ = _Ct_ _∈A_ be the action at time step _t_, where _A_ represents the action space. The charging scheduling policy determines the action _At_ only in those states _St_ that are associated with _Bt_ = 1. The action space _A_ can be derived based on the first case in (5). When the EB is in the operating period ( _Bt_ = 0), _Ct_ is a random variable whose value at each time step _t_ is given by the environment rather than being determined by the agent. The range of the random variable _Ct_ is specified by the second case in (5). _C._ _Transition_ _Probability_ The state transition probability is derived as Pr ( _St_ +1 _|St, At_ ) = Pr ( _Bt_ +1 _|Bt, τt, kt_ ) Pr ( _kt_ +1 _|kt, Bt, Bt_ +1) (8) Pr ( _τt_ +1 _|τt, Bt, Bt_ +1 _, kt_ +1) Pr ( _Et_ +1 _|Et, At_ ) Pr ( _Ht_ +1 _|Ht_ ) _,_ where the transition probability of state _St_ is decomposed into the product of the transition probabilities of each component in the state definition. The transition probabilities of historical electricity prices Pr ( _Ht_ +1 _|Ht_ ) are not available, but samples of the trajectory can be obtained from real-world data. The transition probability of SoC level, i.e., Pr ( _Et_ +1 _|Et, At_ ) can be calculated by (6). Next, the transition probability Pr ( _Bt_ +1 _|Bt, τt, kt_ ) can be derived from the termination probability _Γt_ ( _Bt_ ), i.e., Pr ( _Bt_ +1 _|Bt, τt, kt_ ) = 1 _−_ _Γt_ ( _Bt_ ) _,_ if _Bt_ +1 = _Bt_ _Γt_ ( _Bt_ ) _,_ if _Bt_ +1 = 1 _−_ _Bt_ _,_ (9) where _Γt_ ( _Bt_ ) is given by (2) and (3). The transition probability of _kt_, i.e., Pr ( _kt_ +1 _|kt, Bt, Bt_ +1), is derived by the iterative calculation for _kt_ +1, i.e., _kt_ +1 = _kt_ + 1 _,_ if _Bt_ +1 = 0 and _Bt_ = 1 _,_ (10) _kt,_ otherwise where _k_ 0 = 0. Finally, the iterative calculation for _τt_ +1 in (1) can be used for calculating Pr ( _τt_ +1 _|τt, Bt, Bt_ +1 _, kt_ +1). _D._ _Reward_ _Function_ The optimization objective is to minimize the charging costs, while guaranteeing sufficient energy in the EB battery during the operating period. Therefore, we define the reward function as _r_ ( _St, At_ ) = _−Ct_ ∆ _tPtBt,_ if _St_ _∈S_ (11) _−C_ <sup>end</sup> _,_ if _St_ _∈S_ <sup>T</sup> <sup>_,_</sup> where _Ct_ ∆ _tPtBt_ is the charging cost and _C_ <sup>end</sup> is the penalty to the agent for entering the terminal states. This means that the EB battery is not sufficiently charged to support the entire operating period to completion. As a result, the EBs having depleted batteries receive more negative expected cumulative rewards than their counterpart associated with normal operation, due to receiving a large negative reward _−C_ <sup>end</sup> upon entering the terminal state. In practice, _C_ <sup>end</sup> is a hyperparameter tuned empirically. If set too small, the agent risks reaching the terminal state, whereas a value that is too large may lead to an overly conservative policy, increasing charging costs. In our experiments, the optimal _C_ <sup>end</sup> is typically around 5 to 10 times _Ct_ ∆ _tPtBt_, ensuring that the agent consistently avoids terminal states while still optimizing for lower charging cost. _E._ _Optimization_ _Objective_ Define the return _Gt_ as the sum of rewards starting from time step _t_, i.e., _Gt_ = _T −_ 1 _t_ <sup>_′_</sup> = _t_ _r_ ( _St′, At′_ ) _._ (12) The state-value or value function _Vπ_ ( _s_ ) is defined as the expected return from starting in state _s_ and then following policy _π_, i.e., _Vπ_ ( _s_ ) = E _π_ [ _Gt|St_ = _s_ ] _, ∀s ∈S._ (13) Note that the value function of terminal states is always _−C_ <sup>end</sup>, i.e., _Vπ_ ( _s_ ) = _−C_ <sup>end</sup> _, ∀s_ _∈S_ <sup>T</sup> . Thus, our objective is to derive the optimal policy _π_ <sup>_∗_</sup> that maximizes the value function for all the non-terminal states _Vπ∗_ ( _s_ ) = max _Vπ_ ( _s_ ) _, ∀s ∈S._ (14) _π_ In order to derive the optimal policy, the action-value function or Q function _Qπ_ ( _s, a_ ) is defined as the expected return from starting in state _s_, taking action _a_, and then following policy _π_, i.e., _Qπ_ ( _s, a_ ) = E _π_ [ _Gt|St_ = _s, At_ = _a_ ] _, ∀s ∈S, a ∈A._ (15) Note that the Q function for the terminal states is always _−C_ <sup>end</sup>, i.e., _Qπ_ ( _s, a_ ) = _−C_ <sup>end</sup> _, ∀s_ _∈S_ <sup>T</sup> _, a_ _∈A_ . The optimal action-value function is then _Q_ <sup>_∗_</sup> _π_ <sup>(</sup> <sup>_s, a_</sup> <sup>) = max</sup> <sup>_π_</sup> <sup>_Qπ_</sup> <sup>(</sup> <sup>_s, a_</sup> <sup>).</sup> <sup>Given</sup> <sup>_Q∗_</sup> _π_ <sup>(</sup> <sup>_s, a_</sup> <sup>),</sup> <sup>the</sup> <sup>optimal</sup> <sup>policy</sup> <sup>selects</sup> <sup>the</sup> <sup>highest-valued</sup> <sup>action</sup> in each state. In order to estimate _Q_ <sup>_∗_</sup> _π_ <sup>(</sup> <sup>_s, a_</sup> <sup>)</sup> <sup>typically,</sup> <sup>the</sup> <sup>following</sup> <sup>Bellman</sup> <sup>Equation</sup> <sup>is</sup> <sup>used</sup> <sup>as</sup> <sup>an</sup> <sup>iterative</sup> <sup>update,</sup> <sup>where</sup> _._ (16) _Q_ <sup>_∗_</sup> ( _s, a_ ) = E _r_ ( _s, a_ ) + max _a_ <sup>_′_</sup> _a_ <sup>_′_</sup> <sup>_Q∗_</sup> <sup>(</sup> <sup>_s′, a′_</sup> <sup>)</sup> The formulated EB charging problem corresponds to an episodic task with a maximum of _T_ time steps in an episode. An episode terminates earlier if the terminal state is reached, which means that the EB runs out of battery. For any full episode where the EB does not run into the terminal state, the last period is always the charging period _K −_ 1, where the EB has to charge sufficient energy for the operating period 0 of the next day. The optimal policy is stationary for any episodic task [37], [46]. V. OPTIONS OVER MDP The MDP model defined in Section IV is essentially a long-range multiple-phase planning problem, since the time horizon is divided into multiple charging and operating periods, where each phase consists of a large number of time steps. In the following, we adopt the framework of options [37], [40] to tackle this problem, which enables the agent to abstract actions at different temporal levels. _A._ _Definition_ _of_ _Options_ Let _ω_ _∈_ _Ω_ denote the options, where _Ω_ is the option space. Options can be regarded as temporally extended “actions”, which can last for multiple time steps. An option is prescribed by the _policy_ _over_ _options_ _µ_ according to the current state _St_ . Each option _ω_ is associated with the triple of ( _Iω, πω, βω_ ), where _Iω_ is the initiation set of states, i.e., _ω_ is available in state _St_ if and only if _St_ _∈Iω_, while _πω_ is the _intra-option_ _policy_ and _βω_ is the termination condition. If an option _ω_ is chosen at time step _t_, the option will terminate with probability _βω_ ( _St_ + _l_ ) at each time step _t_ + _l_, _∀l ∈_ 1 _,_ 2 _, . . ._ . If the option _ω_ does not terminate at time step _t_ + _l_, _∀l_ _∈_ 0 _,_ 1 _,_ 2 _, . . ._, an action _At_ + _l_ is chosen according to the intra-option policy _πω_ ( _St_ + _l_ ) and the environment moves on to the next time step _t_ + _l_ + 1. Otherwise, a new option _ω_ <sup>_′_</sup> may be selected according to the policy over options _µ_ ( _St_ + _l_ ), and the same process is repeated for the following time steps. In this paper, we define the charging target option _ω_, which corresponds to the target SoC level of the EB’s battery, when a charging period terminates. Note that the option space is defined by the _Et_ constraints in (4). Since the charging targets only have to be determined in the charging periods, _Iω_ is defined as _Iω_ = _{St_ _∈S|Bt_ = 1 _} ._ (17) The termination condition is defined as _βω_ ( _St_ ) = - 1 _,_ if _Bt_ = 0 and _Bt_ +1 = 1 _,_ (18) 0 _,_ otherwise which means the option should be terminated when an operating period ends and the next charging period will start. _B._ _Decoupling_ _the_ _original_ _MDP_ As shown in Fig.4, by introducing options, our original MDP model is divided into low-level and high-level decision processes. The top panel illustrates the original MDP defined in Section IV, where a flat policy _π_ is used for determining the charging schedule action _Ct_ at each time step _t_ during the charging periods. Meanwhile, _Ct_ is given by the environment according to the amount of power discharged during each time step in the operating periods. Therefore, the original MDP consists of an interleaving of MDPs corresponding to charging periods and Markov Reward Processes (MRPs) representing the operating periods. Although the original MDP can be solved directly to obtain _π_, a more efficient solution is to divide it into two levels through options. The middle panel shows the high-level SMDP, where the policy over options _µ_ prescribes the charging target option _ω_ at the selected time steps _{tk}_ <sup>_K_</sup> _k_ =0 <sup>_−_</sup> <sup>2</sup> <sup>when</sup> <sup>the</sup> <sup>charging</sup> <sup>periods</sup> <sup>start.</sup> <sup>Assume</sup> <sup>that</sup> <sup>option</sup> <sup>_ω_</sup> <sup>is</sup> <sup>selected</sup> <sup>according</sup> <sup>to</sup> <sup>_µ_</sup> <sup>(</sup> <sup>_St_</sup> _k_ <sup>)</sup> at time step _tk_ when a charging period starts. When the charging period terminates after a random number of _Tk_ <sup>c</sup> <sup>time</sup> <sup>steps,</sup> at time step _tk_ when a charging period starts. When the charging period terminates after a random number of _Tk_ <sup>c</sup> <sup>time</sup> <sup>steps,</sup> the state _Stk_ transits to _Stk_ + _Tk_ <sup>c</sup> <sup>,</sup> <sup>where</sup> <sup>_Etk_</sup> <sup>+</sup> <sup>_T_</sup> _k_ <sup>c</sup> <sup>should</sup> <sup>be</sup> <sup>as</sup> <sup>close</sup> <sup>to</sup> <sup>the</sup> <sup>desired</sup> <sup>charging</sup> <sup>target</sup> <sup>_ω_</sup> <sup>as</sup> <sup>possible.</sup> <sup>When</sup> <sup>the</sup> <sup>next</sup> the state _Stk_ transits to _Stk_ + _Tk_ <sup>c</sup> <sup>,</sup> <sup>where</sup> <sup>_Etk_</sup> <sup>+</sup> <sup>_T_</sup> _k_ <sup>c</sup> <sup>should</sup> <sup>be</sup> <sup>as</sup> <sup>close</sup> <sup>to</sup> <sup>the</sup> <sup>desired</sup> <sup>charging</sup> <sup>target</sup> <sup>_ω_</sup> <sup>as</sup> <sup>possible.</sup> <sup>When</sup> <sup>the</sup> <sup>next</sup> charging period starts at time step _tk_ +1 = _tk_ + _Tk_ <sup>a,</sup> <sup>the</sup> <sup>next</sup> <sup>option</sup> <sup>_ω′_</sup> <sup>is</sup> <sup>selected</sup> <sup>according</sup> <sup>to</sup> <sup>_µ_</sup> <sup>(</sup> <sup>_St_</sup> _k_ +1 <sup>).</sup> _k_ <sup>c</sup> <sup>,</sup> <sup>where</sup> <sup>_Etk_</sup> <sup>+</sup> <sup>_T_</sup> _k_ <sup>c</sup> charging period starts at time step _tk_ +1 = _tk_ + _Tk_ <sup>a,</sup> <sup>the</sup> <sup>next</sup> <sup>option</sup> <sup>_ω′_</sup> <sup>is</sup> <sup>selected</sup> <sup>according</sup> <sup>to</sup> <sup>_µ_</sup> <sup>(</sup> <sup>_St_</sup> _k_ +1 <sup>).</sup> Finally, the bottom panel shows that the low-level MDPs are embedded into the high-level SMDP, where at each charging period, the intra-option policy _πω_ of the selected option _ω_ determines the optimal charging schedule action _Ct_ that minimizes the charging cost, while ensuring that the charging target of _ω_ is realized. By superimposing the high-level policy over options _µ_ and the low-level intra-option policy _πω_, a flat policy is constructed to solve the original MDP problem. Notably, the long timehorizon of the original MDP is divided into multiple shorter time-horizons of the low-level MDPs. Since each low-level MDP is provided with a charging target option obtained by solving the high-level MDP, the low-level MDPs become independent of each other. In other words, each low-level MDP only has to concentrate on its immediate time-horizon for decision-making, without having to look further into the future and consider those low-level MDPs in subsequent time-horizons. By adopting the hierarchical structure and solving the high-level SMDP and low-level MDPs instead of the original MDP, the learning efficiency and convergence speed can be significantly improved. _C._ _The_ _High-Level_ _SMDP_ When we only consider the high-level policy over options _µ_ to select options (i.e., assuming the intra-option policy _πω_ is available for each option _ω_ _∈_ Ω), the decision process becomes an SMDP [46] that can be derived from the original MDP. In SMDP, state transitions and action selections take place at discrete time, but the length of time interval from one transition to the next is random. Therefore, an SMDP consists of state space, action space, an expected cumulative discounted reward for each state-action pair, and a joint distribution of the next state and transit interval. In our high-level SMDP, the states are the same as those of the original MDP, while the actions correspond to the options. For each state transition when option _ω_ is selected, the transit time is _Tk_ <sup>_ω_</sup> <sup>time</sup> <sup>steps.</sup> <sup>Note</sup> <sup>that</sup> <sup>an</sup> <sup>option</sup> <sup>terminates</sup> <sup>when</sup> <sup>either</sup> <sup>the</sup> <sup>EB</sup> <sup>arrives</sup> <sup>at</sup> <sup>the</sup> <sup>terminal</sup> <sup>station</sup> where _Tk_ <sup>_ω_</sup> <sup>=</sup> <sup>_T_</sup> <sup>a</sup> _k_ <sup>, or the EB runs out of battery during the trip where</sup> <sup>_T ω_</sup> _k_ <sup>_< T_</sup> _k_ <sup>a. The SMDP model has its corresponding reward</sup> _k_ <sup>_ω_</sup> <sup>=</sup> <sup>_T_</sup> <sup>a</sup> _k_ <sup>a</sup> _k_ <sup>, or the EB runs out of battery during the trip where</sup> <sup>_T ω_</sup> _k_ <sup>_ω_</sup> _k_ <sup>_< T_</sup> _k_ <sup>a</sup> _k_ <sup>a. The SMDP model has its corresponding reward</sup> Fig. 4: The schematic diagram of the original MDP, high-level SMDP, and low-level MDPs. _r_ <sup>H</sup> ( _s, ω_ ), i.e., the expected cumulative reward within one transition of SMDP in _Tk_ <sup>_ω_</sup> <sup>time</sup> <sup>steps.</sup> <sup>Let</sup> <sup>_E_</sup> <sup>(</sup> <sup>_ω, s, tk_</sup> <sup>)</sup> <sup>denote</sup> <sup>the</sup> event that _ω_ starts in state _s_ at time step _tk_ . The reward _r_ <sup>H</sup> ( _s, ω_ ) can be derived by  _k_ <sup>_ω−_</sup> <sup>1</sup> _Tk_ <sup>_ω_</sup>  _r_ ( _Stk_ + _l, Atk_ + _l_ ) _|E_ ( _ω, s, tk_ ) _,_ (19) _r_ <sup>H</sup> ( _s, ω_ ) = E _πω_  _l_ =0 where the action _Atk_ + _l_ is derived based on the intra-option policy _πw_ for the first _Tk_ <sup>c</sup> where the action _Atk_ + _l_ is derived based on the intra-option policy _πw_ for the first _Tk_ <sup>c</sup> <sup>time</sup> <sup>steps</sup> <sup>during</sup> <sup>the</sup> <sup>charging</sup> <sup>period,</sup> and then provided by the environment for the following _Tk_ <sup>_ω_</sup> <sup>_−_</sup> <sup>_T_</sup> <sup>c</sup> _k_ <sup>time</sup> <sup>steps</sup> <sup>during</sup> <sup>the</sup> <sup>operating</sup> <sup>period.</sup> _k_ <sup>_ω_</sup> <sup>_−_</sup> <sup>_T_</sup> <sup>c</sup> _k_ then provided by the environment for the following _Tk_ <sup>_ω_</sup> <sup>_−_</sup> <sup>_T_</sup> <sup>c</sup> _k_ <sup>time</sup> <sup>steps</sup> <sup>during</sup> <sup>the</sup> <sup>operating</sup> <sup>period.</sup> The transition distributions of the SMDP _Pss_ <sup>_ω_</sup> <sup>_′_</sup> <sup>can</sup> <sup>be</sup> <sup>formulated</sup> <sup>as</sup> _ss_ <sup>_ω_</sup> <sup>_′_</sup> <sup>can</sup> <sup>be</sup> <sup>formulated</sup> <sup>as</sup> _Pss_ <sup>_ω_</sup> <sup>_′_</sup> <sup>=</sup> _∞_ _Tk_ <sup>_ω_</sup> <sup>=1</sup> _P_ ( _s_ <sup>_′_</sup> _, Tk_ <sup>_ω_</sup> <sup>)</sup> <sup>_,_</sup> (20) where _P_ ( _s_ <sup>_′_</sup> _, Tk_ <sup>_ω_</sup> where _P_ ( _s_ <sup>_′_</sup> _, Tk_ <sup>_ω_</sup> <sup>)</sup> <sup>represents</sup> <sup>the</sup> <sup>probability</sup> <sup>that</sup> <sup>the</sup> <sup>option</sup> <sup>terminates</sup> <sup>after</sup> <sup>_T ω_</sup> _k_ <sup>time</sup> <sup>steps</sup> <sup>when</sup> <sup>the</sup> <sup>state</sup> <sup>_s_</sup> <sup>changes</sup> <sup>to</sup> <sup>_s′_</sup> <sup>.</sup> Let us define the high-level return _G_ <sup>H</sup> _k_ <sup>as</sup> <sup>the</sup> <sup>sum</sup> <sup>of</sup> <sup>the</sup> <sup>high-level</sup> <sup>rewards</sup> <sup>starting</sup> <sup>from</sup> <sup>time</sup> <sup>step</sup> <sup>_tk_</sup> <sup>,</sup> <sup>i.e.,</sup> _k_ <sup>_ω_</sup> <sup>)</sup> <sup>represents</sup> <sup>the</sup> <sup>probability</sup> <sup>that</sup> <sup>the</sup> <sup>option</sup> <sup>terminates</sup> <sup>after</sup> <sup>_T ω_</sup> _k_ <sup>H</sup> _k_ <sup>as</sup> <sup>the</sup> <sup>sum</sup> <sup>of</sup> <sup>the</sup> <sup>high-level</sup> <sup>rewards</sup> <sup>starting</sup> <sup>from</sup> <sup>time</sup> <sup>step</sup> <sup>_tk_</sup> <sup>,</sup> <sup>i.e.,</sup> _G_ <sup>H</sup> _k_ <sup>=</sup> _K−_ 1 _k_ <sup>_′_</sup> = _k_ _r_ <sup>H �</sup> - _, ∀k_ _∈{_ 0 _,_ 1 _, · · ·_ _, K −_ 2 _}_ (21) _Stk′_ _, ωtk′_ The high-level value function _Vµ_ <sup>H(</sup> <sup>_s_</sup> <sup>)</sup> <sup>is</sup> <sup>defined</sup> <sup>as</sup> <sup>the</sup> <sup>expected</sup> <sup>high-level</sup> <sup>return</sup> <sup>from</sup> <sup>starting</sup> <sup>in</sup> <sup>state</sup> <sup>_s_</sup> <sup>and</sup> <sup>then</sup> <sup>following</sup> the policy over options _µ_, i.e., _Vµ_ <sup>H(</sup> <sup>_s_</sup> <sup>) = E</sup> <sup>_µ_</sup> <sup>E</sup> <sup>_π_</sup> _ω_ _Vµ_ <sup>H</sup> - _G_ <sup>H</sup> _k_ <sup>H</sup> _k_ <sup>_|St_</sup> _k_ <sup>=</sup> <sup>_s_</sup> - _, ∀s ∈S._ (22) Note that the high-level value function of the terminal states is always _−C_ <sup>end</sup>, i.e., _Vµ_ <sup>H(</sup> <sup>_s_</sup> <sup>) =</sup> <sup>_−C_</sup> <sup>end</sup> <sup>_, ∀s ∈S_</sup> <sup>T.</sup> <sup>The</sup> <sup>objective</sup> of the high-level SMDP is to derive the optimal policy over option _µ_ <sup>_∗_</sup> that maximizes the high-level value function for all the nonterminal states _V∗_ <sup>H</sup> _∗_ <sup>H(</sup> <sup>_s_</sup> <sup>) =</sup> <sup>_V_</sup> _µ_ <sup>H</sup> <sup>_∗_</sup> _µ_ <sup>H</sup> <sup>_∗_</sup> <sup>(</sup> <sup>_s_</sup> <sup>) = max</sup> _µ_ _Vµ_ <sup>H</sup> _µ_ <sup>H(</sup> <sup>_s_</sup> <sup>)</sup> <sup>_, ∀s ∈S._</sup> (23) In order to derive the optimal policy over options, the option-value function or high-level Q function _Q_ <sup>H</sup> _µ_ <sup>(</sup> <sup>_s, ω_</sup> <sup>)</sup> <sup>is</sup> <sup>defined</sup> as the expected return from starting in state _s_, taking option _ω_, and then following policy _µ_, i.e., _Q_ <sup>H</sup> _µ_ <sup>(</sup> <sup>_s, ω_</sup> <sup>) = E</sup> <sup>_µ_</sup> <sup>E</sup> <sup>_π_</sup> _ω_ - _G_ <sup>H</sup> _t_ <sup>_|St_</sup> _k_ <sup>=</sup> <sup>_s, ωt_</sup> _k_ <sup>=</sup> <sup>_ω_</sup> - _, ∀s ∈S, ω_ _∈_ _Ω._ (24) Note that the option-value function for the terminal states is always _−C_ <sup>end</sup>, i.e., _Q_ <sup>H</sup> _µ_ Note that the option-value function for the terminal states is always _−C_ <sup>end</sup>, i.e., _Q_ <sup>H</sup> _µ_ <sup>(</sup> <sup>_s, ω_</sup> <sup>) =</sup> <sup>_−C_</sup> <sup>end</sup> <sup>_, ∀s ∈S_</sup> <sup>T</sup> <sup>_, ω_</sup> <sup>_∈_</sup> <sup>_Ω_</sup> <sup>.</sup> <sup>Given</sup> the optimal option-value function _Q_ <sup>H</sup> _∗_ <sup>(</sup> <sup>_s, ω_</sup> <sup>) = max</sup> <sup>_µ_</sup> <sup>_Q_</sup> <sup>H</sup> _µ_ <sup>(</sup> <sup>_s, ω_</sup> <sup>), the optimal policy over options selects the highest-valued option</sup> in state _s_ at time step _tk_ . The Bellman Optimality Equation is <sup>H</sup> _∗_ <sup>(</sup> <sup>_s, ω_</sup> <sup>) = max</sup> <sup>_µ_</sup> <sup>_Q_</sup> <sup>H</sup> _µ_ _∗_ <sup>H(</sup> <sup>_s′, ω′_</sup> <sup>)</sup> <sup>_|E_</sup> <sup>(</sup> <sup>_ω, s_</sup> <sup>)</sup> _Q_ <sup>H</sup> _∗_ <sup>(</sup> <sup>_s, ω_</sup> <sup>) = E</sup> _Q_ <sup>H</sup> _∗_ - _r_ <sup>H</sup> ( _s, ω_ ) + max _ω_ <sup>_′_</sup> _ω_ <sup>_′_</sup> <sup>_Q_</sup> _∗_ <sup>H</sup> _,_ (25) where _E_ ( _ω, s_ ) denotes option _ω_ being initiated in state _s_ . _D._ _The_ _Low-Level_ _MDP_ As illustrated in Fig. 4, the course of the original MDP is divided into an interleaving of low-level MDPs and MRPs, where the time horizon _Tk_ <sup>c</sup> <sup>(resp.</sup> <sup>_T_</sup> <sup>o</sup> _k_ <sup>)</sup> <sup>of</sup> <sup>each</sup> <sup>low-level</sup> <sup>MDP</sup> <sup>(resp.</sup> <sup>MRP)</sup> <sup>corresponds</sup> <sup>to</sup> <sup>the</sup> <sup>charging</sup> <sup>(resp.</sup> <sup>operating)</sup> <sup>period</sup> <sup>in</sup> one transition of the high-level SMDP. In order to derive the intra-option policy _πω_, the low-level MDP is formulated below. In the low-level MDPs, the state is denoted as ( _St, ωt_ ), where the state in the original MDP, i.e., _St_, is augmented by including the current option _ωt_ . Let _S_ L <sup>+</sup> <sup>denote</sup> <sup>the</sup> <sup>low-level</sup> <sup>state</sup> <sup>space,</sup> <sup>which</sup> <sup>can</sup> <sup>be</sup> <sup>divided</sup> <sup>into</sup> <sup>the</sup> <sup>set</sup> <sup>of</sup> <sup>low-level</sup> <sup>non-</sup> terminal states _S_ L = _{St_ _∈S, ωt_ _∈_ _Ω|Bt_ = 1 _}_ and the set of low-level terminal states _S_ L <sup>T</sup> <sup>=</sup> <sup>_{St_</sup> <sup>_∈S, ωt_</sup> <sup>_∈_</sup> <sup>_Ω|Bt_</sup> <sup>= 0</sup> <sup>_}_</sup> <sup>.</sup> <sup>Note</sup> _k_ <sup>c</sup> <sup>(resp.</sup> <sup>_T_</sup> <sup>o</sup> _k_ terminal states _S_ L = _{St_ _∈S, ωt_ _∈_ _Ω|Bt_ = 1 _}_ and the set of low-level terminal states _S_ L <sup>T</sup> <sup>=</sup> <sup>_{St_</sup> <sup>_∈S, ωt_</sup> <sup>_∈_</sup> <sup>_Ω|Bt_</sup> <sup>= 0</sup> <sup>_}_</sup> <sup>.</sup> <sup>Note</sup> that the low-level MDP terminates whenever the EB enters the operating period, i.e., _Bt_ = 0. The actions and the transition probabilities are the same as those of the original MDP, since _ωt_ remains the same throughout the time horizon of the low-level MDP. Since we should ensure that the charging target of the selected option _ω_ is realized at the end of the current charging period, the intrinsic reward of the low-level MDPs is defined as _r_ <sup>L</sup> ( _s, ω, a_ ) = _−Ct_ ∆ _tPtBt,_ if ( _s, ω_ ) _∈S_ L _−κc_ <sup>tar</sup> ( _s, ω_ ) _,_ if ( _s, ω_ ) _∈S_ L <sup>T</sup> _−Ct_ ∆ _tPtBt,_ if ( _s, ω_ ) _∈S_ L _−κc_ <sup>tar</sup> ( _s, ω_ ) _,_ if ( _s, ω_ ) _∈S_ L <sup>T</sup> _,_ (26) where _c_ <sup>tar</sup> ( _s, ω_ ) = - _ω −_ _Etk_ + _Tk_ <sup>c</sup> �2 _._ (27) Note that _s_ = _St_ and _a_ = _πω_ ( _s_ ) when ( _s, ω_ ) _∈S_ L. Although no action is selected when ( _s, ω_ ) _∈S_ L <sup>T</sup> Note that _s_ = _St_ and _a_ = _πω_ ( _s_ ) when ( _s, ω_ ) _∈S_ L. Although no action is selected when ( _s, ω_ ) _∈S_ L <sup>T,</sup> <sup>we</sup> <sup>keep</sup> <sup>the</sup> <sup>action</sup> <sup>in</sup> the reward function of the terminal state for notational simplicity. Furthermore, _c_ <sup>tar</sup> ( _s, ω_ ) in (27) represents the penalty of not realizing the charging target, which is the squared error between the charging target _ω_ and the actual SoC level _Etk_ + _Tk_ <sup>c</sup> <sup>at</sup> <sup>the</sup> realizing the charging target, which is the squared error between the charging target _ω_ and the actual SoC level _Etk_ + _Tk_ <sup>c</sup> <sup>at</sup> <sup>the</sup> end of the charging period. Finally, _κ_ in (26) is the coefficient representing the relative importance of minimizing the charging cost versus the penalty _c_ <sup>tar</sup> ( _s, ω_ ). _κ_ is set to a high enough value to ensure that the charging target is met whenever possible. Let us define the low-level return _G_ <sup>L</sup> _t_ <sup>as</sup> <sup>the</sup> <sup>sum</sup> <sup>of</sup> <sup>the</sup> <sup>intrinsic</sup> <sup>rewards</sup> <sup>from</sup> <sup>time</sup> <sup>step</sup> <sup>_t_</sup> <sup>to</sup> <sup>the</sup> <sup>end</sup> <sup>of</sup> <sup>the</sup> <sup>time</sup> <sup>horizon</sup> <sup>of</sup> the low-level MDP, i.e., Let us define the low-level return _G_ <sup>L</sup> _t_  _tk_ + _Tk_ <sup>c</sup>  _k_ <sup>c]</sup> <sup>_._</sup> (28) _G_ <sup>L</sup> _t_ <sup>=</sup>  _k_ _t_ <sup>_′_</sup> = _t_ _r_ <sup>L</sup> ( _St′, ω, At′_ )  _, ∀t ∈_ [ _tk, tk_ + _Tk_ <sup>c</sup> The low-level value function _Vπ_ <sup>L</sup> _ω_ <sup>(</sup> <sup>_s, ω_</sup> <sup>)</sup> <sup>is</sup> <sup>defined</sup> <sup>as</sup> <sup>the</sup> <sup>expected</sup> <sup>return</sup> <sup>from</sup> <sup>starting</sup> <sup>in</sup> <sup>state</sup> <sup>(</sup> <sup>_s, ω_</sup> <sup>)</sup> <sup>and</sup> <sup>then</sup> <sup>following</sup> <sup>the</sup> intra-option policy _πω_, i.e., _Vπ_ <sup>L</sup> _ω_ <sup>(</sup> <sup>_s, ω_</sup> <sup>) = E</sup> <sup>_π_</sup> _ω_ - _G_ <sup>L</sup> _t_ <sup>_|St_</sup> <sup>=</sup> <sup>_s, ω_</sup> - _G_ <sup>L</sup> _t_ - _, ∀_ ( _s, ω_ ) _∈S_ L _._ (29) Note that the value function of low-level terminal states is always _−κc_ <sup>tar</sup> ( _s, ω_ ), i.e., _Vπ_ <sup>L</sup> _π_ <sup>L</sup> _ω_ <sup>(</sup> <sup>_s, ω_</sup> <sup>) =</sup> <sup>_−κc_</sup> <sup>tar(</sup> <sup>_s, ω_</sup> <sup>)</sup> <sup>_, ∀_</sup> <sup>(</sup> <sup>_s, ω_</sup> <sup>)</sup> <sup>_∈S_</sup> L <sup>T.</sup> Note that the value function of low-level terminal states is always _−κc_ <sup>tar</sup> ( _s, ω_ ), i.e., _Vπ_ <sup>L</sup> _ω_ <sup>(</sup> <sup>_s, ω_</sup> <sup>) =</sup> <sup>_−κc_</sup> <sup>tar(</sup> <sup>_s, ω_</sup> <sup>)</sup> <sup>_, ∀_</sup> <sup>(</sup> <sup>_s, ω_</sup> <sup>)</sup> <sup>_∈S_</sup> L <sup>T.</sup> The objective of the low-level MDP is to derive the optimal intra-option policy _πω_ <sup>_∗_</sup> <sup>that maximizes</sup> <sup>the low-level value</sup> <sup>function</sup> for all the states _V∗_ <sup>L</sup> _π_ <sup>L</sup> _ω_ <sup>_∗_</sup> <sup>(</sup> <sup>_s, ω_</sup> <sup>) = max</sup> _πω_ _∗_ <sup>L(</sup> <sup>_s, ω_</sup> <sup>) =</sup> <sup>_V_</sup> _π_ <sup>L</sup> _ω_ <sup>_∗_</sup> _πω_ <sup>_V_</sup> _π_ <sup>L</sup> _ω_ _π_ <sup>L</sup> _ω_ <sup>(</sup> <sup>_s, ω_</sup> <sup>)</sup> <sup>_, ∀_</sup> <sup>(</sup> <sup>_s, ω_</sup> <sup>)</sup> <sup>_∈S_</sup> <sup>L</sup> <sup>_._</sup> (30) In order to derive the optimal intra-option policy, the low-level action-value function or Q function _Q_ <sup>L</sup> _πω_ <sup>(</sup> <sup>_s, ω, a_</sup> <sup>)</sup> <sup>is</sup> <sup>defined</sup> as the expected low-level return from starting in state ( _s, ω_ ), taking action _a_, and then following policy _πω_, i.e., _Q_ <sup>L</sup> _πω_ <sup>(</sup> <sup>_s, ω, a_</sup> <sup>) = E</sup> <sup>_π_</sup> _ω_ - _G_ <sup>L</sup> _t_ <sup>_|_</sup> (31) _∀_ ( _s, ω_ ) _∈S_ L _, a ∈A._ <sup>L</sup> _t_ <sup>_|St_</sup> <sup>=</sup> <sup>_s, At_</sup> <sup>=</sup> <sup>_a, ω_</sup> - _,_ Note that the action-value function for the low-level terminal states is always _−κc_ <sup>tar</sup> ( _s, ω_ ), i.e., _Q_ <sup>L</sup> _πω_ <sup>(</sup> <sup>_s, ω, a_</sup> <sup>) =</sup> <sup>_−κc_</sup> <sup>tar(</sup> <sup>_s, ω_</sup> <sup>)</sup> <sup>_, ∀_</sup> <sup>(</sup> <sup>_s, ω_</sup> <sup>)</sup> <sup>_∈_</sup> _S_ L <sup>T</sup> <sup>_, a ∈A_</sup> <sup>.</sup> <sup>Given</sup> <sup>the</sup> <sup>optimal</sup> <sup>action-value</sup> <sup>function</sup> <sup>_Q_</sup> _∗_ <sup>L(</sup> <sup>_s, ω, a_</sup> <sup>) = max</sup> <sup>_π_</sup> _ω_ <sup>_Q_</sup> <sup>L</sup> _πω_ <sup>(</sup> <sup>_s, ω, a_</sup> <sup>),</sup> <sup>the</sup> <sup>optimal</sup> <sup>intra-option</sup> <sup>policy</sup> <sup>selects</sup> Note that the action-value function for the low-level terminal states is always _−κc_ <sup>tar</sup> ( _s, ω_ ), i.e., _Q_ <sup>L</sup> _π_ L <sup>T</sup> <sup>_, a ∈A_</sup> <sup>.</sup> <sup>Given</sup> <sup>the</sup> <sup>optimal</sup> <sup>action-value</sup> <sup>function</sup> <sup>_Q_</sup> _∗_ <sup>L</sup> _∗_ <sup>L(</sup> <sup>_s, ω, a_</sup> <sup>) = max</sup> <sup>_π_</sup> _ω_ <sup>_Q_</sup> <sup>L</sup> _π_ _S_ L <sup>T</sup> <sup>_, a ∈A_</sup> <sup>.</sup> <sup>Given</sup> <sup>the</sup> <sup>optimal</sup> <sup>action-value</sup> <sup>function</sup> <sup>_Q_</sup> _∗_ <sup>L(</sup> <sup>_s, ω, a_</sup> <sup>) = max</sup> <sup>_π_</sup> _ω_ <sup>_Q_</sup> <sup>L</sup> _πω_ <sup>(</sup> <sup>_s, ω, a_</sup> <sup>),</sup> <sup>the</sup> <sup>optimal</sup> <sup>intra-option</sup> <sup>policy</sup> <sup>selects</sup> the highest-valued action in state ( _s, ω_ ). The Bellman Optimality Equation is given as _∗_ <sup>L(</sup> <sup>_s′, ω, a′_</sup> <sup>)</sup> _Q_ <sup>L</sup> _∗_ <sup>(</sup> <sup>_s, ω, a_</sup> <sup>) = E</sup> _Q_ <sup>L</sup> _∗_ - _r_ <sup>L</sup> ( _s, ω, a_ ) + max _a_ <sup>_′_</sup> _a_ <sup>_′_</sup> <sup>_Q_</sup> _∗_ <sup>L</sup> _._ (32) Theorem 1. _The_ _flat_ _policy_ _created_ _by_ _superimposing_ _the_ _optimal_ _high-level_ _policy_ _over_ _options_ _µ_ <sup>_∗_</sup> _and_ _the_ _optimal_ _low-level_ _intra-option_ _policy_ _πω_ <sup>_∗_</sup> <sup>_performs_</sup> <sup>_as_</sup> <sup>_well_</sup> <sup>_as_</sup> <sup>_the_</sup> <sup>_optimal_</sup> <sup>_policy_</sup> <sup>_of_</sup> <sup>_the_</sup> <sup>_original_</sup> <sup>_MDP_</sup> <sup>_π∗,_</sup> <sup>_i.e.,_</sup> _Vπ∗_ ( _s_ ) = E _µ∗_ E _πω_ <sup>_∗_</sup> <sup>_∗_</sup> - _T −_ 1 _t_ =0 _r_ ( _St, At_ ) _|S_ 0 = _s_ _, ∀s ∈S,_ (33) _where_ _ω_ <sup>_∗_</sup> = _µ_ <sup>_∗_</sup> ( _s_ ) _,_ _∀s_ _∈S_ _represents_ _the_ _charging_ _targets_ _prescribed_ _by_ _µ_ <sup>_∗_</sup> _._ _Moreover,_ _µ_ <sup>_∗_</sup> _is_ _the_ _optimal_ _high-level_ _policy_ _over_ _options_ _when_ _the_ _optimal_ _low-level_ _intra-option_ _policy_ _πω_ <sup>_∗_</sup> <sup>_is_</sup> <sup>_available_</sup> <sup>_in_</sup> <sup>_the_</sup> <sup>_high-level_</sup> <sup>_SMDP._</sup> VI. DRL SOLUTION In this section, we present a DRL algorithm, namely the HDDQN-HER conceived for learning the optimal policy over options _µ_ <sup>_∗_</sup> by solving the high-level SMDP; and the optimal intra-option policy _πω_ <sup>_∗_</sup> <sup>by</sup> <sup>solving</sup> <sup>the</sup> <sup>low-level</sup> <sup>MDPs.</sup> _A._ _Overall_ _Training_ _Framework_ We adopt two deep Q networks, i.e., _Q_ <sup>H �</sup> _·_ ; _θ_ <sup>H�</sup> and _Q_ <sup>L �</sup> _·_ ; _θ_ <sup>L�</sup> with parameters _θ_ <sup>H</sup> and _θ_ L to approximate _Q_ <sup>H</sup> _∗_ <sup>(</sup> <sup>_s, ω_</sup> <sup>)</sup> <sup>and</sup> _Q_ <sup>L</sup> _∗_ <sup>(</sup> <sup>_s, ω, a_</sup> <sup>),</sup> <sup>respectively.</sup> <sup>The</sup> <sup>two</sup> <sup>networks</sup> <sup>are</sup> <sup>jointly</sup> <sup>trained,</sup> <sup>where</sup> <sup>the</sup> <sup>overall</sup> <sup>framework</sup> <sup>is</sup> <sup>illustrated</sup> <sup>in</sup> <sup>Fig.</sup> <sup>5.</sup> <sup>At</sup> <sup>each</sup> time step _t_, both the high-level and low-level agents receive state _St_ from the environment. The high-level agent only selects a charging target option _ωt_ based on _St_ when a new charging period starts, i.e., _Bt_ = 1 _, Bt−_ 1 = 0. The option is fed to the low-level agent instead of being fed to the environment. The low-level agent selects a charging schedule action _At_ at every time step _t_ in the charging period ( _Bt_ = 1) based on the state _St_ and the option _ωt_ . The action _At_ is fed to the environment, which responds to the agent by providing the reward _r_ ( _St, At_ ). Meanwhile, the environment directly provides the agent with the reward at each time step _t_ in the operating period ( _Bt_ = 0) without requiring an action from the agent. The high-level agent calculates the high-level reward _r_ <sup>H</sup> ( _St, ωt_ ) by summing up the reward _r_ ( _St, At_ ) during each SMDP transition. Meanwhile, the low-level agent derives the low-level reward _r_ <sup>L</sup> ( _St, ωt, At_ ) at each time step based on _r_ ( _St, At_ ) and _ωt_ according to (26) and (27). The two Q networks _Q_ <sup>H �</sup> _·_ ; _θ_ <sup>H�</sup> and _Q_ <sup>L �</sup> _·_ ; _θ_ <sup>L�</sup> are trained simultaneously based on the DDQN algorithm. We refer interested readers to [20] for details of the DDQN algorithm. The high-level and low-level agents draw experiences from their own replay buffers, i.e., _R_ <sup>H</sup> and _R_ <sup>L</sup>, respectively. The two replay buffers are updated at different time scales. More specifically, transitions for the low-level MDPs are collected and stored into _R_ <sup>L</sup> at each time step in the time horizon of the low-level MDP. However, only when the agent enters the terminal state or when an operating period terminates (i.e., _Bt_ = 0 and _Bt_ +1 = 1), will a new transition for the high-level SMDP be collected and stored into _R_ <sup>H</sup> . We adopt two deep Q networks, i.e., _Q_ <sup>H �</sup> _·_ ; _θ_ <sup>H�</sup> and _Q_ <sup>L �</sup> _·_ ; _θ_ <sup>L�</sup> with parameters _θ_ <sup>H</sup> and _θ_ L to approximate _Q_ <sup>H</sup> _∗_ The two Q networks _Q_ <sup>H �</sup> _·_ ; _θ_ <sup>H�</sup> and _Q_ <sup>L �</sup> _B._ _Overcoming_ _Non-Stationarity_ _in_ _Training_ _High-Level_ _Agent_ Based on the above framework, it is challenging to directly learn the high-level policy over options _µ_ <sup>_∗_</sup> and low-level intraoption policy _πω_ <sup>_∗_</sup> <sup>in</sup> <sup>parallel.</sup> <sup>This</sup> <sup>is</sup> <sup>mainly</sup> <sup>due</sup> <sup>to</sup> <sup>the</sup> <sup>non-stationary</sup> <sup>environment</sup> <sup>of</sup> <sup>the</sup> <sup>high-level</sup> <sup>agent,</sup> <sup>which</sup> <sup>is</sup> <sup>caused</sup> <sup>by</sup> exploring and updating low-level policy during training. Specifically, the non-stationarity has two facets. _•_ Non-stationary reward function: according to the low-level reward function defined in (26), the low-level agent learns to minimize the cumulative charging cost during the charging period, while ensuring that the charging target is realized. Therefore, the cumulative charging cost decreases, while the low-level policy improves during training, which means that the high-level reward function _r_ <sup>H</sup> ( _s, ω_ ) as defined in (19) changes over time. _•_ Non-stationary transition probabilities: a sub-optimal low-level policy activated during training might not be able to achieve the charging target _ω_ set by the high-level agent, while the charging target is actually achievable by the optimal low-level policy. In this case, the transition probability _Pss_ <sup>_ω_</sup> <sup>_′_</sup> <sup>of</sup> <sup>the</sup> <sup>high-level</sup> <sup>SMDP</sup> <sup>will</sup> <sup>change</sup> <sup>over</sup> <sup>time</sup> <sup>as</sup> <sup>the</sup> <sup>low-level</sup> <sup>policy</sup> learns to achieve the charging target. To overcome the above challenges, we adopt the following pair of measures so that the high-level SMDP model remains independent of the changing and exploring low-level policy. _•_ To deal with the non-stationary reward function, we divide the joint learning process into two phases. In the first phase when the number of training episodes is smaller than a threshold, i.e., _e_ _<_ _Mϵ_, the high-level rewards _r_ ˆ <sup>H</sup> stored in the high-level replay buffer _R_ <sup>H</sup> are obtained by running a fixed low-level policy _π_ q instead of those actually achieved by the low-level behavior policy that is being trained. In the second phase when _e_ ⩾ _Mϵ_, we calculate the high-level rewards Fig. 5: The framework of HDDQN-HER algorithm. _r_ ˆ <sup>H</sup> based on the low-level behavior policy, i.e., _r_ ˆ <sup>H</sup> = _r_ <sup>H</sup>, since the low-level policy almost converges to the optimal one at this phase and the non-stationary reward issue is negligible. _•_ To deal with the non-stationary transition probabilities, the actual SoC level of the battery _Etk_ + _Tk_ <sup>c</sup> <sup>at</sup> <sup>the</sup> <sup>end</sup> <sup>of</sup> <sup>the</sup> charging period is stored in the high-level replay buffer _R_ <sup>H</sup> as the option, instead of the actual option _ω_ that has been prescribed by the high-level agent at time step _tk_, when the charging period started. Therefore, the transition stored in _R_ <sup>H</sup> is - _Stk_ _,_ ˜ _ω,_ ˆ _r_ <sup>H</sup> ( _Stk_ _,_ ˜ _ω_ ) _, Stk_ + _T_ <sup>a</sup> - instead of - _Stk_ _, ω,_ ˆ _r_ <sup>H</sup> ( _Stk_ _, ω_ ) _, Stk_ + _T_ <sup>a</sup> �, where _ω_ ˜ = _Etk_ + _Tk_ <sup>c</sup> <sup>_._</sup> <sup>Note</sup> <sup>that</sup> <sup>the</sup> <sup>next</sup> <sup>state</sup> - _Stk_ _, ω,_ ˆ _r_ <sup>H</sup> ( _Stk_ _, ω_ ) _, Stk_ + _Tk_ <sup>a</sup> _k_ - _Stk_ _,_ ˜ _ω,_ ˆ _r_ <sup>H</sup> ( _Stk_ _,_ ˜ _ω_ ) _, Stk_ + _Tk_ <sup>a</sup> _R_ <sup>H</sup> is - _Stk_ _,_ ˜ _ω,_ ˆ _r_ <sup>H</sup> ( _Stk_ _,_ ˜ _ω_ ) _, Stk_ + _Tk_ <sup>a</sup> - instead of - _Stk_ _, ω,_ ˆ _r_ <sup>H</sup> ( _Stk_ _, ω_ ) _, Stk_ + _Tk_ <sup>a</sup> �, where _ω_ ˜ = _Etk_ + _Tk_ <sup>c</sup> <sup>_._</sup> <sup>Note</sup> <sup>that</sup> <sup>the</sup> <sup>next</sup> <sup>state</sup> _Stk_ + _Tk_ <sup>a</sup> <sup>is</sup> <sup>the</sup> <sup>one</sup> <sup>that</sup> <sup>is</sup> <sup>actually</sup> <sup>visited</sup> <sup>in</sup> <sup>this</sup> <sup>episode,</sup> <sup>and</sup> <sup>the</sup> <sup>reward</sup> <sup>_r_</sup> <sup>ˆH(</sup> <sup>_Stk_</sup> <sup>_,_</sup> <sup>˜</sup> <sup>_ω_</sup> <sup>)</sup> <sup>is</sup> <sup>calculated</sup> <sup>as</sup> <sup>described</sup> <sup>above,</sup> �, where _ω_ ˜ = _Etk_ + _Tk_ <sup>c</sup> _k_ - instead of _Stk_ + _Tk_ <sup>a</sup> <sup>is</sup> <sup>the</sup> <sup>one</sup> <sup>that</sup> <sup>is</sup> <sup>actually</sup> <sup>visited</sup> <sup>in</sup> <sup>this</sup> <sup>episode,</sup> <sup>and</sup> <sup>the</sup> <sup>reward</sup> <sup>_r_</sup> <sup>ˆH(</sup> <sup>_Stk_</sup> <sup>_,_</sup> <sup>˜</sup> <sup>_ω_</sup> <sup>)</sup> <sup>is</sup> <sup>calculated</sup> <sup>as</sup> <sup>described</sup> <sup>above,</sup> depending on the current training phase. _C._ _Improving_ _Sample_ _Efficiency_ _in_ _Training_ _the_ _Low-Level_ _Agent_ The low-level agent has to learn to achieve multiple charging targets, while only at the end of an episode will the penalty _c_ <sup>tar</sup> ( _s, ω_ ) of not realizing a given charging target be available in the low-level reward defined in (26). Both the multi-goal and sparse reward issues impair the sample efficiency in training the low-level agent, which leads to slow convergence in learning the low-level policy, as well as to an adverse effect in overcoming the non-stationarity for the high-level agent. To deal with the above challenges, we harness the following measures for improving the sample efficiency. _•_ _Restricting_ _the_ _Option_ _Space_ : In each charging period, the low-level agent tries to achieve the charging target prescribed by the high-level agent. However, some charging targets might be unachievable, when the high-level agent has not yet learned a good policy. As a result, learning to achieve such charging targets is futile for the low-level agent, and the corresponding experiences are wasted. – Given the SoC level _Et_ at the beginning of a charging period, some charging targets are unachievable by the end of the charging period even if the EB is fully charged or discharged at all the time steps. According to the dynamics of the SoC level in (6), a state-dependent option space _Ω_ <sup>_′_</sup> can be defined as _Ω_ <sup>_′_</sup> = _{ω_ _∈_ _Ω|ω_ _∈_ [ _Et −_ _τtD_ max _, Et_ + _τtC_ max] _} ._ (34) – If a charging target is too low, the EB will run out of battery power during operation and the MDP enters the terminal states. To exclude these unreasonable charging targets, all transitions ( _{−, ω}, −, −, {−, ω}_ ) associated with the current option _ω_ are deleted from _R_ <sup>L</sup>, whenever the agent enters the terminal states. _•_ _HER_ : In addition to the original transition - _{s, ω}, a, r_ <sup>L</sup> _, {s_ <sup>_′_</sup> _, ω}_ _HER_ : In addition to the original transition - _{s, ω}, a, r_ <sup>L</sup> _, {s_ <sup>_′_</sup> _, ω}_ - that is stored in the low-level replay buffer _R_ <sup>L</sup>, we create another hindsight transition, i.e., - _{s, TBD}, a,_ ˆ _r_ <sup>L</sup> _, {s_ <sup>_′_</sup> _, TBD}_ �. At the end of the charging period, the actual achieved - _{s, TBD}, a,_ ˆ _r_ <sup>L</sup> _, {s_ <sup>_′_</sup> _, TBD}_ another hindsight transition, i.e., - _{s, TBD}, a,_ ˆ _r_ <sup>L</sup> _, {s_ <sup>_′_</sup> _, TBD}_ �. At the end of the charging period, the actual achieved SoC levels _Etk_ + _Tk_ <sup>c</sup> <sup>are</sup> <sup>filled</sup> <sup>in</sup> <sup>the</sup> <sup>TBD</sup> <sup>components</sup> <sup>and</sup> <sup>the</sup> <sup>additional</sup> <sup>hindsight</sup> <sup>transitions</sup> <sup>are</sup> <sup>stored</sup> <sup>into</sup> <sup>_R_</sup> <sup>L</sup> <sup>if</sup> <sup>the</sup> SoC levels _Etk_ + _Tk_ <sup>c</sup> <sup>are</sup> <sup>filled</sup> <sup>in</sup> <sup>the</sup> <sup>TBD</sup> <sup>components</sup> <sup>and</sup> <sup>the</sup> <sup>additional</sup> <sup>hindsight</sup> <sup>transitions</sup> <sup>are</sup> <sup>stored</sup> <sup>into</sup> <sup>_R_</sup> <sup>L</sup> <sup>if</sup> <sup>the</sup> charging target _ω_ is not realized. Note that _r_ ˆ <sup>L</sup> = _r_ <sup>L</sup> at all the time steps, except for the last time step in the time horizon of the low-level MDP, i.e., _Bt_ = 0 and _Bt−_ 1 = 1, where _c_ <sup>tar</sup> ( _s, ω_ ) = 0 in _r_ ˆ <sup>L</sup> ( _s, ω, a_ ) since the substituted charging target _Etk_ + _Tk_ <sup>c</sup> <sup>is</sup> <sup>realized.</sup> <sup>This</sup> <sup>method</sup> <sup>guarantees</sup> <sup>that</sup> <sup>at</sup> <sup>least</sup> <sup>one</sup> <sup>sequence</sup> <sup>of</sup> <sup>transitions</sup> <sup>is</sup> <sup>stored</sup> <sup>in</sup> <sup>_R_</sup> <sup>L</sup> <sup>that</sup> <sup>succeeds</sup> target _Etk_ + _Tk_ <sup>c</sup> <sup>is</sup> <sup>realized.</sup> <sup>This</sup> <sup>method</sup> <sup>guarantees</sup> <sup>that</sup> <sup>at</sup> <sup>least</sup> <sup>one</sup> <sup>sequence</sup> <sup>of</sup> <sup>transitions</sup> <sup>is</sup> <sup>stored</sup> <sup>in</sup> <sup>_R_</sup> <sup>L</sup> <sup>that</sup> <sup>succeeds</sup> in realizing the charging target for each charging period. Algorithm 1 describes the pseudocode of the HDDQN-HER algorithm. The functions to select actions or options, store hindsight transitions into _R_ <sup>L</sup>, and to update the associated Q networks are presented by Algorithms 2, 3, and 4, respectively. <u>Algorithm</u> <u>1</u> <u>HDDQN-HER</u> <u>algorithm</u> Initialize _Q_ <sup>H �</sup> _s, ω_ ; _θ_ <sup>H�</sup> and _Q_ <sup>L �</sup> _s, ω, a_ ; _θ_ <sup>L�</sup> with _θ_ <sup>H</sup> = _θ_ 0 <sup>H</sup> <sup>and</sup> <sup>_θ_</sup> <sup>L</sup> <sup>=</sup> <sup>_θ_</sup> 0 <sup>L,</sup> <sup>respectively.</sup> <sup>Initialize</sup> <sup>target</sup> <sup>Q</sup> <sup>networks</sup> _Q_ <sup>H</sup> <sup>_−_</sup> <sup>�</sup> _s, a_ ; _θ_ <sup>H</sup> <sup>_−_</sup> <sup>�</sup> and _Q_ <sup>L</sup> <sup>_−_</sup> <sup>�</sup> _s, ω, a_ ; _θ_ <sup>L</sup> <sup>_−_</sup> <sup>�</sup> with _θ_ <sup>H</sup> <sup>_−_</sup> _←_ _θ_ <sup>H</sup> and _θ_ <sup>L</sup> <sup>_−_</sup> _←_ _θ_ <sup>L</sup> . Initialize _R_ <sup>H</sup> and _R_ <sup>L</sup>, exploration probability 1: Initialize _Q_ <sup>H �</sup> _s, ω_ ; _θ_ <sup>H�</sup> and _Q_ <sup>L �</sup> _s, ω, a_ ; _θ_ <sup>L�</sup> with _θ_ <sup>H</sup> = _θ_ 0 <sup>H</sup> _Q_ <sup>H</sup> <sup>_−_</sup> <sup>�</sup> _s, a_ ; _θ_ <sup>H</sup> <sup>_−_</sup> <sup>�</sup> and _Q_ <sup>L</sup> <sup>_−_</sup> <sup>�</sup> _s, ω, a_ ; _θ_ <sup>L</sup> <sup>_−_</sup> <sup>�</sup> with _θ_ <sup>H</sup> <sup>_−_</sup> _←_ _θ_ <sup>H</sup> and _θ_ <sup>L</sup> <sup>_−_</sup> _←_ _θ_ <sup>L</sup> . Initialize _R_ <sup>H</sup> and _R_ <sup>L</sup>, exploration probability _ϵ_ <sup>L</sup> = 1 and _ϵ_ <sup>H</sup> = 1. 2: for episode _e_ = 1 _, ..., M_ do 3: Receive the start state _s_ 4: Derive the option space _Ω_ <sup>_′_</sup> based on (34) 5: _r_ <sup>H</sup> ( _s, ω_ ) _←_ 0, _s_ 0 _←_ _s_ 6: _ω_ _←_ _ϵ_ -GREEDY( _s_ 0, _Ω_ <sup>_′_</sup>, _ϵ_ <sup>H</sup>, _Q_ <sup>H �</sup> _s_ 0 _, ω_ ; _θ_ <sup>H�</sup> ), _ω_ ˜ _←_ _ω_ _s, a_ ; _θ_ <sup>H</sup> <sup>_−_</sup> <sup>�</sup> and _Q_ <sup>L</sup> <sup>_−_</sup> <sup>�</sup> _s, ω, a_ ; _θ_ <sup>L</sup> <sup>_−_</sup> <sup>�</sup> _s_ 0 _, ω_ ; _θ_ <sup>H�</sup> ), _ω_ ˜ _←_ _ω_ 7: for _t_ = 1 _, ..., T_ do 8: if _Bt_ = 1 then 9: _a ←_ _ϵ_ -GREEDY( _{s, ω}_, _A_, _ϵ_ <sup>L</sup>, _Q_ <sup>L �</sup> _s, ω, a_ ; _θ_ <sup>L�</sup> 9: _a ←_ _ϵ_ -GREEDY( _{s, ω}_, _A_, _ϵ_ <sup>L</sup>, _Q_ <sup>L �</sup> _s, ω, a_ ; _θ_ <sup>L�</sup> ) 10: Execute action _a_ and observe reward _r_ ( _s, a_ ), and next state _s_ <sup>_′_</sup> from environment 11: Derive low-level reward _r_ <sup>L</sup> ( _s, ω, a_ ), - 12: Store _{s, ω}, a, r_ <sup>L</sup> _, {s_ <sup>_′_</sup> _, ω}_ into _R_ <sup>L</sup> - _{s, ω}, a, r_ <sup>L</sup> _, {s_ <sup>_′_</sup> _, ω}_ - into _R_ <sup>L</sup> 13: HER( _s, ω, a, r_ <sup>L</sup> _, s_ <sup>_′_</sup> _,_ ˜ _ω, R_ <sup>L</sup> ) 14: else 15: Observe action _a_, reward _r_ ( _s, a_ ), and next state _s_ <sup>_′_</sup> from environment 16: end if 17: UPDATE( _R_ <sup>L</sup>, _Q_ <sup>L �</sup> _·_ ; _θ_ <sup>L�</sup>, _Q_ <sup>L</sup> <sup>_−_</sup> <sup>�</sup> _·_ ; _θ_ <sup>L</sup> <sup>_−_</sup> <sup>�</sup> ) 17: UPDATE( _R_ <sup>L</sup>, _Q_ <sup>L �</sup> _·_ ; _θ_ <sup>L�</sup>, _Q_ <sup>L</sup> <sup>_−_</sup> <sup>�</sup> _·_ ; _θ_ <sup>L</sup> <sup>_−_</sup> <sup>�</sup> ) 18: _r_ <sup>H</sup> _←_ _r_ <sup>H</sup> + _r_ ( _s, a_ ) _·_ ; _θ_ <sup>L�</sup>, _Q_ <sup>L</sup> <sup>_−_</sup> <sup>�</sup> _·_ 19: if _s_ is terminal state or _Bt_ = 0 _, Bt_ +1 = 1 then 20: if _e < Mϵ_ then 21: Derive _r_ ˆ <sup>H</sup> by running policy _π_ <sup>q</sup> 22: else 23: _r_ ˆ <sup>H</sup> = _r_ <sup>H</sup> 24: end if 25: Store transition - _s_ 0 _,_ ˜ _ω,_ ˆ _r_ <sup>H</sup> _, s_ <sup>_′_</sup> <sup>�</sup> into _R_ <sup>H</sup> 26: UPDATE( _R_ <sup>H</sup>, _Q_ <sup>H �</sup> _·_ ; _θ_ <sup>H�</sup>, _Q_ <sup>H</sup> <sup>_−_</sup> <sup>�</sup> _·_ ; _θ_ <sup>H</sup> <sup>_−_</sup> <sup>�</sup> ) 27: if _s_ is terminal state then 28: Delete ( _{−, ω}, −, −, {−, ω}_ ) from _R_ <sup>L</sup> 26: UPDATE( _R_ <sup>H</sup>, _Q_ <sup>H �</sup> _·_ ; _θ_ <sup>H�</sup>, _Q_ <sup>H</sup> <sup>_−_</sup> <sup>�</sup> 29: Terminate this episode 30: else 31: Update _Ω_ <sup>_′_</sup> based on (34) 32: _ω_ _←_ _ϵ_ -GREEDY( _s_ <sup>_′_</sup>, _Ω_ <sup>_′_</sup>, _ϵ_ <sup>H</sup>, _Q_ <sup>H �</sup> _s_ <sup>_′_</sup> _, ω_ ; _θ_ <sup>H�</sup> 32: _ω_ _←_ _ϵ_ -GREEDY( _s_ <sup>_′_</sup>, _Ω_ <sup>_′_</sup>, _ϵ_ <sup>H</sup>, _Q_ <sup>H �</sup> _s_ <sup>_′_</sup> _, ω_ ; _θ_ <sup>H�</sup> ) 33: _r_ <sup>H</sup> ( _s, ω_ ) _←_ 0, _s_ 0 _←_ _s_ <sup>_′_</sup>, _ω_ ˜ _←_ _ω_ 34: end if 35: end if 36: _s ←_ _s_ <sup>_′_</sup> 37: end for 38: Anneal _ϵ_ <sup>L</sup> and _ϵ_ <sup>H</sup> 39: <u>end</u> <u>for</u> In Algorithm 2, the options or actions are prescribed based on the popular _ϵ_ -greedy policy, while in Algorithm 4, the two Q networks _Q_ <sup>H �</sup> _·_ ; _θ_ <sup>H�</sup> and _Q_ <sup>L �</sup> _·_ ; _θ_ <sup>L�</sup> are updated based on the corresponding sampled minibatch of transitions. _·_ ; _θ_ <sup>H�</sup> and _Q_ <sup>L �</sup> _·_ ; _θ_ <sup>L�</sup> are updated based on the corresponding sampled minibatch of transitions. VII. NUMERICAL ANALYSIS In order to evaluate the effectiveness of the proposed HDDQN-HER algorithm, we perform experiments based on real-world data. All the experiments are performed on a Linux server, where the DRL algorithms are implemented in Tensorflow 1.14 using Python 3.6. _A._ _Experimental_ _Setup_ _1)_ _Simulated_ _Environment:_ The environment that is simulated in our experiments comprises three EBs serving the same bus route. Each of the EBs operates according to a fixed daily schedule [47]. Specifically, the first EB departs from the terminal station at 6:30 in the morning, and the last one departs at midnight, i.e., 0:00. An EB is scheduled to depart every 30 minutes during this period, which means that the duration between two consecutive departures of each EB is 90 minutes. The <u>Algorithm</u> <u>2</u> <u>Select</u> <u>action</u> _<u>a</u>_ <u>or</u> <u>options</u> _<u>ω</u>_ 1: function _ϵ_ -GREEDY( _x_, _B_, _ϵ_, _Q_ ( _·_ ; _θ_ )) 2: if random() _< ϵ_ then 3: return random element from set _B_ 4: else 5: return arg max _Q_ ( _x, b_ ; _θ_ ) _b∈B_ 6: end if 7: <u>end</u> <u>function</u> <u>Algorithm</u> <u>3</u> <u>Store</u> <u>hindsight</u> <u>transitions</u> 1: function HER( _s, ω, a, r_ <sup>L</sup> _, s_ <sup>_′_</sup> _,_ ˜ _ω, R_ <sup>L</sup> ) 2: Creat hindsight transition _{s, TBD_ - where _r_ ˆ <sup>L</sup> = _r_ <sup>L</sup> - _{s, TBD}, a,_ ˆ _r_ <sup>L</sup> _, {s_ <sup>_′_</sup> _, TBD}_ 3: if _Bt_ +1 = 0 and _ω̸_ = _Et_ +1 then 4: _ω_ ˜ _←_ _Et_ +1, update reward _r_ ˆ <sup>L</sup> 5: Replace _TBD_ with _ω_ ˜ and store hindsight transitions into _R_ <sup>L</sup> 6: end if 7: <u>end</u> <u>function</u> duration of the operating period _Tk_ <sup>o</sup> duration of the operating period _Tk_ <sup>o</sup> <sup>follows</sup> <sup>normal</sup> <sup>distributions</sup> <sup>with</sup> <sup>different</sup> <sup>mean</sup> <sup>values</sup> <sup>at</sup> <sup>different</sup> <sup>times</sup> <sup>of</sup> <sup>the</sup> <sup>day,</sup> <sup>i.e.,</sup> _Tk_ <sup>o</sup> <sup>_∼N_</sup> <sup>(50</sup> <sup>_,_</sup> <sup>8)</sup> <sup>at</sup> <sup>rush</sup> <sup>hours</sup> <sup>(7:00-9:00</sup> <sup>and</sup> <sup>17:00-19:00)</sup> <sup>and</sup> <sup>_T_</sup> <sup>o</sup> _k_ <sup>_∼N_</sup> <sup>(40</sup> <sup>_,_</sup> <sup>8)</sup> <sup>at</sup> <sup>other</sup> <sup>times.</sup> The time horizon for each EB always starts with a charging period, when it arrives at the terminal station after its first departure in the morning, where a pair of consecutive charging and operating periods corresponds to one transition in the high-level SMDP. The duration of a time step is set to 10 minutes, i.e., ∆ _t_ = 10 min. The parameters of the environment are listed in Table III. _2)_ _Experimental data:_ We use real-world data on electricity prices to train the DRL agents. The dataset contains hourly timevarying electricity prices that reflect the wholesale market price derived from the Midcontinent Independent System Operator (MISO) delivery point [48]. Since the electricity price data from one month closely approximates the statistical distribution observed over an entire year, we adopt the one-month electricity price data for training. Specifically, the data in January 2023 is used for training, and the data in the first week of February 2023 is used for testing. Fig. 6 shows the trajectories of electricity prices on a typical day. By observing the fluctuations over time, we find that electricity prices are highest with the value of $0 _._ 03921/kWh during the hours of peak demand (between 17:00 and 18:00 daily). _k_ <sup>o</sup> <sup>_∼N_</sup> <sup>(50</sup> <sup>_,_</sup> <sup>8)</sup> <sup>at</sup> <sup>rush</sup> <sup>hours</sup> <sup>(7:00-9:00</sup> <sup>and</sup> <sup>17:00-19:00)</sup> <sup>and</sup> <sup>_T_</sup> <sup>o</sup> _k_ _3)_ _Baseline_ _algorithms:_ Several baseline algorithms are simulated for performance comparison with HDDQN-HER. 1) _DDQN-Original_ : The original MDP of Section III is directly solved by DDQN to obtain a flat policy _π_ . 2) _DDQN-Low_ : The low-level MDPs corresponding to the charging periods are solved by DDQN. However, the charging target is set to the maximum battery capacity, as in [3], [26], rather than being determined by the policy over options. The reward function of the low-level MDPs is similar to that defined in (26), except that _κc_ <sup>tar</sup> ( _s, ω_ ) is replaced by _κ_ <sup>_′_</sup> <sup>�</sup> _E_ max _−_ _Etk_ + _T_ <sup>c</sup> �2, which measures the range anxiety. _κ_ <sup>_′_</sup> <sup>�</sup> _E_ max _−_ _Etk_ + _Tk_ <sup>c</sup> �2, which measures the range anxiety. 3) _DDQN-High_ : The high-level SMDP is solved by DDQN to learn the charging target. However, the low-level MDPs are solved by a fixed policy _π_ <sup>q</sup> rather than by the intra-option policy _πω_ <sup>_∗_</sup> <sup>learned</sup> <sup>by</sup> <sup>training</sup> <sup>the</sup> <sup>low-level</sup> <sup>agent.</sup> <sup>Specifically,</sup> _E_ max _−_ _Etk_ + _Tk_ <sup>c</sup> _k_ solved by a fixed policy _π_ <sup>q</sup> rather than by the intra-option policy _πω_ <sup>_∗_</sup> <sup>learned</sup> <sup>by</sup> <sup>training</sup> <sup>the</sup> <sup>low-level</sup> <sup>agent.</sup> <sup>Specifically,</sup> the charging target is realized whenever possible without considering the fluctuating electricity prices. This approach adapts the charging power at a coarse time scale, specifically once per charging period, similar to the method in [13]. 4) _HDDQN_ : Both the high-level SMDP and low-level MDPs are solved by two DDQN networks, respectively. This approach adopts the same framework as in Fig. 5, namely the HDDQN-HER. However, the methods of overcoming non-stationarity and improving sample efficiency in Section VI.B and C are not adopted. Note that a fixed low-level policy _π_ <sup>q</sup> is used in DDQN-High as well as the first learning phase in HDDQN-HER. In the experiments, we set _π_ <sup>q</sup> as follows: at each time step in a charging period, the charging power _ct_ is set to the maximum value until the charging target is realized. The hyper-parameters of the DDQN networks are listed in Table IV. Note that the total number of training episodes is 24000. The training process of HDDQN-HER is divided into two phases with the threshold of _Me_ = 6000. Therefore, the first phase corresponds to when the training episodes obey _e_ _<_ 6000, while the second phase corresponds to 6000 _≤_ _e_ _≤_ 24000. The entire training process took approximately 10 hours, while executing a single episode during the deployment process took less than 15 seconds. _B._ _Experimental_ _Results_ _1)_ _Performance_ _for_ _the_ _test_ _set:_ For each EB, we executed 100 complete episodes based on the test set after training. We obtain the individual performance of each EB by averaging its return over the test episodes, where the return of one <u>Algorithm</u> <u>4</u> <u>Networks</u> <u>updating</u> 1: function UPDATE( _R_, _Q_ ( _·_ ; _θ_ ), _Q_ <sup>_−_</sup> ( _·_ ; _θ_ <sup>_−_</sup> )) 2: Sample a random minibatch _M_ = _{s_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> _, a_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> _, r_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> _, s_ <sup>_′_</sup> <sup>(</sup> <sup>_i_</sup> <sup>)</sup> _}_ from _R_ and set the target - ; _θ_ <sup>_−_</sup> _y_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> = _r_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> + _Q_ <sup>_−_</sup> _s_ <sup>_′_</sup> <sup>(</sup> <sup>_i_</sup> <sup>)</sup> _,_ arg max _Q_ _a_ - _s_ <sup>_′_</sup> <sup>(</sup> <sup>_i_</sup> <sup>)</sup> _, a_ ; _θ_ 3: Update _Q_ by gradient descent on loss _L_ ( _θ_ ), where <u>1</u> _L_ ( _θ_ ) = _|M|_ _i∈M_ - _s_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> _, a_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> ; _θ_ ��2 _,_ - _y_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> _−Q_ 4: <u>end</u> <u>function</u> TABLE III: Parameter configuration in the system model. <u>Notations</u> <u>Values</u> <u>Description</u> _wp_ 4 The length of the time window to look into the past prices _C_ max / _D_ max 120kW / The maximum absolute 120kW value of charging/discharging power of EBs _E_ min / _E_ max 0kWh / The minimum / maximum 240kWh storage constraint of the battery _C_ <sup>end</sup> 50 The penalty for EB to enter the terminal states _κ_ / _κ_ <sup>_′_</sup> 0.005 / The coefficients of the 0.0006 penalty _c_ <sup>tar</sup> ( _St, ωt_ )/ the cost of range anxiety episode is defined in (12). Table V summarizes the individual performance of each EB, as well as the average and maximum performance over the three EBs for all the algorithms. The performance rankings are consistent, where HDDQN-HER achieves the best performance, followed by HDDQN, DDQN-High, DDQN-Original, and DDQN-Low. The average performance of HDDQN-HER is better than those of the baseline algorithms by 0.097%, 9.85%, 28.44%, and 39.60%, respectively. Both HDDQN and HDDQN-HER achieve much better performance than the other algorithms, demonstrating the effectiveness of our proposed framework in Fig. 5. Note that HDDQN-HER only achieves slightly better average performance than HDDQN, while the maximum performances of the two algorithms are nearly the same. These results show that the proposed methods of overcoming non-stationarity and improving sample efficiency do not improve the final performance of HDDQN-HER much over HDDQN as long as sufficient training episodes are run. However, a significant convergence speed of the training process is observed, as it will be discussed in Section VII.B 2). DDQN-Original performs worse than both HDDQN-HER and HDDQN, since it struggles to learn an optimal policy by directly solving the original MDP for a long horizon. As the penalty _C_ <sup>end</sup> for entering the terminal states is sparse, a long sequence of highly-specific actions must be executed prior to observing a terminal reward, which makes the learning task challenging. Meanwhile, the hierarchical framework in HDDQN-HER provides an intrinsic reward for the low-level MDPs through options, which substantially improves the sample efficiency. HDDQN-HER outperforms DDQN-Low due to the more reasonable charging target in the reward function. The charging target of DDQN-Low is set to the maximum battery capacity, while those of HDDQN-HER are learned by solving the high-level SMDP. Therefore, HDDQN-HER can adapt to the electricity price changes throughout the day and consider the long-range effects of decisions. In addition, compared to HDDQN-HER, DDQN-High discards the low-level DDQN network, which prevents it from adapting EB charging power at a fine time scale to fluctuating electricity prices. Consequently, it cannot learn optimal policies for the low-level MDPs. Finally, comparisons with both DDQN-High and DDQN-Low demonstrate the importance of both levels of DDQN networks for the proposed algorithm. Omitting either level would hinder the algorithm’s ability to achieve optimal performance. _2)_ _Convergence_ _Properties:_ Fig. 7 shows the performance curves of the algorithms, which are obtained by periodically evaluating the policies during training. Specifically, we ran 10 test episodes for every 100 training episode, where the X-axis Fig. 6: The trajectories of the electricity prices of a typical day in the experimental data. Fig. 7: The performance curves of the algorithms in the training process. The vertical axis corresponds to the average performance across the three EBs, and the shaded areas represent the standard errors. is the number of training episodes and the Y-axis is the performance corresponding to the average return over the latest 10 test episodes. The shaded areas indicate the standard errors across the three EBs. The proposed HDDQN-HER converges first at approximately 8500 episodes, followed by DDQN-Low at approximately 10000 episodes due to its simple framework and short time horizon. However, the performance of DDQN-Low after convergence is inferior to those of the other algorithms. DDQN-High also converges relatively fast at approximately 12000 episodes. By contrast, without the methods of overcoming non-stationarity and improving sample efficiency in HDDQN-HER, HDDQN converges slowly at around 15000 episodes. Finally, the convergence of DDQN-Original is the slowest, which converges at around 18000 episodes. This result further demonstrates the low sample and learning efficiency, when directly solving a longrange planning problem by RL. The shaded areas of all the algorithms are relatively small, which shows that all the algorithms perform consistently for different EBs. _3)_ _Charging_ _Schedule_ _Results:_ Fig. 8 illustrates the detailed charging schedule decisions and corresponding costs for EB A at each time step in a typical episode based on the test set. The grey and white regions indicate the operating and charging periods, respectively. Fig. 8(a), 8(c), and 8(e) show the charging power at each time step and the EB’s battery trajectory. Notice that there is a horizontal line for each charging period in Fig. 8(a), which represents the learned charging target. In Fig. 8(b), 8(d), and 8(f), the sum cost trajectory is displayed as a curve, where the sum cost at time step _t_ is derived by the negative reward _−r_ ( _St, At_ ) in (11). Since the sum cost consists of two components, i.e., the charging cost and the cost of entering terminal states, we use the bar chart to visualize the individual costs in detail. Moreover, the cost components in the reward function of low-level MDPs are displayed, which include the cost of not realizing the charging target _κc_ <sup>tar</sup> ( _St, ωt_ ) in HDDQN-HER, and the cost of range anxiety _κ_ <sup>_′_</sup> <sup>�</sup> _E_ max _−_ _Etk_ + _T_ <sup>c</sup> �2 in DDQN-Low. HDDQN-HER, and the cost of range anxiety _κ_ <sup>_′_</sup> <sup>�</sup> _E_ max _−_ _Etk_ + _Tk_ <sup>c</sup> �2 in DDQN-Low. Fig. 8(b), 8(d), and 8(f) show that there is no cost for entering the terminal states, which means that the basic requirement of ensuring sufficient battery energy can be met by all the algorithms. A closer examination of Fig. 8(a) and 8(c) shows that the battery trajectory curve of HDDQN-HER fluctuates much more than that of DDQN-Original, which is because the high-level _E_ max _−_ _Etk_ + _Tk_ <sup>c</sup> _k_ TABLE IV: Hyper-parameters of various DRL algorithms. Algorithms Parameters DDQN- Q network size Learning Rate Batch Size Training Episodes high-level 256,300,100 5e-6 128 6000+18000 low-level 256,300,100 5e-6 64 6000+18000 Original 256,300,100 5e-6 128 24000 High 256,300,100 5e-6 128 24000 Low 400,300,100 1e-6 64 24000 TABLE V: The individual, average, and maximum performance of the algorithms across three EBs. <u>Performance</u> Algorithms <u>EB</u> <u>A</u> <u>EB</u> <u>B</u> <u>EB</u> <u>C</u> <u>Max</u> <u>Average</u> <u>HDDQN-HER</u> <u>-10.23</u> <u>-10.48</u> <u>-10.31</u> <u>-10.23</u> <u>-10.34</u> <u>HDDQN</u> <u>-10.23</u> <u>-10.50</u> <u>-10.32</u> <u>-10.23</u> <u>-10.35</u> <u>DDQN-High</u> <u>-11.25</u> <u>-11.67</u> <u>-11.48</u> <u>-11.25</u> <u>-11.47</u> <u>DDQN-Original</u> <u>-14.08</u> <u>-14.67</u> <u>-14.59</u> <u>-14.08</u> <u>-14.45</u> <u>DDQN-Low</u> <u>-16.92</u> <u>-17.38</u> <u>-17.05</u> <u>-16.92</u> <u>-17.12</u> DDQN in the proposed algorithm can better learn the fluctuating trends of electricity prices in a full day. Therefore, the high-level agent decides to charge more when the electricity price is low in the afternoon from 14:00 to 16:00, and sell more electricity when the price is the highest, namely from 17:00 to 19:00 to minimize its charging cost. Meanwhile, DDQN-Original is unable to learn such an efficient policy, which leads to the relatively high charging cost seen in Fig. 8(d). Additionally, Fig. 8(a) shows that HDDQN-HER can realize the charging target in every charging period, and thus no corresponding cost is incurred, as shown in Fig. 8(b). Finally, as shown in Fig. 8(e), the battery SoC curve of DDQN-Low continues to remain high, since the charging target is the constant full battery capacity. Due to the cost of range anxiety, the agent tends to fully charge the EB in most charging periods, which is an essential reason why DDQN-Low has the highest charging cost. It can be observed in Fig. 8(f) that the cost of range anxiety is always zero except in the 8-th and 9-th charging periods, which means that the EB is always fully charged except in these two periods. VIII. CONCLUSIONS We have studied how to use HDRL techniques to learn optimal charging schedules for EBs in a system model giving full cognizance to both the charging and operating periods. An MDP model has been conceived, which has been reformulated into a two-level decision process in order to overcome the challenges of long-range multi-phase planning with sparse rewards. It has been proved that the flat policy created by superimposing the optimal high-level and low-level policies performs as well as the optimal policy of the original MDP. The HDDQN-HER algorithm has been conceived for training the two levels of agents simultaneously, in which compelling methods leveraging the idea of HER are proposed to deal with the non-stationarity encountered in training the high-level agent and to improve the sample efficiency in training the low-level agent. Finally, experiments have been performed to demonstrate that the proposed algorithm achieves better performance than the baseline algorithms. In our future work, the HDRL framework will be extended to consider charging schedules for EB fleets, where the high-level bus scheduling decisions that are made at a coarser time-scale can be optimized jointly with the low-level charging power decisions made at a finer time-scale. Our ultimate goal is to leash all solutions of the multi-component Pareto-front having a gradually increased number of parameters in the objective function. Additionally, we will integrate safe RL techniques to provide formal guarantees that the agent does not enter terminal states. This enhancement will further improve the robustness of our approach in real-world deployments. Finally, we plan to incorporate real-world EB operational data instead of simulated data in our experiments to better capture real-world uncertainties and refine policy performance under practical conditions. APPENDIX A PROOF FOR THEOREM 1 _Proof._ _•_ Reparation stage: Without loss of generality, the R.H.S. of (33) in Theorem 1 can be derived as (a) charging scheduling of HDDQN-HER (b) costs of HDDQN-HER (c) charging scheduling of DDQN-Original (d) costs of DDQN-Original (e) charging scheduling of DDQN-Low (f) costs of DDQN-Low Fig. 8: A specific test episode on an EB. _r_ ( _St, At_ ) _|S_ 0 = _s_  (b) = max _π_ <sup>E</sup> <sup>_π_</sup> - _T −_ 1 _t_ =0 _Vπ∗_ ( _s_ ) (a) = max _π_ <sup>_Vπ_</sup> <sup>(</sup> <sup>_s_</sup> <sup>)</sup> _Tk_ <sup>a</sup> <sup>_−_</sup> <sup>1</sup> _l_ =0 (c) = max _π_ <sup>E</sup> <sup>_π_</sup>  _K−_ 1  _k_ =0 _r_ ( _Stk_ + _l, Atk_ + _l_ ) _|S_ 0 = _s_  _, ∀s ∈S,_ (35) where (a) is because _π_ <sup>_∗_</sup> is the optimal flat policy; (b) is derived by definition of _Vπ_ ( _s_ ); (c) reformulates the reward summation by grouping rewards according to periods. When a charging period _k_ _∈{_ 0 _,_ 1 _, · · ·_ _, K −_ 1 _}_ terminates after a random number of _Tk_ <sup>c</sup> <sup>time</sup> <sup>steps,</sup> <sup>we</sup> <sup>denote</sup> <sup>the</sup> <sup>SoC</sup> <sup>of</sup> the battery when following the optimal flat policy _π_ <sup>_∗_</sup> as _Et_ <sup>_∗_</sup> _k_ + _Tk_ <sup>c</sup> <sup>.</sup> In the following, we will prove Theorem 1 in two steps . Specifically, we decouple _π_ <sup>_∗_</sup> into a high-level policy over options _µ_ ˆ and a low-level intra-option policy _π_ ˆ _ω_ . Thus, the SoC levels _Et_ <sup>_∗_</sup> _k_ + _Tk_ <sup>c</sup> <sup>,</sup> <sup>_∀k_</sup> <sup>_∈{_</sup> <sup>0</sup> <sup>_,_</sup> <sup>1</sup> <sup>_, · · ·_</sup> <sup>_, K −_</sup> <sup>1</sup> <sup>_}_</sup> <sup>can</sup> <sup>be</sup> <sup>regarded</sup> <sup>as</sup> <sup>the</sup> <sup>charging</sup> When a charging period _k_ _∈{_ 0 _,_ 1 _, · · ·_ _, K −_ 1 _}_ terminates after a random number of _Tk_ <sup>c</sup> _tk_ + _Tk_ <sup>c</sup> and a low-level intra-option policy _π_ ˆ _ω_ . Thus, the SoC levels _Et_ <sup>_∗_</sup> _k_ + _Tk_ <sup>c</sup> <sup>,</sup> <sup>_∀k_</sup> <sup>_∈{_</sup> <sup>0</sup> <sup>_,_</sup> <sup>1</sup> <sup>_, · · ·_</sup> <sup>_, K −_</sup> <sup>1</sup> <sup>_}_</sup> <sup>can</sup> <sup>be</sup> <sup>regarded</sup> <sup>as</sup> <sup>the</sup> <sup>charging</sup> targets prescribed by _µ_ ˆ, i.e., _tk_ + _Tk_ <sup>c</sup> _µ_ ˆ( _Stk_ ) = _ω_ ˆ = _Et_ <sup>_∗_</sup> _k_ <sup>c</sup> <sup>_, ∀k_</sup> <sup>_∈{_</sup> <sup>0</sup> <sup>_,_</sup> <sup>1</sup> <sup>_, · · ·_</sup> <sup>_, K −_</sup> <sup>1</sup> <sup>_},_</sup> (36) _t_ <sup>_∗_</sup> _k_ + _Tk_ <sup>c</sup> while the charging target _ω_ ˆ is fulfilled by the policy _π_ ˆ _ω_ ˆ, i.e., _π_ ˆ _ω_ ˆ ( _St_ ) = _π_ <sup>_∗_</sup> ( _St_ ) _, ∀t ∈{tk, · · ·_ _, tk_ + _Tk_ <sup>c</sup> <sup>_−_</sup> <sup>1</sup> <sup>_}._</sup> (37) _•_ In the first step, we will prove that the optimal low-level intra-option policy _πω_ <sup>_∗_</sup> ˆ <sup>achieves</sup> <sup>the</sup> <sup>same</sup> <sup>performance</sup> <sup>as</sup> <sup>_π_</sup> <sup>ˆ</sup> <sup>_ω_</sup> <sup>ˆ</sup> does when their charging targets are both prescribed by _µ_ ˆ in (36), i.e.,  _Tk_ <sup>c</sup>  E _πω_ <sup>_∗_</sup> ˆ _k_  _l_ =0  _Tk_ <sup>c</sup> _r_ ( _Stk_ + _l, Atk_ + _l_ ) _|Stk_ = _s_  _._ (38) _r_ ( _Stk_ + _l, Atk_ + _l_ ) _|Stk_ = _s_   = E _π_ ˆ _ω_ ˆ _k_  _l_ =0 For this purpose, we adopt the proof by contradiction method and assume that (38) does not hold. Firstly, we have   E _πω_ <sup>_∗_</sup> ˆ _Tk_ <sup>c</sup>  _r_ ( _Stk_ + _l, Atk_ + _l_ ) _|Stk_ = _s_  _l_ =0  _r_ <sup>L</sup> ( _Stk_ + _l,_ ˆ _ω, Atk_ + _l_ ) _|Stk_ = _s_  (a) = E _πω_ <sup>_∗_</sup> ˆ  _Tk_ <sup>c</sup>  _l_ =0  _Tk_ <sup>c</sup>  (b) = max _πω_ ˆ <sup>E</sup> <sup>_π_</sup> _ω_ <sup>ˆ</sup> _k_ _l_ =0  _r_ <sup>L</sup> ( _Stk_ + _l,_ ˆ _ω, Atk_ + _l_ ) _|Stk_ = _s_    (c) ⩾ E _π_ ˆ _ω_ ˆ (d) = E _π_ ˆ _ω_ ˆ  _k_ _Tk_ <sup>c</sup>  _r_ <sup>L</sup> ( _Stk_ + _l,_ ˆ _ω, Atk_ + _l_ ) _|Stk_ = _s_  _r_ <sup>L</sup> ( _Stk_ + _l,_ ˆ _ω, Atk_ + _l_ ) _|Stk_ = _s_ _l_ =0  _Tk_ <sup>c</sup> _k_  _r_ ( _Stk_ + _l, Atk_ + _l_ ) _|Stk_ = _s_  _,_ (39) _l_ =0 where (a) and (d) are valid, because there is no penalty for failing to realize the charging target in (26), i.e., _c_ <sup>tar</sup> ( _s, ω_ ) = 0 since both _πω_ <sup>_∗_</sup> ˆ <sup>and</sup> <sup>_π_</sup> <sup>ˆ</sup> <sup>_ω_</sup> <sup>ˆ</sup> <sup>can</sup> <sup>realize</sup> <sup>the</sup> <sup>charging</sup> <sup>target</sup> <sup>_ω_</sup> <sup>ˆ;</sup> <sup>(b)</sup> <sup>and</sup> <sup>(c)</sup> <sup>are</sup> <sup>true</sup> <sup>according</sup> <sup>to</sup> <sup>the</sup> <sup>definition</sup> <sup>of</sup> <sup>the</sup> <sup>optimal</sup> <sup>value</sup> function in (30). Since we assume that (38) does not hold, (c) in (39) is a strict inequality due to the property of the max operator, which means that we have _Tk_ <sup>c</sup>  E _µ_ ˆE _πω_ <sup>_∗_</sup> ˆ  _K−_ 1  _k_ =0 _Tk_ <sup>c</sup> _r_ ( _Stk_ + _l, Atk_ + _l_ ) _|S_ 0 = _s_  _l_ =0  _r_ ( _Stk_ + _l, Atk_ + _l_ ) _|S_ 0 = _s_   (a) _>_ E _µ_ ˆE _π_ ˆ _ω_ ˆ  _K−_ 1 _Tk_ <sup>c</sup> -  _k_ =0 _l_ =0 _Tk_ <sup>c</sup> _l_ =0 (b) = E _π∗_ (c) = E _π∗_  _K−_ 1  _k_ =0  _K−_ 1 _Tk_ <sup>a</sup> <sup>_−_</sup> <sup>1</sup> -  _k_ =0 _l_ =0 _r_ ( _Stk_ + _l, Atk_ + _l_ ) _|S_ 0 = _s_   _r_ ( _Stk_ + _l, Atk_ + _l_ ) _|S_ 0 = _s_  _,_ (40) where (a) is derived from (39) with strict inequality; (b) is due to the fact that _π_ <sup>_∗_</sup> is the superimposition of _µ_ ˆ and _π_ ˆ _ω_ ˆ ; (c) is because of the zero rewards during the operating periods from _Tk_ <sup>c</sup> <sup>to</sup> <sup>_T_</sup> <sup>a</sup> _k_ <sup>_−_</sup> <sup>1,</sup> <sup>since</sup> <sup>there</sup> <sup>is</sup> <sup>no</sup> <sup>charging</sup> <sup>cost</sup> <sup>in</sup> <sup>the</sup> <sup>operating</sup> period. Moreover, the optimal flat policy _π_ <sup>_∗_</sup> ensures that there is no penalty for entering the terminal states, i.e., _C_ <sup>end</sup> = 0 in (11). Furthermore, (40) implies that the flat policy created by superimposing the policy _µ_ ˆ and the optimal intra-option policy _πω_ <sup>_∗_</sup> ˆ performs better than the optimal policy _π_ <sup>_∗_</sup> for the original MDP, which cannot be true by the definition of _π_ <sup>_∗_</sup> . Therefore, (40) contradicts to (35), and we have thus proved that (38) holds. _k_ <sup>c</sup> <sup>to</sup> <sup>_T_</sup> <sup>a</sup> _k_ Furthermore, (40) implies that the flat policy created by superimposing the policy _µ_ ˆ and the optimal intra-option policy _πω_ <sup>_∗_</sup> ˆ _•_ In the second step, we will prove that the optimal high-level policy over options _µ_ <sup>_∗_</sup> achieves the same performance as _µ_ ˆ does when the low-level intra-option policy is _πω_ <sup>_∗_</sup> <sup>,</sup> <sup>i.e.,</sup> E _µ∗_ E _πω_ <sup>_∗_</sup> <sup>_∗_</sup> - _K−_ 1 - _r_ <sup>H</sup> ( _Stk_ _, ω_ <sup>_∗_</sup> ) _|S_ 0 = _s_ _k_ =0 = E _µ_ ˆE _πω_ <sup>_∗_</sup> ˆ - _K−_ 1 _k_ =0 _r_ <sup>H</sup> ( _Stk_ _,_ ˆ _ω_ ) _|S_ 0 = _s_ _._ (41) In order to prove (41), we also adopt the proof by contradiction method and assume that (41) does not hold. Thus, we have E _µ∗_ E _πω_ <sup>_∗_</sup> <sup>_∗_</sup> - _T −_ 1 - _r_ ( _St, At_ ) _|S_ 0 = _s_ _t_ =0 (a) = E _µ_ <sup>_∗_</sup> E _πω_ <sup>_∗_</sup> <sup>_∗_</sup> - _K−_ 1 _k_ =0 _r_ <sup>H</sup> ( _Stk_ _, ω_ <sup>_∗_</sup> ) _|S_ 0 = _s_ _r_ <sup>H</sup> ( _Stk_ _, ω_ ) _|S_ 0 = _s_ (b) = max _µ_ _ω_ - _K−_ 1 _k_ =0 _µ_ <sup>E</sup> <sup>_µ_</sup> <sup>E</sup> <sup>_π_</sup> _ω_ <sup>_∗_</sup> (c) _>_ E _µ_ ˆE _πω_ <sup>_∗_</sup> ˆ _ω_ ˆ - _K−_ 1 _k_ =0 - _K−_ 1 _k_ =0 _r_ <sup>H</sup> ( _Stk_ _,_ ˆ _ω_ ) _|S_ 0 = _s_ (d) = E _µ_ ˆE _π_ ˆ _ω_ ˆ _r_ <sup>H</sup> ( _Stk_ _,_ ˆ _ω_ ) _|S_ 0 = _s_ (e) = E _π_ <sup>_∗_</sup> - _T −_ 1 - _r_ ( _St, At_ ) _|S_ 0 = _s_ _t_ =0 (f) = _Vπ_ <sup>_∗_</sup> ( _s_ ) _,_ (42) where (a) is derived by definition of the high-level reward in (19); (b) is derived by definition of the optimal value function in (23); (c) is a strict inequality due to the property of the max operator and the assumption that (41) does not hold; (d) is due to (38); (e) is because the policies _µ_ ˆ and _π_ ˆ _ω_ ˆ superimpose the optimal flat policy _π_ <sup>_∗_</sup> ; (f) is by definition of the value function in (13). Finally, (42) implies that the flat policy created by superimposing _µ_ <sup>_∗_</sup> and _πω_ <sup>_∗_</sup> <sup>_∗_</sup> <sup>performs</sup> <sup>better</sup> <sup>than</sup> <sup>the</sup> <sup>optimal</sup> <sup>policy</sup> <sup>_π∗_</sup> <sup>for</sup> the original MDP, which cannot be true by the definition of _π_ <sup>_∗_</sup> . Therefore, (42) contradicts to (35), and we have thus proved that (41) holds. Moreover, if (41) holds, (c) in (42) should be an equality. Notably, the first term in (42) corresponds to the right-hand side of (33), while the last term corresponds to its left-hand side, which means that (33) in Theorem 1 holds. REFERENCES [1] T. Aldhanhani, A. Abraham, W. Hamidouche, and M. Shaaban, “Future trends in smart green iov: Vehicle-to-everything in the era of electric vehicles,” _IEEE_ _Open_ _Journal_ _of_ _Vehicular_ _Technology_, vol. 5, pp. 278–297, 2024. [2] G. Wang, X. Xie, F. Zhang, Y. Liu, and D. Zhang, “bcharge: Data-driven real-time charging scheduling for large-scale electric bus fleets,” in _2018_ _IEEE_ _Real-Time_ _Systems_ _Symposium_ _(RTSS)_ . IEEE, 2018, pp. 45–55. [3] J. He, N. Yan, J. Zhang, T. Wang, Y.-Y. Chen, and T.-Q. Tang, “Battery electricity bus charging schedule considering bus journey’s energy consumption estimation,” _Transportation_ _Research_ _Part_ _D:_ _Transport_ _and_ _Environment_, vol. 115, p. 103587, 2023. [4] J. A. Manzolli, J. P. F. Trovao, and C. H. Antunes, “Electric bus coordinated charging strategy considering v2g and battery degradation,” _Energy_, vol. 254, p. 124252, 2022. [5] I. S. Bayram and X. Shi, “Bidirectional charging hubs in the electric vehicle retail landscape: Opportunities and challenges for the u.k. case,” _IEEE_ _Open_ _Journal_ _of_ _Vehicular_ _Technology_, vol. 5, pp. 1470–1495, 2024. [6] Y. Liu, L. Wang, Z. Zeng, and Y. Bie, “Optimal charging plan for electric bus considering time-of-day electricity tariff,” _Journal_ _of_ _Intelligent_ _and_ _Connected_ _Vehicles_, vol. 5, no. 2, pp. 123–137, 2022. [7] Y. Bie, J. Ji, X. Wang, and X. Qu, “Optimization of electric bus scheduling considering stochastic volatilities in trip travel time and energy consumption,” _Computer-Aided_ _Civil_ _and_ _Infrastructure_ _Engineering_, vol. 36, no. 12, pp. 1530–1548, 2021. [8] X. Tang, X. Lin, and F. He, “Robust scheduling strategies of electric buses under stochastic traffic conditions,” _Transportation Research Part C: Emerging_ _Technologies_, vol. 105, pp. 163–182, 2019. [9] H. Hu, B. Du, W. Liu, and P. Perez, “A joint optimisation model for charger locating and electric bus charging scheduling considering opportunity fast charging and uncertainties,” _Transportation_ _Research_ _Part_ _C:_ _Emerging_ _Technologies_, vol. 141, p. 103732, 2022. [10] Y. Zhou, H. Wang, Y. Wang, and R. Li, “Robust optimization for integrated planning of electric-bus charger deployment and charging scheduling,” _Transportation_ _Research_ _Part_ _D:_ _Transport_ _and_ _Environment_, vol. 110, p. 103410, 2022. [11] K. Liu, H. Gao, Y. Wang, T. Feng, and C. Li, “Robust charging strategies for electric bus fleets under energy consumption uncertainty,” _Transportation_ _Research_ _Part_ _D:_ _Transport_ _and_ _Environment_, vol. 104, p. 103215, 2022. [12] L. Lei, Y. Tan, G. Dahlenburg, W. Xiang, and K. Zheng, “Dynamic energy dispatch based on deep reinforcement learning in iot-driven smart isolated microgrids,” _IEEE_ _Internet_ _of_ _Things_ _Journal_, vol. 8, no. 10, pp. 7938–7953, May 2021. [13] W. Chen, P. Zhuang, and H. Liang, “Reinforcement learning for smart charging of electric buses in smart grid,” in _2019_ _IEEE_ _Global_ _Communications_ _Conference_ _(GLOBECOM)_, 2019, pp. 1–6. [14] Y. Yan, H. Wen, Y. Deng, A. H. Chow, Q. Wu, and Y.-H. Kuo, “A mixed-integer programming-based q-learning approach for electric bus scheduling with multiple termini and service routes,” _Transportation_ _Research_ _Part_ _C:_ _Emerging_ _Technologies_, vol. 162, p. 104570, 2024. [15] W. Wang, B. Yu, and Y. Zhou, “A real-time synchronous dispatching and recharging strategy for multi-line electric bus systems,” _Transportation_ _Research_ _Part_ _E:_ _Logistics_ _and_ _Transportation_ _Review_, vol. 185, p. 103516, 2024. [Online]. Available: [https://www.sciencedirect.com/science/article/](https://www.sciencedirect.com/science/article/pii/S1366554524001078) [pii/S1366554524001078](https://www.sciencedirect.com/science/article/pii/S1366554524001078) [16] X. Bi, R. Wang, H. Ye, Q. Hu, S. Bu, and E. Chung, “Real-time scheduling of electric bus flash charging at intermediate stops: A deep reinforcement learning approach,” _IEEE_ _Transactions_ _on_ _Transportation_ _Electrification_, pp. 1–1, 2023. [17] Y. Zhou, G. P. Ong, Q. Meng, and H. Cui, “Electric bus charging facility planning with uncertainties: Model formulation and algorithm design,” _Transportation_ _Research_ _Part_ _C:_ _Emerging_ _Technologies_, vol. 150, p. 104108, 2023. [18] A. Curtis, M. Xin, D. Arumugam, K. Feigelis, and D. Yamins, “Flexible and efficient long-range planning through curious exploration,” in _International_ _Conference_ _on_ _Machine_ _Learning_ . PMLR, 2020, pp. 2238–2249. [19] S. Pateria, B. Subagdja, A.-h. Tan, and C. Quek, “Hierarchical reinforcement learning: A comprehensive survey,” _ACM_ _Comput._ _Surv._, vol. 54, no. 5, jun 2021. [Online]. Available: [https://doi.org/10.1145/3453160](https://doi.org/10.1145/3453160) [20] H. Van Hasselt, A. Guez, and D. Silver, “Deep reinforcement learning with double q-learning,” in _Proceedings_ _of_ _the_ _AAAI_ _conference_ _on_ _artificial_ _intelligence_, vol. 30, no. 1, 2016. [21] Y. Zhou, H. Wang, Y. Wang, B. Yu, and T. Tang, “Charging facility planning and scheduling problems for battery electric bus systems: A comprehensive review,” _Transportation_ _Research_ _Part_ _E:_ _Logistics_ _and_ _Transportation_ _Review_, vol. 183, p. 103463, 2024. [22] J. Ji, Y. Bie, and L. Wang, “Optimal electric bus fleet scheduling for a route with charging facility sharing,” _Transportation_ _Research_ _Part_ _C:_ _Emerging_ _Technologies_, vol. 147, p. 104010, 2023. [23] L. Zhang, S. Wang, and X. Qu, “Optimal electric bus fleet scheduling considering battery degradation and non-linear charging profile,” _Transportation_ _research._ _Part_ _E,_ _Logistics_ _and_ _transportation_ _review_, vol. 154, pp. 102 445–, 2021. [24] Z. Bao, J. Li, X. Bai, C. Xie, Z. Chen, M. Xu, W.-L. Shang, and H. Li, “An optimal charging scheduling model and algorithm for electric buses,” _Applied_ _Energy_, vol. 332, p. 120512, 2023. [25] Y. Zhou, Q. Meng, and G. P. Ong, “Electric bus charging scheduling for a single public transport route considering nonlinear charging profile and battery degradation effect,” _Transportation_ _Research_ _Part_ _B:_ _Methodological_, vol. 159, pp. 49–75, 2022. [26] M. Rinaldi, E. Picarelli, A. D’Ariano, and F. Viti, “Mixed-fleet single-terminal bus scheduling problem: Modelling, solution scheme and potential applications,” _Omega_, vol. 96, p. 102070, 2020. [27] Y. He, Z. Liu, and Z. Song, “Optimal charging scheduling and management for a fast-charging battery electric bus system,” _Transportation_ _Research_ _Part_ _E:_ _Logistics_ _and_ _Transportation_ _Review_, vol. 142, p. 102056, 2020. [28] J. Whitaker, G. Droge, M. Hansen, D. Mortensen, and J. Gunther, “A network flow approach to battery electric bus scheduling,” _IEEE_ _Transactions_ _on_ _Intelligent_ _Transportation_ _Systems_, 2023. [29] D.-F. Xie, Y.-P. Yu, G.-J. Zhou, X.-M. Zhao, and Y.-J. Chen, “Collaborative optimization of electric bus line scheduling with multiple charging modes,” _Transportation_ _Research_ _Part_ _D:_ _Transport_ _and_ _Environment_, vol. 114, p. 103551, 2023. [30] Y. Zhou, Q. Meng, G. P. Ong, and H. Wang, “Electric bus charging scheduling on a bus network,” _Transportation Research Part C: Emerging Technologies_, vol. 161, p. 104553, 2024. [31] “Real-time energy market,” Online, 2024. [Online]. Available: [https://www.ieso.ca/en/Sector-Participants/Market-Operations/](https://www.ieso.ca/en/Sector-Participants/Market-Operations/Markets-and-Related-Programs/Real-time-Energy-Market) [Markets-and-Related-Programs/Real-time-Energy-Market](https://www.ieso.ca/en/Sector-Participants/Market-Operations/Markets-and-Related-Programs/Real-time-Energy-Market) [32] ISO New England, “Day-ahead and real-time energy markets,” Online, 2024. [Online]. Available: [https://www.iso-ne.com/markets-operations/markets/](https://www.iso-ne.com/markets-operations/markets/da-rt-energy-markets) [da-rt-energy-markets](https://www.iso-ne.com/markets-operations/markets/da-rt-energy-markets) [33] P. M. S. Frade, J. V. G. A. Vieira-Costa, G. J. Os´orio, J. J. E. Santana, and J. P. S. Catal˜ao, “Influence of wind power on intraday electricity spot market: A comparative study based on real data,” _Energies_, vol. 11, no. 11, 2018. [Online]. Available: [https://www.mdpi.com/1996-1073/11/11/2974](https://www.mdpi.com/1996-1073/11/11/2974) [34] H. L. Le, V. Ilea, and C. Bovo, “Integrated european intra-day electricity market: Rules, modeling and analysis,” _Applied_ _Energy_, vol. 238, pp. 258–273, 2019. [Online]. Available: [https://www.sciencedirect.com/science/article/pii/S0306261918318920](https://www.sciencedirect.com/science/article/pii/S0306261918318920) [35] F. Fei, W. Sun, R. Iacobucci, and J.-D. Schm¨ocker, “Exploring the profitability of using electric bus fleets for transport and power grid services,” _Transportation_ _Research_ _Part_ _C:_ _Emerging_ _Technologies_, vol. 149, p. 104060, 2023. [36] A. G. Barto and S. Mahadevan, “Recent advances in hierarchical reinforcement learning,” _Discrete_ _event_ _dynamic_ _systems_, vol. 13, no. 1-2, pp. 41–77, 2003. [37] R. S. Sutton, D. Precup, and S. Singh, “Between mdps and semi-mdps: A framework for temporal abstraction in reinforcement learning,” _Artificial_ _intelligence_, vol. 112, no. 1-2, pp. 181–211, 1999. [38] T. G. Dietterich, “Hierarchical reinforcement learning with the maxq value function decomposition,” _Journal_ _of_ _artificial_ _intelligence_ _research_, vol. 13, pp. 227–303, 2000. [39] R. Parr and S. Russell, “Reinforcement learning with hierarchies of machines,” _Advances_ _in_ _neural_ _information_ _processing_ _systems_, vol. 10, 1997. [40] P.-L. Bacon, J. Harb, and D. Precup, “The option-critic architecture,” in _Proceedings_ _of_ _the_ _AAAI_ _conference_ _on_ _artificial_ _intelligence_, vol. 31, no. 1, 2017. [41] M. Klissarov, P.-L. Bacon, J. Harb, and D. Precup, “Learnings options end-to-end for continuous action tasks,” _arXiv_ _preprint_ _arXiv:1712.00004_, 2017. [42] T. D. Kulkarni, K. Narasimhan, A. Saeedi, and J. Tenenbaum, “Hierarchical deep reinforcement learning: Integrating temporal abstraction and intrinsic motivation,” _Advances_ _in_ _neural_ _information_ _processing_ _systems_, vol. 29, 2016. [43] O. Nachum, S. S. Gu, H. Lee, and S. Levine, “Data-efficient hierarchical reinforcement learning,” _Advances_ _in_ _neural_ _information_ _processing_ _systems_, vol. 31, 2018. [44] A. Levy, G. Konidaris, R. Platt, and K. Saenko, “Learning multi-level hierarchies with hindsight,” _arXiv_ _preprint_ _arXiv:1712.00948_, 2017. [45] M. Andrychowicz, F. Wolski, A. Ray, J. Schneider, R. Fong, P. Welinder, B. McGrew, J. Tobin, O. Pieter Abbeel, and W. Zaremba, “Hindsight experience replay,” _Advances_ _in_ _neural_ _information_ _processing_ _systems_, vol. 30, 2017. [46] M. L. Puterman, _Markov_ _decision_ _processes:_ _discrete_ _stochastic_ _dynamic_ _programming_ . John Wiley & Sons, 2014. [47] “Guelph transit route 17 woodlawn watson,” Online, 2023. [Online]. Available: [https://docs.google.com/spreadsheets/d/](https://docs.google.com/spreadsheets/d/1c-W6M6Z6yyOpLBU05BJXBbttaozXzPTY/edit#gid=618450992) [1c-W6M6Z6yyOpLBU05BJXBbttaozXzPTY/edit#gid=618450992](https://docs.google.com/spreadsheets/d/1c-W6M6Z6yyOpLBU05BJXBbttaozXzPTY/edit#gid=618450992) [48] Ameren, “Day-ahead and historical rtp/hss prices,” Online, 2023. [Online]. Available: [https://www.ameren.com/account/retail-energy](https://www.ameren.com/account/retail-energy)

섹션 본문 186문단 · 73,354자

(제목 없음)

1The charging scheduling problem of Electric Buses (EBs) is investigated based on Deep Reinforcement Learning (DRL).A Markov Decision Process (MDP) is conceived, where the time horizon includes multiple charging and operating periods in a day, while each period is further divided into multiple time steps.To overcome the challenge of long-range multi-phase planning with sparse reward, we conceive Hierarchical DRL (HDRL) for decoupling the original MDP into a high-level Semi-MDP (SMDP) and multiple low-level MDPs.The Hierarchical Double Deep Q-Network (HDDQN)-Hindsight Experience Replay (HER) algorithm is proposed for simultaneously solving the decision problems arising at different temporal resolutions.As a result, the high-level agent learns an effective policy for prescribing the charging targets for every charging period, while the low-level agent learns an optimal policy for setting the charging power of every time step within a single charging period, with the aim of minimizing the charging costs while meeting the charging target.It is proved that the flat policy constructed by superimposing the optimal high-level policy and the optimal low-level policy performs as well as the optimal policy of the original MDP.Since jointly learning both levels of policies is challenging due to the non-stationarity of the high-level agent and the sampling inefficiency of the low-level agent, we divide the joint learning process into two phases and exploit our new HER algorithm to manipulate the experience replay buffers for both levels of agents.Numerical experiments are performed with the aid of real-world data to evaluate the performance of the proposed algorithm.

2I N recent years, the adoption of Electric Buses (EBs) in public transportation fleets has been growing rapidly.Electrification of public transport reduces GreenHouse Gas (GHG) emissions, lowers maintenance and fuel costs, and provides the public with a more comfortable riding experience [1].With the increasing penetration of EBs, the question of how the charging cost can be reduced has become a key concern for bus companies [2].Concurrently, in an attempt to spread the demand for electricity and efficiently utilize the Renewable Energy Sources (RES), power utility companies have adopted real-time electricity prices.Consequently, bus companies are presented with an effective measure to reduce costs and participate in the grid services by implementing intelligent charging schedules.

3In order for EBs to fully take advantage of the time-varying electricity prices, intelligent strategies for charging scheduling are essential.Specifically, it is crucial to set an appropriate charging target, which is the target State of Charge (SoC) level at the end of a charging period.A high value may lead to unnecessary charging and high charging cost, while a low value could result in battery depletion during a trip.

4The optimization of EB charging schedules has been extensively explored, with existing contributions generally categorized into deterministic and stochastic schemes based on their system modeling approaches.Many studies, such as [3], [4], fall into the deterministic category.They consider system models where the parameter values are deterministic or constant, and typically derive optimal policies through solving Mixed Integer Linear Programming (MILP) problems.

5While deterministic models do simplify the problem formulation and solution processes, they struggle to address two significant types of uncertainties encountered in practical scenarios, i.e., uncertainties in EB operation, such as random variations in travel time and energy consumption; plus uncertainties in the smart grid, including fluctuations in electricity prices.Consequently, system models that incorporate these uncertainties and stochastic elements offer a more realistic and applicable representation of the real world, ultimately leading to more reliable and efficient charging schedules.

6However, the realistic consideration of uncertainties exacerbates the complexities of finding optimal charging targets.Firstly, since the amount of energy consumption during each trip depends on the time-varying traffic conditions along the bus route, the charging targets must be high enough to support the full trip taking into account these variations.For example, the charging targets have to be higher during rush hours, since it will take the EBs longer time and more energy to complete the trip.Secondly, the charging cost can be reduced by leveraging the real-time electricity prices.For example, EBs can create charging schedules that favor off-peak hours for charging, while discharging energy to the grid during peak hours in the Vehicle-to-Grid (V2G) mode [5].

7In recent years, some studies within the stochastic category, such as [6]- [11], have explored the uncertainties in EB travel time and energy consumption, utilizing methodologies such as Robust Optimization (RO) [8]- [11], Immune Algorithms (IA) [6], and Genetic Algorithms (GA) [7].These approaches aim to enhance adaptability to the variable nature of EB operations.However, existing studies generally do not account for the uncertainties in real-time electricity prices, limiting their ability to optimize charging targets for different charging periods.Additionally, many existing investigations assume a constant charging power throughout the entire charging period, restricting EBs from discharging to the power grid via V2G and adjusting charging power in real time based on fluctuating electricity prices-both of which could further reduce charging costs.

8To address the above limitations, this paper develops a charging strategy for EBs based on Deep Reinforcement Learning (DRL).DRL combines Reinforcement Learning (RL) with Deep Neural Networks (DNNs), and has shown significant potential to address uncertainties in operational environments in recent years.Compared with other techniques of dealing with uncertainty, such as RO, IA, and GA, DRL learns optimal policies directly from interactions with the environment, without relying on predefined stochastic models of the variables [12].Moreover, DRL dynamically learns and updates policies in real time, allowing it to swiftly adapt to changes in dynamic environments.Despite its great potential, there is currently a scarcity of literature applying DRL to charging scheduling for EBs [13]- [17], mainly due to the difficulty in designing an efficient and stable learning process.

9Unlike existing DRL-based studies for EB charging, our work accounts for uncertainties in both electricity prices and traffic conditions while also incorporating flexible charging power decisions on a fine time-scale -such as every few minutes -to minimize the charging costs while ensuring sufficient battery energy for EB operations.Unfortunately, this task corresponds to a long-range multi-phase planning problem, which has not been addressed by the aforementioned DRL-based works.The solution to this problem is a key challenge in DRL, where the long action sequences give rise to issues such as slow convergence, high complexity, and insufficiently diverse exploration [18].The situation further deteriorates when rewards are sparse, as in the EB charging problem when the penalty for running out of battery during trips occurs sporadically.As a result, learning from this undesirable outcome is challenging, because of its rare occurrence.

10To overcome the aforementioned challenges, we design a novel Hierarchical DRL (HDRL) algorithm [19] in this paper.The main contributions are summarized as follows.

111) System Model: Our system model extends beyond the bus transit system to include interactions with the electrical grid, embracing the uncertainties of electricity prices and integrating V2G capabilities.Furthermore, charging scheduling decisions at a finer time-scale are considered, which determine the amount of real-time charging power, rather than relying on fixed charging power levels.2) HDRL Model: To address the challenges in solving the long-range multiple-phase planning problem with sparse reward, the charging target option is defined, which simultaneously serves as a temporally extended action and a closed-loop policy.By introducing options, the original MDP is decomposed into a novel two-level decision process including a high-level Semi-MDP (SMDP) and low-level MDPs.We demonstrate that effective policies can be learned from solving the high-level SMDP for prescribing data-driven charging targets.In order to learn a charging scheduling policy to realize the charging targets whenever possible with minimal charging cost, we define an intrinsic reward for the low-level MDPs.

12It is proved that the flat policy created by superimposing the optimal high-level policy and the optimal low-level policy performs as well as the optimal policy of the original MDP.Meanwhile, since the long-range effect is captured by the options, the low-level MDPs become isolated from each other, which can be trained over a shorter time horizon to improve the learning efficiency of long-range planning.3) HDRL Solution: A novel algorithm, namely the so-called Hierarchical Double Deep Q Network (HDDQN)-Hindsight Experience Replay (HER) is proposed for simultaneously solving the high-level SMDP and low-level MDPs while capturing the interplay between them.Specifically, both the high-level and low-level agents adopt the DDQN framework [20], but along with separate experience replay buffers.Both agents observe the system states and rewards from the environment for constructing their own rewards.The high-level agent prescribes specific charging target options that are fed to the low-level agent, which decides on the charging powers that are implemented in the environment.Finally, novel approaches based on HER are applied in order to reduce the impact of non-stationarity on the high-level agent and sample inefficiency on the low-level agent brought about by simultaneously learning multiple levels of policies.This innovation enables the proposed algorithm to learn more efficiently and converge faster.The rest of the paper is organized as follows.Section II critically appraises the state-of-the-art.The system model and MDP model are introduced in Sections III and IV, respectively, while the two-level decision process with options is formulated in Section V.The HDDQN-HER algorithm is proposed in Section VI.Finally, our experiments are highlighted in Section VII, and conclusions are offered in Section VIII.

II. STATE-OF-THE-ART A. Research on EB charging scheduling problem

13There are three major charging technologies for EBs: (i) conductive charging; (ii) battery swapping; and (iii) wireless charging.The studies on conductive charging scheduling can be further divided into plug-in charging and pantograph charging.Both types are classified into two distinct approaches: (i) depot charging which adopts normal or slow chargers to charge EBs at bus depots overnight; (ii) opportunistic charging 1 which utilizes fast chargers to charge EBs at terminal stations or stops [21].In the following, we will primarily review the existing literature on the EB Charging Scheduling Problem (EBCSP) for plug-in charging and opportunistic charging, which constitutes the main focus of this paper.

14Broadly speaking, the EBCSP involves one or more EBs, a set of trips to be fulfilled by the EBs, and charging infrastructures.The objective is to optimize the charging schedule for minimizing costs, ensuring there is sufficient battery energy to support the EBs' trips, while adhering to various operational constraints, primarily concerning the bus schedules, power grid, and charger availability.

15Traditionally, all the parameters in the EBCSP, such as the travel time and energy consumption for each trip, are assumed to be constant or known.Based on this deterministic information, the EBCSP is normally formulated as a MILP problem and solved by different methods such as Branch & Price (BP) [22], the column generation based algorithm [23], dynamic programming [24], and optimization solvers such as CPLIX [3], [4], [25]- [27].

16There are different types of decisions on charging schedules.The simplest type is a binary variable indicating whether to charge or not, whenever an EB arrives at the terminal station after a trip.Most studies on binary charging decisions adopted a full charging policy, i.e., once an EB is assigned for charging, it must be fully charged before embarking on a new trip [3], [26].Given the constraints imposed by bus schedules, which may not provide ample time for full charging, the studies in [22], [23], [28] opted for partial charging, and derived the achieved SoC level of battery based on factors including the energy consumption rate and the length of time until the next departure of the EB.Given that a simplistic binary decision could result in unnecessarily high SoC level and increased charging cost, most studies on partial charging made decisions on the charging duration while assuming a fixed charging power [24], [29], [30].In order to further enhance the flexibility in making charging scheduling decisions, [27] divided the charging period into smaller time intervals and optimized the charging power for each time interval.

17However, MILP-based methods have several limitations.First, MILP becomes intractable for large-scale problems, with computation time growing exponentially.Additionally, its adaptability to dynamic environments is poor, as any environment change requires re-modeling and re-solving, further exacerbated by its high computational cost.Most importantly, in realistic scenarios, the travel time and energy consumption are inherently stochastic due to factors such as traffic flow and intersection waiting time.Therefore, their exact values are unknown when solving the EBCSP in practice.Since MILP relies on deterministic modeling, it struggles to effectively handle these uncertainties.To address this issue, He et al. [3] estimated an EB's travel time and energy consumption using the K-means clustering algorithm, and plugged in the predicted values in the MILP model to derive the charging schedule.However, it is impossible to completely eliminate the prediction errors given current technology limitations.

18In order to address the uncertainties associated with stochastic travel time and/or energy consumption, stochastic models have been formulated.These models inherently increase the complexity of the optimization algorithms designed for charging scheduling.For example, RO was widely used by the studies [8], [9], [10], and [11], to achieve the dual goals of reducing charging costs and improving system robustness.Both [8] and [9] considered a fixed charging power, with the former making binary charging decisions, while the latter optimizing the charging time.Conversely, both [10] and [11] optimized the charging power at smaller time-scales.Although RO can handle uncertainties and provide robust solutions within a predefined uncertainty set, it often leads to overly conservative policies, sacrificing performance to mitigate risks.RO requires modeling the uncertainty set and optimizing across multiple uncertain scenarios, resulting in high computational complexity, but its complexity is still lower than that of MILP.Additionally, RO lacks adaptability to dynamic environmental changes.

19Some studies opted for heuristic algorithms to address the uncertainties.For example, Liu et al. [6] employed the ant colony algorithm and IA to optimize charging plans under fixed and stochastic travel times, respectively, with a focus on charging time as the optimization variable.Bie et al. [7] presented the probability distribution function of trip energy consumption and adopted GA to reduce the charging costs as well as the delay in trip departure times.Compared to MILP, heuristic algorithms represented by GA have lower computational costs.However, they require multiple iterative optimizations, resulting in slow convergence.Additionally, GA typically operates offline and requires the entire algorithm to be re-run to integrate new information or accommodate changes in the environment, limiting its adaptability to dynamic environments.This limitation underscores the suitability of DRL for solving EBCSP.

20Unlike traditional methods, DRL does not require precise modeling; instead, it learns directly from interactions with the environment, making it the most effective in handling uncertainty.It also demonstrates strong adaptability in dynamic environments.The training process of DRL requires a significant amount of time.However, once training is complete, DRL can make decisions quickly in real time during the deployment phase, as it only requires forward propagation through the trained neural network.However, a limitation of DRL is its heavy reliance on training data.Therefore, when designing new DRL algorithms, achieving higher sample efficiency is crucial.In Fig. 1, we visually present the comparison of MILP, RO, GA, and DRL.

21There is relatively little research on DRL-based solutions for EBCSP.Among these studies, Wang et al. [15] combined clipped Double Q-learning (DQL) with Soft Actor-Critic (SAC) to simultaneously solve EB dispatching and charging scheduling problems, where the charging scheduling decision is a simple binary variable.Yan et al. [14] adopted Q-Learning and Twin Delayed Deep Deterministic Policy Gradient (TD-DDPG) to determine the EBs' target SoC levels and their assigned service routes, while assuming fixed charging power.Chen et al. [13] used DQL to make decisions regarding the charging power for EBs upon their arrivals at the terminal station.However, the charging power remains constant for each charging period.By contrast, our work considers more flexible charging power decisions at a smaller time-scale.In summary, while prior works apply various classical DRL techniques, they face challenges due to the inherent long-range multi-phase planning problem when applied to our system model.Therefore, our study aims to address this complexity by introducing a hierarchical framework with options.

22In addition to the parameters associated with the bus transit system, the characteristics of the smart grid have also been considered in some treatises.In order to reduce the charging cost, Manzolli et al. [4] explored the potential of the V2G scheme, which allows EBs to sell electricity back to the grid.Meanwhile, some studies [6], [10], [24], [28] examined the impact of Time-of-Use (TOU) electricity tariffs, which facilitate learning of optimal charging policies that exploit time-varying electricity prices.However, the electricity prices are typically assumed to be known and static for different periods of the day in all the above studies.In recent years, with the increasing penetration of RES into the electric grid, the adoption of the Real-Time Energy Market (RTEM) [31] has been on the rise.This market allows participants to buy and sell wholesale electricity throughout the operating day, aiming to balance actual real-time demand with the fluctuating production of electricity [32].We direct interested readers to [33], [34] for more information on how real-time electricity prices are determined and communicated to users.By transiting from static pricing contracts to real-time pricing contracts, the bus companies can potentially reduce their charging costs, while supporting the grid in achieving long-term stability in power supply [35].However, the inherent randomness of real-time electricity prices poses an additional challenge in solving EBCSP, where a sequence of charging schedule decisions must be made to minimize the charging cost without knowing the fluctuating electricity prices for the rest of the day.This challenge has been rarely touched upon in previous research.This knowledge gap is addressed in our paper.

23Table I boldly contrasts our work to the existing literature on EBCSP in terms of key features.While most existing work aims for minimizing the charging cost and considers the more flexible partial charging option rather than full charging, only some of the studies take into account the uncertainties in energy consumption and/or travel time, and consider the charging power as an adjustable decision variable.In addition, existing treatises generally do not incorporate more advanced smart grid characteristics, such as the V2G mode and uncertainty in electricity price.Furthermore, the DRL-based algorithms are rarely adopted to solve the EBCSP, addressing the uncertainties in practical systems.As shown in Table I, our paper considers all the listed features, filling the corresponding gaps in this field.

B. Hierarchical RL (HRL)

24The existing approaches on HRL are mainly developed based on three basic frameworks [36], i.e., the option framework by Sutton et al. [37], MAXQ by Dietterich et al. [38], and the Hierarchy of Abstract Machines (HAMs) by Parr and Russell [39].In the most widely-used option framework, an option is associated with a subtask and can be regarded as a high-level action.It is represented by three key components including the initiation condition, the low-level intra-option policy that is used for choosing actions, and the termination probability function.It can be proved that any MDP having a fixed set of options is an SMDP, and its solution leads to a high-level policy over options that is used for prescribing the options.In contrast to MAXQ, the individual intra-option policies cannot be learned as an independent unit in the option framework.They should be integrated into the original MDP and optimized as a whole [19].Thus, the optimality of learning a hierarchical policy is theoretically guaranteed.

25The studies on the option framework can be categorized into the approaches with or without subtask discovery.The approaches with subtask discovery, such as those in [40], [41], do not predefine the subtasks for the options.By contrast, the approaches without subtask discovery, such as the H-DQN by Kulkarni et al. [42], associate each option with a subgoal state for the low-level policy to achieve.In this case, some of the key components of option such as the termination function may not have to be learned, since an option may be deemed to be terminated, once the subgoal is achieved.In this paper, we adopt the option framework without subtask discovery and associate the options with the charging targets.In contrast to the existing HRL algorithms operating without subtask discovery [42]- [44], we formally formulate our problem associated with the options, providing a unified framework for both option learning and subgoal learning.

26An important challenge when simultaneously learning a hierarchy of policies is associated with the non-stationarity [19], since the low-level policy may change during the training process, which leads to non-stationary reward functions and transition probabilities of the high-level SMDP.To address this challenge, the Hierarchical Reinforcement Learning with Off-policy Correction (HIRO) by Nachum et al. [43] adopted a mechanism of subgoal re-labeling.The Hierarchical Actor-Critic (HAC) regime of Levy et al. [44] integrates the ideas of Hindsight Experience Replay (HER) [45] with HIRO for further improvement.Since our objective in this paper involves not only achieving the charging target subgoals but also minimizing the charging cost, our problem is more challenging compared to the studies in [43] and [44].Fig. 2 shows the contributions of this paper in contrast to the literature of HRL.

III. SYSTEM MODEL

27The variables and parameters used in this paper are summarized in Table II.In general, we use cursive letters to represent a set, such as S and A, uppercase letters to represent the total number of variables in a set, such as T and K, and the corresponding lowercase letters to represent the variable indexes in a set, such as t and k.In addition, following the convention of reinforcement learning, we generally use the capital letters with subscript t to denote random variables, such as S t and A t , while the corresponding lowercase letters represent sample values of the random variables, such as s and a.We use uppercase letters to represent constant values, such as E max and E min .Finally, we use lowercase letters to represent the functions, such as r(S t , A t ).

28In this paper, we consider an EB routinely traveling along a bus route that includes several bus stops and a terminal station.When the EB arrives at the terminal station, its battery pack can be charged.Therefore, the status of the EB can be divided into two alternating periods.One is the charging period, in which the EB stays at the terminal station for charging.The other is the operating period, in which the EB travels along the designated route.

29As shown in Fig. 3, consider that there are K operating periods for the EB in a single day according to its bus schedule, where each operating period is indexed by k ∈ {0, . . ., K − 1}.Additionally, each operating period k ∈ {0, . . ., K − 2} is The initiation set of states for option ω S + ,S T /S

30The state space, the set of terminal/non-terminal states Ω

31The option space Parameters B t

32The EB status at time step t, 0 for operating periods and 1 for charging periods C end

33The penalty for EB to enter the terminal states

34The maximum absolute value of charging/discharging power of EBs E t

35The SoC level of the battery at time step t E max /E min

36The maximum/minimum storage constraint of the battery H t

37The historical electricity prices in the period spanning from time step t − w p up to time step t K

38The number of operating periods in a day k

39The index of an operating/charging period k t

40The index of the current charging/operating period at the time step t P t

41The electricity price at time step t S t

42The system state at time step t t k

43The random time step at which the EB arrives at the terminal station from the operating period k T a k The random number of time steps between two consecutive arrivals of the EB from operating periods k and k + 1 at t k and t k+1 , respectively

44The fixed number of time steps between two consecutive departures of the EB for operating periods k and k + 1 according to the bus schedule

45The random number of time steps in the charging/operating period k w p

46The length of the time window to look into the past prices ∆t

47The duration of each time step τ t

48The number of remaining time steps from time step t to the next departure time Decision Variables A t

49The action at time step t C t

50The charging/discharging power of the battery at time step t ω t

51The charging target option at time step t Functions c tar (S t , ω t )

52The penalty of not realizing the charging target r(S t , A t )

53The reward function r H (S t , ω t )

54The expected cumulative reward within one transition of SMDP r L (S t , ω t , A t )

55The intrinsic reward of the low-level MDPs

56The termination condition of option ω Γ t (B t )

57The probability that the current period is terminated at time step t π ω (S t )

58The intra-option policy for option ω µ(S t )

59The policy over options followed by a charging period with the same index k.Given our focus on opportunistic charging, which involves fast chargers at terminal stations, we exclude depot charging that typically occurs overnight after the last operating period K − 1 of the day.Therefore, the time horizon considered in this paper starts and ends with an operating period, and there are K − 1 charging periods sandwiched between K operating periods. .We define B t as a random variable that represents the EB status at time step t, where B t = 1 and B t = 0 correspond to the charging and operating periods, respectively.In addition, let k t denote the index of the current charging or operating period at time step t2 .

60Let τ t denote the number of remaining time steps from time step t to the next departure time.The iterative calculation for τ t+1 is derived as

61which means that τ t decreases by 1 at each time step until it reaches 0. When τ t = 0, the EB will depart for operating period k t+1 at the next time step t + 1.In this case, τ t+1 is set to a fixed value T d kt+1 according to the bus schedule.We use Γ t (B t ) to denote the conditional probability that the current period is terminated at time step t, given whether the current period is charging (i.e., B t = 1) or operating (i.e., B t = 0).Note that Γ t (B t ) depends on τ t and k t .Intuitively, in the operating period (B t = 0), the probability of the EB returning to the terminal station increases as its traveling time elapses.Mathematically, we have

62where the numerator represents the probability of the EB arriving at the terminal station at time step t, while the denominator represents the probability of the EB not arriving at the terminal station before time step t.

63For the charging period (B t = 1), we consider that the bus line works in accordance with a fixed schedule and the EBs must depart on time.Therefore, when the scheduled departure time is reached, i.e., τ t = 0, the charging period terminates with Γ t = 1.Meanwhile, we have Γ t = 0 in all the other time steps.Therefore, we have

64The optimization objective is to determine the EB charging schedule in the charging period that minimizes the charging cost while keeping a sufficient SoC level in the battery to ensure reliable operation in the operating period.The charging cost depends on real-time electricity prices, which fluctuate over time.At each time step t, we use P t to denote the electricity price.

65Let E t denote the SoC level of the battery for the EB at time step t, which is constrained by

66Furthermore, let C t denote the charging/discharging power of the EB battery at time step t, which is positive when charging and negative when discharging.Note that the charging schedule C t only has to be determined in the charging period, where the EB can either draw energy from or return energy back to the electric grid in the V2G mode.On the other hand, the EB is always discharging in the operating period when the EB travels along the route, and thus C t is negative.Expressed mathematically, the constraint of C t can be written as:

67where C max and D max denote the maximum absolute value of charging and discharging power, respectively.In addition,

68/∆t] represents the value range due to the limitation of the EB battery capacity.Finally, the dynamics of the EB battery can be modeled as

IV. MDP MODEL A. State

69Let S t = (E t , B t , τ t , H t , k t ) be the system state at time step t.H t denotes the historical electricity prices in the period spanning from time step (t − w p ) up to time step t, i.e., H t = P t−wp , P t−wp+1 , ..., P t−1 , P t .

70Note that w p is the length of the time window used for considering past prices.Let S + denote the state space, which can be divided into the set of non-terminal states S = {S t |E t ≥ E min } and the set of terminal states S T = {S t |E t < E min }.When the SoC level in the EB's battery is lower than the minimum battery capacity constraint, i.e., E t < E min , the agent will enter the terminal states and the current episode will end before the maximum time step T is reached.

B. Action

71Let A t = C t ∈ A be the action at time step t, where A represents the action space.The charging scheduling policy determines the action A t only in those states S t that are associated with B t = 1.The action space A can be derived based on the first case in (5).When the EB is in the operating period (B t = 0), C t is a random variable whose value at each time step t is given by the environment rather than being determined by the agent.The range of the random variable C t is specified by the second case in (5).

C. Transition Probability

72The state transition probability is derived as

73where the transition probability of state S t is decomposed into the product of the transition probabilities of each component in the state definition.The transition probabilities of historical electricity prices Pr (H t+1 |H t ) are not available, but samples of the trajectory can be obtained from real-world data.The transition probability of SoC level, i.e., Pr (E t+1 |E t , A t ) can be calculated by (6).Next, the transition probability Pr (B t+1 |B t , τ t , k t ) can be derived from the termination probability Γ t (B t ), i.e.,

74where Γ t (B t ) is given by ( 2) and ( 3).The transition probability of k t , i.e., Pr (k t+1 |k t , B t , B t+1 ), is derived by the iterative calculation for k t+1 , i.e.,

75where k 0 = 0. Finally, the iterative calculation for τ t+1 in (1) can be used for calculating Pr (τ t+1 |τ t , B t , B t+1 , k t+1 ).

D. Reward Function

76The optimization objective is to minimize the charging costs, while guaranteeing sufficient energy in the EB battery during the operating period.Therefore, we define the reward function as

77where C t ∆tP t B t is the charging cost and C end is the penalty to the agent for entering the terminal states.This means that the EB battery is not sufficiently charged to support the entire operating period to completion.As a result, the EBs having depleted batteries receive more negative expected cumulative rewards than their counterpart associated with normal operation, due to receiving a large negative reward −C end upon entering the terminal state.In practice, C end is a hyperparameter tuned empirically.If set too small, the agent risks reaching the terminal state, whereas a value that is too large may lead to an overly conservative policy, increasing charging costs.In our experiments, the optimal C end is typically around 5 to 10 times C t ∆tP t B t , ensuring that the agent consistently avoids terminal states while still optimizing for lower charging cost.

E. Optimization Objective

78Define the return G t as the sum of rewards starting from time step t, i.e.,

79The state-value or value function V π (s) is defined as the expected return from starting in state s and then following policy π, i.e.,

80Note that the value function of terminal states is always −C end , i.e., V π (s) = −C end , ∀s ∈ S T .Thus, our objective is to derive the optimal policy π * that maximizes the value function for all the non-terminal states

81In order to derive the optimal policy, the action-value function or Q function Q π (s, a) is defined as the expected return from starting in state s, taking action a, and then following policy π, i.e.,

82Note that the Q function for the terminal states is always −C end , i.e., Q π (s, a) = −C end , ∀s ∈ S T , a ∈ A. The optimal action-value function is then

83, the optimal policy selects the highest-valued action in each state.

84In order to estimate Q * π (s, a) typically, the following Bellman Equation is used as an iterative update, where

85The formulated EB charging problem corresponds to an episodic task with a maximum of T time steps in an episode.An episode terminates earlier if the terminal state is reached, which means that the EB runs out of battery.For any full episode where the EB does not run into the terminal state, the last period is always the charging period K − 1, where the EB has to charge sufficient energy for the operating period 0 of the next day.The optimal policy is stationary for any episodic task [37], [46].

V. OPTIONS OVER MDP

86The MDP model defined in Section IV is essentially a long-range multiple-phase planning problem, since the time horizon is divided into multiple charging and operating periods, where each phase consists of a large number of time steps.In the following, we adopt the framework of options [37], [40] to tackle this problem, which enables the agent to abstract actions at different temporal levels.

A. Definition of Options

87Let ω ∈ Ω denote the options, where Ω is the option space.Options can be regarded as temporally extended "actions", which can last for multiple time steps.An option is prescribed by the policy over options µ according to the current state S t .Each option ω is associated with the triple of (I ω , π ω , β ω ), where I ω is the initiation set of states, i.e., ω is available in state S t if and only if S t ∈ I ω , while π ω is the intra-option policy and β ω is the termination condition.If an option ω is chosen at time step t, the option will terminate with probability β ω (S t+l ) at each time step t + l, ∀l ∈ 1, 2, . ... If the option ω does not terminate at time step t + l, ∀l ∈ 0, 1, 2, . .., an action A t+l is chosen according to the intra-option policy π ω (S t+l ) and the environment moves on to the next time step t + l + 1.Otherwise, a new option ω ′ may be selected according to the policy over options µ(S t+l ), and the same process is repeated for the following time steps.

88In this paper, we define the charging target option ω, which corresponds to the target SoC level of the EB's battery, when a charging period terminates.Note that the option space is defined by the E t constraints in (4).Since the charging targets only have to be determined in the charging periods, I ω is defined as

89The termination condition is defined as

90which means the option should be terminated when an operating period ends and the next charging period will start.

B. Decoupling the original MDP

91As shown in Fig. 4, by introducing options, our original MDP model is divided into low-level and high-level decision processes.The top panel illustrates the original MDP defined in Section IV, where a flat policy π is used for determining the charging schedule action C t at each time step t during the charging periods.Meanwhile, C t is given by the environment according to the amount of power discharged during each time step in the operating periods.Therefore, the original MDP consists of an interleaving of MDPs corresponding to charging periods and Markov Reward Processes (MRPs) representing the operating periods.

92Although the original MDP can be solved directly to obtain π, a more efficient solution is to divide it into two levels through options.The middle panel shows the high-level SMDP, where the policy over options µ prescribes the charging target option ω at the selected time steps {t k } K−2 k=0 when the charging periods start.Assume that option ω is selected according to µ(S t k ) at time step t k when a charging period starts.When the charging period terminates after a random number of T c k time steps, the state S t k transits to S t k +T c k , where E t k +T c k should be as close to the desired charging target ω as possible.When the next charging period starts at time step t k+1 = t k + T a k , the next option ω ′ is selected according to µ(S t k+1 ).Finally, the bottom panel shows that the low-level MDPs are embedded into the high-level SMDP, where at each charging period, the intra-option policy π ω of the selected option ω determines the optimal charging schedule action C t that minimizes the charging cost, while ensuring that the charging target of ω is realized.By superimposing the high-level policy over options µ and the low-level intra-option policy π ω , a flat policy is constructed to solve the original MDP problem.Notably, the long timehorizon of the original MDP is divided into multiple shorter time-horizons of the low-level MDPs.Since each low-level MDP is provided with a charging target option obtained by solving the high-level MDP, the low-level MDPs become independent of each other.In other words, each low-level MDP only has to concentrate on its immediate time-horizon for decision-making, without having to look further into the future and consider those low-level MDPs in subsequent time-horizons.

93By adopting the hierarchical structure and solving the high-level SMDP and low-level MDPs instead of the original MDP, the learning efficiency and convergence speed can be significantly improved.

C. The High-Level SMDP

94When we only consider the high-level policy over options µ to select options (i.e., assuming the intra-option policy π ω is available for each option ω ∈ Ω), the decision process becomes an SMDP [46] that can be derived from the original MDP.

95In SMDP, state transitions and action selections take place at discrete time, but the length of time interval from one transition to the next is random.Therefore, an SMDP consists of state space, action space, an expected cumulative discounted reward for each state-action pair, and a joint distribution of the next state and transit interval.In our high-level SMDP, the states are the same as those of the original MDP, while the actions correspond to the options.For each state transition when option ω is selected, the transit time is T ω k time steps.Note that an option terminates when either the EB arrives at the terminal station where T ω k = T a k , or the EB runs out of battery during the trip where T ω k < T a k .The SMDP model has its corresponding reward r H (s, ω), i.e., the expected cumulative reward within one transition of SMDP in T ω k time steps.Let E(ω, s, t k ) denote the event that ω starts in state s at time step t k .The reward r H (s, ω) can be derived by

96where the action A t k +l is derived based on the intra-option policy π w for the first T c k time steps during the charging period, and then provided by the environment for the following T ω k − T c k time steps during the operating period.The transition distributions of the SMDP P ω ss ′ can be formulated as

97where P (s ′ , T ω k ) represents the probability that the option terminates after T ω k time steps when the state s changes to s ′ .Let us define the high-level return G H k as the sum of the high-level rewards starting from time step t k , i.e.,

98The high-level value function V H µ (s) is defined as the expected high-level return from starting in state s and then following the policy over options µ, i.e.,

99Note that the high-level value function of the terminal states is always −C end , i.e., V H µ (s) = −C end , ∀s ∈ S T .The objective of the high-level SMDP is to derive the optimal policy over option µ * that maximizes the high-level value function for all the nonterminal states

100In order to derive the optimal policy over options, the option-value function or high-level Q function Q H µ (s, ω) is defined as the expected return from starting in state s, taking option ω, and then following policy µ, i.e.,

101Note that the option-value function for the terminal states is always −C end , i.e., Q H µ (s, ω) = −C end , ∀s ∈ S T , ω ∈ Ω.Given the optimal option-value function Q H * (s, ω) = max µ Q H µ (s, ω), the optimal policy over options selects the highest-valued option in state s at time step t k .The Bellman Optimality Equation is

102where E (ω, s) denotes option ω being initiated in state s.

D. The Low-Level MDP

103As illustrated in Fig. 4, the course of the original MDP is divided into an interleaving of low-level MDPs and MRPs, where the time horizon T c k (resp.T o k ) of each low-level MDP (resp.MRP) corresponds to the charging (resp.operating) period in one transition of the high-level SMDP.In order to derive the intra-option policy π ω , the low-level MDP is formulated below.

104In the low-level MDPs, the state is denoted as (S t , ω t ), where the state in the original MDP, i.e., S t , is augmented by including the current option ω t .Let S + L denote the low-level state space, which can be divided into the set of low-level nonterminal states S L = {S t ∈ S, ω t ∈ Ω|B t = 1} and the set of low-level terminal states S T L = {S t ∈ S, ω t ∈ Ω|B t = 0}.Note that the low-level MDP terminates whenever the EB enters the operating period, i.e., B t = 0.The actions and the transition probabilities are the same as those of the original MDP, since ω t remains the same throughout the time horizon of the low-level MDP.Since we should ensure that the charging target of the selected option ω is realized at the end of the current charging period, the intrinsic reward of the low-level MDPs is defined as

105where

106Note that s = S t and a = π ω (s) when (s, ω) ∈ S L .Although no action is selected when (s, ω) ∈ S T L , we keep the action in the reward function of the terminal state for notational simplicity.Furthermore, c tar (s, ω) in ( 27) represents the penalty of not realizing the charging target, which is the squared error between the charging target ω and the actual SoC level E t k +T c k at the end of the charging period.Finally, κ in ( 26) is the coefficient representing the relative importance of minimizing the charging cost versus the penalty c tar (s, ω).κ is set to a high enough value to ensure that the charging target is met whenever possible.

107Let us define the low-level return G L t as the sum of the intrinsic rewards from time step t to the end of the time horizon of the low-level MDP, i.e.,

108The low-level value function V L πω (s, ω) is defined as the expected return from starting in state (s, ω) and then following the intra-option policy π ω , i.e.,

109Note that the value function of low-level terminal states is always −κc tar (s, ω), i.e., V L πω (s, ω) = −κc tar (s, ω), ∀(s, ω) ∈ S T L .The objective of the low-level MDP is to derive the optimal intra-option policy π * ω that maximizes the low-level value function for all the states

110In order to derive the optimal intra-option policy, the low-level action-value function or Q function Q L πω (s, ω, a) is defined as the expected low-level return from starting in state (s, ω), taking action a, and then following policy π ω , i.e.,

111Note that the action-value function for the low-level terminal states is always −κc tar (s, ω), i.e., Q L πω (s, ω, a) = −κc tar (s, ω), ∀(s, ω) ∈ S T L , a ∈ A. Given the optimal action-value function Q L * (s, ω, a) = max πω Q L πω (s, ω, a), the optimal intra-option policy selects the highest-valued action in state (s, ω).The Bellman Optimality Equation is given as

112Theorem 1.The flat policy created by superimposing the optimal high-level policy over options µ * and the optimal low-level intra-option policy π * ω performs as well as the optimal policy of the original MDP π * , i.e.,

113where ω * = µ * (s), ∀s ∈ S represents the charging targets prescribed by µ * .Moreover, µ * is the optimal high-level policy over options when the optimal low-level intra-option policy π * ω is available in the high-level SMDP.

VI. DRL SOLUTION

114In this section, we present a DRL algorithm, namely the HDDQN-HER conceived for learning the optimal policy over options µ * by solving the high-level SMDP; and the optimal intra-option policy π * ω by solving the low-level MDPs.

A. Overall Training Framework

115We adopt two deep Q networks, i.e., Q H •; θ H and Q L •; θ L with parameters θ H and θ L to approximate Q H * (s, ω) and Q L * (s, ω, a), respectively.The two networks are jointly trained, where the overall framework is illustrated in Fig. 5.At each time step t, both the high-level and low-level agents receive state S t from the environment.The high-level agent only selects a charging target option ω t based on S t when a new charging period starts, i.e., B t = 1, B t−1 = 0.The option is fed to the low-level agent instead of being fed to the environment.The low-level agent selects a charging schedule action A t at every time step t in the charging period (B t = 1) based on the state S t and the option ω t .The action A t is fed to the environment, which responds to the agent by providing the reward r(S t , A t ).Meanwhile, the environment directly provides the agent with the reward at each time step t in the operating period (B t = 0) without requiring an action from the agent.The high-level agent calculates the high-level reward r H (S t , ω t ) by summing up the reward r(S t , A t ) during each SMDP transition.Meanwhile, the low-level agent derives the low-level reward r L (S t , ω t , A t ) at each time step based on r(S t , A t ) and ω t according to (26) and (27).

116The two Q networks Q H •; θ H and Q L •; θ L are trained simultaneously based on the DDQN algorithm.We refer interested readers to [20] for details of the DDQN algorithm.The high-level and low-level agents draw experiences from their own replay buffers, i.e., R H and R L , respectively.The two replay buffers are updated at different time scales.More specifically, transitions for the low-level MDPs are collected and stored into R L at each time step in the time horizon of the low-level MDP.However, only when the agent enters the terminal state or when an operating period terminates (i.e., B t = 0 and B t+1 = 1), will a new transition for the high-level SMDP be collected and stored into R H .

B. Overcoming Non-Stationarity in Training High-Level Agent

117Based on the above framework, it is challenging to directly learn the high-level policy over options µ * and low-level intraoption policy π * ω in parallel.This is mainly due to the non-stationary environment of the high-level agent, which is caused by exploring and updating low-level policy during training.Specifically, the non-stationarity has two facets.

118• Non-stationary reward function: according to the low-level reward function defined in (26), the low-level agent learns to minimize the cumulative charging cost during the charging period, while ensuring that the charging target is realized.Therefore, the cumulative charging cost decreases, while the low-level policy improves during training, which means that the high-level reward function r H (s, ω) as defined in (19) changes over time.• Non-stationary transition probabilities: a sub-optimal low-level policy activated during training might not be able to achieve the charging target ω set by the high-level agent, while the charging target is actually achievable by the optimal low-level policy.In this case, the transition probability P ω ss ′ of the high-level SMDP will change over time as the low-level policy learns to achieve the charging target.To overcome the above challenges, we adopt the following pair of measures so that the high-level SMDP model remains independent of the changing and exploring low-level policy.

119• To deal with the non-stationary reward function, we divide the joint learning process into two phases.In the first phase when the number of training episodes is smaller than a threshold, i.e., e < M ϵ , the high-level rewards rH stored in the high-level replay buffer R H are obtained by running a fixed low-level policy π q instead of those actually achieved by the low-level behavior policy that is being trained.In the second phase when e ⩾ M ϵ , we calculate the high-level rewards rH based on the low-level behavior policy, i.e., rH = r H , since the low-level policy almost converges to the optimal one at this phase and the non-stationary reward issue is negligible.• To deal with the non-stationary transition probabilities, the actual SoC level of the battery E t k +T c k at the end of the charging period is stored in the high-level replay buffer R H as the option, instead of the actual option ω that has been prescribed by the high-level agent at time step t k , when the charging period started.Therefore, the transition stored in

120k is the one that is actually visited in this episode, and the reward rH (S t k , ω) is calculated as described above, depending on the current training phase.

C. Improving Sample Efficiency in Training the Low-Level Agent

121The low-level agent has to learn to achieve multiple charging targets, while only at the end of an episode will the penalty c tar (s, ω) of not realizing a given charging target be available in the low-level reward defined in (26).Both the multi-goal and sparse reward issues impair the sample efficiency in training the low-level agent, which leads to slow convergence in learning the low-level policy, as well as to an adverse effect in overcoming the non-stationarity for the high-level agent.To deal with the above challenges, we harness the following measures for improving the sample efficiency.

122• Restricting the Option Space: In each charging period, the low-level agent tries to achieve the charging target prescribed by the high-level agent.However, some charging targets might be unachievable, when the high-level agent has not yet learned a good policy.As a result, learning to achieve such charging targets is futile for the low-level agent, and the corresponding experiences are wasted.

123-Given the SoC level E t at the beginning of a charging period, some charging targets are unachievable by the end of the charging period even if the EB is fully charged or discharged at all the time steps.According to the dynamics of the SoC level in ( 6), a state-dependent option space Ω ′ can be defined as

124-If a charging target is too low, the EB will run out of battery power during operation and the MDP enters the terminal states.To exclude these unreasonable charging targets, all transitions ({−, ω}, −, −, {−, ω}) associated with the current option ω are deleted from R L , whenever the agent enters the terminal states.

125• HER: In addition to the original transition {s, ω}, a, r L , {s ′ , ω} that is stored in the low-level replay buffer R L , we create another hindsight transition, i.e., {s, T BD}, a, rL , {s ′ , T BD} .At the end of the charging period, the actual achieved SoC levels E t k +T c k are filled in the TBD components and the additional hindsight transitions are stored into R L if the charging target ω is not realized.Note that rL = r L at all the time steps, except for the last time step in the time horizon of the low-level MDP, i.e., B t = 0 and B t−1 = 1, where c tar (s, ω) = 0 in rL (s, ω, a) since the substituted charging target E t k +T c k is realized.This method guarantees that at least one sequence of transitions is stored in R L that succeeds in realizing the charging target for each charging period.Algorithm 1 describes the pseudocode of the HDDQN-HER algorithm.The functions to select actions or options, store hindsight transitions into R L , and to update the associated Q networks are presented by Algorithms 2, 3, and 4, respectively.

126Algorithm 1 HDDQN-HER algorithm 1: Initialize Q H s, ω; θ H and Q L s, ω, a; θ L with θ H = θ H 0 and θ L = θ L 0 , respectively.Initialize target Q networks Q H− s, a; θ H− and Q L− s, ω, a; θ L− with θ H− ← θ H and θ L− ← θ L .Initialize R H and R L , exploration probability ϵ L = 1 and ϵ H = 1.2: for episode e = 1, ..., M do 3:

127Receive the start state s 4:

128Derive the option space Ω ′ based on (34) 5:

129for t = 1, ..., T do 8:

130Execute action a and observe reward r(s, a), and next state s ′ from environment 11:

131Derive low-level reward r L (s, ω, a), Observe action a, reward r(s, a), and next state s ′ from environment 16:

132Derive rH by running policy π q 22: else 23:

133if s is terminal state then Update Ω ′ based on (34) 32:

134end for

38:

135Anneal ϵ L and ϵ H 39: end for In Algorithm 2, the options or actions are prescribed based on the popular ϵ-greedy policy, while in Algorithm 4, the two Q networks Q H •; θ H and Q L •; θ L are updated based on the corresponding sampled minibatch of transitions.

VII. NUMERICAL ANALYSIS

136In order to evaluate the effectiveness of the proposed HDDQN-HER algorithm, we perform experiments based on real-world data.All the experiments are performed on a Linux server, where the DRL algorithms are implemented in Tensorflow 1.14 using Python 3.6.

A. Experimental Setup

1371) Simulated Environment: The environment that is simulated in our experiments comprises three EBs serving the same bus route.Each of the EBs operates according to a fixed daily schedule [47].Specifically, the first EB departs from the terminal station at 6:30 in the morning, and the last one departs at midnight, i.e., 0:00.An EB is scheduled to depart every 30 minutes during this period, which means that the duration between two consecutive departures of each EB is 90 minutes.The Algorithm 2 Select action a or options ω

138if random()< ϵ then ) at other times.The time horizon for each EB always starts with a charging period, when it arrives at the terminal station after its first departure in the morning, where a pair of consecutive charging and operating periods corresponds to one transition in the high-level SMDP.The duration of a time step is set to 10 minutes, i.e., ∆t = 10 min.The parameters of the environment are listed in Table III.

1392) Experimental data: We use real-world data on electricity prices to train the DRL agents.The dataset contains hourly timevarying electricity prices that reflect the wholesale market price derived from the Midcontinent Independent System Operator (MISO) delivery point [48].Since the electricity price data from one month closely approximates the statistical distribution observed over an entire year, we adopt the one-month electricity price data for training.Specifically, the data in January 2023 is used for training, and the data in the first week of February 2023 is used for testing.Fig. 6 shows the trajectories of electricity prices on a typical day.By observing the fluctuations over time, we find that electricity prices are highest with the value of $0.03921/kWh during the hours of peak demand (between 17:00 and 18:00 daily).

1403) Baseline algorithms: Several baseline algorithms are simulated for performance comparison with HDDQN-HER.1) DDQN-Original: The original MDP of Section III is directly solved by DDQN to obtain a flat policy π.

1412) DDQN-Low: The low-level MDPs corresponding to the charging periods are solved by DDQN.However, the charging target is set to the maximum battery capacity, as in [3], [26], rather than being determined by the policy over options.The reward function of the low-level MDPs is similar to that defined in (26), except that κc tar (s, ω) is replaced by

142, which measures the range anxiety.

1433) DDQN-High: The high-level SMDP is solved by DDQN to learn the charging target.However, the low-level MDPs are solved by a fixed policy π q rather than by the intra-option policy π * ω learned by training the low-level agent.Specifically, the charging target is realized whenever possible without considering the fluctuating electricity prices.This approach adapts the charging power at a coarse time scale, specifically once per charging period, similar to the method in [13].4) HDDQN: Both the high-level SMDP and low-level MDPs are solved by two DDQN networks, respectively.This approach adopts the same framework as in Fig. 5, namely the HDDQN-HER.However, the methods of overcoming non-stationarity and improving sample efficiency in Section VI.B and C are not adopted.Note that a fixed low-level policy π q is used in DDQN-High as well as the first learning phase in HDDQN-HER.In the experiments, we set π q as follows: at each time step in a charging period, the charging power c t is set to the maximum value until the charging target is realized.

144The hyper-parameters of the DDQN networks are listed in Table IV.Note that the total number of training episodes is 24000.The training process of HDDQN-HER is divided into two phases with the threshold of M e = 6000.Therefore, the first phase corresponds to when the training episodes obey e < 6000, while the second phase corresponds to 6000 ≤ e ≤ 24000.The entire training process took approximately 10 hours, while executing a single episode during the deployment process took less than 15 seconds.

B. Experimental Results

1451) Performance for the test set: For each EB, we executed 100 complete episodes based on the test set after training.We obtain the individual performance of each EB by averaging its return over the test episodes, where the return of one Algorithm 4 Networks updating

146Sample a random minibatch M = {s (i) , a (i) , r (i) , s ′(i) } from R and set the target

147Update Q by gradient descent on loss L(θ), where The coefficients of the penalty c tar (S t , ω t )/ the cost of range anxiety episode is defined in (12).Table V summarizes the individual performance of each EB, as well as the average and maximum performance over the three EBs for all the algorithms.The performance rankings are consistent, where HDDQN-HER achieves the best performance, followed by HDDQN, DDQN-High, DDQN-Original, and DDQN-Low.The average performance of HDDQN-HER is better than those of the baseline algorithms by 0.097%, 9.85%, 28.44%, and 39.60%, respectively.Both HDDQN and HDDQN-HER achieve much better performance than the other algorithms, demonstrating the effectiveness of our proposed framework in Fig. 5.Note that HDDQN-HER only achieves slightly better average performance than HDDQN, while the maximum performances of the two algorithms are nearly the same.These results show that the proposed methods of overcoming non-stationarity and improving sample efficiency do not improve the final performance of HDDQN-HER much over HDDQN as long as sufficient training episodes are run.However, a significant convergence speed of the training process is observed, as it will be discussed in Section VII.B 2).

148DDQN-Original performs worse than both HDDQN-HER and HDDQN, since it struggles to learn an optimal policy by directly solving the original MDP for a long horizon.As the penalty C end for entering the terminal states is sparse, a long sequence of highly-specific actions must be executed prior to observing a terminal reward, which makes the learning task challenging.Meanwhile, the hierarchical framework in HDDQN-HER provides an intrinsic reward for the low-level MDPs through options, which substantially improves the sample efficiency.

149HDDQN-HER outperforms DDQN-Low due to the more reasonable charging target in the reward function.The charging target of DDQN-Low is set to the maximum battery capacity, while those of HDDQN-HER are learned by solving the high-level SMDP.Therefore, HDDQN-HER can adapt to the electricity price changes throughout the day and consider the long-range effects of decisions.In addition, compared to HDDQN-HER, DDQN-High discards the low-level DDQN network, which prevents it from adapting EB charging power at a fine time scale to fluctuating electricity prices.Consequently, it cannot learn optimal policies for the low-level MDPs.Finally, comparisons with both DDQN-High and DDQN-Low demonstrate the importance of both levels of DDQN networks for the proposed algorithm.Omitting either level would hinder the algorithm's ability to achieve optimal performance.

1502) Convergence Properties: Fig. 7 shows the performance curves of the algorithms, which are obtained by periodically evaluating the policies during training.Specifically, we ran 10 test episodes for every 100 training episode, where the X-axis The proposed HDDQN-HER converges first at approximately 8500 episodes, followed by DDQN-Low at approximately 10000 episodes due to its simple framework and short time horizon.However, the performance of DDQN-Low after convergence is inferior to those of the other algorithms.DDQN-High also converges relatively fast at approximately 12000 episodes.By contrast, without the methods of overcoming non-stationarity and improving sample efficiency in HDDQN-HER, HDDQN converges slowly at around 15000 episodes.Finally, the convergence of DDQN-Original is the slowest, which converges at around 18000 episodes.This result further demonstrates the low sample and learning efficiency, when directly solving a longrange planning problem by RL.The shaded areas of all the algorithms are relatively small, which shows that all the algorithms perform consistently for different EBs.

1513) Charging Schedule Results: Fig. 8 illustrates the detailed charging schedule decisions and corresponding costs for EB A at each time step in a typical episode based on the test set.The grey and white regions indicate the operating and charging periods, respectively.Fig. 8(a), 8(c), and 8(e) show the charging power at each time step and the EB's battery trajectory.Notice that there is a horizontal line for each charging period in Fig. 8(a), which represents the learned charging target.In Fig. 8(b), 8(d), and 8(f), the sum cost trajectory is displayed as a curve, where the sum cost at time step t is derived by the negative reward −r(S t , A t ) in (11).Since the sum cost consists of two components, i.e., the charging cost and the cost of entering terminal states, we use the bar chart to visualize the individual costs in detail.Moreover, the cost components in the reward function of low-level MDPs are displayed, which include the cost of not realizing the charging target κc tar (S t , ω t ) in HDDQN-HER, and the cost of range anxiety κ DDQN in the proposed algorithm can better learn the fluctuating trends of electricity prices in a full day.Therefore, the high-level agent decides to charge more when the electricity price is low in the afternoon from 14:00 to 16:00, and sell more electricity when the price is the highest, namely from 17:00 to 19:00 to minimize its charging cost.Meanwhile, DDQN-Original is unable to learn such an efficient policy, which leads to the relatively high charging cost seen in Fig. 8(d).Additionally, Fig. 8(a) shows that HDDQN-HER can realize the charging target in every charging period, and thus no corresponding cost is incurred, as shown in Fig. 8(b).Finally, as shown in Fig. 8(e), the battery SoC curve of DDQN-Low continues to remain high, since the charging target is the constant full battery capacity.Due to the cost of range anxiety, the agent tends to fully charge the EB in most charging periods, which is an essential reason why DDQN-Low has the highest charging cost.It can be observed in Fig. 8(f) that the cost of range anxiety is always zero except in the 8-th and 9-th charging periods, which means that the EB is always fully charged except in these two periods.

VIII. CONCLUSIONS

152We have studied how to use HDRL techniques to learn optimal charging schedules for EBs in a system model giving full cognizance to both the charging and operating periods.An MDP model has been conceived, which has been reformulated into a two-level decision process in order to overcome the challenges of long-range multi-phase planning with sparse rewards.It has been proved that the flat policy created by superimposing the optimal high-level and low-level policies performs as well as the optimal policy of the original MDP.The HDDQN-HER algorithm has been conceived for training the two levels of agents simultaneously, in which compelling methods leveraging the idea of HER are proposed to deal with the non-stationarity encountered in training the high-level agent and to improve the sample efficiency in training the low-level agent.Finally, experiments have been performed to demonstrate that the proposed algorithm achieves better performance than the baseline algorithms.

153In our future work, the HDRL framework will be extended to consider charging schedules for EB fleets, where the high-level bus scheduling decisions that are made at a coarser time-scale can be optimized jointly with the low-level charging power decisions made at a finer time-scale.Our ultimate goal is to leash all solutions of the multi-component Pareto-front having a gradually increased number of parameters in the objective function.Additionally, we will integrate safe RL techniques to provide formal guarantees that the agent does not enter terminal states.This enhancement will further improve the robustness of our approach in real-world deployments.Finally, we plan to incorporate real-world EB operational data instead of simulated data in our experiments to better capture real-world uncertainties and refine policy performance under practical conditions.APPENDIX A PROOF FOR THEOREM 1 Proof.

154• Reparation stage: Without loss of generality, the R.H.S. of (33) in Theorem 1 can be derived as In the following, we will prove Theorem 1 in two steps.Specifically, we decouple π * into a high-level policy over options μ and a low-level intra-option policy πω .Thus, the SoC levels E *

155• In the first step, we will prove that the optimal low-level intra-option policy π * ω achieves the same performance as πω does when their charging targets are both prescribed by μ in (36)

156For this purpose, we adopt the proof by contradiction method and assume that (38) does not hold.Firstly, we have

157where (a) and (d) are valid, because there is no penalty for failing to realize the charging target in (26), i.e., c tar (s, ω) = 0 since both π * ω and πω can realize the charging target ω; (b) and (c) are true according to the definition of the optimal value function in (30).

158Since we assume that (38) does not hold, (c) in ( 39) is a strict inequality due to the property of the max operator, which means that we have

159where (a) is derived from (39) with strict inequality; (b) is due to the fact that π * is the superimposition of μ and πω ; (c) is because of the zero rewards during the operating periods from T c k to T a k − 1, since there is no charging cost in the operating period.Moreover, the optimal flat policy π * ensures that there is no penalty for entering the terminal states, i.e., C end = 0 in (11).

160Furthermore, (40) implies that the flat policy created by superimposing the policy μ and the optimal intra-option policy π * ω performs better than the optimal policy π * for the original MDP, which cannot be true by the definition of π * .Therefore, (40) contradicts to (35), and we have thus proved that (38) holds.

161• In the second step, we will prove that the optimal high-level policy over options µ * achieves the same performance as μ does when the low-level intra-option policy is π * ω , i.e.,

162In order to prove (41), we also adopt the proof by contradiction method and assume that (41) does not hold.Thus, we have

163where (a) is derived by definition of the high-level reward in (19); (b) is derived by definition of the optimal value function in (23); (c) is a strict inequality due to the property of the max operator and the assumption that (41) does not hold; (d) is due to (38); (e) is because the policies μ and πω superimpose the optimal flat policy π * ; (f) is by definition of the value function in (13).

164Finally, (42) implies that the flat policy created by superimposing µ * and π * ω * performs better than the optimal policy π * for the original MDP, which cannot be true by the definition of π * .Therefore, (42) contradicts to (35), and we have thus proved that (41) holds.Moreover, if (41) holds, (c) in (42) should be an equality.Notably, the first term in (42) corresponds to the right-hand side of (33), while the last term corresponds to its left-hand side, which means that (33) in Theorem 1 holds.

Fig. 1 :

165Fig. 1: Comparison of MILP, RO, GA, and DRL in terms of four key criteria: lower computational complexity, data independency, uncertainty handling, and adaptability to dynamic environments.

Fig. 2 :

166Fig. 2: The contributions of this paper in contrast to the literature on HRL.

167The time in a full day is discretized into T equal-length time steps, indexed by {0, . . ., T − 1}.The duration of each time step is denoted as ∆t.Let T o k , ∀k ∈ {0, . . ., K − 1} and T c k , ∀k ∈ {0, . . ., K − 2} be random variables that represent the number of time steps in the operating period k and the charging period k, respectively.Note that the variables T c k and T o k are random due to the uncertainty in the arrival times of the EBs at the terminal station, which is caused by the stochastic traffic conditions along the bus route.The random time step at which the EB arrives at the terminal station from the operating period k is denoted by t k , where k ∈ {0, . . ., K − 1}.Then, the EB enters the charging period k upon its arrival at t k , where k ∈ {0, . . ., K − 2}.Let T d k , ∀k ∈ {0, . . ., K − 2} denote the fixed number of time steps between two consecutive departures of the EB for operating periods k and k + 1 according to the bus schedule.This corresponds to the sum duration of a pair of consecutive

Fig. 3 :

168Fig. 3: The schematic diagram of the system model for the EB charging problem.

Fig. 4 :

169Fig. 4: The schematic diagram of the original MDP, high-level SMDP, and low-level MDPs.

Fig. 5 :

170Fig. 5: The framework of HDDQN-HER algorithm.

12 :

171Store {s, ω}, a, r L , {s ′ , ω} into R L 13: HER(s, ω, a, r L , s ′ , ω, R L )

28 :

172Delete ({−, ω}, −, −, {−, ω}) from R L

3 2 :

173Store hindsight transitions 1: function HER(s, ω, a, r L , s ′ , ω, R L ) Creat hindsight transition {s, T BD}, a, rL , {s ′ , T BD} where rL = r L 3: if B t+1 = 0 and ω ̸ = E t+1 then 4: ω ← E t+1 , update reward rL 5: Replace T BD with ω and store hindsight transitions into R L 6: end if 7: end function duration of the operating period T o k follows normal distributions with different mean values at different times of the day, i.e., T o k ∼ N (50, 8) at rush hours (7:00-9:00 and 17:00-19:00) and T o k ∼ N (40, 8

Fig. 6 :

174Fig. 6: The trajectories of the electricity prices of a typical day in the experimental data.

Fig. 7 :

175Fig. 7: The performance curves of the algorithms in the training process.The vertical axis corresponds to the average performance across the three EBs, and the shaded areas represent the standard errors.

Fig. 8 (

176Fig.8(b), 8(d), and 8(f) show that there is no cost for entering the terminal states, which means that the basic requirement of ensuring sufficient battery energy can be met by all the algorithms.A closer examination of Fig.8(a) and 8(c) shows that the battery trajectory curve of HDDQN-HER fluctuates much more than that of DDQN-Original, which is because the high-level

Fig. 8 :

177Fig. 8: A specific test episode on an EB.

t k +T c k ,

178∀k ∈ {0, 1, • • • , K − 1} can be regarded as the charging targets prescribed by μ , i.e., μ(St k ) = ω = E * t k +T c k , ∀k ∈ {0, 1, • • • , K − 1},(36)while the charging target ω is fulfilled by the policy πω , i.e.,πω (S t ) = π * (S t ), ∀t ∈ {t k , • • • , t k + T c k − 1}.

179t k +l , A t k +l )|S 0 = s t k +l , A t k +l )|S 0 = s t k +l , A t k +l )|S 0 = s t k +l , A t k +l )|S 0 = s   ,

E µ * E π * ω * T − 1 t=0rK− 1 k=0rr= E π * T − 1 t=0r

180(S t , A t )|S 0 = s (a) = E µ * E π * ω * H (S t k , ω * )|S 0 = s H (S t k , ω)|S 0 = s (c) > E μE π * ω K−1 k=0 r H (S t k , ω)|S 0 = s (d) = E μE πω K−1 k=0 r H (S t k , ω)|S 0 = s (e) (S t , A t )|S 0 = s (f)

TABLE I :

181Contrasting this paper to the literature on EBCSP.

TABLE II :

182Notation used in this paper

TABLE III :

183Parameter configuration in the system model.

TABLE IV :

184Hyper-parameters of various DRL algorithms.

TABLE V :

185The individual, average, and maximum performance of the algorithms across three EBs.

186, i.e., (S t k +l , A t k +l )|S t k = s (S t k +l , A t k +l )|S t k = s

참고문헌 39건

  1. (제목 없음) Discrete Event Dynamic Systems · Springer Science+Business Media · 2003 10.1023/a:1022140919877
  2. Between MDPs and semi-MDPs: A framework for temporal abstraction in reinforcement learning Artificial Intelligence · Elsevier BV · 1999 10.1016/s0004-3702(99)00052-1
  3. Hierarchical Reinforcement Learning with the MAXQ Value Function Decomposition Journal of Artificial Intelligence Research · AI Access Foundation · 2000 10.1613/jair.639
  4. Deep Reinforcement Learning with Double Q-Learning Proceedings of the AAAI Conference on Artificial Intelligence · Association for the Advancement of Artificial Intelligence · 2016 10.1609/aaai.v30i1.10295
  5. Learnings Options End-to-End for Continuous Action Tasks arXiv (Cornell University) · Cornell University · 2017 10.48550/arxiv.1712.00004
  6. Influence of Wind Power on Intraday Electricity Spot Market: A Comparative Study Based on Real Data Energies · Multidisciplinary Digital Publishing Institute · 2018 10.3390/en11112974
  7. Integrated European intra-day electricity market: Rules, modeling and analysis Applied Energy · Elsevier BV · 2019 10.1016/j.apenergy.2018.12.073
  8. bCharge: Data-Driven Real-Time Charging Scheduling for Large-Scale Electric Bus Fleets 2018 10.1109/rtss.2018.00015
  9. Mixed-fleet single-terminal bus scheduling problem: Modelling, solution scheme and potential applications Omega · Elsevier BV · 2019 10.1016/j.omega.2019.05.006
  10. Learning Multi-Level Hierarchies with Hindsight 2017
  11. Robust scheduling strategies of electric buses under stochastic traffic conditions Transportation Research Part C Emerging Technologies · Elsevier BV · 2019 10.1016/j.trc.2019.05.032
  12. The Option-Critic Architecture Proceedings of the AAAI Conference on Artificial Intelligence · Association for the Advancement of Artificial Intelligence · 2017 10.1609/aaai.v31i1.10916
  13. Reinforcement Learning for Smart Charging of Electric Buses in Smart Grid 2015 IEEE Global Communications Conference (GLOBECOM) · 2019 10.1109/globecom38437.2019.9014160
  14. Optimal charging scheduling and management for a fast-charging battery electric bus system Transportation Research Part E Logistics and Transportation Review · Elsevier BV · 2020 10.1016/j.tre.2020.102056
  15. Dynamic Energy Dispatch Based on Deep Reinforcement Learning in IoT-Driven Smart Isolated Microgrids IEEE Internet of Things Journal · Institute of Electrical and Electronics Engineers · 2020 10.1109/jiot.2020.3042007
  16. Optimization of electric bus scheduling considering stochastic volatilities in trip travel time and energy consumption Computer-Aided Civil and Infrastructure Engineering · Wiley · 2021 10.1111/mice.12684
  17. Hierarchical Reinforcement Learning ACM Computing Surveys · Association for Computing Machinery · 2021 10.1145/3453160
  18. Optimal electric bus fleet scheduling considering battery degradation and non-linear charging profile Transportation Research Part E Logistics and Transportation Review · Elsevier BV · 2021 10.1016/j.tre.2021.102445
  19. Robust charging strategies for electric bus fleets under energy consumption uncertainty Transportation Research Part D Transport and Environment · Elsevier BV · 2022 10.1016/j.trd.2022.103215
  20. Electric Bus Charging Scheduling for a Single Public Transport Route Considering Nonlinear Charging Profile and Battery Degradation Effect Transportation Research Part B Methodological · Elsevier BV · 2022 10.1016/j.trb.2022.03.002
  21. Optimal charging plan for electric bus considering time-of-day electricity tariff Journal of Intelligent and Connected Vehicles · Emerald Publishing Limited · 2022 10.1108/jicv-04-2022-0008
  22. Markov Decision Processes: Discrete Stochastic Dynamic Programming Technometrics · Taylor & Francis · 1995 10.1080/00401706.1995.10484354
  23. Electric bus coordinated charging strategy considering V2G and battery degradation Energy · Elsevier BV · 2022 10.1016/j.energy.2022.124252
  24. A joint optimisation model for charger locating and electric bus charging scheduling considering opportunity fast charging and uncertainties Transportation Research Part C Emerging Technologies · Elsevier BV · 2022 10.1016/j.trc.2022.103732
  25. Robust optimization for integrated planning of electric-bus charger deployment and charging scheduling Transportation Research Part D Transport and Environment · Elsevier BV · 2022 10.1016/j.trd.2022.103410
  26. Collaborative optimization of electric bus line scheduling with multiple charging modes Transportation Research Part D Transport and Environment · Elsevier BV · 2022 10.1016/j.trd.2022.103551
  27. An optimal charging scheduling model and algorithm for electric buses Applied Energy · Elsevier BV · 2022 10.1016/j.apenergy.2022.120512
  28. Optimal electric bus fleet scheduling for a route with charging facility sharing Transportation Research Part C Emerging Technologies · Elsevier BV · 2022 10.1016/j.trc.2022.104010
  29. Battery electricity bus charging schedule considering bus journey’s energy consumption estimation Transportation Research Part D Transport and Environment · Elsevier BV · 2022 10.1016/j.trd.2022.103587
  30. Exploring the profitability of using electric bus fleets for transport and power grid services Transportation Research Part C Emerging Technologies · Elsevier BV · 2023 10.1016/j.trc.2023.104060
  31. Electric bus charging facility planning with uncertainties: Model formulation and algorithm design Transportation Research Part C Emerging Technologies · Elsevier BV · 2023 10.1016/j.trc.2023.104108
  32. A Network Flow Approach to Battery Electric Bus Scheduling IEEE Transactions on Intelligent Transportation Systems · Institute of Electrical and Electronics Engineers · 2023 10.1109/tits.2023.3276269
  33. Real-Time Scheduling of Electric Bus Flash Charging at Intermediate Stops: A Deep Reinforcement Learning Approach IEEE Transactions on Transportation Electrification · Institute of Electrical and Electronics Engineers · 2023 10.1109/tte.2023.3343810
  34. Future Trends in Smart Green IoV: Vehicle-to-Everything in the Era of Electric Vehicles IEEE Open Journal of Vehicular Technology · Institute of Electrical and Electronics Engineers · 2024 10.1109/ojvt.2024.3358893
  35. Charging facility planning and scheduling problems for battery electric bus systems: A comprehensive review Transportation Research Part E Logistics and Transportation Review · Elsevier BV · 2024 10.1016/j.tre.2024.103463
  36. Electric bus charging scheduling on a bus network Transportation Research Part C Emerging Technologies · Elsevier BV · 2024 10.1016/j.trc.2024.104553
  37. A mixed-integer programming-based Q-learning approach for electric bus scheduling with multiple termini and service routes Transportation Research Part C Emerging Technologies · Elsevier BV · 2024 10.1016/j.trc.2024.104570
  38. A real-time synchronous dispatching and recharging strategy for multi-line electric bus systems Transportation Research Part E Logistics and Transportation Review · Elsevier BV · 2024 10.1016/j.tre.2024.103516
  39. Bidirectional Charging Hubs in the Electric Vehicle Retail Landscape: Opportunities and Challenges for the U.K. Case IEEE Open Journal of Vehicular Technology · Institute of Electrical and Electronics Engineers · 2024 10.1109/ojvt.2024.3474426