#  Predict. Optimize. Revise. On Forecast and Policy Stability in Energy
Management Systems

Evgenii Genov, Julian Ruddick, Christoph Bergmeir, Majid Vafaeipour, Thierry
Coosemans, Salvador García, Maarten Messagie E. Genov, J. Ruddick, M.
Vafaeipour, T. Coosemans, M. Messagie are with EVERGi Research Group, MOBI
Research Centre & ETEC Department, Vrije Universiteit Brussel (VUB).C.
Bergmeir, S. García are with Data Science and Computational Intelligence
Andalusian Institute, DaSCI, Andalucía, Spain.C. Bergmeir, S. García are with
Department of Computer Science and Artificial Intelligence, University of
Granada, Granada, Andalucía, Spain.C. Bergmeir is with Department of Data
Science and Artificial Intelligence Monash University, Australia.This work has
partially received funding from the European Union’s research and innovation
programme Horizon Europe under the grant agreement No.101136211, and by the
ECOFLEX project funded by FOD Economie, K.M.O., Middenstand en Energie.This
work was partially supported by Project PID2020-119478GB-I00 funded by
MICINN/AEI/10.13039/501100011033 and is part of the I+D+i project granted by
C-ING-250-UGR23 co-funded by “Consejería de Universidad, Investigación e
Innovación” and for the European Union related to the FEDER Andalucía Program
2021-2027

###### Abstract

This research addresses the challenge of integrating forecasting and
optimization in energy management systems, focusing on the impacts of
switching costs, forecast accuracy, and stability. It proposes a novel
framework for analyzing online optimization problems with switching costs and
enabled by deterministic and probabilistic forecasts. Through empirical
evaluation and theoretical analysis, the research reveals the balance between
forecast accuracy, stability, and switching costs in shaping policy
performance. Conducted in the context of battery scheduling within energy
management applications, it introduces a metric for evaluating probabilistic
forecast stability and examines the effects of forecast accuracy and stability
on optimization outcomes using the real-world case of the Citylearn 2022
competition. Findings indicate that switching costs significantly influence
the trade-off between forecast accuracy and stability, highlighting the
importance of integrated systems that enable collaboration between forecasting
and operational units for improved decision-making. The study shows that
committing to a policy for longer periods can be advantageous over frequent
updates. Results also show a correlation between forecast stability and policy
performance, suggesting that stable forecasts can mitigate switching costs.
The proposed framework provides valuable insights for energy sector decision-
makers and forecast practitioners when designing the operation of an energy
management system.

###### Index Terms:

Energy Management Systems, Forecasting, Optimization, Switching Costs,
Forecast Stability, Model Predictive Control

##  I Introduction

Managing energy assets in a grid system is a complex task that requires
decision-making under uncertainty. The dynamics and stochasticity of the
environment create a constantly evolving and inherently complex system. This
reality necessitates making decisions with an incomplete knowledge of the
future and for a limited time window, a scenario frequently approached through
the lens of online optimization.

To effectively manage this, it is useful to combine the forecast of the
problem environment with the optimization of the decision-making process. This
combination of forecasting and decision-making is often referred to as the
predict, then optimize problem, or an online optimization with predictions.
The online optimization problems with predictions are commonly seen in energy
applications such as electric vehicle charging [1] [2], battery scheduling
[3][4] and energy and flexibility dispatch problems [5] [6]. In number of
these applications, the decision-maker is faced with switching costs, which
are the costs associated with updating the operational plan. For instance,
transitioning from $x_{t-1}$ to $x_{t}$ typically incurs a switching cost or
ramp cost, $d(x_{t}-x_{t-1})$. Consequently, the stage cost becomes time-
coupled and is defined as:
$C_{t}(x_{t-1},x_{t}):=f_{t}(x_{t})+d(x_{t}-x_{t-1})$.

In the energy sector, the switching costs can arise from various factors, such
as the physical limitations of ramping up or down energy production [7],
managing server load balancing [8] and payment of network fees associated with
energy trading [9]. While there has been a significant amount of research on
online optimization problems with predictions, there is a gap in the
literature on the impact of switching costs on the interaction between
forecast model and the optimization algorithm. We address this gap by studying
two aspects of the combined system: time-coupling and forecast stability.

Switching costs are a direct consequence of time-coupling, when the action
$x_{t}$ at time $t$ influences the future actions $x_{t+1}$ and system states
$S_{t+1}$, as defined by Lin et al. [8]. Errors in forecasts act as ’switching
incentive‘ compelling policy revisions using more accurate predictions aligned
with up-to-date information and the actual state of the system. This
perspective suggests a balancing act between forecast accuracy and switching
costs. This paper explores how this trade-off influences the system’s design
and operation, suggesting a nuanced view of forecasting’s role in
optimization.

In principle, forecasts used in optimization can be updated every time new
information becomes available, often span multiple steps ahead and are revised
periodically. Transitioning from the concept of time-coupling, we speculate
that switching costs not only underscore the importance of forecast accuracy
but also elevate the value of forecast stability. In this context, a stable
forecast with minimal variation despite periodic updates, minimizes the need
for frequent policy changes, effectively reducing switching costs.
Consequently, this research aims to answer the following questions:

  * •

Do switching costs influence the balance between forecast accuracy and
stability?

  * •

What are the optimal strategies for forecast revision in the presence of such
costs?

  * •

And how can integrated systems be designed to effectively balance these
considerations for improved decision-making in energy management?

###  I-A Related work

Literature solutions for integrating forecasting and optimization are
classified based on the linkage of these subproblems. There are three
categories: Direct, Indirect, and Semi-direct methods.

Direct methods engage with the optimization problem during training of the
forecast making it an integrated approach which is known as ‘predict and
optimize’. Such approach is proposed in Elmachtoub and Grigas [10], with
optimization cost integrated directly into the forecast loss function to align
forecasts with end-use optimization. This optimizes the prediction model in
the forecasting stage for better decision-making in the optimization stage.
The computational burden is partially resolved by using a simplified loss
function, however more complex problems can still pose significant
computational challenges. There are also other works that design an
alternative task-specific loss function, such as reported in Mandi et al.
[11], and tested on a real-world energy management problem.

Indirect methods regard the two subproblems as separate, also referred in
literature as ‘predict, then optimize’. This approach is regarded as standard
and is widely applied in practice. In the study by Vanderschueren et al. [12],
an empirical evaluation of direct and indirect approaches is conducted in the
context of cost-sensitive classification. Although the study is not directly
applicable to the scheduling problems, it is interesting to note that those
authors find that the indirect approach where optimization is performed on the
predictions of the classifier outperforms the integrated approach. Therefore,
the effectiveness of cost-sensitive classification may not always align with
the intuitively expected benefits of integrated training within the ’predict
and optimize’.

The third category, Semi-direct methods, considers characteristics of the
optimization problem but abstains from direct interaction during training of
the forecast. These methods can take various forms, as potential improvements
can occur at any stage outside of the training process. An example is found in
the work by Kazmi and Paskevich [13], where those authors propose a Bayesian
Optimization approach for integrating the downstream optimization problem into
the hyperparameter tuning process of the forecast model.

There is a noticeable gap in the literature when it comes to studying
operational aspects of forecasting model and optimization deployment. For
forecasting, the frequency of the forecast revision can be interpreted as both
the frequency of the forecast model deployment and the frequency of model
training. The latter aspect is studied by Spiliotis and Petropoulos [14],
where those authors investigate different scenarios of updating the model fit
for univariate exponential smoothing (ES) and univariate gradient boosting
models (LightGBM).

We are particularly interested in the applications of optimization with
predictions in environments where switching costs are present. This topic has
featured in research on online convex optimization (OCO) problems. In control
theory, a widespread strategy for tackling online multi-step optimization
challenges is the employment of the Receding Horizon Control (RHC) algorithm,
also referred to as model predictive control (MPC). When rerun at every time
step, this method commits to the first step of the future horizon while
treating later decisions as advisory. The research conducted by Chen et al.
[15] sheds light on the role of noisy prediction in the design of the OCO
algorithm. Those authors propose a model that simulates realistic prediction
errors. Using this model, they show analytically that an alternative Averaging
Fixed Horizon Control (AFHC) algorithm can achieve sublinear regret and a
constant competitive ratio, which indicate a desirable level of optimality in
reference to the theoretical best policy. Figure 1 shows an overview of the
RHC and AFHC algorithm designs, along with other algorithms discussed further.
Those authors state that other algorithms can reach better performance if they
can use the predictions more efficiently. A later work, Chen et al. [16],
introduces a class of policies known as Committed Horizon Control (CHC), which
extends the principles of Receding Horizon Control (RHC) and Adaptive Forward
Horizon Control (AFHC) through the integration of a commitment concept. This
concept involves specifying a predetermined number of steps that the algorithm
executes. The analysis of the generalized problem reveals a trade-off set by
the varying levels of switching costs and quality of the predictions. The
general observation is that the level of commitment is problem-specific and
depends on the nature of the switching costs and the quality of the
predictions. Therefore, the results show that the commitment level should be
tuned for maximizing the performance of the policy.

