#### 2.2.1. The Shape Model Approach

Let us denote by

$(t,{X}_{j}(t))$ the observations representing the energy demand at a specified day

j where

$t\in [0,24)$ represents the hour of the day and

${X}_{j}(t)$ the observed energy demand at time instant

t. In general, these measurements are available only on certain time segments (e.g., per hour); therefore, the accurate daily shape is not known. That means that although the true shape of the energy demand is a continuous function with respect to time parameter

t, in practice only some points of this shape are known at specified time segments

${t}_{i}$; therefore, the available data are of the form

${\{{t}_{i},{X}_{j}({t}_{i})\}}_{i=1}^{n}$, which can be considered as landmarks. As we are interested in working with the shapes of the daily energy demands, we need to consider the shape of the day

j as a function with respect to time, i.e.,

${f}_{j}:[0,24)\to \mathbb{R}$. Then, using the available data

${\{{t}_{i},{X}_{j}({t}_{i})\}}_{i=1}^{n}$ from day

j we are able to estimate a smoothed version of the energy shape employing any typical interpolation method or nonparametric filters (e.g., spline smoothers, kernel-based smoothing methods, etc. [

22,

23,

24]) by choosing appropriately the mollification parameters in order not to lose important aspects of the information. In this manner, the shape function of the intra-day power demand is sufficiently recovered with the advantage that we can get estimates for the demand even in time instants that no data are available and allowing to treat data with functional statistics techniques.

The daily shape of the energy demand is not expected to change dramatically between two days given that we consider typical working days (i.e., not weekends or public holidays). As a result, a standard energy-demand picture is expected to be observed with small fluctuations from one day to another, where these fluctuations can be efficiently calibrated by appropriate shape model considerations. Consider, for example, that for an arbitrary day

j,

${f}_{j}(t)$ denotes the observed energy demand and

${\tilde{f}}_{j}(t)$ denotes the prediction obtained by the simulation model discussed in

Section 2.1. Clearly, as the simulation model prediction is not expected to coincide with the true state of the energy demand, if systematic inefficiencies are presented between the prediction and reality, then a shape correction procedure could remarkably reduce errors caused to daily energy shape deviances. We discuss an approach under which we expect to provide corrections to the simulation model prediction by properly “reshaping” the simulation output in order to better match the observed energy shapes based on previous data. Such an approach is possible under the framework of deformation models (see, e.g., [

25,

26,

27,

28]) where the observed function

${f}_{j}$ (i.e., observed energy shape) is considered as a deformation of the prediction model

${\tilde{f}}_{j}$ (predicted energy shape), and this relation is mathematically expressed through the model

where

${R}_{j}:\mathbb{R}\to \mathbb{R}$ is called a deformation function and

${\u03f5}_{j}(t)$ is considered as a white noise process. Although several models can be proposed to parameterize the deformation function (e.g., shape-invariant model [

25,

26,

27]), for the particular nature of the data we consider in this paper, we may propose a simpler model which consists of modeling the reshape function

${\alpha}_{j}$ defined by

If the modeler had knowledge of the reshape function, then he/she could perfectly adjust the initial prediction

${\tilde{f}}_{j}(t)$, provided by the simulation model discussed in

Section 2.1, to obtain exactly the true energy demand

${f}_{j}(t)$. In particular, knowledge of the exact functional form for

$\alpha (\xb7)$ would allow predictions even at intermediate time instants for which observations are not available. In this section, we propose a functional statistical model to estimate the reshape function from past data of initial simulation model discrepancies from the actual measured energy shapes, so that it can be used for future predictions.

As the exact knowledge of the reshape function is not an option, we can estimate it using data from the previous days (we should choose a small time window ~5–10 days) to model the “typical” reshape function that is observed in the near past. Clearly, using the information provided from the last

N days, let us define the set of reshape functions

$\mathcal{A}:=\{{\alpha}_{1},{\alpha}_{2},\dots ,{\alpha}_{N}\}$. For the case under consideration, it is expected that there are certain aspects of the daily energy shape which the prediction model cannot efficiently calibrate and systematically does not capture, and as a result, the reshape functions must be very similar objects as shown for example for a typical set of observations in

