{'fraction_non_alphanumeric': 0.024644720273430475, 'fraction_numerical': 0.007285483000539665, 'mean_word_length': 5.016774891774892, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
A Centralised Soft Actor Critic Deep Reinforcement Learning Approach to District Demand Side Management through CityLearn

Reinforcement learning is a promising model-free and adaptive controller for demand side management, as part of the future smart grid, at the district level. This paper presents the results of the algorithm that was submitted for the CityLearn Challenge, which was hosted in early 2020 with the aim of designing and tuning a reinforcement learning agent to flatten and smooth the aggregated curve of electrical demand of a district of diverse buildings. The proposed solution secured second place in the challenge using a centralised 'Soft Actor Critic' deep reinforcement learning agent that was able to handle continuous action spaces. The controller was able to achieve an averaged score of 0.967 on the challenge dataset comprising of different buildings and climates. This highlights the potential application of deep reinforcement learning as a plug-and-play style controller, that is capable of handling different climates and a heterogenous building stock, for district demand side management of buildings.


INTRODUCTION
Buildings are complex systems influenced by changing weather, occupancy, schedules and in a demand response (DR) contextgrid signals. Capturing these dynamics in a physics-based simulation model capable of facilitating DR is highly challenging. This is due to highly non-linear behaviour of the thermal-dynamics and the fact that no one building is identical to another in the highly heterogenous building stock [3]. Reinforcement learning (RL) is a model-free algorithm that learns from historical and real-time data and has shown promise in recent research applied to building energy management problems [8,9]. Given the novelty associated with RL in this domain, the behaviour of multiple energy consuming agents (i.e., buildings), subject to demand-dependent grid signals, is an area that is not well understood [8]. The CityLearn project (https://github.com/intelligent-environments-lab/CityLearn) is an OpenAI Gym environment [1], which aims to facilitate the implementation of RL agents in a multi-agent DR context for a diverse group of buildings [7]. The main objective of CityLearn is to facilitate and standardize the evaluation and comparison of different RL agents and algorithms. The CityLearn Challenge was organised virtually and ran from January to July 2020. It invited participants to design, develop and tune a RL agent to flatten and smooth the aggregated curve of electrical demand for a district comprising of 9 diverse buildings. The current paper presents the results from a centralised "Soft Actor Critic" deep RL based algorithm that was submitted to the challenge.

RELATED WORK
The review of RL for DR by Vázquez-Canteli and Nagy [8] shows its promising potential as a model-free technique, mitigating the need to develop physics-based control-oriented models, and capable of dealing with the heterogenous nature of the building stock. The review found that most studies to date focus on single building systems with demand-independent electricity prices. Focusing on deep RL, which has gained significant interest and traction in recent years, e.g., using Deep Q Networks [5], such approaches have often been limited to discrete and low-dimensional action spaces [4]. There is a research gap in the application of deep reinforcement learning to problems with continuous action spaces in the building energy management domain.
The Soft Actor-Critic (SAC) algorithm, an off-policy maximum entropy actor-critic algorithm, as first proposed by Haarnoja  LG] 22 Sep 2020 [2] in 2018, is one of the algorithms that is capable of operating over continuous action spaces. At their core, actor-critic methods are a type of policy gradient method, which have separate memory structures to explicitly represent the policy [6]. The policy structure is known as the actor and the estimated value function is known as the critic. The actor selects the actions whereas the critic evaluates the actions made by the actor. The reader is referred to Sutton [6] for a more detailed explanation of Actor-Critic methods. Haarnoja et al. [2] suggest that the SAC algorithm provides for both sample-efficient learning and stability and hence extends readily to complex, high-dimensional tasks. They found the SAC algorithm showed substantial improvement in both performance and sample efficiency over both off-policy and on-policy prior methods. This current research investigates the suitability of the SAC algorithm for tackling the district DSM problem utilising CityLearn.

CityLearn Challenge
The CityLearn challenge used a multi-objective cost function of five equally weighted metrics applied to an entire district of nine buildings (as outlined in Table 1). These are described below: (1) Peak electricity demand (for the evaluation period of 1 year) (2) Average daily electricity peak demand (daily peak demand of the district averaged over the evaluation period) (3) Ramping (a measure of how much the district electricity consumption changes from one timestep to the next) (4) 1 -Load factor (the average monthly electricity demand divided by its maximum peak) (5) Net electricity consumption of the district over the evaluation period The multi-objective cost function is normalised by a baseline cost obtained from the performance of a predefined manually tuned Rule-Based Controller (RBC). This implied that a cost function of less than 1 resulted in a better performance than the RBC. This RBC controller charges cooling (and domestic hot water (DHW) if available) during the night and discharges during the day based only on the hour of the day. The adaptive potential of RL to deal with different environments, rather than solely the one it was trained on, was tested through evaluating the controller on different datasets. Participants used the design dataset to implement their RL agent (including design, tuning and pre-training) and could test their agent on the evaluation dataset and receive feedback through the cost function based on the generalisation results of their agents. Each dataset contains year-long hourly information about the cooling and DHW demand of the building, electricity consumed by appliances, solar power generation, as well as weather data and other variables. The evaluation dataset featured different buildings from different cities than the design dataset, albeit within the same climate zones (see Table 2). The challenge dataset is different from both the design and evaluation datasets featuring different buildings and climates.

State Space and Hyperparameters
The state space is what the RL agent observes for each control step. The CityLearn environment allows for a total of 27 observations  per building that may be passed to the agent. The final state design used in the submission was determined by utilising a combination of expert assessment and trial and error and is outlined in Table  3. A centralised solution is presented here with one agent, which has complete oversight of all nine buildings. The SAC RL algorithm used has several key hyperparameters and the values used in the submission are detailed in Table 4. Note that some parameters were modified in the deployment (evaluation) phase to allow the agent to adapt to new environments (such as a new climate), whilst also retaining the initial weights of the pre-trained agent.

Reward Function
The reward function was designed based on a virtual price signal (penalising peak consumption) together with manual reward shaping to incentivise charging during the night and discharging during the day. The reward (R) function used is shown in Eq. 1 where β  is a weighting coefficient (with a value of 0.005), N is the number of buildings in the district, e t ot al is the total district electricity consumption and e i is the building i electricity consumption. The final reward value was also scaled and clipped to be in the range of -1 to 1. where:

RESULTS
The centralised SAC RL Agent shows promising performance applied to the district DSM problem. Within 10 episodes of training on the dataset for climate zone 1 (see Fig. 1), the agent realises an improved multi-objective cost function (as defined in Section 3.1) as compared to the RBC baseline (manually predefined controller). Note that the cost function is computed relative to the RBC baseline, i.e., a cost function of less than 1 is considered to be an improved performance over the baseline and a cost function of greater than 1 is considered to be a poorer performance compared to the baseline. When this pre-trained agent is evaluated (i.e., deployed) for the same climate zone, it produces an improvement of 10.7% (a score of 0.893) over the RBC baseline (see Figure 2 for the district electricity consumption profile and Table 5 for the scores). This table also shows the ability of the RL agent to generalise and adapt to new climatic conditions, and although they suffered a performance drop, still managed to outperform the manually tuned RBC. The Challenge dataset scores showed that the agent was further generalisable to unseen data (see Table 5) featuring both different building properties and climates. Overall, an average improvement of 3.3% was seen over the manually tuned RBC over the four different climate zones tested. Whilst these improvements are modest, they are promising given the adaptability over a range of buildings and climates and the limited information required for the state space.

CONCLUSIONS AND FURTHER WORK
In this paper, a centralised 'Soft Actor Critic' reinforcement learning agent, capable of handling continuous action spaces, is proposed for  the district demand side management problem and the performance of the agent applied to the CityLearn challenge is outlined. The agent was able to secure second place in the competition achieving an average score of 0.967 over the challenge dataset featuring different buildings and climates when compared to the reference manually tuned rule-based controller. This highlights the potential of deep reinforcement learning as a plug-and-play style controller for district level demand side management of buildings. Limitations include the manual reward shaping applied which perhaps limits the generalisation ability of the RL agent to districts with significantly different demand profiles. Given the centralised agent with oversight of all buildings, it is not known how the computational requirements and performance would scale over a larger number buildings. A further limitation of CityLearn is that the cooling load is precomputed and hence currently does not support thermal comfort considerations and utilisation of the passive thermal mass for load shifting. Future work aims to further the robustness of the RL agent through reducing the amount of manual reward shaping applied and testing the performance of the algorithm for different hyperparameters. The addition of further energy systems such as batteries and electric vehicles to CityLearn will also be considered.