(a) RHC

(b) FHC

(c) AFHC

(d) CHC

Figure 1: Diagrams of the Online Optimization algorithms. RHC: Receding
Horizon Control, FHC: Fixed Horizon Control, AFHC: Averaging Fixed Horizon
Control, CHC: Committed Horizon Control.

Current work sets to explore the performance of commitment-based policies in
the context of energy management systems. We are particularly interested in
analyzing the forecast and planning stability, as a potential factor that
influences the performance of the policy. A comprehensive study of forecast
stability is made by Godahewa et al. [17]. Those authors categorize the
stability into two types: vertical and horizontal. Vertical stability refers
to the variation period-to-period variability between forecasts given for the
same time period but issued from different origins. Horizontal stability
describes the variation between predictions made at one instance within a
prediction window. The lack of planning stability has long been recognized an
important issue within research on supply chain management. The vertical
stability in order forecasts is often referred to as the system nervousness.
It is a well-known phenomenon that can lead to inefficient production and
inventory management. The extra capacity implications are also referred to as
the bullwhip effect [18]. The commonly used methods to obtain a stable plan
include increased commitment, referred as freezing intervals [19] [20], using
smoothing techniques [21], and incorporating changing costs into the objective
function [22] [23].

Unlike supply chain management, energy management systems are more dynamic and
require more frequent updates of forecasts and policies. Switching costs are
also observed in energy, such as the ramping costs of generating units [7]
[24] and toggling server load balancing [8] [25]. Furthermore, the literature
is scarcer when considering the operational aspects of a combined forecasting
and optimization problem. Guo et al. [26] review the historical evolution and
state-of-the-art for the optimization methods for energy storage dispatch.
They conclude that current research indicates that RHC performance relies
strongly on the quality of predictions, and therefore, it may not be robust to
uncertainty. Christianson et al. [27] analyze the problem of resource
procurement and online economic dispatch for power system operators. They
present a customized FHC algorithm — Feasible Fixed Horizon Control (FFHC) —
which incorporates a regularization term to solve the multi-interval
optimization problem while ensuring feasibility and robustness amidst the
complexities introduced by ramping costs. A study by La Tona et al. [28]
explores how the frequency of forecast revisions affects the Energy Management
System’s (EMS) performance in online replanning tasks, focusing on battery
control to align actual and declared consumption. Their findings suggest that
more frequent forecasts enhance EMS performance, with diminishing returns at
intervals of 60 minutes and shorter. The current work examines applications in
energy storage optimization and the relationship between forecast and optimal
commitment level.

###  I-B Contents and Contributions

Through a systematic review of the literature, it becomes evident that the
effects of predictions on online optimization problems with switching costs
are not well understood. This present research aims to address this gap by
studying the impact of forecast stability and accuracy on the performance of
the policy in the context of energy management systems. The principle
contributions are as follows:

  * •

First, we formally define the problem and the metric used for evaluating the
downstream performance, both with and without switching costs. We also conduct
a theoretical analysis of the performance bounds of the Fixed Horizon Control
(FHC) algorithm, highlighting how the commitment level influences the trade-
off between forecast accuracy and switching costs.

  * •

We investigate the effect of forecast accuracy and stability on the downstream
performance of the optimization policy. We extend the definition of forecast
stability towards probabilistic forecasts and propose a metric for measuring
horizontal and vertical stability of scenario sets.

  * •

An empirical evaluation of the stability of deterministic and probabilistic
scenario sets is conducted. We use the case study of the integrated
forecasting and optimization energy management problem from the Citylearn 2022
competition. Based on the case study, we analyze the relationship between
forecast accuracy, stability and the performance of the policy. We show that
running the policy for a longer period provides a simple mechanism to avoid
switching costs while maintaining or improving the performance.

  * •

Lastly, the paper concludes with a discussion of the general implications of
the results for the design of the energy management systems followed by
suggested future research directions.

##  II Methodology

###  II-A Problem statement

This paper addresses the challenge of optimizing battery storage management
within a multi-agent energy management system. The setting of the problem is
first outlined in the CityLearn Challenge 2022 [29] and based on a real-world
dataset from a grid-interactive community. More generally, we consider an
online optimization with switching costs. The problem is solved with model
predictive control (MPC) and full details of the objective score and relevant
constraints are provided in Online Appendix A111Appendix A. [Online]
Available: https://arxiv.org/abs/2407.03368. The problem includes finding an
optimal state-dependent policy $X_{t}^{MPC}(S_{t}|\theta^{LA})$. The decision-
maker is faced with a sequence of decisions, where the decision at each step
is based on the current state $S_{t}$ of the system and the direct lookahead
approximation $\theta^{LA}$. Using the framework proposed by Powell [30], we
use the following formulation:

$\displaystyle
X_{t}^{MPC}(S_{t}|\theta^{LA})=\arg\min_{x_{t}}\Biggl{(}\sum_{i\in
n}W_{i}\cdot\mathbb{C}(\textbf{x};\textbf{S})\Biggr{)}=$
$\displaystyle\arg\min_{x_{t+1},\ldots,x_{t+H}}\Biggl{(}\sum_{t^{\prime}=t+1}^{t+H}\sum_{i\in
n}W_{i}\cdot\Bigl{[}\mathit{h}(x_{tt^{\prime}};\theta^{LA}_{i,tt^{\prime}})$
(1)
$\displaystyle+\beta\left\lVert\tilde{y}_{tt^{\prime}}-\tilde{y}_{t(t^{\prime}-1)}\right\rVert\Bigr{]}\Biggr{)}$

In this formulation:

  * •

$X_{t}^{MPC}(S_{t}|\theta^{LA})$ Represents the optimal set of decisions
(battery charging $x_{t}^{pos}$ and discharging $x_{t}^{neg}$ actions) made by
the MPC at time $t$ based on the current state $S_{t}$ and the lookahead
approximation model $\theta^{LA}$. This model enables predicting future costs
within a horizon $H$, taking into account the expected electric load and PV
generation.

  * •

$\mathbb{C}(\textbf{x};\textbf{S})$ is the cost function, which is a function
of actions $\textbf{x}=x_{t},...x_{t+H}$ and states
$\textbf{S}=S_{t},...S_{t+H}$.

  * •

$W_{s}$ Weight factor for scenario $s$, indicating the importance of different
scenarios in the decision-making process. We assume that the weight factors
are equal for all scenarios. In the deterministic case, the number of
scenarios is equal to 1.

  * •

$\mathit{h}(x_{tt^{\prime}};\theta^{LA}_{i,tt^{\prime}})$ Represents the cost
of the set of decisions $x_{t+1},...,x_{t+H}$ given the future forecast
scenarios generated by the model $\theta^{LA}_{i,tt^{\prime}}$

  * •

$\beta\left\lVert\tilde{y}_{tt^{\prime}}-\tilde{y}_{t(t^{\prime}-1)}\right\rVert$
is a switching cost, where $\beta\in\mathbb{R}^{+}$, and $\|\cdot\|$ can be
any norm in $\mathbb{R}^{n}$. The switching cost is imposed by ramping costs,
integral to the objective function.

Optimized battery schedules are evaluated using a set of KPIs. The
optimization targets the minimization of the equally weighted sum of the
normalized electricity cost $C$ and carbon emissions $G$. The optimization
score is defined as:

$\text{Average
Score}=\operatorname{avg}\left(\frac{C_{\text{entry}}}{C_{\text{no\
battery}}},\frac{G_{\text{entry}}}{G_{\text{no\ battery}}}\right)$ (2)

When grid-related Key Performance Indicators (KPIs) are included, the average
includes the grid score $D$. The grid score is computed as the mean of the
normalized ramping KPI $R$ and the Load Factor KPI $(1-L)$. The grid score,
$D$, introduces switching costs in the optimization by accounting for the
ramping costs associated with frequent changes in forecasting. Therefore, in
order to provide a comprehensive analysis of the impact of switching costs on
the optimization, in this study we consider both optimizations with and
without the grid score. The average score with the grid cost is defined as:

$\displaystyle\text{Average Score (with grid cost)}=$ (3)
$\displaystyle\operatorname{avg}\left(\frac{C_{\text{entry}}}{C_{\text{no\
battery}}},\frac{G_{\text{entry}}}{G_{\text{no\ battery}}},D\right)$

All the scores range from 0 to 1 because they are normalized by the no-battery
scenario, representing the improvement as a fraction of the metric compared to
the no-battery scenario. The full formulation of the cost function, along with
the definition of each of the KPIs and the formulation of the MPC problem is
given in Online Appendix A 222Appendix A. [Online] Available:
https://arxiv.org/abs/2407.03368. Furthermore, In the Online Appendix C
333Appendix C. [Online] Available: https://arxiv.org/abs/2407.03368, we
conduct a theoretical analysis of the performance bounds on the solving
algorithm in an online optimization problem with switching costs. We discuss
the role of policy commitment and draw a parallel to stability. A trade off is
demonstrated between forecast accuracy and switching costs, with the
commitment level regulating the balance between the two.

###  II-B Optimization

The optimal policy is computed for the current state of the system and the
forecast for the next $H$ time steps. An online optimization algorithm
typically determines the optimal actions $x_{t+1},...,x_{t+H}$ given a
prediction window of length $H$. Every $v$ time steps, the optimization is
rerun to generate a new plan. This algorithm is referred to as a Fixed Horizon
Control (FHC) algorithm.

In the context of the online optimization algorithms, the term “commitment”
refers to the duration or number of time steps for which the optimized policy
is committed to before the optimization process is rerun to generate a new
plan. This concept plays a crucial role in determining how frequently the
optimization is updated based on new information, accumulation of forecast
errors and changes in the system’s state. An FHC algorithm with the shortest
commitment is the Receding Horizon Control (RHC) algorithm. In RHC, the
commitment is $v=1$, indicating that the optimization is rerun at every time
step.

Similar to the optimization, the forecast is also run in a rolling origin
fashion. The optimal policy is then applied to the system for the next $v_{F}$
time steps and the process is repeated every $v_{F}$ steps. In summary, both
the forecast and the optimization have the same rolling origin setup and need
to be updated at certain intervals while committing to $v$ steps. Ultimately,
at each time step, the decision-maker is faced with a decision to either reuse
the current plan or to revise it. Similarly, the forecast can be reused or
revised. The resulting decision matrix is shown in Table I.

TABLE I: Decision Matrix illustrating the possible actions based on the
decisions made in the forecasting and optimization stages.

| Optimization Decision
---|---
Forecasting Decision |  Reuse |  Revise
Reuse |  Continue with current plan |  Evaluate
& adjust current plan
Revise |  Evaluate &
retain current plan |  Re-evaluate both
forecasting & plan

###  II-C Forecast

Following the solution implemented in the winning submission of the
competition, the forecasts are generated with gradient boosting regression
trees and the linear least squares regression model. The gradient boosting
implementation is LightGBM [31]. Predictions are made for the next 24 hours
with 24 independent models. The scenario sets are generated with added
gaussian noise. The details of the forecast models and the generation of the
scenario sets are outlined in the competition paper by Nweye et al. [29] and
the code repository of the winner solution is available on GitLab [32]. The
evaluation conducted in this study is available in the code repository [33].

While typical forecasting models use a building’s own historical data for
training, in this case, we apply forecasts to out-of-sample buildings using a
model trained on an isolated set of buildings. This setup follows the problem
setting given in the Citylearn Challenge 2022 [29]. Although this train-test
splitting is not typical in applied tasks, the setup is still relevant to
real-world scenarios, as the lack of historical data within the test subset is
compensated by the availability of perfect weather forecast and similarity
between the train and test sets.

####  II-C1 Rolling Origin Window

In practical applications, the forecast is issued periodically for a finite
number of future time steps. This process is run iteratively in a rolling
origin fashion, where the forecast is updated every $v_{f}$ time steps. A
schematic of this process is shown in Figure 2. This approach involves
continuously moving the time window forward by a certain step size after each
forecasting iteration. For example, if we have a window size of 3 and a step
size of 1, we would first generate the predictions and optimize for the steps
1-3, then at a second iteration, the forecasts are issued for the steps 2-4.

Figure 2: Vertical stability between rolling origin windows
in time-series forecast

The rolling horizon setup enables an update of the prediction using the most
recent information. When the commitment period is shorter than the forecast
horizon, the regular updates create overlaps between prediction windows, when
the forecasts associated with a particular target time in the future are
released in multiple revisions. The overlaps between windows with a rolling
origin are shown in the Figure 2. The overlapping interval is highlighted in
light grey.

####  II-C2 Stability

As a potential factor influencing the performance of the policy, we are
interested in the stability of the forecast. The stability of the forecast is
defined as the consistency of the predictions over time. Following the
categorization, first proposed by Godahewa et al. [17], we distinguish
vertical and horizontal stability. The difference between the two concepts is
illustrated in Figure 3. We define the vertical stability as the difference
between the predictions produced at different origins for the same time
period, marked with the overlap area in Figure 2. If the forecast revisions
are vertically stable, the corresponding adjustment costs in policy are set to
be minimal. Horizontal stability characterizes the difference between
predictions generated at the same origin. The horizontally stable forecasts
are meant to reduce fluctuations between time steps within a prediction
window.

(a) Vertical Stability

(b) Horizontal Stability

Figure 3: Diagrams demonstrating the concepts of vertical and horizontal
stability between predictions

Stability is evaluated for deterministic forecasts using the stability mean
absolute change (MAC). The formulations of the stability metrics vary for
vertical and horizontal types. In line with the definition of sMAPC in [34],
we define the absolute scale stability metric, Mean Absolute Change (MAC). The
metric measures the change between the predictions between overlapping rolling
windows — ${MAC}_{V}$, or the change of predictions generated at the same
origin — ${MAC}_{H}$

$\operatorname{MAC}_{V}=\frac{\sum_{i=1}^{H-1}\left|\hat{y}_{t+i\mid
t}-\hat{y}_{t+i\mid t-1}\right|}{H-1}$ (4)

$\operatorname{MAC}_{H}=\frac{\sum_{i=2}^{H}\left|\hat{y}_{t+i\mid
t}-\hat{y}_{t+i-1\mid t}\right|}{H-1}$ (5)

where $\hat{y}_{t+i\mid t}$ is the forecast for time $t+i$ generated at time
$t$, $H$ is the forecast horizon, and $t$ is the current time step.

####  II-C3 Stability of Probabilistic Forecasts

The Earth Mover’s Distance (EMD), or Wasserstein distance, quantifies the
minimum ”work” required to transform one distribution into another, making it
ideal for assessing the stability of scenario sets in stochastic optimization.
EMD is chosen for its symmetric nature, adherence to the triangle inequality,
and ability to compare distributions on different probability spaces, making
it effective even when forecasts differ significantly. It also accounts for
the metric space dimension, akin to the mean absolute change (MAC) used for
point forecasts. Other metrics like Kullback-Leibler (KL) divergence and
Jensen-Shannon distance measure statistical distance, but EMD is preferred for
scenario sample sets. In a 1-dimensional case with empirical sets $P$ and $Q$,
EMD is defined as:

$\operatorname{EMD}(P,Q)=\frac{1}{n}\sum_{i=1}^{n}\left\|P_{(i)}-Q_{(i)}\right\|$
(6)

where $P_{(i)}$ and $Q_{(i)}$ are the sorted samples of $P$ and $Q$
respectively. This metric measures the dissimilarity between two sets of
scenarios. To assess the stability of forecasts, the EMD can be computed for
both horizontal and vertical stability:

$EMD_{H}=\frac{1}{H-1}\sum_{i=1}^{H-1}\frac{1}{N}\sum_{j=1}^{N}\left|\hat{y}_{t+i\mid
t,j}-\hat{y}_{t+i\mid t-1,j}\right|$ (7)
$EMD_{V}=\frac{1}{H-1}\sum_{i=2}^{H}\frac{1}{N}\sum_{j=1}^{N}\left|\hat{y}_{t+i\mid
t,j}-\hat{y}_{t+i-1\mid t,j}\right|$ (8)