Figure 2. In such a case, the approach we propose here is valid.

Under this consideration, for an appropriately chosen period of time each function,

${\alpha}_{j}$ should not present significant fluctuations from the reshape function that is considered as the “typical” one. Therefore, an appropriate notion of mean regarding the set of reshape functions

$\mathcal{A}$ is needed to properly define/represent the mean element in the set. The latter task requires the calculation of the mean element among a number of functions living in a space which does not necessarily has linear structure, therefore the notion of Fréchet mean needs to be exploited [

29,

30] for this purpose. In the context we discuss here, each reshape function

${\alpha}_{j}(\xb7)$ is considered as a deformation to the mean element (i.e., Fréchet mean)

$\overline{\alpha}(\xb7)$ with respect to which an appropriate notion of deviance is defined and its minimization will provide the mean element (please see [

31] for technical details on this subject). A general model like the

shape-invariant model [

26] can be used for the parameterization of the functional characteristics of the reshape functions in order to define a consistent parametric form for the Fréchet mean. According to the shape-invariant model, shape deformations like vertical (scale) and horizontal (time) shifts can be efficiently captured. The standard shape-invariant model applied to the energy reshape functions can be written as

where

$\overline{\alpha}(t)$ denotes the mean pattern of the energy reshape function,

${\beta}_{j}$ and

${\kappa}_{j}$ introduce vertical shifts parameterization, while

${\zeta}_{j}$ introduces time-shift parameterization. Recall that any

${\alpha}_{j}$ is considered as a deformation of the observed mean pattern (Fréchet mean) of the set

$\mathcal{A}$. As a result, the incurred mean energy reshape function estimated by the data from the previous

N days can be calculated through the equation

where vector

${\mathit{\theta}}^{*}={(\mathit{\kappa},\mathit{\zeta},\mathit{\beta})}^{\prime}={({\kappa}_{1},\dots ,{\kappa}_{N},{\zeta}_{1},\dots ,{\zeta}_{N},{\beta}_{1},\dots ,{\beta}_{N})}^{\prime}$ contains all the deformation parameters. Clearly, as these parameters uniquely define the mean reshape function must be selected to minimize the mean model variance from the set

$\mathcal{A}$, i.e., the vector

${\mathit{\theta}}^{*}$ is chosen as

where

$\mathcal{T}$ represents the time period within a day and

$\mathsf{\Theta}$ represents the space of the deformation parameters which are subjected to some normalization constraints, i.e.,

Clearly, the estimation of the reshape function for the day

$j=N+1$ will be used to improve the initial prediction, provided by the simulation model, for the energy demand of this day through the model

where the error term

${\eta}_{j}(t)$ is considered as a white noise process. After the initial mean reshape function estimation from the first batch of data corresponding to the initial

N days has been obtained, an exponentially weighted scheme can be used to update appropriately the reshape functions taking into account both the effect of the initial reshape function and more recent observations on the reshape function. In particular, the proposed scheme can be described through the following steps.

**Initial** **Step** Set

$k=0$ and provide a choice for

$\lambda \in (0,1)$. Given the simulation model predictions

$\{{\tilde{f}}_{j}\}$ and the corresponding measurements

$\{{f}_{j}\}$ for

$j=1,2,\dots ,N$ estimate the reshape functions

$\{{\alpha}_{j}\}$ from (

17). Then, set as

${\widehat{\alpha}}^{(k)}(t)$ the Fréchet mean of

$\{{\alpha}_{j}\}$ (calculated by (

19)–(

20)) and provide the prediction

${\widehat{f}}_{j}(t)={\widehat{\alpha}}^{(k)}(t){\tilde{f}}_{j}(t)$ for

$j=N+1$. For every new prediction task, repeat steps 1–3.

**Step** **1** Given the new measurement ${f}_{j}(t)$ set $k=k+1$, ${\alpha}_{0}(t):={\widehat{\alpha}}^{(k-1)}(t)$ and ${\alpha}_{1}(t):={\tilde{f}}_{j}^{-1}(t){f}_{j}(t)$.

