{'fraction_non_alphanumeric': 0.029654782116581777, 'fraction_numerical': 0.007696661007357102, 'mean_word_length': 4.828166226912929, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Latent Neural ODE for Integrating Multi-timescale measurements in Smart Distribution Grids

Under a smart grid paradigm, there has been an increase in sensor installations to enhance situational awareness. The measurements from these sensors can be leveraged for real-time monitoring, control, and protection. However, these measurements are typically irregularly sampled. These measurements may also be intermittent due to communication bandwidth limitations. To tackle this problem, this paper proposes a novel latent neural ordinary differential equations (LODE) approach to aggregate the unevenly sampled multivariate time-series measurements. The proposed approach is flexible in performing both imputations and predictions while being computationally efficient. Simulation results on IEEE 37 bus test systems illustrate the efficiency of the proposed approach.


I. INTRODUCTION
In conventional distribution systems, the lack of sufficient real-time measurements in a distribution grid hinders the ability to obtain situational awareness. With increasing penetration of PV and EVs, more extensive real-time monitoring and control is required for effective operation of the system and for good quality of service to the customers [1]. To ensure situational awareness, classic distribution system state estimation (DSSE) uses pseudo-measurements with conventional weighted least squares approaches [2]. Recently, sparsityaware DSSE techniques [3]- [5] are proposed to deal with the issue of low observability. Alongside, the utilities are upgrading their distribution system to cope with the low observability issue. This has led to a significant increase in the availability of real-time measurements to the control center. For instance, the installation of smart meters and supervisory control and data acquisition (SCADA) sensors have increased to improve the measurement redundancy. Furthermore, new generations of phasor measurement units (PMU) and IEDs (Intelligent Electronic Devices) enhance situational awareness, protection and control functions in substations. However, aggregating the measurements from different sources presents some challenges. Firstly, the measurements are unevenly sampled i.e., they are obtained at different rates. For example, the smart meter measurements are typically sampled at 15min interval while the SCADA sensors are sampled at 1sec to 1-min interval. Furthermore, these measurements may be intermittent or corrupt due to communication network impairments. It is therefore important to reconcile the multi time-scale measurements for situational awareness in a power distribution grid.

A. Related work
Research efforts have focused on aggregating two time-scale measurements using linear interpolation/extrapolation based weighted least squares (WLS) approach [6]. However, this approach fails to exploit the spatio-temporal relationships in the time-series data and performs poorly in the case of intermittent measurements. The issue of irregular sensor sampling and random communication delays was proposed in [7]. A multi-task Gaussian process (GP) framework to reconcile heterogeneous measurements was proposed in [8], [9]. This approach is computationally expensive as it requires an inversion operation of the kernel matrix to impute or predict the slowrate measurements. An exponential moving average method to extrapolate the slow-rate measurements was proposed in [10]. Authors in [11] use PMU and SCADA measurements for state estimation. This approach performs DSSE by incorporating a subset of PMU measurements available at time t along with the predicted SCADA measurements. The future predictions of the SCADA measurements are obtained using the information from the previous state estimates. It suffers from large measurement redundancy requirements (around 1.7), which makes it impractical for low-observable distribution systems. Furthermore, [11] fails to take into account any missing measurements scenario that could occur while aggregating measurements over finite bandwidth communication networks. A recursive Gaussian process based framework is proposed in [12] that sequentially aggregates measurements batch-wise or real-time. The proposed approach requires careful selection of the hyper-parameters of the GP function as well as inversion of the kernel matrix at the initial time step.
In this paper, we propose a novel approach that leverages spatio-temporal dependencies in time-series data without involving matrix inverse operations. The proposed approach uses neural ordinary differential equations [13] that are ideal for imputing and predicting time-series measurements collected at non-uniform intervals.

B. Contributions
The main contributions of this paper are summarized below: • For the first time, we propose a latent neural ordinary differential equations (LODE) approach to reconcile the multi time-scale measurements in a distribution grid. The proposed approach is capable of performing imputations as well as predictions at any desired time instant. • The proposed approach is computationally efficient and performs fast predictions once the model is trained offline. • Simulation results for three-phase unbalanced IEEE 37 bus system reveal the superior performance of the proposed approach. The proposed approach provides smooth imputations and predictions with high fidelity.

II. BACKGROUND: NEURAL ODE
The measurements obtained from multiple grid sensors are obtained at different sampling rates. The multivariate timeseries sensor data with D variables and of N length can be written as, This data may contain missing values due to the sensor sampling rate or communication impairments. A mask M ∈ R N ×D identifies the missing measurements. The entries in M i.e., m d t is set to 1 if the corresponding measurement x d t is observed; else, they are set to 0. The goal is to reconcile the unevenly sampled measurements at the finest time resolution. Learning a generative model for the multivariate time-series will help accomplish this goal.
Generative models using a deep neural network is typically built on the concept of a fixed number of layers. In the forward pass, each network consists of a stack of L transformations, where L is the depth of the model. In order to update these models, a backpropagation algorithm is run through the same L layers via chain rule. This process necessitates that we store the intermediate values of the layers. Thus, training standard deep neural networks are computationally challenging as the memory requirement for storing the intermediate quantity increases as the model depth is increased. Furthermore, limited number of transformations are performed due to the fixed number of layers.
Neural ODE is a recent novel framework that is effective for modeling irregularly-sampled time series commonly encountered in various real-world application, including smart grid and medical data. It combines deep neural network principles with ordinary differential equations, and thus are more effective than conventional time series models. Particularly, in this work, Neural ODE is used for learning generative models for multivariate time series data from the distribution grid. Neural ODE offers a continuous time transformation of variables from input state to final predictions unlike standard deep neural network which only performs a limited number of transformations depending on the number of layers. The transformed values (or intermediate values) are obtained via ODE solvers by providing initial state and dynamics as inputs. The dynamics of the transformation function is determined by a neural network as shown below: where, f is a neural network parameterized by θ that defines the ODE dynamics. z t is the hidden state of the Neural ODE. Thus, starting from an initial point z(t 0 ), the transformed state at any time t i is given by integrating an ODE forward in time, given as, (3) can be solved numerically using any ODE Solver (e.g., Euler's method). In order to train the parameters of the ODE function f , an adjoint sensitivity approach is proposed in [13]. This approach computes the derivatives of the loss function with respect to the model parameters θ by solving a second augmented ODE backwards in time. Some of the advantages of using Neural ODE solvers over other conventional approaches are: (1) Memory efficiency: The adjoint sensitivity approach allows us to train the model with constant memory cost independent of the layers in the ODE function f ; (2) Adaptive computation: In deep neural networks, the number of layers are fixed and therefore, they generally have a fixed amount of function evaluations. However, the number of layers in a neural ODE is the number of steps an adaptive ODE solver decides to take. This means that the neural ODE can effectively adapt the number of layers on the fly for different datasets and take adaptive steps wherever necessary to determine the solution with desired accuracy; (3) Effective formulation: In addition to above two advantages, the continuously defined dynamics can naturally incorporate data which arrives at arbitrary times. Therefore, we propose to use the Neural ODE for reconciling the unevenly sampled distribution grid data.

III. PROPOSED APPROACH
The basic neural ODEs evaluate the hidden state values at any desired time instants. However, such models are hard to interpret, especially for multi-time scale power measurements, due to the combined dynamics of power system and the ODE solver. Therefore, we propose to use Latent ODE (LODE) approach for reconciling the multi-time scale power measurements. The LODE approach is a continuous-time generative process for integrating multi-time scale measurements. This approach uses Neural ODEs, and variational autoencoder within a single framework [14]. LODE has two key advantages over neural ODE: First, it explicitly decouples the dynamics of the power system, the likelihood of observations, and the recognition model so that each component can be analyzed separately. Secondly, the posterior distribution over an initial latent state provides a measure of uncertainty which further increases the reliability of our predictions. The proposed framework (LODE) has three different modules, namely an encoder, a decoder, and the ODE solver. The architecture of LODE for smart distribution grid is illustrated in Fig. 1. Each module of LODE is described in the forthcoming subsection.

A. Encoder: Recognition network
This module encodes the input measurements from data space and transforms it into a latent space. Encoding is typically carried out via a recurrent neural network since it is effective in capturing long term dependencies of time series data. Encoder takes {x i , t i } N i=1 as an input, where x i represents the observations and t i represents the corresponding observation times. The data is processed backward in time from time t N to t 0 . An approximate posterior over the initial is computed from the last hidden layer of the encoder network. In our approach, the mean and standard deviation of the approximate posterior q φ (z 0 |{x i , t i } N i=1 ) are the function of the final hidden state of an encoder network, characterized by, where, µ z0 , σ z0 = g(RN N φ ({x i , t i } N i=1 )). Here, the function g represents a neural network layer, translating the final hidden state of the encoder into the mean and variance of z 0 .

B. ODE Solver
Once an approximate posterior distribution q(z 0 |{x i , t i } N i=1 ) is obtained from the encoder, an initial latent state (z 0 ) for the ODE solver is sampled from the corresponding distribution. The initial latent state serves as an input to the ODE solver together with a ODE dynamic function f . Then, a ODE solver is used to obtain latent space observations for all the given times, Thus, given observation times t 0 , t 1 , ..., t N and an initial state z 0 , an ODE solver produces z 1 , ..., z N , which describes the latent state at each observation. The ODE solver is capable of imputing historical time points as well as forecasting future values by providing appropriate latent states at desired time instants. As the function f is time-invariant, a unique latent trajectory can be defined given the initial latent state.

C. Decoder
the decoder transforms the latent trajectory defined at various time instants back into the data space using the neural network. Standard multi layer perceptron can be used in decoder network since we only need to map two function spaces.

D. Training of LODE
The training of the proposed LODE framework is similar to that of a variational autoencoder, and it is end-to-end. The encoder-decoder model is trained by maximizing the Evidence Lower Bound (ELBO) given as, The first term in the ELBO represents the log probability of the decoder estimates. The second term denotes the KL divergence or degree of "dissimilarilty" between the two distributions q φ (z 0 |{x i , t i } N i=0 ) and p(z 0 ). Here, the prior over latent states p(z 0 ) is chosen as N (0, 1). The overall pipeline of the proposed Latent ODE approach summarized in Algorithm 1.

Algorithm 1 Latent ODE Approach
Input: Datapoints {x i } N i=1 and the corresponding times

IV. SIMULATION RESULTS
This section evaluates the efficacy of the proposed framework for the imputation and predictions tasks related to smart distribution grid. Experiments are carried out in standard IEEE 37 bus system.

A. Data processing
We consider measurements from smart meter and SCADA sensors. The smart meter measurements consist of 24-hr active and reactive power injection time-series data aggregated at the primary nodes. This 24-hr load profile consists of a mixture of load profiles, i.e., industrial/commercial load profiles [15], and residential loads [16]. Reactive power profiles are obtained by assuming a power factor of 0.9 lagging. The SCADA measurements are obtained by executing load flows on the test network. The SCADA measurements consists of the voltage magnitude measurements at a subset of node locations. The aggregated smart meter data are averaged over 15-min intervals while the SCADA measurements are sampled at a 1-min interval. A Gaussian noise with 0 mean and standard deviation equal to 10% of the actual power values is added Figure 1: Architecture of proposed Latent ODE approach for smart distribution grid in the smart meter data to mimic real-world patterns. The smart meter and SCADA measurements constitute our training dataset.
Once the distribution grid's measurements are obtained, we represent the dataset as a list of records. Each record represents the information about the time-series data with the format given as, record = [measurement type, values, times, mask]. Here, time-series data at each node of the IEEE 37 bus network represents one record. The measurement type denotes the sensor type, i.e., P, Q, or V . Values ∈ R N ×1 represents the sensor measurements with times ∈ R N as the corresponding time instants. Mask ∈ R N ×1 represents the availability of the corresponding measurements. The dataset is further normalized between [0,1] interval. We take the union of all time points across different nodes in the dataset that are irregularly sampled. This is needed to perform batching during training.

B. Model Specifications
The encoder is a gated recurrent unit (GRU) [17]. We consider 40-dimensional hidden states of encoder with tanh activation functions. The ODE function is a feedforward neural network with three layers and 100 units on each layer. The ODE solver is a fifth-order 'dopri5' solver. The decoder consists of a feedforward neural network with a single layer. Here, we consider an adaptive learning rate with an initial value of the learning rate set to 0.01. We consider batch size as 10, and report loss as mean squared error (MSE) and negative ELBO. The model is trained using stochastic gradient descent through Adam optimizer for 200 iterations. All the experiments are conducted on the system with Intel i9 core processor, 32 GB RAM, 8 GB GPU. Python is explicitly used for coding the entire framework with the support of PyTorch's Torchdiffeq package [13]. The results of our experiments are discussed in the following subsections.

C. Imputation
In this task, the smart meter measurements are interpolated at a 1-min interval. The training is performed using the observed 15-minute interval data. In order to perform interpolation, the encoder runs backward in time to compute the approximate posterior distribution at the initial time t 0 . Fig.  2 demonstrates the imputation performance using the proposed LODE approach. Table. I shows the comparison of LODE approach with linear interpolation approach [6] and recursive GP with graphs (RGP-G) approach [12]. As seen from Table. I, the proposed approach is accurate with 0.2% MSE error in the test data. The trajectory of MSE and negative ELBO on the test data are illustrated in Fig. 3 and Fig. 4, respectively. The convergence of the losses demonstrate the effective training of the model.

D. Prediction
In this task, we split the time-series into two halves, t 0 to t N/2 and t N/2 to t N . The model is trained by conditioning the observations in the first 12 hrs of the time-series data and reconstructing the other half, i.e., training loss is considered on the second half. Once the model is trained, it can perform predictions for any desired time horizon. As seen from Fig.  5, the model only observes the first 12 hours of measurement data (blue in color) and extrapolates the next 12 hours (red in color). The predictions on the testing data are accurate with MSE of 0.72%.