where $\hat{y}_{t+i\mid t,j}$ is the $j$-th scenario of the forecast for time
step $t+i$ generated at time $t$, and $N$ is the number of scenarios.

####  II-C4 Accuracy of Determinstic Forecasts

For deterministic forecasts, the MAE is utilized to quantify the forecast
accuracy. It calculates the average absolute difference between each
forecasted value and the corresponding actual value. Mathematically, it is
expressed as:

$\operatorname{MAE}=\Biggl{(}\frac{1}{H}\sum_{i=1}^{H}\left|y_{i}-\hat{y}_{i}\right|\Biggr{)}$
(9)

where $y_{i}$ is the actual value and $\hat{y}_{i}$ is the forecasted value at
time $i$.

####  II-C5 Accuracy of Probabilistic Forecasts

For probabilistic forecasts, we employ the Energy Score (ES). The ES is a
multivariate generalization of the continuous ranked probability score (CRPS),
a widely used metric for evaluating probabilistic forecasts. The ES measures
the distance between the forecasted distribution and the actual value. The
lower the ES, the better the forecast. The ES is defined as:

$ES=\left(\frac{1}{N}\sum_{j=1}^{N}\left\|y_{i}-\hat{y}_{ij}\right\|^{p}-\frac{1}{2N^{2}}\sum_{j=1}^{N}\sum_{k=1}^{N}\left\|\hat{y}_{ij}-\hat{y}_{ik}\right\|^{p}\right)^{\frac{1}{p}}$
(10)

where $y_{i}$ is the actual value, $\hat{y}_{ij}$ is the $j$-th scenario of
the forecasted value at time $i$, $N$ is the number of scenarios, and $p$ is
the order of the norm. The second term in the equation is the mean pairwise
distance between the scenarios.

##  III Experimentation and Results

Compared to theoretical analysis, practical setups are more complex. They
often deal with non-trivial correlation structures in forecast errors and the
potential for non-convex behaviors in optimization. This complexity is due to
the necessity for cooperative behavior across multiple buildings.
Additionally, various temporal dependencies emerge from switching costs and
system feedback. To confirm the initial theoretical findings, we proceed with
evaluating the performance of the FHC algorithm with different combinations of
forecast and optimization commitment in a real-world scenario.

According to the decision matrix in Figure I, at every time step the forecast
and optimization plans can be updated or retained. Therefore, the forecast and
optimization run with commitment periods $v_{F}$ and $v_{O}$. respectively. We
evaluate the performance of the FHC algorithm with different combinations of
forecast and optimization commitment. The result is shown in Tables II(a) and
II(b). The scores in the tables indicate that updating the optimization plan
more frequently than the forecast offers no added benefit. The optimal
performance is achieved when the forecast and optimization are updated at the
same frequency. Therefore, in the following analysis, we set $v=v_{F}=v_{O}$.

(a) FHC algorithm with deterministic forecast | $v_{O}$ |
---|---|---
$v_{F}$ |  1 |  2 |  3 |  4 |  5 |  6 |  7 |  8 |  9 |  10 |  11 |  12
1 |  0.899 |  |  |  |  |  |  |  |  |  |  |
2 |  0.910 |  0.904 |  |  |  |  |  |  |  |  |  |
3 |  0.911 |  0.907 |  0.904 |  |  |  |  |  |  |  |  |
4 |  0.912 |  0.908 |  0.907 |  0.905 |  |  |  |  |  |  |  |
5 |  0.913 |  0.910 |  0.908 |  0.908 |  0.903 |  |  |  |  |  |  |
6 |  0.912 |  0.910 |  0.907 |  0.908 |  0.908 |  0.906 |  |  |  |  |  |
7 |  0.912 |  0.910 |  0.907 |  0.910 |  0.908 |  0.909 |  0.902 |  |  |  |  |
8 |  0.910 |  0.907 |  0.908 |  0.905 |  0.906 |  0.908 |  0.902 |  0.903 |  |  |  |
9 |  0.911 |  0.909 |  0.906 |  0.908 |  0.908 |  0.908 |  0.904 |  0.908 |  0.903 |  |  |
10 |  0.913 |  0.909 |  0.909 |  0.907 |  0.906 |  0.908 |  0.903 |  0.906 |  0.905 |  0.905 |  |
11 |  0.912 |  0.910 |  0.909 |  0.910 |  0.908 |  0.909 |  0.905 |  0.906 |  0.906 |  0.907 |  0.903 |
12 |  0.917 |  0.911 |  0.911 |  0.909 |  0.908 |  0.910 |  0.904 |  0.907 |  0.907 |  0.907 |  0.904 |  0.908

(b) FHC algorithm with stochastic forecast | $v_{O}$ |
---|---|---
$v_{F}$ |  1 |  2 |  3 |  4 |  5 |  6 |  7 |  8 |  9 |  10 |  11 |  12
1 |  0.875 |  |  |  |  |  |  |  |  |  |  |
2 |  0.888 |  0.875 |  |  |  |  |  |  |  |  |  |
3 |  0.894 |  0.886 |  0.873 |  |  |  |  |  |  |  |  |
4 |  0.895 |  0.885 |  0.882 |  0.874 |  |  |  |  |  |  |  |
5 |  0.899 |  0.892 |  0.885 |  0.886 |  0.875 |  |  |  |  |  |  |
6 |  0.901 |  0.891 |  0.881 |  0.883 |  0.884 |  0.876 |  |  |  |  |  |
7 |  0.901 |  0.896 |  0.887 |  0.888 |  0.886 |  0.883 |  0.875 |  |  |  |  |
8 |  0.900 |  0.894 |  0.887 |  0.884 |  0.884 |  0.885 |  0.882 |  0.874 |  |  |  |
9 |  0.902 |  0.894 |  0.883 |  0.887 |  0.884 |  0.882 |  0.883 |  0.880 |  0.876 |  |  |
10 |  0.903 |  0.894 |  0.888 |  0.887 |  0.881 |  0.884 |  0.883 |  0.880 |  0.883 |  0.876 |  |
11 |  0.902 |  0.895 |  0.889 |  0.887 |  0.885 |  0.885 |  0.884 |  0.880 |  0.884 |  0.882 |  0.876 |
12 |  0.905 |  0.895 |  0.887 |  0.884 |  0.886 |  0.880 |  0.884 |  0.880 |  0.883 |  0.882 |  0.882 |  0.879

TABLE II: Optimization KPIs score for combinations of forecast and
optimization commitment between 1 and 12

Further, we investigate the relationship between the performance of the FHC
algorithm and properties of the forecast, namely accuracy and stability. In
Figure 4, the accuracy and stability of the deterministic and stochastic
forecasts are evaluated for different commitment periods. The comparison is
made between the optimization with and without switching costs for the
forecasts generated for out-of-sample buildings. Similar evaluation is done
for the in-sample buildings and shown in Online Appendix D 444Appendix D.
[Online] Available: https://arxiv.org/abs/2407.03368. It is observed from the
plots that the forecast error generally decreases with shorter commitment
periods, while the vertical stability is better with longer commitment
periods. The horizontal stability demonstrates a trade-off where the optimal
level is reached at a certain commitment period between 1 and 12 hours.

For stochastic forecast error, measured with the Energy Score, we observe an
anomaly when the lowest error is observed for scenarios updated every 8 hours.
The hypothesis is that this is due to the nature of the implemented method of
noise simulation. The magnitude of added gaussian noise is proportional to the
value of the respective point prediction, which produces low variation in the
regions around zero, where this specific configuration captures most
accurately, therefore the resulting scenario sets capture the real
distribution with a low variation.

The plots of the optimization scores show different behavior depending on the
presence of the switching costs. The optimization score without switching
costs is optimal with shorter commitment periods, while the addition of
switching costs adds more fluctuation to this relationship. The optimal
commitment period remains at 1 for the deterministic forecast, while the
stochastic forecast enables an optimal performance at a longer commitment
period.

These observations are supported by the correlation coefficients in the tables
III(a) and III(b) with the correlation coefficients between the forecast
properties and the optimization scores. The accuracy metrics are in positive
correlation with the optimization score. When switching costs are factored in,
the inverse correlation between the vertical stability and the cost becomes
less pronounced. Yet, the correlation between the horizontal stability and the
cost changes from negative to positive correlation when switching costs are
included.

Accuracy

Stability: vertical (top) and horizontal (bottom)

Optimization Score: without switching costs

Optimization Score: with switching costs