**Step** **2** Set as ${\widehat{\alpha}}^{(k)}(t)$ the Fréchet mean of ${\alpha}_{0}(t)$ and ${\alpha}_{1}(t)$ with weights $1-\lambda $ and $\lambda $, respectively.

**Step** **3** Given the simulation model prediction ${\tilde{f}}_{j+1}(t)$ provide the improved (reshaped) prediction ${\widehat{f}}_{j+1}(t)={\widehat{\alpha}}^{(k)}(t){\tilde{f}}_{j+1}(t)$.

The exponential weighting is used to reduce the effect of older observations to the new predictions, i.e., for the prediction on the day $N+2$ using the weight parameter $\lambda \in (0,1)$ we could weight the most recent information (last observed reshape function ${\alpha}_{N+1}(\xb7)$) by $\lambda $ and the older observations by $(1-\lambda )$. In this manner, choosing $\lambda $ close to 1 we allocate more weight to the most recent realizations and reduce the effect of the older observations. Otherwise, choosing $\lambda $ close to zero, we forget the older observations with a very slow rate allowing the past information to contribute more to the prediction. Clearly, the choice of this parameter is critical to the quality of the prediction, and the final choice of this parameter depends strongly to the nature of the application that the prediction model is employed to. Note also that at each step the Fréchet mean of previous reshape functions is taken into account as an observation through the term ${\alpha}_{0}(t)$ although it is not. However, this modification allows to simultaneously condense and appropriately weight (according to our preferences provided by the choice of $\lambda $) the past information into a single term.

#### 2.2.2. The Weighted Shape Model Approach

In practice, it has been proved that there are periods of time that the prediction models do not provide reliable predictions and they may significantly deviate from the true situation. An example of such a situation is the energy demand prediction of the building during the period of summer holidays discussed in

Section 3. In such cases, it is very important to quickly perceive when this happens and rapidly adjust the prediction to an acceptable level of deviance from the reality. For such purposes, we present here a small variation of the scheme presented in

Section 2.2.1 where a weighted version of the reshape model is used.

The main idea is to divide the prediction into two parts: (a) the prediction provided by the reshape model and weight it by a proportion

$w\in (0,1)$ and (b) the prediction provided by previous observed energy shapes (measurements only) weighted by the proportion

$1-w$. For the second part, the same procedure that used for the estimation of the mean reshape function is used, i.e., given the past measurements of the daily energy shapes

$\{{f}_{1},{f}_{2},\dots ,{f}_{N}\}$ their Fréchet mean

$\overline{f}(t)$ is estimated by (

19)–(

20) substituting

${\alpha}_{j}$ with

${f}_{j}$. The Fréchet mean in this case is interpreted as the most typical energy shape observed in the previous days without taking into account any information provided by the energy simulation model (predictive model). Then, one could shape the prediction either by constantly setting the weighting parameter

w to a specific value or by changing this value each time new data become available to adjust the weighted shape model as close as it is possible to the true situation as observed until that time instant. Such a weight allocation criterion could be constructed as follows. Define by

${g}_{j+1}(t;w):=w{\widehat{f}}_{j}(t)+(1-w){\overline{f}}_{j}(t)$ the weighted prediction, where

${\overline{f}}_{j}$ denotes the mean energy shape as estimated until day

j and

${\widehat{f}}_{j}$ denotes the shape model’s prediction for the day

$j+1$ derived from the approach discussed in

Section 2.2.1. Then, given the measurement of the day

$j+1$,

${f}_{j+1}(t)$, the weight

w for the next prediction (i.e., the day

$j+2$) is chosen as the minimizer to the criterion

Clearly, if the prediction provided by the simulation model is completely misplaced, then this criterion will act rapidly as a safety filter and will provide a prediction that is based more on the empirical data (previously observed energy shapes); otherwise, the prediction will be based on the simulation model. Therefore, criterion (

23) will act as a detection mechanism of significant inconsistencies of the estimates provided by the simulation model and if such a significant shift occurs, will immediately properly adjust the prediction and improve its accuracy. Moreover, monitoring the value of

w for a reasonable period of time, provides a measure of efficiency for the prediction model that is used. Ideally, we expect the value of

w to remain in high levels (near to 1) except of some periods that major changes happen where the simulation model has not yet re-adjusted.