Point Forecast + Deterministic MPC

Probabilistic forecast + Stochastic MPC

Figure 4: Accuracy (Top), Horizontal (Second) and Vertical Stability (Third
row) of stochastic forecast over different revision periods with data from
out-of-sample buildings. The optimization score is shown with and without
switching costs. The forecast error is measured with MAE and Energy Score,
while the stability is measured with MAC and EMD. The optimization score is
measured with the cost function of the FHC algorithm.

(a) FHC algorithm with deterministic forecast Correlation Coef. |  $MAE$ |  $MAC_{V}$ |  $MAC_{H}$
---|---|---|---
$cost(FHC(v))$ |  0.95 |  -0.94 |  -0.27
$cost(FHC(v))$ w/ switching costs |  0.70 |  -0.62 |  0.17

(b) FHC algorithm with stochastic forecast Correlation Coef. |  $ES$ |  $EMD_{V}$ |  $EMD_{H}$
---|---|---|---
$cost(FHC_{stochastic}(v))$ |  0.63 |  -0.86 |  -0.29
$cost(FHC_{stochastic}(v))$ w/ switching costs |  0.71 |  -0.06 |  0.47

TABLE III: Correlation Coefficients for Forecast Metrics and Optimization
Score

##  IV Discussion

The observations from the results are consistent with the theoretical analysis
of the upper bound on the competitive difference of the FHC algorithm. We
observe that the optimal commitment period is dependent on the forecast
properties. The inclusion of switching costs in the optimization problem
changes the relationship between desired forecast properties and the
optimization score. The forecast error is broadly lower with shorter
commitment periods, however, the horizontal and vertical stability become also
relevant. In the theoretical analysis in Online Appendix C, we see that for a
more realistic model of the prediction noise with exponentially decaying
correlation, a trade-off emerges between the forecast error and the switching
costs. Through testing with real data, we observe that switching costs can be
partially mitigated by committing to more stable forecasts and optimization
plans.

The addition of switching costs makes the algorithmic problem harder as it
forces current actions to depend on beliefs about future cost functions. In
Figure 5, we can see that the shape of the final load curve is significantly
different when switching costs are included into the optimization. Without
switching costs, the battery is charged and discharged while following the
price and emissions cost signals. The resulting net load curve (in green) is
compared to the perfect scenario (in yellow), where the battery is charged and
discharged following the perfect forecast. In the case with switching costs,
the optimal policy is regulating the net load curve to a smoother shape with
less drops and peaks. The charging and discharging actions are the means of
such regulation. However, due to the error in the forecast, the actual net
load curve (in green) is not as smooth and flat as the optimal policy (in
yellow). It generally follows the optimal policy, but with oscillation around
it.

(a) Without switching costs

(b) With switching costs

Figure 5: The difference in net load between MPC with and without switching
costs. Actual net load is shown in yellow. The base load is shown in green.
The net load following the perfect forecast is shown in red. The electricity
price is shown in blue.

Minimal commitment periods $v$ of the control algorithm, combined with
imperfect predictions, can lead to a scenario where the control strategy is
constantly “chasing” the optimal state based on imperfect prediction. This can
aggravate the impact of switching costs, as the control actions may change
frequently in response to new information, even when such changes are not
cost-effective in the long run. While traditional forward-looking RHC
formulations can include terms in the objective function to penalize switching
costs, the longer commitment period provides a native mechanism that respects
past actions of the FHC algorithm. This mechanism can reduce the need for
frequent adjustments, thus avoiding some of the switching costs.

We identify two reasons for underperformance of the algorithm with a minimal
commitment period (RHC, equivalent to FHC with $v_{O}=1$). Firstly, when the
policy is computed for a period in a problem with switching cost, the past
decisions are calculated as optimal with respect to future decisions given the
forecast, however, after the policy is reviewed at the next iteration with an
updated forecast, the optimality of the executed decision at the recent time
step does not hold, since the future policies within the same horizon are
reviewed. A simple illustrative example would be the battery is discharged
first with an outlook for charging in the future when the price is more
favorable. Once the forecast and policy updates, the updated policy is
discharging again, however the battery has been discharged earlier. The second
reason is that while the objective cost function does include the term for the
switching costs $\beta||{x_{t}}-x_{t-1}||$, the switching costs are computed
pairwise between loads at close time instances. However, since the total
charging capacity of batteries is finite and limited, it is advantageous to
regulate switching costs within longer action windows.

When prediction is inaccurate in the look-ahead window, the RHC is more
effective than FHC with a commitment period. If we make predictions accurate
for a small window $\gamma$ and then inaccurate for the remaining
$(\omega-\gamma)$ steps of the lookahead window, the fixed horizon policy is
affected by the inaccurate predictions whereas RHC only acts on the correct
ones. This is typically the case for a multi-step horizon forecast when the
nearest steps are predicted at a higher accuracy. The situation changes for a
stochastic MPC, generally hedged better against prediction errors. We can see
from the results that FHC with longer commitment period becomes viable when
the optimization is computed for a set of scenarios, as opposed to a
deterministic point forecast.

##  V Conclusion

In conclusion, this study highlights the critical role that switching costs,
forecast accuracy, and stability play in the design and operation of energy
management systems. In summary, our analysis shows that in systems where
forecasts guide decision making, stability of predictions can reduce the
frequency and severity of policy revisions, thereby mitigating the financial
and operational impacts of switching costs. Our findings have significant
implications for the design of energy management systems. They suggest that
enhancing the stability of forecasts can improve system performance by
reducing the need for frequent adjustments and managing the trade-offs between
immediate and future resource allocation more effectively. Furthermore, we
propose a novel approach to evaluating the stability of probabilistic
forecasts using the Earth Mover’s Distance, which provides a robust measure of
the dissimilarity between scenario sets.

Looking ahead, there are questions remaining to be addressed. For future
research, we recommend further exploration into methods that enhance forecast
stability without compromising accuracy. It would be beneficial to extend this
work to other applications with switching costs, such as supply chain
management and financial trading. Furthermore, from literature and current
findings, there are indications that methods like AFHC and stochastic FHC,
show more robustness in hedging against the forecast errors by aggregating
policies with different underlying scenarios. However, they require more
computational resources and are more complex to implement. An interesting
avenue for future research would be defining the criteria for problems where
these methods are most effective. These efforts would contribute to a deeper
understanding of forecast-dependent optimization and improve the operational
strategies of energy management systems facing an evolving energy landscape.

## References

  * Kriekinge et al. [2021] G. V. Kriekinge, C. D. Cauwer, N. Sapountzoglou, T. Coosemans, and M. Messagie, “Peak shaving and cost minimization using model predictive control for uni- and bi-directional charging of electric vehicles,” _Energy Reports_ , vol. 7, pp. 8760–8771, 2021.
  * Yoon et al. [2023] D.-H. Yoon, H. Seo, J. Lee, and Y. Kim, “Online electric vehicle charging strategy in residential areas with limited power supply,” _IEEE Transactions on Smart Grid_ , 2023.
  * Hong and Lee [2023] S.-H. Hong and H.-S. Lee, “Robust energy management system with safe reinforcement learning using short-horizon forecasts,” _IEEE Transactions on Smart Grid_ , vol. 14, no. 3, pp. 2485–2488, 2023.
  * Nath and Wu [2020] S. Nath and J. Wu, “Online battery scheduling for grid-connected photo-voltaic systems,” _Journal of Energy Storage_ , vol. 31, p. 101713, 2020.
  * Nottrott et al. [2013] A. Nottrott, J. Kleissl, and B. Washom, “Energy dispatch schedule optimization and cost benefit analysis for grid-connected, photovoltaic-battery storage systems,” _Renewable Energy_ , vol. 55, pp. 230–240, 2013.
  * Antoniadou-Plytaria et al. [2022] K. Antoniadou-Plytaria, D. Steen, O. Carlson, B. Mohandes, M. A. F. Ghazvini _et al._ , “Scenario-based stochastic optimization for energy and flexibility dispatch of a microgrid,” _IEEE Transactions on Smart Grid_ , vol. 13, no. 5, pp. 3328–3341, 2022.
  * Wu et al. [2013] H. Wu, M. Shahidehpour, and M. E. Khodayar, “Hourly demand response in day-ahead scheduling considering generating unit ramping cost,” _IEEE Transactions on Power Systems_ , vol. 28, no. 3, pp. 2446–2454, 2013.
  * Lin et al. [2012] M. Lin, Z. Liu, A. Wierman, and L. L. Andrew, “Online algorithms for geographical load balancing,” in _2012 international green computing conference (IGCC)_. IEEE, 2012, pp. 1–10.
  * Yang et al. [2023] Y. Yang, Y. Chen, G. Hu, and C. J. Spanos, “Optimal network charge for peer-to-peer energy trading: A grid perspective,” _IEEE Transactions on Power Systems_ , vol. 38, no. 3, pp. 2398–2410, 2023.
  * Elmachtoub and Grigas [2022] A. N. Elmachtoub and P. Grigas, “Smart “predict, then optimize”,” _Management Science_ , vol. 68, no. 1, pp. 9–26, 2022.
  * Mandi et al. [2020] J. Mandi, P. J. Stuckey, T. Guns _et al._ , “Smart predict-and-optimize for hard combinatorial optimization problems,” in _Proceedings of the AAAI Conference on Artificial Intelligence_ , vol. 34, no. 02, 2020, pp. 1603–1610.
  * Vanderschueren et al. [2022] T. Vanderschueren, T. Verdonck, B. Baesens, and W. Verbeke, “Predict-then-optimize or predict-and-optimize? an empirical evaluation of cost-sensitive learning strategies,” _Information Sciences_ , vol. 594, pp. 400–415, 2022.
  * Kazmi and Paskevich [2023] H. Kazmi and M. Paskevich, “Incorporating downstream, task-specific information in forecasting models,” 2023.
  * Spiliotis and Petropoulos [2024] E. Spiliotis and F. Petropoulos, “On the update frequency of univariate forecasting models,” _European Journal of Operational Research_ , vol. 314, no. 1, pp. 111–121, Apr. 2024. [Online]. Available: https://linkinghub.elsevier.com/retrieve/pii/S0377221723006859
  * Chen et al. [2015] N. Chen, A. Agarwal, A. Wierman, S. Barman, and L. L. Andrew, “Online convex optimization using predictions,” in _Proceedings of the 2015 ACM SIGMETRICS International Conference on Measurement and Modeling of Computer Systems_ , 2015, pp. 191–204.
  * Chen et al. [2016] N. Chen, J. Comden, Z. Liu, A. Gandhi, and A. Wierman, “Using predictions in online optimization: Looking forward with an eye on the past,” _ACM SIGMETRICS Performance Evaluation Review_ , vol. 44, no. 1, pp. 193–206, 2016.
  * Godahewa et al. [2023] R. Godahewa, C. Bergmeir, Z. E. Baz, C. Zhu, Z. Song, S. García, and D. Benavides, “On forecast stability,” _arXiv preprint arXiv:2310.17332_ , 2023.
  * Wang and Disney [2016] X. Wang and S. M. Disney, “The bullwhip effect: Progress, trends and directions,” _European Journal of Operational Research_ , vol. 250, no. 3, pp. 691–701, 2016.
  * Sahin et al. [2013] F. Sahin, A. Narayanan, and E. P. Robinson, “Rolling horizon planning in supply chains: review, implications and directions for future research,” _International Journal of Production Research_ , vol. 51, no. 18, pp. 5413–5436, 2013.
  * Xie et al. [2003] J. Xie, X. Zhao, and T. Lee, “Freezing the master production schedule under single resource constraint and demand uncertainty,” _International Journal of Production Economics_ , vol. 83, no. 1, pp. 65–84, 2003.
  * Ho* [2005] C.-J. Ho*, “Examining dampening effects for alternative dampening procedures to cope with system nervousness,” _International journal of production research_ , vol. 43, no. 19, pp. 4009–4033, 2005.
  * Lin and Uzsoy [2016] P.-C. Lin and R. Uzsoy, “Estimating the costs of planned changes implied by freezing production plans,” _Heuristics, Metaheuristics and Approximate Methods in Planning and Scheduling_ , pp. 17–44, 2016.
  * Herrera et al. [2016] C. Herrera, S. Belmokhtar-Berraf, A. Thomas, and V. Parada, “A reactive decision-making approach to reduce instability in a master production schedule,” _International Journal of Production Research_ , vol. 54, no. 8, pp. 2394–2404, 2016.
  * Tanaka [2006] M. Tanaka, “Real-time pricing with ramping costs: A new approach to managing a steep change in electricity demand,” _Energy Policy_ , vol. 34, no. 18, pp. 3634–3643, 2006.
  * Lee et al. [2021] R. Lee, J. Maghakian, M. Hajiesmaili, J. Li, R. Sitaraman, and Z. Liu, “Online peak-aware energy scheduling with untrusted advice,” _ACM SIGENERGY Energy Informatics Review_ , vol. 1, no. 1, pp. 59–77, 2021.
  * Guo et al. [2022] Z. Guo, W. Wei, M. Shahidehpour, Z. Wang, and S. Mei, “Optimisation methods for dispatch and control of energy storage with renewable integration,” _IET Smart Grid_ , vol. 5, no. 3, pp. 137–160, 2022.
  * Christianson et al. [2022] N. Christianson, L. Werner, A. Wierman, and S. Low, “Dispatch-aware planning for feasible power system operation,” _Electric Power Systems Research_ , vol. 212, p. 108597, 2022.
  * La Tona et al. [2021] G. La Tona, M. C. Di Piazza, and M. Luna, “Effect of daily forecasting frequency on rolling-horizon-based ems reducing electrical demand uncertainty in microgrids,” _Energies_ , vol. 14, no. 6, p. 1598, 2021.
  * Nweye et al. [2022] K. Nweye, Z. Nagy, S. Mohanty, D. Chakraborty, S. Sankaranarayanan, T. Hong, S. Dey, G. Henze, J. Drgona, F. Lin _et al._ , “The citylearn challenge 2022: Overview, results, and lessons learned,” _NeurIPS 2022 Competition Track_ , pp. 85–103, 2022.
  * Powell [2019] W. B. Powell, “A unified framework for stochastic optimization,” _European Journal of Operational Research_ , vol. 275, no. 3, pp. 795–821, 2019.
  * Ke et al. [2017] G. Ke, Q. Meng, T. Finley, T. Wang, W. Chen, W. Ma, Q. Ye, and T.-Y. Liu, “Lightgbm: A highly efficient gradient boosting decision tree,” _Advances in neural information processing systems_ , vol. 30, 2017.
  * Kafka [2022] Kafka, “Buildings’ energy management through an ensemble approach of forecasting, optimization and reinforcement learning,” https://gitlab.aicrowd.com/Kafka/citylearn-2022-starter-kit, 2022, accessed: 2024-04-16.
  * Evgenii Genov [2024] J. R. Evgenii Genov, “Predict-optimize-revise,” https://github.com/ujohn33/citylearn_scenarios, 2024, accessed: 2024-06-18.
  * Van Belle et al. [2023] J. Van Belle, R. Crevits, and W. Verbeke, “Improving forecast stability using deep learning,” _International Journal of Forecasting_ , vol. 39, no. 3, pp. 1333–1350, 2023.

##  Appendix A Cost Function and Optimization

###  A-A Optimization score

Optimized battery schedules are evaluated using a set of KPIs, each of which
is targeted for minimization. The optimization targets the minimization of the
equally weighted sum of the normalized electricity cost $C$ and carbon
emissions $G$. The optimization score is defined as:

$\text{Average
Score}=\operatorname{avg}\left(\frac{C_{\text{entry}}}{C_{\text{no\
battery}}},\frac{G_{\text{entry}}}{G_{\text{no\ battery}}}\right)$ (11)

When grid-related KPIs are included, the average includes the grid score $D$.
The grid score is computed as the mean of the normalized ramping KPI $R$ and
the Load Factor KPI $(1-L)$. The grid score, $D$, introduces switching costs
in the optimization by accounting for the ramping costs associated with
frequent changes in forecasting. Therefore, in order to provide a
comprehensive analysis of the impact of switching costs on the optimization,
in this study we consider both optimizations with and without the grid score.
The average score with the grid cost is defined as:

$\displaystyle\text{Average Score (with grid cost)}=$ (12)
$\displaystyle\operatorname{avg}\left(\frac{C_{\text{entry}}}{C_{\text{no\
battery}}},\frac{G_{\text{entry}}}{G_{\text{no\ battery}}},D\right)$

All the scores range from 0 to 1 because they are normalized by the no-battery
scenario, representing the improvement as a fraction of the metric compared to
the no-battery scenario.

The normalized electricity cost, $C$, as delineated in Eq. 13, is the ratio of
electricity spending in a given policy, $c_{policy}$, to the spending in a
reference scenario without battery intervention, $c_{{nobattery}}$ The cost
metric $c$ is further defined in Eq. 14 as the aggregate of the non-negative
product of district-level net electricity price, $E_{h}\times T_{h}(\$)$,
where $E_{h}$ denotes the electricity consumption of the district at the hour
$h$ and $T_{h}$ specifies the electricity rate corresponding to that hour.

$\displaystyle C=\frac{c_{{submission}}}{c_{{nobattery}}}$ (13) $\displaystyle
c=\sum_{h=0}^{n-1}\max\left(0,E_{h}\times T_{h}\right)$ (14)

Similarly, the normalized carbon emissions, $G$, is defined in Eq. 15 as the
ratio of district carbon emissions for a given policy, $g_{{policy}}$,
relative to the emissions in the aforementioned baseline scenario,
$g_{{nobattery}}$. The emission metric $g$ is elaborated in Eq. 16 as the sum
of carbon emissions, measured in
$\left({kg}_{\mathrm{CO}_{2}\mathrm{e}}/\mathrm{kWh}\right)$, given by
$E_{h}\times O_{h}$. Here, $O_{h}$ represents the carbon intensity for the
hour $h$.

$\displaystyle G=\frac{g_{{submission}}}{g_{{nobattery}}}$ (15) $\displaystyle
g=\sum_{h=0}^{n-1}\max\left(0,E_{h}\times O_{h}\right)$ (16)

Lastly, the evaluation metric includes a grid-related KPI, $D$. The metric
follows grid-level objectives, such as the minimization of ramping and load
factor. It is defined as the mean of the normalized ramping KPI, $R$, and the
Load Factor KPI, $(1-L)$. The formulation, scaled by the grid cost in the
baseline no-battery scenario, is given in Eq. 17.

$D=\operatorname{avg}\left(\frac{R_{\text{entry}}}{R_{\text{no\
battery}}},\frac{1-L_{\text{entry}}}{1-L_{\text{no\ battery}}}\right)$ (17)

The ramping KPI, $R$, reflects the smoothness of the district’s load profile.
A low $R$ indicates a gradual increase in grid electricity demand even after
self-generation becomes unavailable in the evening and early morning, while a
high $R$ indicates abrupt changes in load on the grid, which may lead to
unscheduled strain on grid infrastructure and potential blackouts due to
supply deficits. It is calculated as the sum of the absolute difference of net
electricity consumption between consecutive time steps:

$R=\sum_{t=1}^{8760}|E_{t}-E_{t-1}|$ (18)

The Load Factor, $L$, indicates the efficiency of electricity consumption and
is bounded between 0 (very inefficient) and 1 (highly efficient). Thus, the
goal is to minimize $(1-L)$. $L$ is calculated as the average ratio of monthly
average to maximum net electricity consumption:

$L=\left(\frac{1}{12}\sum_{m=0}^{11}\left(\frac{\sum_{h=0}^{729}E_{730m+h}}{730\max(E_{730m},\ldots,E_{730m+729})}\right)\right)$
(19)

###  A-B MPC Formulation

$\displaystyle\mathbf{C}(S_{t},x_{t},\theta^{LA}_{t})=\sum_{i\in{price,carbon,grid}}\mathbf{C}_{i}(\tilde{S}{tt^{\prime}},\tilde{x}_{tt^{\prime}})$
(20) $\displaystyle=$ (21)

subject to $\displaystyle SOC_{min}\leq SOC_{t}\leq SOC_{max},\quad\forall t,$
(22) $\displaystyle x_{t}=x_{t}^{pos}+x_{t}^{neg},\quad\forall t,$ (23)
$\displaystyle-P_{max}\leq x_{t}^{neg}\leq 0,\quad\forall t,$ (24)
$\displaystyle SOC_{t}=SOC_{t-1}+$ (25) $\displaystyle\eta_{charging}\cdot
x_{t}^{pos}-\frac{1}{\eta_{discharging}}\cdot x_{t}^{neg},\quad\forall t.$
(26)

In this formulation:

  * •

$X_{t}^{MPC}(S_{t}|\theta^{LA})$ Represents the optimal set of decisions
(battery charging $x_{t}^{pos}$ and discharing $x_{t}^{neg}$ actions) made by
the MPC at time $t$ based on the current state $S_{t}$ and the lookahead
approximation model $\theta^{LA}$ This model enables predicting future costs
within a horizon $H$, taking into account the expected electric load and PV
generation.

  * •

$W_{s}$ Weight factor for scenario $s$, indicating the importance of different
scenarios in the decision-making process. We assume that the weight factors
are equal for all scenarios. In the deterministic case, the number of
scenarios is equal to 1.

  * •

$C_{price}$, $C_{carbon}$, and $C_{grid}$ are cost functions representing the
cost of electricity, the cost associated with carbon emissions, and the cost
related to grid reliance, respectively. Each of these costs depends on the
action taken ($x_{t}^{pos}$ and $x_{t}^{neg}$) and the current system state
$S_{t}$.

  * •

$SOC_{t}$ denotes the state of charge of the battery at time $t$, with
$SOC_{min}$ and $SOC_{max}$ being the minimum and maximum allowable states of
charge, respectively.

  * •

$P_{max}$ is the maximum power with which the battery can be charged or
discharged.

  * •

$\eta_{charging}$ and $\eta_{discharging}$ are the charging and discharging
efficiencies of the battery, respectively.

###  A-C Theoretical Analysis of Performance Bounds

In this section, we analyze the upper bound on the performance of the FHC
algorithm with a limited commitment $v$. We focus on the cost difference
between the optimal policy and the policy produced by the FHC algorithm.
Specifically, we examine the impact of the commitment $v$, which defines how
often the policy and forecast are updated. Our goal is to show how the
performance bound is influenced by a trade-off between forecast accuracy and
switching costs.

To illustrate this, we consider two models of forecast error: independent and
identically distributed (i.i.d.) noise, noise with exponentially decaying
correlation and a probabilistic forecast. We start with the deterministic case
(point forecast) and then extend to the probabilistic case (set of scenarios).
Following the derivation in Chen et al. [16], we derive the average-case
performance of the FHC algorithm by taking the expectation of the cost
difference with respect to the prediction noise $(e(t))^{T}_{t=1}$.

Here, OPT represents the optimal policy that would achieve the lowest possible
cost if there were perfect information and no prediction errors.

$\displaystyle\mathbb{E}\operatorname{cost}(FHC)\leq$ (27)
$\displaystyle\mathbb{E}\operatorname{cost}(OPT)+\frac{2T\beta
D}{v}+2G\mathbb{E}\sum_{t=1}^{T}\left\|y_{t}-y_{t\mid
t-\phi^{1}(t)}\right\|_{2}^{\alpha}$
$\displaystyle\mathbb{E}\operatorname{cost}(FHC)\leq\mathbb{E}\operatorname{cost}(OPT)+\frac{2T\beta
D}{v}+2GT\left\|f_{v}\right\|^{\alpha}.$ (28)

The term $\left\|f_{v}\right\|^{\alpha}$ is the $\alpha$-norm of the
prediction error covariance, where $\alpha$ is the exponent of the Hölder
condition. The two noise models (i.i.d. and exponentially decaying
correlation) are explained below.

#### Independent and Identically Distributed Noise

The i.i.d. noise is a simple and understandable baseline for forecast error,
without time dependency. For i.i.d. noise, we have:

$f(s)=\begin{cases}I,&s=0\\\ 0,&\text{otherwise.}\end{cases}$

The statistical properties of prediction errors in this context are:

$\displaystyle\mathbb{E}\left[e(s)e(s)^{T}\right]=R_{e}$
$\displaystyle\operatorname{trace}(R_{e})=\sigma^{2}$

This leads to the upper bound on the FHC cost:

$\mathbb{E}\operatorname{cost}(FHC(v))\leq\mathbb{E}\operatorname{cost}(OPT)+\frac{2T\beta
D}{v}+2GT\sigma^{\alpha}$ (29)

The upper bound on the competitive difference depends on $v$ only in the first
term (in the denominator). Therefore, the optimal cost is minimized when
$v=H$, i.e., the commitment level reaches the maximum allowable duration and
corresponds to the forecast horizon length. The first term represents
switching costs, so a shorter commitment period leads to more frequent updates
and higher switching costs. The second term, representing i.i.d. noise, is
independent of $v$.

#### Exponentially Decaying Correlation

A more realistic model of prediction noise uses correlations that decay
exponentially over time. For this, given $a<1$, the Frobenius norm of the
correlation structure is:

$\|f(s)\|_{F}=\begin{cases}ca^{s},&s\geq 0\\\ 0,&s<0\end{cases}$ (30)

We then express the prediction error covariance as:

$\displaystyle\left\|f_{v}\right\|^{2}$
$\displaystyle=\sum_{s=0}^{v}\operatorname{trace}(R_{e}f(s)^{T}f(s))=\sum_{s=0}^{v}\left\langle
R_{e}^{1/2},f(s)\right\rangle^{2}$
$\displaystyle\leq\sum_{s=0}^{v}\left(\left\|R_{e}^{1/2}\right\|_{F}\|f(s)\|_{F}\right)^{2}$
$\displaystyle=\sum_{s=0}^{v}c^{2}\sigma^{2}a^{2s}=c^{2}\sigma^{2}\frac{1-a^{2v}}{1-a^{2}}$

Given that $h$ exhibits G-Lipschitz continuity ($\alpha=1$), the norm of the
correlation function $\|f_{v}\|$ is bounded by:

$\left\|f_{v}\right\|\leq\frac{c\sigma(1-a^{2(v+1)}/2)}{1-a^{2}}$ (31)

Plugging this into the expression for the expected competitive difference of
the FHC algorithm, we get:

$\displaystyle\mathbb{E}\operatorname{cost}(FHC(v))\leq$ (32)
$\displaystyle\mathbb{E}\operatorname{cost}(OPT)+2\left[\frac{T}{v}\right]\beta
D+2GT\sigma^{\alpha}\frac{c(1-a^{2(v+1)})/2}{1-a^{2}}$
$\displaystyle\leq\mathbb{E}\operatorname{cost}(OPT)+2\left[\frac{T}{v}\right]\beta
D+2GTc\sigma\left(\frac{a^{2v+2}-2}{2(a^{2}-1)}\right)$

To simplify, we group the parameters independent of $v$:

$A=2T\beta D\quad B=\frac{1}{a^{2}-1}\quad C=GTc\sigma a^{2}$

Thus, the expected competitive difference of the FHC algorithm is:

$\mathbb{E}\operatorname{cost}(FHC(v))\leq\mathbb{E}\operatorname{cost}(OPT)+\frac{A}{v}+B(Ca^{2v}-1)$
(33)

The competitive difference behavior depends on two main components. The term
$\frac{A}{v}$ decreases with $v$, while the term $B(Ca^{2v}-1)$ increases with
$v$. Since $Ca^{2v}$ approaches 0 as $v$ increases, the second term is bound
by $B$. Therefore, the minimal competitive difference is a trade-off between
switching costs (first term) and forecast errors (second term).

#### Stochastic Optimization

For stochastic optimization with Fixed Horizon Control (FHC) applied across
$n$ scenarios, we examine how the stochastic nature influences the competitive
difference compared to an optimal solution. The expected cost for the
stochastic algorithm across all scenarios is:

$\mathbb{E}\operatorname{cost}(FHC_{stochastic}(v))=\sum_{i=1}^{n}\mathbb{E}\operatorname{cost}(FHC(v,i))$
(34)

Taking the expectation of the competitive difference across all scenarios:

$\displaystyle\mathbb{E}\operatorname{cost}(FHC_{stochastic}(v))\leq$ (35)
$\displaystyle\mathbb{E}\operatorname{cost}(OPT)+\frac{2T\beta
D}{v}+2G\mathbb{E}\left[\sum_{t=1}^{T}\left\|y_{t}-y_{t\mid
t-\phi^{1}(t)}\right\|_{2}^{\alpha}\right]$

In the stochastic case, the forecast errors across the scenario ensemble would
be lower in expectation than in any singular, deterministic scenario. This is
because the stochastic approach averages out the errors across multiple
scenarios, reducing the overall forecast error. Hence, the competitive
difference of the FHC algorithm in the stochastic case will likely be lower,
favoring a higher commitment level, as the first term (switching costs)
decreases with $v$ at the same rate as in the deterministic case.

###  A-D In-sample Performance

(a) Performance of the FHC algorithm with deterministic forecast. Study over combinations of forecast and optimization commitment between 1 and 12 | $v_{O}$ |
---|---|---
$v_{F}$ |  1 |  2 |  3 |  4 |  5 |  6 |  7 |  8 |  9 |  10 |  11 |  12
1 |  0.486 |  |  |  |  |  |  |  |  |  |  |
2 |  0.489 |  0.489 |  |  |  |  |  |  |  |  |  |
3 |  0.491 |  0.492 |  0.491 |  |  |  |  |  |  |  |  |
4 |  0.492 |  0.492 |  0.494 |  0.492 |  |  |  |  |  |  |  |
5 |  0.493 |  0.494 |  0.494 |  0.494 |  0.493 |  |  |  |  |  |  |
6 |  0.493 |  0.493 |  0.493 |  0.495 |  0.495 |  0.493 |  |  |  |  |  |
7 |  0.493 |  0.494 |  0.495 |  0.495 |  0.495 |  0.495 |  0.493 |  |  |  |  |
8 |  0.493 |  0.493 |  0.495 |  0.493 |  0.495 |  0.496 |  0.495 |  0.493 |  |  |  |
9 |  0.494 |  0.495 |  0.494 |  0.495 |  0.495 |  0.495 |  0.495 |  0.496 |  0.494 |  |  |
10 |  0.494 |  0.494 |  0.495 |  0.495 |  0.494 |  0.495 |  0.496 |  0.495 |  0.496 |  0.494 |  |
11 |  0.494 |  0.495 |  0.495 |  0.495 |  0.495 |  0.495 |  0.495 |  0.495 |  0.496 |  0.496 |  0.494 |
12 |  0.495 |  0.495 |  0.495 |  0.495 |  0.495 |  0.495 |  0.496 |  0.496 |  0.495 |  0.496 |  0.496 |  0.495

(b) Performance of the FHC algorithm with stochastic forecast. Study over combinations of forecast and optimization commitment between 1 and 12 | $v_{O}$ |
---|---|---
$v_{F}$ |  1 |  2 |  3 |  4 |  5 |  6 |  7 |  8 |  9 |  10 |  11 |  12
1 |  0.798 |  |  |  |  |  |  |  |  |  |  |
2 |  0.805 |  0.800 |  |  |  |  |  |  |  |  |  |
3 |  0.809 |  0.806 |  0.803 |  |  |  |  |  |  |  |  |
4 |  0.809 |  0.805 |  0.807 |  0.802 |  |  |  |  |  |  |  |
5 |  0.811 |  0.807 |  0.806 |  0.805 |  0.805 |  |  |  |  |  |  |
6 |  0.812 |  0.807 |  0.805 |  0.805 |  0.806 |  0.805 |  |  |  |  |  |
7 |  0.810 |  0.808 |  0.807 |  0.805 |  0.806 |  0.808 |  0.805 |  |  |  |  |
8 |  0.808 |  0.806 |  0.808 |  0.802 |  0.807 |  0.807 |  0.807 |  0.804 |  |  |  |
9 |  0.811 |  0.809 |  0.806 |  0.805 |  0.806 |  0.807 |  0.808 |  0.806 |  0.805 |  |  |
10 |  0.811 |  0.807 |  0.807 |  0.805 |  0.806 |  0.807 |  0.808 |  0.806 |  0.808 |  0.806 |  |
11 |  0.810 |  0.808 |  0.808 |  0.805 |  0.807 |  0.808 |  0.807 |  0.807 |  0.808 |  0.808 |  0.806 |
12 |  0.813 |  0.809 |  0.807 |  0.805 |  0.806 |  0.808 |  0.807 |  0.806 |  0.807 |  0.808 |  0.808 |  0.807

TABLE IV: Optimization KPIs score for combinations of forecast and
optimization commitment between 1 and 12 (with data from in-sample buildings)
Accuracy

Optimization Score: without switching costs

Stability: vertical (top) and horizontal (bottom)

Optimization Score: with switching costs

Point Forecast + Deterministic MPC

Probabilistic forecast + Stochastic MPC

Figure 6: Accuracy (Top), Horizontal (Middle) and Vertical Stability (Bottom
row) of stochastic forecast over different revision periods with data from in-
sample buildings