#  Transactive Framework for Dynamic Energy Storage Allocation for Critical
Load Management

Arnab Dey1, Vivek Khatana1, Ankur Mani2, and Murti V. Salapaka1 This work is
supported by Advanced Research Projects Agency-Energy OPEN through the project
titled "Rapidly Viable Sustained Grid" via grant no. DE-AR0001016.1Arnab Dey
(e-mail: dey00011@umn.edu), Vivek Khatana (e-mail: khata010@umn.edu), and
Murti V. Salapaka (e-mail<EMAIL_ADDRESS>are with Department of Electrical
and Computer Engineering, University of Minnesota, Twin Cities, USA, and
2Ankur Mani (e-mail<EMAIL_ADDRESS>is with Department of Industrial and
Systems Engineering, University of Minnesota, Twin Cities, USA.

###### Abstract

With the increased penetration of Distributed Energy Resources and Renewable
Energy Systems (RES), the conventional distribution grid is advancing towards
a transactive framework supervised by a distribution system operator (DSO).
However, the inherent uncertainty of RES poses a challenge in meeting the
power demand of critical infrastructures in the microgrid unless sufficient
battery energy storage is maintained. Yet, maintaining expensive battery
storage increases the operating cost of the DSO. In this article, we propose a
dynamic resource allocation strategy to optimize the battery reserve
requirement while ensuring the critical demand is met with a provable
guarantee. Our solution is built upon stochastic control techniques where we
model the uncertain nature of RES with geometric Brownian motion. Our proposed
scheme enables the DSO to optimize the RES and battery reserve allocation to
eliminate the risk of over or underproduction. We apply the proposed scheme to
derive battery reserve allocation strategy for conventional and transactive
grid settings. Finally, we present numerical simulations under three different
scenarios of multiple microgrids with uncertain renewable generation with
detailed comparison of the performance of the proposed algorithm for
conventional and transactive grid. The simulation results demonstrate the
efficacy of the proposed transactive stochastic control algorithm.

Index terms: Microgrids, optimization, partial differential equations,
photovoltaic, renewable energy sources, stochastic process, transactive grid,
uncertainty minimization, wind energy.

##  I INTRODUCTION

In recent times, the proliferation of distributed energy resources (DER),
propelled by a mounting interest towards the generation and utilization of
clean renewable energies, has fostered a paradigm change in the operation and
control of power distribution networks. Renewable energy sources (RES), like
solar photo-voltaic systems and wind energy systems, reduce the adverse
environmental effects of traditional energy sources; integration of DERs also
offer improved grid assistance, efficiency and reliability. As renewables are
expected to contribute $60\%$ of total generation by $2050$ [1], a rapid
growth of ‘prosumers’, equipped with distributed RES, is envisaged to
transform the conventional energy systems (CES) to transactive energy systems
(TES). According to U.S. Department of Energy GridWise Architecture Council,
TES are defined as the systems of coordinated control mechanisms that allow
dynamic balance of supply and demand, using value as a key operational
parameter [2]. However, due to the intermittent nature of RES, maintaining the
balance between power supply and demand in a distributed framework is
challenging if extra measures such as mechanisms for ancillary services are
not present [3]. Moreover, climate related catastrophic events are increasing
in frequency and magnitude [4]. In this context, collaborative operation
across multiple critical facilities allows for pooling renewable resources and
reduces uncertainty and impact of idiosyncratic generation shocks due to
catastrophic failure at a facility. For such critical infrastructures, it is
important to guarantee needed power and thus managing uncertainty of RES needs
to be addressed. Hence, collaborative operation with uncertainty mitigation
techniques, provides an attractive solution when RES are used to supply power.

Energy storage allocation for demand-supply balance, considering fluctuating
renewable generation, is of significant interest presently to the researchers.
However, most of the existing works primarily focus on optimizing energy
trading cost without considering explicit stochastic models of the renewables.
In this context, various optimization techniques [5, 6, 7] are used with
applications in both TES and CES frameworks. Prior works have also considered
game theoretic approaches [8, 9], stochastic programming [10] and, mixed-
integer linear programming [11] to maximize the profit of each agent in TES
with high penetration of RES; however without explicitly modelling the RES
output and considering real-time power balance. An analytical approach, based
on cost-benefit analysis, is devised in [12] to improve energy sharing instead
of profit maximization, within a residential microgrid, however, stochasticity
of the renewable generation is not addressed. In [13], an intelligent network
of agents, connected to a DC microgrid, is considered to conduct power trading
based on min-consensus algorithm. Here, each agent broadcasts power demand
request and based on the request received from the neighbors, optimal power
dispatch solution is obtained. Reference [14] provides a case study of a TES
where the distribution system operator controls the energy trading between
transactive nodes in a day-ahead market and benefits of the participants are
estimated based on locational marginal price. In [15, 16], authors have
proposed Monte Carlo simulation methodology for optimal allocation of battery
storage under fluctuating wind and solar power. Optimization algorithms
emphasizing on investment and operational cost reduction is the focus of [15,
16, 17]. To address the stochastic nature of solar radiation and wind, [18,
19] incorporate probabilistic approaches in CES frameworks. Such probabilistic
approaches are missing for TES frameworks. Also, most of the existing works
either focus on cost optimization for energy trading in TES without addressing
the energy storage requirement and supply guarantee required by the critical
infrastructures (e.g. hospitals), or, solely consider energy storage
optimization without exploring the benefit of utilization of the same in
transactive architecture. Here, an approach for optimal energy storage
allocation to mitigate the uncertainty of meeting load demands of critical
infrastructures in a TES, due to stochastic nature of renewable generations,
is required.

To this end, in this article we focus on a TES framework consisting of
centralized battery storage and multiple small-scale microgrids with critical
infrastructures that require guarantee of supplying the demand requested at a
future time. Each microgrid is equipped with RES which are uncertain in
nature, and has no recourse to local energy storage, thus posing a risk of not
being able to meet the local critical demand. To mitigate this uncertainty,
the distribution system operator (DSO), which supervises the TES, allocates
battery storage to support the microgrids and also enables the microgrids to
trade renewable energies with each other. The focus of the article is on the
optimal allocation of battery storage by the DSO to meet the power demand of
each microgrid at the requested time.

The major contributions are summarized below:

(i) We study a TES framework with multiple prosumers managed by DSO, allowing
energy sharing with each other, to provide a solution to the problem of
meeting power demand of each prosumer in real-time with provable guarantees,
in the presence of stochasticity of the renewable energy sources. Such a
guarantee is essential for critical applications.

(ii) We also provide exact solutions for continuous time resource allocations
for the DSO to manage renewable and battery resources, eliminating risks of
underproduction and overproduction in the presence of uncertainty in renewable
generation. Our solution builds upon stochastic control techniques and we also
provide an approximation algorithm for discrete time resource management. We
remark that such a solution is pertinent for supporting critical
infrastructures.

(iii) We present a comparative study with a CES based approach where energy
sharing among the prosumers is not possible and the DSO is solely responsible
to meet the critical load demands of the prosumers by dynamic allocation of
renewable and battery storage. The solution is compared to the TES framework
to show the advantage of cooperation in TES setting with high penetration of
DER and critical loads.

The rest of the paper is organized as follows: description of the TES
architecture is given in Section II. A formal problem formulation is
introduced in Section III. Section IV describes the proposed resource
allocation algorithms for both CES and TES and the simulation results are
shown in Section V. Section VI concludes the article with concluding remarks.

##  II System Description

Renewable based large distribution networks, with centralized battery storage
[20], consist of several small-scale microgrids geographically apart from each
other, under the supervision of DSOs. We consider such a distributed framework
constituting a TES, where the DSO can operate the network more efficiently
than CES by utilising the ability of cooperation between the microgrids. Fig.
1 shows the hierarchical architecture of the TES under consideration, which
contains $N_{m}$ microgrids and a DSO which controls the energy transaction
among the microgrids and dispatches the centralized battery units, based on
the requirements, to maintain system reliability. Each microgrid has RES to
supply its local demands. However, the uncertain nature of RES poses the risk
of either power deficit, when generation is less than demand, or excess power
that forces curtailment, when generation exceeds demand. In CES, this risk is
minimized by using independent energy storage systems such as batteries for
individual microgrid, thus requiring large ancillary battery energy storage
systems (BESS) [21]. In contrast, a TES, as shown in Fig. 1, enables
microgrids to share energy among each other in a controlled fashion to
maintain demand-supply balance, where excess generation from one microgrid is
utilized to minimize the deficit of another, instead of power curtailment,
thus reducing the amount of BESS. DSO controls the energy transactions and the
dispatch of batteries. A communication layer is used to transmit real-time
power measurements of individual microgrid to aid the DSO for efficient
resource allocation. To reduce the energy cost, the DSO needs to estimate
optimal battery storage while ensuring that the load demands of the microgrids
are met, irrespective of the irregularities of RES. In the subsequent sections
we formally introduce the problem and provide a solution along with a
comparison with CES.

Figure 1: TES architecture with centralized BESS and microgrids with RES.

##  III Problem formulation

Let $\mathcal{I}=\\{1,2,\ldots,N_{m}\\}$ denote the set of microgrids present
in the distribution network. Each microgrid has its own renewable generation
unit (ReGU) producing $P_{gi}(t),i\in\mathcal{I}$, units of power at time $t$,
which is stochastic in nature and is modeled by Geometric Brownian Motion
(GBM) given by:

$\displaystyle\text{d}P_{gi}(t)=\mu_{gi}P_{gi}(t)\text{d}t+\sigma_{gi}P_{gi}(t)\text{d}W_{ti},$
(1)

with an initial condition, $P_{gi}(0)\mspace{-2.0mu}>\mspace{-2.0mu}0$, for
all $i\mspace{-2.0mu}\in\mspace{-2.0mu}\mathcal{I}$. The constants $\mu_{gi}$
and $\sigma_{gi}$ are the drift and volatility terms respectively and $W_{ti}$
denotes a Weiner process. We empirically verify this model assumption with RES
generation data in Section V. The Weiner processes $W_{ti},W_{tj}$ are
correlated according to

$\displaystyle\text{d}W_{ti}\text{d}W_{tj}=\rho_{ij}\text{d}t,\
i,j\in\mathcal{I},$ (2)

where $\rho_{ij}$ is the correlation coefficient. Therefore,

$\displaystyle\text{d}P_{gi}\text{d}P_{gj}=\sigma_{i}\sigma_{j}\rho_{ij}P_{gi}P_{gj}\text{d}t,\
i,j\in\mathcal{I}.$ (3)

Each microgrid also postulates a constant critical power demand of $D_{ci}$
units, $i\mspace{-2.0mu}\in\mspace{-2.0mu}\mathcal{I}$, at a future time
denoted as $T_{f}$. In TES, the objective of the system is to satisfy power
demand and supply balance at $T_{f}$, almost surely with minimum amount of
resources collectively. In case of
$P_{gi}(T_{f})\mspace{-2.0mu}\geq\mspace{-2.0mu}D_{ci}$ for microgrid $i$, it
can ensure sustained operation of its own load demand. In addition, the excess
generation of $D_{ci}\mspace{-2.0mu}-\mspace{-2.0mu}P_{gi}(T_{f})$ units can
be used to supply the load demands of other microgrids, thus requiring less
overall energy storage capacity to maintain grid reliability. Note, that this
excess generation will need to be curtailed in CES. On the other hand when
$P_{gi}(T_{f})\mspace{-2.0mu}<\mspace{-2.0mu}D_{ci}$, to avoid the risk of
microgrid $i$ not being able to meet the power demand of its critical loads,
it can be supported by either excess renewable generation from other
microgrids or the energy storage maintained by the DSO. To avail these
benefits of TES, microgrids participate in a contract with the DSO, which
controls the energy transactions and battery allocation for the whole system
by independently maintaining a portfolio consisting of fractions of ReGUs from
each participant microgrid and centralized battery units. In particular, as
shown in Fig. 1, the ReGUs in the portfilo of the DSO are physically located
at the premises of the individual microgrid, thus following same dynamics (1),
while the battery storage, being shared by all the microgrids, is fully
controlled and allocated by the DSO. Considering the battery storage has the
ability to dispatch in smaller units, each producing constant $P_{b}$ units of
power, the total available power in the portfolio maintained by the DSO at any
time $t$ is given by,

$\displaystyle
V(P_{g1}(t),\ldots,P_{gN_{m}}(t),t)=\sum_{i=1}^{N_{m}}[a_{i}(t)P_{gi}(t)]+b(t)P_{b},$
(4)

where, $a_{i}(t),i\mspace{-2.0mu}\in\mspace{-2.0mu}\mathcal{I},$ is the number
of ReGUs allocated from microgrid $i$ and $b(t)$ is the number of battery
units in the portfolio. At time $t\mspace{-2.0mu}=\mspace{-2.0mu}T_{f}$, we
assume that a total of $m$, with
$0\mspace{-2.0mu}\leq\mspace{-2.0mu}m\mspace{-2.0mu}\leq\mspace{-2.0mu}N_{m}$,
microgrids will have enough individual generation to supply their local
demand. We denote the set of indices of the microgrids with sufficient
generation at time $T_{f}$ as $\mathcal{I}_{s}$, with
$|\mathcal{I}_{s}|\mspace{-2.0mu}=\mspace{-2.0mu}m$, and let $\mathcal{I}_{d}$
be the set of indices of the microgrids not capable of supplying their own
local demand by renewable generation individually at time $T_{f}$; thus
$|\mathcal{I}_{d}|\mspace{-2.0mu}=\mspace{-2.0mu}N_{m}-m$. We have
$P_{gi}(T_{f})\mspace{-2.0mu}\geq\mspace{-2.0mu}D_{ci}$ if
$i\mspace{-2.0mu}\in\mspace{-2.0mu}\mathcal{I}_{s}$ and
$P_{gi}(T_{f})\mspace{-2.0mu}<\mspace{-2.0mu}D_{ci}$ if
$i\mspace{-2.0mu}\in\mspace{-2.0mu}\mathcal{I}_{d}$. The DSO is responsible
for supporting the $j^{th}$ microgrid,
$j\mspace{-2.0mu}\in\mspace{-2.0mu}\mathcal{I}_{d}$, by utilizing either the
surplus power (if available) from other microgrids, or the battery units in
its portfolio. We remark that, the knowledge of the sets $\mathcal{I}_{s}$ and
$\mathcal{I}_{d}$ are unknown a priori at initial time. Therefore, a focus on
the time evolution of the ReGUs and the battery units from
$t\mspace{-2.0mu}=\mspace{-2.0mu}0$ till the time
$t\mspace{-2.0mu}=\mspace{-2.0mu}T_{f}$ is required to guarantee that the
demand is met at the requested time $T_{f}$. At time $t=T_{f}$, there are two
possibilities:

(1)
$\sum_{i=1}^{N_{m}}P_{gi}(T_{f})\mspace{-2.0mu}\geq\mspace{-2.0mu}\sum_{i=1}^{N_{m}}D_{ci}$:
In this case, collectively the microgrids have sufficient renewable generation
to supply critical load demands of each individual microgrid. Hence, no
additional power from battery units is required.

(2)
$\sum_{i=1}^{N_{m}}P_{gi}(T_{f})\mspace{-2.0mu}<\mspace{-2.0mu}\sum_{i=1}^{N_{m}}D_{ci}$:
Here, the total deficit of $\sum_{i=1}^{N_{m}}[{D_{ci}-P_{gi}(T_{f})}]$ units
of power is required to be maintained in the portfolio of the DSO to support
the critical load demand of microgrid
$j\mspace{-2.0mu}\in\mspace{-2.0mu}\mathcal{I}_{d}$, from the combination of
battery units and surplus power, if any, from microgrid $i$,
$i\mspace{-2.0mu}\in\mspace{-2.0mu}\mathcal{I}_{s}$.

To address both the possibilities with minimum number of energy resources, the
DSO needs to balance its own power portfolio (4). In this context, we
introduce a constraint of rated power conservation of the portfolio, which
requires:

$\displaystyle\sum_{i=1}^{N_{m}}[\text{d}a_{i}(t)P_{gi}(t)]+\text{d}b(t)P_{b}=0,$
(5)

for $t\mspace{-3.0mu}\in\mspace{-3.0mu}(0,T_{f})$ to ensure that the change in
total power output of the generation portfolio due to the changes in the
number of battery units and the number of ReGUs is zero; thus the change in
total power generated by the portfolio maintained by DSO is only due to the
change of renewable generation of individual microgrid. Thus, after initial
allocation $a_{i}(0),i\mspace{-2.0mu}\in\mspace{-2.0mu}\mathcal{I}$, and
$b(0),$ the DSO, at a future time $t$, can change the number of battery units
but has to ensure that the power change is compensated by exchanging with the
ReGUs in the portfolio.

Therefore, the problem from the perspective of the DSO is:

$\displaystyle\text{Determine the number},b(t)\text{ of}\text{ battery
blocks}$ and number, $\displaystyle a_{i}(t)\text{ of renewable}\text{
generation units based}\text{ on }$ $\displaystyle P_{gi}(t),i\in\mathcal{I},$
$\displaystyle\text{ such that
}\textstyle\sum\limits_{i=1}^{N_{m}}[\text{d}a_{i}(t)P_{gi}(t)]+\text{d}b(t)P_{b}=0$
, (6)
$\displaystyle\textstyle\sum\limits_{i=1}^{N_{m}}[a_{i}(T_{f})P_{gi}(T_{f})]+b(T_{f})P_{b}=\textstyle\sum\limits_{i=1}^{N_{m}}r_{i}[D_{ci}-$
$\displaystyle P_{gi}(T_{f})],$ (7)

for $t\in(0,T_{f})$, where $r_{i}=1$ if $i\in\mathcal{I}_{d}$ and $r_{i}=0$ if
$i\in\mathcal{I}_{s}$. Note that, under the constraint of rated power
conservation, finding the amount of initial battery units and the initial
ReGUs is essential for the DSO as having a lesser number of batteries and
ReGUs has a risk of not being able to provide $D_{ci}$ units of power at time
$T_{f}$ for all $i\in\mathcal{I}_{d}$, whereas provisioning more may result in
excess energy produced at $t=T_{f}$ that will lead to a loss of revenue to the
DSO. Section IV of this article presents the proposed strategy to find the
resource allocation policy in real-time under both CES and TES framework.

##  IV Solution Methodology

###  IV-A Conventional Energy System

First, we consider the case of CES where power sharing among the microgrids is
not possoble and each microgrid is treated independently by the DSO i.e.
available power in the portfolio maintained by the DSO for each microgrid is:

$\displaystyle\hat{V}_{i}(P_{gi}(t),t)=\hat{a}_{i}(t)P_{gi}(t)+\hat{b}_{i}(t)P_{b},\
i\in\mathcal{I},$ (8)

and $0\leq t\leq T_{f}$, where $\hat{a}_{i}(t)$ and $\hat{b}_{i}(t)$ are the
number of ReGUs and battery units allocated for microgrid $i$. In case of CES,
the constraint of rated power conservation is given by:

$\displaystyle\text{d}\hat{a}_{i}(t)P_{gi}(t)+\text{d}\hat{b}_{i}(t)P_{b}=0,\
\mbox{for all}\ i\in\mathcal{I},$ (9)

and the total amount of battery units maintained by DSO is:

$\displaystyle\hat{b}(t)=\sum_{i=1}^{N_{m}}\hat{b}_{i}(t),\ \forall
t\in[0,T_{f}].$

To ensure the power demand of $i^{th}$ microgrid is met at the requested time
$T_{f}$, the DSO needs to supply the deficit of $D_{ci}-P_{gi}(T_{f})$ units
of power from the portfolio if the microgrid is not capable of supplying its
own demand from the renewable generation, and $0$ otherwise. Therefore the
power portfolio has to satisfy the following terminal condition,

$\displaystyle\hat{V}_{i}(P_{gi}(T_{f}),T_{f})=\begin{cases}0&\text{if
$P_{gi}(T_{f})\geq D_{ci}$}\\\ D_{ci}-P_{gi}(T_{f})&\text{if
$P_{gi}(T_{f})<D_{ci}$}.\end{cases}$ (10)

As the amount of renewable generation at $T_{f}$ is not deducible and also not
known a priori due to inherent uncertainty [22], we provide a policy of
maintaining the number of battery units, $\hat{b}_{i}(t)$ and ReGUs,
$\hat{a}_{i}(t)$ for $t\mspace{-2.0mu}\in\mspace{-2.0mu}[0,T_{f})$, satisfying
the terminal condition (10), such that the critical demand of $D_{ci}$,
$i\mspace{-2.0mu}\in\mspace{-2.0mu}\mathcal{I}$, units is met almost-surely at
time $T_{f}$ in the following theorem.

######  Theorem 1.

Under the rated power conservation constraint (9), suppose $\hat{a}_{i}(t)$
and $\hat{b}_{i}(t)$ are given by:

$\displaystyle\hat{a}_{i}(t)$
$\displaystyle=-\Phi\bigg{[}\textstyle\frac{\ln\left(\frac{D_{ci}}{P_{gi}(t)}\right)-\textstyle\frac{\sigma_{gi}^{2}}{2}(T_{f}-t)}{\sigma_{gi}\sqrt{(T_{f}-t)}}\bigg{]},$
$\displaystyle\hat{b}_{i}(t)$
$\displaystyle=\textstyle\frac{D_{ci}}{P_{b}}\Phi\bigg{[}\frac{\ln\left(\frac{D_{ci}}{P_{gi}(t)}\right)+\textstyle\frac{\sigma_{gi}^{2}}{2}(T_{f}-t)}{\sigma_{gi}\sqrt{(T_{f}-t)}}\bigg{]},\
t\in[0,T_{f})$

where, $\Phi(\cdot)$ is the standard normal cumulative distribution function,
then the terminal condition specified by (10) is satisfied almost surely at
time $T_{f}$.

###### Proof.

Please see Appendix B. ∎

It follows that, in case of conventional grid, the total amount of battery
units required by the DSO for all $t\in[0,T_{f})$ is:

$\displaystyle\hat{b}(t)=\sum_{i=1}^{N_{m}}\textstyle\frac{D_{ci}}{P_{b}}\Phi\bigg{[}\frac{\ln\left(\frac{D_{ci}}{P_{gi}(t)}\right)+\textstyle\frac{\sigma_{gi}^{2}}{2}(T_{f}-t)}{\sigma_{gi}\sqrt{(T_{f}-t)}}\bigg{]},$
(11)

while the total power portfolio value at $t=T_{f}$ is:

$\displaystyle\hat{V}(P_{g1}(T_{f}),\ldots,P_{gN_{m}},T_{f})=\sum_{i=1}^{N_{m}}\text{max}(D_{ci}-P_{gi}(T_{f}),0).$

###  IV-B Transactive Energy System

Let us now consider the case of TES where the power available in the portfolio
maintained by the DSO is given by (4). In contrast to the CES, here a single
power portfolio is maintained instead of $N_{m}$ independent portfolios. The
TES needs to ensure that the DSO is able to make up for the deficit
$D_{ci}-P_{gi}(T_{f}),i\mspace{-2.0mu}\in\mspace{-2.0mu}\mathcal{I}_{d}$ at
$t\mspace{-2.0mu}=\mspace{-2.0mu}T_{f}$ from the surplus generation
$P_{gj}(T_{f})-D_{cj},j\in\mathcal{I}_{s}$, thus requiring less amount of
centralized battery units $b(t)$. In the following sections, we provide a
policy of maintaining the number of shared battery units, $b(t)$ and ReGUs,
$a_{i}(t),i\mspace{-2.0mu}\in\mspace{-2.0mu}\mathcal{I}$ for all
$t\mspace{-2.0mu}\leq\mspace{-2.0mu}T_{f}$, that ensures that the power
deficit is optimally met with guarantees given the knowledge of
$\mathcal{I}_{d}$ and $\mathcal{I}_{s}$ is unknown a priori. Let the value of
power portfolio, $V$ at any time $t\in[0,T_{f}]$ be denoted by $V_{t}$. In
case of TES, the terminal condition is given by,

$\displaystyle\textstyle V_{T_{f}}=\text{max
}(\sum\limits_{i=1}^{N_{m}}(D_{ci}-P_{gi}(T_{f}),0).$ (12)

Finding an analytical solution to $a_{i}(t),\ b(t)$ for all $t\in[0,T_{f})$
under the terminal condition (12) is intractable due to higher dimensionality
of (4) (please see Appendix C). We provide a numerical solution in the
following sections.

Let,
$\eta_{gi}\mspace{-1.0mu}\coloneqq\mspace{-1.0mu}\frac{\mu_{gi}}{\sigma_{gi}}$
and consider a function
$\gamma_{i}(x)\mspace{-1.0mu}\coloneqq\mspace{-1.0mu}e^{-\eta_{gi}x-\frac{1}{2}\eta_{gi}^{2}t}$,
and let the distribution function of Wiener process be denoted by, $\textstyle
F_{W_{ti}}(x)\mspace{-5.0mu}=\mspace{-5.0mu}\frac{1}{\sqrt{2\pi
t}}\int_{-\infty}^{x}e^{-\frac{u^{2}}{2t}}\text{d}u$, for all
$i\mspace{-3.0mu}\in\mspace{-3.0mu}\mathcal{I}$. Then define,

$\displaystyle\mspace{-10.0mu}\textstyle
F_{\hat{W}_{ti}}(x)\coloneqq\textstyle\mspace{-5.0mu}\int\limits_{-\infty}^{x}\mspace{-5.0mu}\gamma_{i}(u)\text{d}F_{W_{ti}}(u)=\textstyle\frac{1}{\sqrt{2\pi
t}}\mspace{-5.0mu}\int\limits_{-\infty}^{x}e^{-\frac{(u+\eta_{gi}t)^{2}}{2t}}\text{d}u.$
(13)

$F_{\hat{W}_{ti}}(x)$ is the distribution function of the stochastic process
$\hat{W}_{ti}\coloneqq W_{ti}+\eta_{gi}t$, where
$\hat{W}_{ti}\sim\mathcal{N}(0,t)$ for all $i\in\mathcal{I}$. $\gamma_{i}(x)$
can be used to define a transformed probability measure given by (13). Let us
denote the expected value of a random variable under this transformed
probability measure by $\hat{\mathbb{E}}[\cdot]$. The following theorem
provides the solution of $V_{t}$ for all $t\in[0,T_{f}]$ under this
transformed probability measure.

######  Theorem 2.

Given the rated power conservation constraint (5) for all $t\in[0,T_{f}]$, the
solution of $V_{t}$ under the transformed probability measure (13) is,

$\displaystyle
V_{t}=\textstyle\hat{\mathbb{E}}[\text{max}(\sum\limits_{i=1}^{N_{m}}(D_{ci}-P_{gi}(T_{f}),0)].$
(14)

###### Proof.

Please see Appendix D. ∎

Under the transformed probability measure, the value of $V_{t}$ for any $t\leq
T_{f}$ is the expected value of the portfolio at $T_{f}$, which can be
calculated numerically [23], as described below, to find the provisioning
policy of the ReGUs and battery units, $a_{i}(t),i\in\mathcal{I}$ and $b(t)$
respectively, for $t\in[0,T_{f}]$.

Let the time horizon $[0,T_{f}]$ be partitioned into $N$ equal intervals
$0\mspace{-2.0mu}=\mspace{-2.0mu}t_{0}\mspace{-2.0mu}<\mspace{-2.0mu}t_{1}\mspace{-2.0mu}<\mspace{-2.0mu}\ldots\mspace{-2.0mu}<\mspace{-2.0mu}t_{N}\mspace{-2.0mu}=\mspace{-2.0mu}T_{f}$
such that $t_{n}\mspace{-2.0mu}=\mspace{-2.0mu}n\Delta
t,n\in\\{0,1,\ldots,N\\}$ where $\Delta
t\mspace{-2.0mu}=\mspace{-2.0mu}T_{f}/N$ denotes the length of each interval.
The vector of renewable generation values at
$t\mspace{-2.0mu}=\mspace{-2.0mu}t_{n}$ is denoted by
$\boldsymbol{P_{G}}(t_{n})\mspace{-2.0mu}=\mspace{-2.0mu}\begin{bmatrix}P_{g1}(t_{n})&\mspace{-2.0mu}\ldots\mspace{-2.0mu}&P_{gN_{m}}(t_{n})\end{bmatrix}^{T}$.
We assume that at the end of each time interval, each ReGU output can either
increase or decrease by a constant factor of $u_{i}(\geq 1)$, $d_{i}(<1)$
respectively, with respect to the current values, with certain probabilities.
Here, $\boldsymbol{P_{G}}(t_{n+1})$ can take one of the $2^{N_{m}}$ possible
values with corresponding probabilities
$P_{k}\mspace{-2.0mu}\in\mspace{-2.0mu}\boldsymbol{P}\mspace{-2.0mu}\in\mspace{-2.0mu}\mathbb{R}^{2^{N_{m}}\times
1}$ and $\sum_{k=1}^{2^{N_{m}}}P_{k}\mspace{-2.0mu}=\mspace{-2.0mu}1$. The
time evolution of $\boldsymbol{P_{G}}(t_{n})$ is shown in Fig. 2 for two
consecutive time intervals and $N_{m}=2$ for brevity of exposition. Without
loss of generality, imposing the constraint,
$u_{i}d_{i}\mspace{-2.0mu}=\mspace{-2.0mu}1,i\mspace{-2.0mu}\in\mspace{-2.0mu}\mathcal{I}$,
we can estimate the values of $P_{k},u_{i},d_{i}$, given
$\boldsymbol{P_{G}}(t_{n}),\mu_{gi},\sigma_{gi},\rho_{ij},i,j\in\mathcal{I}$,
by comparing the expectation, variance and covariance of the stochastic
processes, under the transformed probability measure, with that from the
discrete $N_{m}$-ary tree. The detailed procedure is given in Appendix A. Let
$\boldsymbol{U}\mspace{-2.0mu}\in\mspace{-2.0mu}\mathbb{R}^{2^{N_{m}}\times
N_{m}}$ denote a matrix where $k^{th}$ row of $\boldsymbol{U}$ contains the
movement factors of $\boldsymbol{P_{G}}(t_{n})$ associated with probability
$P_{k},k\in\\{1,2,\ldots,2^{N_{m}}\\}$. Once the values of $P_{k},u_{i},d_{i}$
are determined, we divide the algorithm in three sequentially executed parts
as explained below.

Figure 2: Forward and backward propagation steps to calculate $V_{t_{n}}$ for
a TES with $2$ cooperative microgrids

####  IV-B1 Forward propagation

Let us consider that our objective is to find the values of
$a_{i}(t_{n}),i\in\mathcal{I}$ and $b(t_{n})$ where $t_{n}<t_{N}=T_{f}$. Given
the current value of the renewable generation vector,
$\boldsymbol{P_{G}}(t_{n})$, first we estimate all possible values of
$\boldsymbol{P_{G}}(t_{N})$ with corresponding probabilities as shown in Fig.
2. The general algorithm is given in Algorithm 2.

####  IV-B2 Backward propagation

Using the results obtained in the forward propagation step and values of
$D_{ci},i\mspace{-2.0mu}\in\mspace{-2.0mu}\mathcal{I}$, the value of
$V_{t_{N}}$ can be computed using (12) for all possible points at $t=t_{N}$.
To estimate $V_{t_{n}}$, the portfolio value is back propagated from $t=t_{N}$
till $t_{n}$, using (14) at each
$t_{k},k\mspace{-2.0mu}\in\mspace{-2.0mu}\\{N-1,N-2,\mspace{-2.0mu}\ldots\mspace{-2.0mu},n\\}$.
For example, in case of $N_{m}\mspace{-2.0mu}=\mspace{-2.0mu}2$, as shown in
Fig. 2,
$V_{t_{n}}\mspace{-2.0mu}=\mspace{-2.0mu}\sum_{i=1}^{4}P_{i}V_{t_{n+1},i}$,
where $V_{t_{n+1},i}$ are estimated from preceding back propagation steps. The
backpropagation algorithm is given in Algorithm 3.

####  IV-B3 Resources calculation

Once $V_{t_{n}}$ is obtained, we can compute the values of $a_{i}(t_{n})$ and
$b(t_{n})$ calculating the change in portfolio and renewable generation values
obtained from forward and backward propagation as shown in Algorithm 1.

The entire algorithm is summarized in Algorithm 1. Each node in the
implementation of tree data structure, shown in Fig. 2, has elements
$\boldsymbol{P_{G}}$, to contain ReGU output associated with the node, $V$, to
store portfolio value of the node, $p$, which contains probability of
encountering the node starting from initial time $t_{n}$, $ohp$, containing
one hop probability of running into the node from its parent and an unique ID,
$id$, assigned to each node. In the next section, we provide the simulation
results of the algorithm where a TES with two microgrids and a DSO, operating
in hour-ahead market, is considered.

Input :
$\boldsymbol{P_{G}}(t_{n})=\\{P_{gi}(t_{n})\\}_{i=1}^{N_{m}},\boldsymbol{D_{c}}=\\{D_{ci}\\}_{i=1}^{N_{m}}$,

$\boldsymbol{a}=\\{a_{i}(t_{n-1})\\}_{i=1}^{N_{m}}$, $P_{b}$, $T_{f}$, $N$,
$\boldsymbol{P},\boldsymbol{U}$;

Output : $\boldsymbol{r}=\\{r_{i}\\}_{i=1}^{N_{m}+1}$// Resource values

/* Initialization */

$\Delta t\leftarrow T_{f}/N$; $n\leftarrow t_{n}/\Delta t$;
$\boldsymbol{L},\boldsymbol{L_{n}}\leftarrow[\ ]$;

$\boldsymbol{v}\leftarrow\vec{0}\in\mathbb{R}^{(2^{N_{m}})\times 1}$;
$\boldsymbol{r}\leftarrow\vec{0}\in\mathbb{R}^{(N_{m}+1)\times 1}$;

$\boldsymbol{A}\leftarrow\vec{0}\in\mathbb{R}^{2^{N_{m}}\times(N_{m}+1)}$;
$\boldsymbol{A}[:,N_{m}+1]\leftarrow P_{b}$;

/* Forward Propagation */

$\boldsymbol{L}\leftarrow\textnormal{{FP}}(N-n,\boldsymbol{U},\boldsymbol{P},\boldsymbol{P_{G}}(t_{n}))$;

/* Backpropagation */

$V_{t_{n}},\boldsymbol{L_{n}}\leftarrow\textnormal{{BP}}(\boldsymbol{L},\boldsymbol{D_{c}})$;

/* Resources Calculation */

if  _$|\boldsymbol{L_{n}}|\neq 1$_ then

for  _$j=1$ to $2^{N_{m}}$_ do

$c\leftarrow\boldsymbol{L_{n}}[j]$; $\boldsymbol{v}[j]\leftarrow V$ value of
$c$;

$\boldsymbol{p_{g}}\leftarrow\boldsymbol{P_{G}}$ value of $c$;
$\boldsymbol{A}[j,1:N_{m}]\leftarrow\boldsymbol{p_{g}}^{T}$;

end for

$\boldsymbol{r}\leftarrow\boldsymbol{A}^{{\dagger}}\boldsymbol{b}$;

else

$\boldsymbol{r}[1:N_{m}]\leftarrow\boldsymbol{a}$;

$\boldsymbol{r}[N_{m}+1]\leftarrow
V_{t_{n}}-\boldsymbol{r}[1:N_{m}]^{T}\boldsymbol{P_{G}}(t_{n})$;

end if

return _$\boldsymbol{r}$ ;_

Algorithm 1 Dynamic Resource Allocation

Function  _FP
($nStep$,$\boldsymbol{U}$,$\boldsymbol{P}$,$\boldsymbol{P_{GI}}$)_:

create $root$ node with $id=0,p=1,\boldsymbol{P_{G}}=\boldsymbol{P_{GI}}$;

$\boldsymbol{L_{f}}\leftarrow[\ root\ ]$; $pid\leftarrow 0$;

for  _$i=1$ to $nStep$_ do

for  _$j=1$ to ${(2^{N_{m}})}^{i}$_ do

$parent\leftarrow\text{get node with }id=pid$;

$pr\leftarrow p$ value of $parent$ node;

$\boldsymbol{C_{G}}\leftarrow\boldsymbol{P_{G}}$ value of $parent$ node;

for  _$k=1$ to $N_{m}$_ do

$child\leftarrow$ create new node;

$child.\boldsymbol{P_{G}}\leftarrow\boldsymbol{C_{G}}\otimes\boldsymbol{U}[k,:]$;

$child.p\leftarrow pr\otimes\boldsymbol{P}[k]$;

$child.id\leftarrow(2^{N_{m}}\times pid)+k$;

$child.ohp\leftarrow\boldsymbol{P}[k]$;

append $child$ to $parent$;

if  _$i=nStep$_ then

append $child$ to $\boldsymbol{L_{f}}$;

end if

end for

$pid\leftarrow pid+1$;

end for

end for

return _$\boldsymbol{L_{f}}$_ ;

Algorithm 2 Forward Propagation

Function  _BP( $\boldsymbol{L},\boldsymbol{D_{c}}$)_:

foreach  _$c\in\boldsymbol{L}$_ do

$\boldsymbol{p_{g}}\leftarrow$ member $\boldsymbol{P_{G}}$ of node $c$;

$tv\leftarrow\text{max}(\sum_{i=1}^{N_{m}}[\boldsymbol{D_{c}}-\boldsymbol{p_{g}}][i],0)$;

update value of member $V$ of $c$ with $tv$;

end foreach

$\boldsymbol{L_{c}},\boldsymbol{L_{n}}\leftarrow\boldsymbol{L}$;
$end\leftarrow|\boldsymbol{L_{c}}|$; $ev\leftarrow tv$;

while  _$end\neq 1$_ do

$\boldsymbol{L_{p}}\leftarrow[\ ]$; $numNodes\leftarrow end$;

while  _$numNodes >0$_ do

$\boldsymbol{s}\leftarrow$ $2^{N_{m}}$ siblings from $\boldsymbol{L_{c}}$;

$\boldsymbol{v}\leftarrow V$ values of each node in $\boldsymbol{s}$;

$\boldsymbol{p_{s}}\leftarrow ohp$ values of each node in $\boldsymbol{s}$;

$parent\leftarrow$ parent node of siblings in $\boldsymbol{s}$;

$parent.V\leftarrow\sum_{i=1}^{2^{N_{m}}}\boldsymbol{v}[i]\boldsymbol{p_{s}}[i]$;

append $parent$ to $\boldsymbol{L_{p}}$;

$numNodes\leftarrow numNode-2^{N_{m}}$;

end while

$\boldsymbol{L_{c}}\leftarrow\boldsymbol{L_{p}}$;
$end\leftarrow|\boldsymbol{L_{c}}|$;

if  _$end=2^{N_{m}}$_ then

$\boldsymbol{L_{n}}\leftarrow\boldsymbol{L_{c}}$;

end if

end while

return _$ev,\boldsymbol{L_{n}}$_ ;

Algorithm 3 Backpropagation

##  V Simulation results

###  V-A Model assumption verification

First we analyse the empirical wind power time series data to validate the
model assumption (1) and estimate the parameters of the stochastic process.
Wind generation data from the northwestern part of USA is taken from [24] for
the month of June, 2020 at an interval of $5$ minutes. As typical wind
generation dynamics vary over different hours of a day, it is necessary to
modify the parameters of (1) according to period of interest during a day. In
our case, wind data from $10$ a.m.-$5$ p.m. is chosen and maximum likelihood
estimator is used to find drift and volatility parameters. The estimated drift
and volatility parameters are $0.007$ and $0.027$ respectively with chi-square
goodness of fit score of $18.86$ including $13$ degrees of freedom. The
$p$-value, calculated from the goodness of fit test with significance level
$\alpha\mspace{-2.0mu}=\mspace{-2.0mu}0.05$, is $0.128$ which justifies the
validity of GBM model of wind power dynamics [25].

###  V-B Parameters and sample size determination

For the simulation, two microgrids with renewable generations, $P_{g1}(t)$ and
$P_{g2}(t)$ with parameters
$\mu_{g1}\mspace{-2.0mu}=\mspace{-2.0mu}0.006,\sigma_{g1}\mspace{-2.0mu}=\mspace{-2.0mu}0.03$
and
$\mu_{g2}\mspace{-2.0mu}=\mspace{-2.0mu}0.005,\sigma_{g2}\mspace{-2.0mu}=\mspace{-2.0mu}0.04$
respectively, are considered and realized using discrete approximation of (1).
We also assume that the generations are correlated with a correlation
coefficient of $\rho_{12}\mspace{-2.0mu}=\mspace{-2.0mu}0.6$. We assume that
the battery unit power is $P_{b}\mspace{-2.0mu}=\mspace{-2.0mu}1$ kW. The load
demands, $D_{c1}=20$ kW and $D_{c2}=25$ kW, of the two microgrids
respectively, are to be met at $T_{f}=5$ hrs. We use Algorithm 1 to compute
optimal provisioning of initial resources and resource updates at each time
instant, under rated power conservation constraint, that satisfies the power
balance at $T_{f}$. We also assume that the ReGUs and the battery units are
adjusted at an interval of one hour.

We first focus on the number of samples needed to arrive at meaningful
statistical inferences. Fig. 3 shows the density histogram plot of $P_{g1}(t)$
for different time instants for two sample sets each containing $10000$
samples of $P_{g1}(t)$ drawn from numerical simulation of the dynamic equation
(1) with
$\mu_{g1}\mspace{-2.0mu}=\mspace{-2.0mu}0.006,\sigma_{g1}\mspace{-2.0mu}=\mspace{-2.0mu}0.03$
and initial condition, $P_{g1}(0)\mspace{-2.0mu}=\mspace{-2.0mu}20$ kW. Both
sample sets consist of samples of $P_{g1}(t)$ with the terminal case of
$P_{g1}(T_{f})\mspace{-2.0mu}>\mspace{-2.0mu}D_{c1}$. The distribution of the
samples, at $t=1,2,\ldots,5$, in the two sample sets, are compared using Two-
sample Kolmogorov–Smirnov (KS) test [26] which produces KS statistics values
$0.008,0.01,0.0062,0.0079$ and $0.0094$ respectively. For sample size of
$10000$ in each set, the critical value of KS statistics is $0.019$. The lower
values of KS statistics than the critical value indicates that simulation of
our algorithm for $10000$ independent runs can produce highly stable results.
Similar conclusions can be drawn for other terminal cases of $P_{g1}(T_{f})$
and $P_{g2}(t)$, such as,
$P_{g1}(T_{f})\mspace{-2.0mu}\leq\mspace{-2.0mu}D_{c1},P_{g2}(T_{f})\mspace{-2.0mu}>\mspace{-2.0mu}D_{c2}$
and $P_{g2}(T_{f})\mspace{-2.0mu}\leq\mspace{-2.0mu}D_{c2}$.

Figure 3: Histograms of $P_{g1}(t)$ for $t\in\\{1,2,\ldots,5\\}$ with two
sample sets each containing $10000$ samples of $P_{g1}(t)$ with terminal
condition $P_{g1}(T_{f})\mspace{-3.0mu}>\mspace{-3.0mu}D_{c1}$.

Here, in figures, Fig. 4, simulation results are shown for three sets of
$10000$ runs, each set satisfying different terminal conditions of
$P_{g1}(T_{f})$ and $P_{g2}(T_{f})$ w.r.t $D_{c1}$ and $D_{c2}$ respectively,
with mean values plotted for renewable generations along with standard
deviations in shaded regions. For all other resources, mean values along with
$95$% bootstrap confidence interval (CI) around the mean, with $10000$
bootstrap samples, are plotted. The narrow $95$% CI around the means for
battery requirement, power portfolio and battery savings, as seen from Fig. 4,
indicate high confidence of the outcomes of our proposed algorithm.
Implementation is done in Python $3.8$.

###  V-C Case study $1$: $P_{g1}(T_{f})\geq D_{c1},P_{g2}(T_{f})\geq D_{c1}$

Fig. 4a illustrates the scenario where the renewable generations of both the
microgrids are sufficient to meet respective load demands at $t=T_{f}$. We
remark that the algorithm and the methodology has no knowledge of the terminal
state a priori at any time $t<T_{f}$. It is seen that the battery units
requirement and the power portfolio value become $0$ at $t=T_{f}$ as expected
for both CES and TES. The trajectories of $b(t)$, $\hat{b}(t)$ and the average
savings on battery in TES presented here (as shown in Table I and Fig. 5),
reveal that, on an average, TES enables DSO to reduce battery requirement by
$36.94$% and the average savings on initial battery requirement is $13.5$%
over CES.

(a) Case study $1$: $P_{g1}(T_{f})\geq D_{c1},P_{g2}(T_{f})\geq D_{c2}$

(b) Case study $2$: $P_{g1}(T_{f})\geq D_{c1},P_{g2}(T_{f})<D_{c2}$

(c) Case study $3$: $P_{g1}(T_{f})<D_{c1},P_{g2}(T_{f})<D_{c2}$

Figure 4: (a) Both microgrids are capable of supplying their own demand at $T_{f}$, requiring no battery and power to be maintained in the portfolio for both CES ($\hat{V}(t),\hat{b}(t)$) and TES ($V(t),b(t)$). (b) Excess generation from microgrid $1$ is utilized to supply demand of microgrid $2$ in TES at $T_{f}$, whereas in CES, average battery units’ requirement is $25$ to guarantee that the demand is met. (c) Both microgrids are not capable of supplying own demand requiring same battery amount for both CES and TES. For all cases, power required in the portfolio is lower in TES than CES. Standard deviation of $10,000$ realizations of $P_{g1}(t)$ and $P_{g2}(t)$ are shown in the shaded regions with the mean values plotted with solid lines. Zoomed inset, showing an example of $95$% CI around the mean of battery requirement for TES at $t\mspace{-2.0mu}=\mspace{-2.0mu}2$ hours, indicates high confidence in average battery requirement of our proposed scheme. Figure 5: Savings on battery requirement in TES as a percentage of the same in CES for three case studies. For all $t\mspace{-2.0mu}<\mspace{-2.0mu}T_{f}$, in TES, DSO requires less amount of battery units compared to CES while ensuring that the demand is met at $T_{f}$ for all cases. The narrow $95$% CI around the mean battery savings percentage, as shown in the zoomed inset at $t\mspace{-2.0mu}=\mspace{-2.0mu}2$ hours for case $2$ as example, indicates high confidence in average battery savings in our proposed algorithm. TABLE I: Average battery savings (%) in TES for three cases depicted in Fig. 4a-4c. Time (hrs.) | $P_{g1}(T_{f})\geq D_{c1}$ | $P_{g1}(T_{f})\geq D_{c1}$ | $P_{g1}(T_{f})<D_{c1}$
---|---|---|---
| $P_{g2}(T_{f})\geq D_{c2}$ | $P_{g2}(T_{f})<D_{c2}$ | $P_{g2}(T_{f})<D_{c2}$
$0$ | $13.50$ | $13.50$ | $13.50$
$1$ | $24.80$ | $20.43$ | $14.48$
$2$ | $43.96$ | $32.19$ | $15.13$
$3$ | $70.41$ | $51.57$ | $15.25$
$4$ | $68.98$ | $77.85$ | $15.15$
$5$ | $0$ | $100$ | $0$
Overall | $36.94$ | $49.26$ | $12.25$

###  V-D Case study $2$: $P_{g1}(T_{f})\geq D_{c1},P_{g2}(T_{f})<D_{c1}$

Fig. 4b illustrates the scenario where microgrid $1$ is capable of supplying
its load demand of $D_{c1}\mspace{-2.0mu}=\mspace{-2.0mu}20$ kW but renewable
generation of microgrid $2$ is not sufficient to meet
$D_{c2}\mspace{-2.0mu}=\mspace{-2.0mu}25$ kW at $t=T_{f}$ (here too the
terminal state is not available a priori at any time $t<T_{f}$). Here the
power deficit of microgrid $2$ is more than the surplus generated from
microgrid $1$. The plot shows that at the end of the time horizon, TES enables
DSO to utilize the surplus thus requiring no battery unit at
$t\mspace{-2.0mu}=\mspace{-2.0mu}T_{f}$ whereas in case of CES, average
battery units’ requirement is $25$ to guarantee that the demand is met.
Moreover, average savings on battery units, for the entire time horizon, is
$49.26$%, as shown in Table I and Fig. 5. The value of the power portfolio, as
shown in Fig. 4b, becomes $0$ at $T_{f}$ in case of transactive grid while
conventional grid requires DSO to have the power deficit of microgrid $2$ in
its power portfolio.

###  V-E Case study $3$: $P_{g1}(T_{f})<D_{c1},P_{g2}(T_{f})<D_{c1}$

Fig. 4c captures the scenario where both the microgrids are not capable of
meeting their load demands at $t\mspace{-2.0mu}=\mspace{-2.0mu}T_{f}$. In this
case the power portfolio value required by the DSO is equal to the net deficit
of the microgrids for both CES and TES settings. The battery units requirement
is nearly equal to the net load demand of the whole system while in case of
TES, the average savings over CES, on initial battery units requirement and
overall battery requirement are $13.50$% and $12.25$% respectively, as shown
in Table I and Fig. 5.

The results corroborate the effectiveness and the utility of the TES framework
presented with respect to battery resources requirements while providing
provable guarantees of meeting the power needs at the end of the prescribed
horizons. Therefore, it can be concluded that our proposed algorithm enables
DSO to mitigate the uncertainty of supplying the demand of the microgrids at
the requested time while reducing the battery requirement, thus enhancing grid
reliability and efficiency.

##  VI Conclusion

This article develops a novel TES framework containing multiple microgrids,
equipped with DER and critical infrastructure loads, and a DSO with
centralized battery storage, with the focus of efficient energy storage
allocation in real-time, to meet the load demands of the microgrids at the
requested time with almost sure guarantee. Explicit stochastic model of wind
generation is considered to represent the uncertainties of renewable
generations. The proposed algorithms mitigate the uncertainties of meeting the
load demands of the microgrids, due to intermittent renewable generations, at
the requested time, with almost sure guarantee. We also derive the energy
storage allocation policy for CES with no energy sharing facilities and
compare the results with TES. The simulation study shows that TES enables DSO
to have lower amount of battery storage than CES, while still maintaining the
guarantee of meeting the load demands of each microgrid.

##  Appendix A Probabilities and change factors calculation

Applying Ito’s lemma [27] to $\text{d}(\log P_{gi}(t))$ and, ignoring h.o.t.,

$\displaystyle\textstyle\text{d}(\log P_{gi}(t))$
$\displaystyle=\textstyle\frac{\partial(\log P_{gi}(t))}{\partial
P_{gi}(t)}\text{d}P_{gi}(t)+\frac{\partial^{2}(\log P_{gi}(t))}{\partial
P_{gi}^{2}(t)}\frac{(\text{d}P_{gi}(t))^{2}}{2}$
$\displaystyle=\textstyle\frac{\text{d}P_{gi}(t)}{P_{gi}(t)}-\frac{1}{2}\frac{1}{P_{gi}^{2}(t)}\sigma_{gi}^{2}P_{gi}^{2}(t)\text{d}t$
$\displaystyle=\textstyle-\frac{\sigma_{gi}^{2}}{2}\text{d}t+\sigma_{gi}\text{d}\hat{W}_{ti}=\textstyle-\frac{\sigma_{gi}^{2}}{2}\text{d}t+\sigma_{gi}\sqrt{dt}Z,$

where, $Z\sim\mathcal{N}(0,1)$ and
$\text{d}P_{gi}(t)=\sigma_{gi}P_{gi}(t)\text{d}\hat{W}_{ti}$.

Let $X_{n}^{i}=\log P_{gi}(t_{n})$. Therefore,

$\displaystyle\textstyle\hat{\mathbb{E}}[X_{n+1}^{i}-X_{n}^{i}]=-\frac{\sigma_{gi}^{2}}{2}\Delta
t,\ \text{Var}(X_{n+1}^{i}-X_{n}^{i})=\sigma_{gi}^{2}\Delta t.$

Under the transformed probability measure (13), using (2) we get,

$\displaystyle\text{Corr}((X_{n+1}^{i}-X_{n}^{i}),(X_{n+1}^{j}-X_{n}^{j}))=\rho_{ij}\sigma_{gi}\sigma_{gj}\Delta
t.$

Let $\mathcal{I}_{i}$ denote the set of indices of probabilities associated
with upward movement of $P_{gi}(t_{n})$ and
$\mathcal{I}_{ij}=(\mathcal{I}_{i}\cap\mathcal{I}_{j})\cup(\mathcal{I}_{i}^{c}\cap\mathcal{I}_{j}^{c})$,
for all $i,j\in\mathcal{I}$. Let $h_{i}=\log u_{i},i\in\mathcal{I}$, then,

$\displaystyle\textstyle-\frac{\sigma_{gi}^{2}}{2}\Delta t$
$\displaystyle=\textstyle
h_{i}(\sum_{k\in\mathcal{I}_{i}}P_{k}-\sum_{k\notin\mathcal{I}_{i}}P_{k}),$
(15a) $\displaystyle\textstyle\sigma_{gi}^{2}\Delta t$
$\displaystyle=\textstyle
h_{i}^{2}(\sum\limits_{k=1}^{2^{N_{m}}}P_{k})-h_{i}^{2}(\sum\limits_{k\in\mathcal{I}_{i}}P_{k}-\sum\limits_{k\notin\mathcal{I}_{i}}P_{k})^{2},$
(15b) $\displaystyle\textstyle\rho_{ij}\sigma_{gi}\sigma_{gj}\Delta t$
$\displaystyle=\textstyle
h_{i}h_{j}(\sum_{k\in\mathcal{I}_{ij}}P_{k}-\sum_{k\notin\mathcal{I}_{ij}}P_{k}),$
(15c) $\displaystyle 1$ $\displaystyle=\textstyle\sum_{k=1}^{2^{N_{m}}}P_{k}.$
(15d)

The above set of equations can be solved to find the values of
$P_{k},k\in\\{1,2,\ldots,2^{N_{m}}\\}$, $u_{i},d_{i},i\in\mathcal{I}$.

##  Appendix B Proof of Theorem 1

First, we derive a stochastic differential equation involving
$\hat{V}_{i}(P_{gi}(t),t)$ which mitigates the uncertainty associated with the
renewable generation $P_{gi}(t),i\in\mathcal{I}$. Then to guarantee the
critical demand is met at requested time $T_{f}$, we solve the differential
equation with the terminal condition (10) and find the allocation policy of
$\hat{a}_{i}(t)$ and $\hat{b}_{i}(t)$. In the subsequent development, the
explicit dependency of the variables on time $t$ is omitted for brevity of
notation.

The variation of the $P_{gi}(t)$ is governed by the dynamics (1). Also, since
$P_{b}$ is constant,

$\displaystyle\text{d}P_{b}=0.$ (16)

Applying the differentiation operator to the portfolio $\hat{V}_{i}$, given in
(8), we have,

$\displaystyle\text{d}\hat{V}_{i}$
$\displaystyle=\hat{a}_{i}\text{d}P_{gi}+\text{d}\hat{a}_{i}P_{gi}+\hat{b}_{i}\text{d}P_{b}+\text{d}\hat{b}_{i}P_{b}.$
(17)

Under the constraint (9) for all $t\in[0,T_{f}]$ and $i\in\mathcal{I}$, (17)
becomes

$\displaystyle\text{d}\hat{V}_{i}$
$\displaystyle=\hat{a}_{i}\text{d}P_{gi}+\hat{b}_{i}\text{d}P_{b}$
$\displaystyle=\hat{a}_{i}(\mu_{gi}P_{gi}\text{d}t+\sigma_{gi}P_{gi}\text{d}W_{ti}),$
(18)

where, the last step follows from (1) and (16). Applying Ito’s lemma [27] and
considering infinitesimal $\text{d}t$,

$\displaystyle\text{d}\hat{V}_{i}$
$\displaystyle=\textstyle\frac{\partial\hat{V}_{i}}{\partial
t}\text{d}t+\textstyle\frac{\partial\hat{V}_{i}}{\partial
P_{gi}}\text{d}P_{gi}+\textstyle\frac{1}{2}\frac{\partial^{2}\hat{V}_{i}}{\partial
P_{gi}^{2}}(\text{d}P_{gi}^{2})$
$\displaystyle=\textstyle\frac{\partial\hat{V}_{i}}{\partial
t}\text{d}t+\textstyle\frac{\partial\hat{V}_{i}}{\partial
P_{gi}}(\mu_{gi}\text{d}t+\sigma_{gi}\text{d}W_{ti})P_{gi}+\textstyle\frac{\sigma_{gi}^{2}P_{gi}^{2}}{2}\textstyle\frac{\partial^{2}\hat{V}_{i}}{\partial
P_{gi}^{2}}\text{d}t.$ (19)

Using, (B) and (19) we get,

$\displaystyle\left[\textstyle\frac{\partial\hat{V}_{i}}{\partial
t}+\mu_{gi}P_{gi}\textstyle\frac{\partial\hat{V}_{i}}{\partial
P_{gi}}+\textstyle\frac{1}{2}\sigma_{gi}^{2}P_{gi}^{2}\textstyle\frac{\partial^{2}\hat{V}_{i}}{\partial
P_{gi}^{2}}-\hat{a}_{i}\mu_{gi}P_{gi}\right]$
$\displaystyle\text{d}t+\left[\sigma_{gi}P_{gi}\textstyle\frac{\partial\hat{V}_{i}}{\partial
P_{gi}}-\hat{a}_{i}\sigma_{gi}P_{gi}\right]\text{d}W_{ti}=0.$ (20)

Note that, if $\hat{a}_{i}=\frac{\partial\hat{V}}{\partial P_{gi}}$ then
$[\sigma_{gi}P_{gi}\frac{\partial\hat{V}_{i}}{\partial
P_{gi}}-\hat{a}_{i}\sigma_{gi}P_{gi}]=0$, which eliminates the uncertainty.
Thus,

$\textstyle\frac{\partial\hat{V}_{i}}{\partial
t}+\textstyle\frac{1}{2}\sigma_{gi}^{2}P_{gi}^{2}\textstyle\frac{\partial^{2}\hat{V}_{i}}{\partial
P_{gi}^{2}}=0.$ (21)

Therefore, dynamic allocation of ReGUs and battery units to maintain the power
in the portfolio satisfying (21), mitigates the inherent uncertainty
associated with the renewable generation. Next, we derive the allocation
policy of $\hat{a}_{i}(t)$ and $\hat{b}_{i}(t)$ by solving (21) with the
terminal condition (10) to ensure that the critical demand is met almost
surely at the requested time $T_{f}$.

Let $\tau=T_{f}-t$, $x_{i}=\ln(P_{gi})$ for all $i\in\mathcal{I}$. Therefore,

$\displaystyle\textstyle\frac{\partial\hat{V}_{i}}{\partial t}$
$\displaystyle=-\textstyle\frac{\partial\hat{V}_{i}}{\partial\tau},\
\textstyle\frac{\partial\hat{V}_{i}}{\partial
P_{gi}}=\frac{1}{P_{gi}}\textstyle\frac{\partial\hat{V}_{i}}{\partial x_{i}},\
\textstyle\frac{\partial^{2}\hat{V}_{i}}{\partial
P_{gi}^{2}}=\textstyle\frac{1}{P_{gi}^{2}}\Big{[}\frac{\partial^{2}\hat{V}_{i}}{\partial
x_{i}^{2}}-\textstyle\frac{\partial\hat{V}_{i}}{\partial x_{i}}\Big{]}.$

From (21),

$\begin{split}\textstyle\frac{\partial\hat{V}_{i}}{\partial\tau}&=\frac{1}{2}\sigma_{gi}^{2}\textstyle\frac{\partial^{2}\hat{V}_{i}}{\partial
x_{i}^{2}}-\textstyle\frac{1}{2}\sigma_{gi}^{2}\textstyle\frac{\partial\hat{V}_{i}}{\partial
x_{i}}=A_{i}\textstyle\frac{\partial^{2}\hat{V}_{i}}{\partial
x_{i}^{2}}+B_{i}\textstyle\frac{\partial\hat{V}_{i}}{\partial
x_{i}},\end{split}$ (22)

where, $A_{i}=\frac{1}{2}\sigma_{gi}^{2}\ (A_{i}>0),\
B_{i}=-\frac{1}{2}\sigma_{gi}^{2}$. From (10), the final condition on power
portfolio $\hat{V}_{i}(P_{gi}(t),t=T_{f})$, or equivalently, initial condition
on $\hat{V}_{i}(x_{i},\tau=0)$ is given as:

$\hat{V}_{i}(x_{i},0)=\begin{cases}0&\text{if $x_{i}\geq\ln(D_{ci})$}\\\
D_{ci}-e^{x_{i}}&\text{if $x_{i}<\ln(D_{ci})$}.\end{cases}$ (23)

Let
$\hat{V}_{i}(x_{i},\tau)=e^{-(\alpha_{i}x_{i}+\beta_{i}\tau)}\hat{u}_{i}(x_{i},\tau)$,
where $\alpha_{i},\beta_{i}\in\mathbb{R}$. Then,

$\textstyle\frac{\partial\hat{V}_{i}}{\partial\tau}=e^{-(\alpha_{i}x_{i}+\beta_{i}\tau)}\left[\textstyle\frac{\partial\hat{u}_{i}}{\partial\tau}-\beta\hat{u}_{i}\right].$
$\displaystyle\mbox{Similarly,}\ \ \ \ \ \
\textstyle\frac{\partial\hat{V}_{i}}{\partial x_{i}}$
$\displaystyle=e^{-(\alpha_{i}x_{i}+\beta_{i}\tau)}\left[\textstyle\frac{\partial\hat{u}_{i}}{\partial
x_{i}}-\alpha_{i}\hat{u}_{i}\right],$
$\displaystyle\textstyle\frac{\partial^{2}\hat{V}_{i}}{\partial x_{i}^{2}}$
$\displaystyle=e^{-(\alpha_{i}x_{i}+\beta_{i}\tau)}\left[\textstyle\frac{\partial^{2}\hat{u}_{i}}{\partial
x_{i}^{2}}-2\alpha_{i}\textstyle\frac{\partial\hat{u}_{i}}{\partial
x_{i}}+\alpha_{i}^{2}\hat{u}_{i}\right].$

Therefore, using (22),

$\displaystyle\textstyle\frac{\partial\hat{u}_{i}}{\partial\tau}-\beta\hat{u}_{i}=A_{i}\left[\textstyle\frac{\partial^{2}\hat{u}_{i}}{\partial
x_{i}^{2}}-2\alpha_{i}\textstyle\frac{\partial\hat{u}_{i}}{\partial
x_{i}}+\alpha_{i}^{2}\hat{u}_{i}\right]+B_{i}\left[\textstyle\frac{\partial\hat{u}_{i}}{\partial
x_{i}}-\alpha_{i}\hat{u}_{i}\right],$

and thus,

$\displaystyle\textstyle\frac{\partial\hat{u}_{i}}{\partial\tau}=A_{i}\textstyle\frac{\partial^{2}\hat{u}_{i}}{\partial
x_{i}^{2}}+\left[B_{i}-2\alpha_{i}A_{i}\right]\textstyle\frac{\partial\hat{u}_{i}}{\partial
x_{i}}+\left[\beta_{i}+\alpha_{i}^{2}A_{i}-\alpha_{i}B_{i}\right]\hat{u}_{i}.$

Choosing $\alpha_{i}=\frac{B_{i}}{2A_{i}}$ and
$\beta_{i}=\frac{B_{i}^{2}}{4A_{i}}$, we get,
$\textstyle\frac{\partial\hat{u}_{i}}{\partial\tau}=A_{i}\textstyle\frac{\partial^{2}\hat{u}_{i}}{\partial
x_{i}^{2}}.$

Solution of this partial differential equation [28] is given by,

$\displaystyle\textstyle\hat{u}_{i}(x_{i},\tau)=$
$\displaystyle\textstyle\frac{1}{\sqrt{4\pi
A_{i}\tau}}\int_{-\infty}^{\infty}\textstyle\hat{u}_{i}(y,0)e^{-\frac{(x_{i}-y)^{2}}{4A_{i}\tau}}\text{d}y.$

Since, $\hat{V}_{i}(y,0)=e^{-(\alpha_{i}y)}\hat{u}_{i}(y,0)$,
$\alpha_{i}=\textstyle\frac{B_{i}}{2A_{i}}$,
$\beta_{i}=\textstyle\frac{B_{i}^{2}}{4A_{i}}$,

$\displaystyle\textstyle\hat{u}_{i}(x_{i},\tau)=\frac{1}{\sqrt{4\pi
A_{i}\tau}}\textstyle\int_{-\infty}^{\infty}e^{-\frac{(x_{i}-y)^{2}}{4A_{i}\tau}}e^{\alpha
y}\hat{V}_{i}(y,0)\text{d}y$ $\displaystyle=\textstyle\frac{1}{\sqrt{4\pi
A_{i}\tau}}\textstyle\int_{-\infty}^{\infty}e^{-\left[-\frac{B_{i}y}{2A_{i}}+\frac{(x_{i}-y)^{2}}{4A_{i}\tau}\right]}\hat{V}_{i}(y,0)\text{d}y$
$\displaystyle=\textstyle\frac{1}{\sqrt{4\pi
A_{i}\tau}}\textstyle\int_{-\infty}^{\infty}e^{-\left[\textstyle\frac{(y-B_{i}\tau-x)^{2}}{4A_{i}\tau}-\textstyle\frac{B_{i}x_{i}}{2A_{i}}-\textstyle\frac{B_{i}^{2}\tau}{4A_{i}}\right]}\hat{V}_{i}(y,0)\text{d}y$
$\displaystyle=\textstyle\frac{1}{\sqrt{4\pi
A_{i}\tau}}\textstyle\int_{-\infty}^{\infty}e^{-\left[\frac{(y-B_{i}\tau-
x_{i})^{2}}{4A_{i}\tau}-\alpha_{i}x_{i}-\beta_{i}\tau\right]}\hat{V}_{i}(y,0)\text{d}y$
$\displaystyle=\textstyle\frac{1}{\sqrt{4\pi
A_{i}\tau}}\textstyle\int_{-\infty}^{\infty}e^{-\left[\frac{(y-B_{i}\tau-
x_{i})^{2}}{4A_{i}\tau}\right]}e^{(\alpha_{i}x_{i}+\beta_{i}\tau)}\hat{V}_{i}(y,0)\text{d}y.$
(24)

Therefore, $\hat{V}_{i}(x_{i},\tau)$ is given by $\textstyle
e^{-(\alpha_{i}x_{i}+\beta_{i}\tau)}\hat{u}_{i}(x_{i},\tau)$, which can be
further expanded as:

$\displaystyle\textstyle\frac{1}{\sqrt{4\pi
A_{i}\tau}}\int_{-\infty}^{\infty}e^{-\left[\frac{(y-B_{i}\tau-
x_{i})}{2\sqrt{A_{i}\tau}}\right]^{2}}\hat{V}_{i}(y,0)\text{d}y$
$\displaystyle=\textstyle\frac{1}{\sqrt{2\pi\tau}\sigma_{gi}}\int_{-\infty}^{\infty}e^{-[(y+\textstyle\frac{\sigma_{gi}^{2}}{2}\tau-
x_{i})/(\sqrt{2}\textstyle\sigma_{gi}\tau)]^{2}}\hat{V}_{i}(y,0)\text{d}y$
$\displaystyle=\textstyle\frac{1}{\sigma_{gi}\sqrt{2\pi\tau}}\int_{-\infty}^{\infty}e^{-\frac{1}{2}\Big{[}\frac{(y+\frac{\sigma_{gi}^{2}}{2}\tau-
x_{i})}{\sigma_{gi}\sqrt{\tau}}\Big{]}^{2}}\hat{V}_{i}(y,0)\text{d}y.$ (25)

Applying the initial condition (23) to $\hat{V}_{i}(y,0)$ we get:

$\displaystyle\hat{V}_{i}(x_{i},\tau)=$
$\displaystyle\textstyle\frac{1}{\sigma_{gi}\sqrt{2\pi\tau}}\Big{[}\int_{-\infty}^{\ln(D_{ci})}e^{-\frac{1}{2}\big{[}\frac{(y+\frac{\sigma_{gi}^{2}}{2}\tau-
x_{i})}{\sigma_{gi}\sqrt{\tau}}\big{]}^{2}}(D_{ci}-e^{y})\text{d}y\Big{]}$
$\displaystyle=\underbrace{\textstyle\frac{D_{ci}}{\sigma_{gi}\sqrt{2\pi\tau}}\Big{[}\int_{-\infty}^{\ln(D_{ci})}e^{-\frac{1}{2}\big{[}\frac{(y+\frac{\sigma_{gi}^{2}}{2}\tau-
x_{i})}{\sigma_{gi}\sqrt{\tau}}\big{]}^{2}}\text{d}y\Big{]}}_{I_{1}}$
$\displaystyle\hskip
28.45274pt-\underbrace{\textstyle\frac{1}{\sigma_{gi}\sqrt{2\pi\tau}}\Big{[}\int_{-\infty}^{\ln(D_{ci})}e^{-\frac{1}{2}\big{[}\frac{(y+\frac{\sigma_{gi}^{2}}{2}\tau-
x_{i})}{\sigma_{gi}\sqrt{\tau}}\big{]}^{2}}e^{y}\text{d}y\Big{]}}_{I_{2}}.$

Let, $z_{i}=\frac{1}{\sigma_{gi}\sqrt{\tau}}(y+(\sigma_{gi}^{2}/2)\tau-
x_{i})\implies\text{d}z_{i}=\frac{1}{\sigma_{gi}\sqrt{\tau}}\text{d}y$.
Therefore,

$\displaystyle I_{1}$
$\displaystyle=\textstyle\frac{D_{ci}}{\sigma_{gi}\sqrt{2\pi\tau}}\Big{[}\int_{-\infty}^{\ln(D_{ci})}e^{-\frac{1}{2}\big{[}\frac{(y+\frac{\sigma_{gi}^{2}}{2}\tau-
x_{i})}{\sigma_{gi}\sqrt{\tau}}\big{]}^{2}}\text{d}y\Big{]}$
$\displaystyle=\textstyle
D_{ci}\Big{[}\frac{1}{\sqrt{2\pi}}\int_{-\infty}^{\frac{\ln(D_{ci})+\frac{\sigma_{gi}^{2}}{2}\tau-
x_{i}}{\sigma_{gi}\sqrt{\tau}}}e^{-\frac{1}{2}z_{i}^{2}}\text{d}z_{i}\Big{]}$
(26) $\displaystyle=\textstyle
D_{ci}\Phi\Big{[}\frac{\ln\left(\frac{D_{ci}}{P_{gi}}\right)+\frac{\sigma_{gi}^{2}}{2}\tau}{\sigma_{gi}\sqrt{\tau}}\Big{]},$

where, $\Phi(.)$ is the Cumulative Distribution Function of the standard
Gaussian random variable $\sim\mathcal{N}(0,1)$. Similarly,

$\displaystyle I_{2}$
$\displaystyle=\textstyle\frac{1}{\sigma_{gi}\sqrt{2\pi\tau}}\Big{[}\int_{-\infty}^{\ln(D_{ci})}e^{-\frac{1}{2}\big{[}\frac{(y+\frac{\sigma_{gi}^{2}}{2}\tau-
x_{i})}{\sigma_{gi}\sqrt{\tau}}\big{]}^{2}}e^{y}\text{d}y\Big{]}$
$\displaystyle=\textstyle\frac{e^{x}_{i}}{\sqrt{2\pi}}\int_{-\infty}^{\frac{\ln(D_{ci})+\frac{\sigma_{gi}^{2}}{2}\tau-
x_{i}}{\sigma_{gi}\sqrt{\tau}}}e^{-\frac{1}{2}\left[z_{i}-\sigma_{gi}\sqrt{\tau}\right]^{2}}\text{d}z_{i}.$
(27)

Let, $w_{i}=z_{i}-\sigma_{gi}\sqrt{\tau},\implies\text{d}w_{i}=\text{d}z_{i}$.
Therefore, from (B),

$\displaystyle I_{2}$
$\displaystyle=\textstyle\frac{e^{x_{i}}}{\sqrt{2\pi}}\int_{-\infty}^{\frac{\ln(D_{ci})+\frac{\sigma_{gi}^{2}}{2}\tau-
x_{i}-\sigma_{gi}^{2}\tau}{\sigma_{gi}\sqrt{\tau}}}e^{-\frac{1}{2}w_{i}^{2}}\text{d}w_{i}$
$\displaystyle=\textstyle
P_{gi}\Phi\Big{[}\frac{\ln\left(\frac{D_{ci}}{P_{gi}}\right)-\frac{\sigma_{gi}^{2}}{2}\tau}{\sigma_{gi}\sqrt{\tau}}\Big{]},$

where, $\Phi(.)$ is the Cumulative Distribution Function of the standard
Gaussian random variable $\sim\mathcal{N}(0,1)$. Therefore, substituting the
value of $\tau$,

$\displaystyle\hat{V}_{i}(P_{gi}(t),t)$
$\displaystyle=\textstyle(D_{ci})\Phi\Big{[}\frac{\ln\left(\frac{D_{ci}}{P_{gi}(t)}\right)+\frac{\sigma_{gi}^{2}}{2}(T_{f}-t)}{\sigma_{gi}\sqrt{(T_{f}-t)}}\Big{]}$
$\displaystyle-\textstyle
P_{gi}(t)\Phi\Big{[}\frac{\ln\left(\frac{D_{ci}}{P_{gi}(t)}\right)-\frac{\sigma_{gi}^{2}}{2}(T_{f}-t)}{\sigma_{gi}\sqrt{(T_{f}-t)}}\Big{]}.$
(28)

Comparing equation (B) with equation (8),

$\displaystyle\hat{a}_{i}(t)$
$\displaystyle=\textstyle-\Phi\Big{[}\frac{\ln\left(\frac{D_{ci}}{P_{gi}(t)}\right)-\frac{\sigma_{gi}^{2}}{2}(T_{f}-t)}{\sigma_{gi}\sqrt{(T_{f}-t)}}\Big{]},$
(29) $\displaystyle\hat{b}_{i}(t)$
$\displaystyle=\textstyle\frac{D_{ci}}{P_{b}}\Phi\Big{[}\frac{\ln\left(\frac{D_{ci}}{P_{gi}(t)}\right)+\frac{\sigma_{gi}^{2}}{2}(T_{f}-t)}{\sigma_{gi}\sqrt{(T_{f}-t)}}\Big{]}.$

This completes the proof.

##  Appendix C Derivation of stochastic differential equation of $V_{t}$ in
TES for RES uncertainty mitigation

Here, we derive the stochastic differential equation involving $V_{t}$ which
mitigates the uncertainty associated with all the renewable generation
$P_{gi}(t),i\in\mathcal{I}$ in case of TES.

From (1) and for constant $P_{b}$ (i.e. $\text{d}P_{b}=0$), and under the
rated power conservation (5), applying Ito’s lemma [27] on the differential of
$V_{t}$ and considering infinitesimal $\text{d}t$, we obtain:

$\displaystyle\textstyle\frac{\partial V_{t}}{\partial
t}\text{d}t+\sum\limits_{i=1}^{N_{m}}\frac{\partial V_{t}}{\partial
P_{gi}}\text{d}P_{gi}$
$\displaystyle+\frac{1}{2}\sum\limits_{i=1}^{N_{m}}\sum\limits_{j=1}^{N_{m}}\frac{\partial^{2}V_{t}}{\partial
P_{gi}\partial P_{gj}}\text{d}P_{gi}\text{d}P_{gj}$
$\displaystyle=\sum\limits_{i=1}^{N_{m}}a_{i}\text{d}P_{gi}.$

Using (1) and (3),

$\displaystyle\textstyle\Big{[}\frac{\partial V_{t}}{\partial
t}+\textstyle\sum\limits_{i=1}^{N_{m}}\mu_{gi}P_{gi}\frac{\partial
V_{t}}{\partial
P_{gi}}+\frac{1}{2}\sum\limits_{i=1}^{N_{m}}\sum\limits_{j=1}^{N_{m}}\sigma_{gi}\sigma_{gj}\rho_{ij}\frac{\partial^{2}V_{t}}{\partial
P_{gi}\partial
P_{gj}}P_{gi}P_{gj}\textstyle-\sum\limits_{i=1}^{N_{m}}a_{i}\mu_{gi}P_{gi}\Big{]}\text{d}t=\sum\limits_{i=1}^{N_{m}}\Big{[}a_{i}\sigma_{gi}P_{gi}-\frac{\partial
V_{t}}{\partial P_{gi}}\sigma_{gi}P_{gi}\Big{]}\text{d}W_{ti}.$

Note that, if $a_{i}=\frac{\partial V_{t}}{\partial P_{gi}}$, for all
$i\in\mathcal{I}$, uncertainty associated with all the renewable generation is
eliminated, and we have:

$\displaystyle\textstyle\frac{\partial V_{t}}{\partial
t}+\frac{1}{2}\sum\limits_{i=1}^{N_{m}}\sum\limits_{j=1}^{N_{m}}\sigma_{gi}\sigma_{gj}\rho_{ij}P_{gi}P_{gj}\frac{\partial^{2}V_{t}}{\partial
P_{gi}\partial P_{gj}}=0.$ (30)

Note that, if there are numerous microgrids present in the TES ($N_{m}>>1$),
theoretical solution of (30) to find the allocation policy of $a_{i}(t)$ and
$b(t)$, under the terminal condition (12), becomes intractable.

##  Appendix D Proof of Theorem 2

Given the dynamics of the renewable generation (1), we can find the value of
$V_{t}$ at any time $t\in[0,T_{f}]$, given the terminal condition (12), by
changing the probability measure using (13).

From (1), for all $i\in\mathcal{I}$,

$\displaystyle\textstyle\text{d}P_{gi}(t)$
$\displaystyle=\mu_{gi}P_{gi}(t)\text{d}t+\sigma_{gi}P_{gi}(t)(\text{d}\hat{W}_{ti}-\eta_{gi}\text{d}t)$
$\displaystyle=\textstyle\mu_{gi}P_{gi}(t)\text{d}t-\mu_{gi}P_{gi}(t)\text{d}t+\sigma_{gi}P_{gi}(t)\text{d}\hat{W}_{ti}$
$\displaystyle=\sigma_{gi}P_{gi}(t)\text{d}\hat{W}_{ti}.$ (31)

Applying differentiation operator to the portfolio (4) and since $P_{b}$ is
constant,

$\displaystyle\text{d}V_{t}=\textstyle\sum\limits_{i=1}^{N_{m}}a_{i}\text{d}P_{gi}=\textstyle\sum\limits_{i=1}^{N_{m}}a_{i}\sigma_{gi}P_{gi}\text{d}\hat{W}_{ti}.$

Therefore, for any $t\in[0,T_{f}]$, $\textstyle V_{T_{f}}=\textstyle
V_{t}+\int\limits_{t}^{T_{f}}\sum\limits_{i=1}^{N_{m}}a_{i}\sigma_{gi}P_{gi}\text{d}\hat{W}_{ti}$.
Hence, under the transformed probability measure, the expected value of
$V_{T_{f}}$, calculated at $t$, where $t\in[0,T_{f}]$ is,

$\displaystyle\hat{\mathbb{E}}[V_{T_{f}}]$ $\displaystyle=\textstyle
V_{t}+\hat{\mathbb{E}}[\int_{t}^{T_{f}}\sum\limits_{i=1}^{N_{m}}a_{i}\sigma_{gi}P_{gi}\text{d}\hat{W}_{ti}]$
$\displaystyle=\textstyle
V_{t}+\int_{t}^{T_{f}}\sum\limits_{i=1}^{N_{m}}a_{i}\sigma_{gi}P_{gi}\hat{\mathbb{E}}[\text{d}\hat{W}_{ti}]=V_{t},$

where, the last equality follows from the fact that
$\hat{\mathbb{E}}[\text{d}\hat{W}_{ti}]=0$, under the transformed probability
measure (13). From (12),

$\displaystyle V_{t}=\textstyle\hat{\mathbb{E}}[\text{max
}(\sum\limits_{i=1}^{N_{m}}(D_{ci}-P_{gi}(T_{f}),0)].$

This completes the proof.

## References

  * [1] IRENA, “Global energy transformation: A roadmap to 2050,” 2019, [Accessed 31 August 2020]. [Online]. Available: https://www.irena.org/-/media/Files/IRENA/Agency/Publication/2019/Apr/IRENA_Global_Energy_Transformation_2019.pdf
  * [2] GridWise, “Transactive energy systems research, development and deployment roadmap,” 2018, [Accessed 31 August 2020]. [Online]. Available: https://www.gridwiseac.org/pdfs/pnnl_26778_te_roadmap_dec_2018.pdf
  * [3] Y. Yang, S. Bremner, C. Menictas, and M. Kay, “Battery energy storage system size determination in renewable energy systems: A review,” _Renewable and Sustainable Energy Reviews_ , vol. 91, pp. 109–125, 2018.
  * [4] N. Kishore, D. Marqués, A. Mahmud, M. V. Kiang, I. Rodriguez, A. Fuller, P. Ebner, C. Sorensen, F. Racy, J. Lemery _et al._ , “Mortality in puerto rico after hurricane maria,” _New England journal of medicine_ , vol. 379, no. 2, pp. 162–170, 2018.
  * [5] S. Salinas, M. Li, P. Li, and Y. Fu, “Dynamic energy management for the smart grid with distributed energy resources,” _IEEE Transactions on Smart Grid_ , vol. 4, no. 4, pp. 2139–2151, 2013.
  * [6] Y. Liu, H. B. Gooi, Y. Li, H. Xin, and J. Ye, “A secure distributed transactive energy management scheme for multiple interconnected microgrids considering misbehaviors,” _IEEE Transactions on Smart Grid_ , vol. 10, no. 6, pp. 5975–5986, 2019.
  * [7] S. Hu, Y. Xiang, J. Liu, C. Gu, X. Zhang, Y. Tian, Z. Liu, and J. Xiong, “Agent-based coordinated operation strategy for active distribution network with distributed energy resources,” _IEEE Transactions on Industry Applications_ , vol. 55, no. 4, pp. 3310–3320, 2019.
  * [8] P. H. Divshali, B. J. Choi, and H. Liang, “Multi-agent transactive energy management system considering high levels of renewable energy source and electric vehicles,” _IET Generation, Transmission & Distribution_, vol. 11, no. 15, pp. 3713–3721, 2017.
  * [9] J. Zhang, B.-C. Seet, and T. T. Lie, “Dynamic energy scheduling for virtual power plant with prosumer resources using game theory,” in _2019 IEEE Power & Energy Society General Meeting (PESGM)_. IEEE, 2019, pp. 1–5.
  * [10] J. Wang, H. Zhong, J. Qin, W. Tang, R. Rajagopal, Q. Xia, and C. Kang, “Incentive mechanism for sharing distributed energy resources,” _Journal of Modern Power Systems and Clean Energy_ , vol. 7, no. 4, pp. 837–850, 2019.
  * [11] Y. K. Renani, M. Ehsan, and M. Shahidehpour, “Optimal transactive market operations with distribution system operators,” _IEEE Transactions on Smart Grid_ , vol. 9, no. 6, pp. 6692–6701, 2017.
  * [12] M. N. Akter, M. A. Mahmud, and A. M. Oo, “A hierarchical transactive energy management system for microgrids,” in _2016 IEEE Power and Energy Society General Meeting (PESGM)_. IEEE, 2016, pp. 1–5.
  * [13] Y. Xu, H. Sun, and W. Gu, “A novel discounted min-consensus algorithm for optimal electrical power trading in grid-connected dc microgrids,” _IEEE Transactions on Industrial Electronics_ , vol. 66, no. 11, pp. 8474–8484, 2019.
  * [14] S. M. Sajjadi, P. Mandal, T.-L. B. Tseng, and M. Velez-Reyes, “Transactive energy market in distribution systems: A case study of energy trading between transactive nodes,” in _2016 North American Power Symposium (NAPS)_. IEEE, 2016, pp. 1–6.
  * [15] Y. Zhang, Z. Y. Dong, F. Luo, Y. Zheng, K. Meng, and K. P. Wong, “Optimal allocation of battery energy storage systems in distribution networks with high wind power penetration,” _IET Renewable Power Generation_ , vol. 10, no. 8, pp. 1105–1113, 2016.
  * [16] A. Maleki, M. G. Khajeh, and M. Ameri, “Optimal sizing of a grid independent hybrid renewable energy system incorporating resource uncertainty, and load uncertainty,” _International Journal of Electrical Power & Energy Systems_, vol. 83, pp. 514–524, 2016.
  * [17] K. W. Hedman and G. B. Sheblé, “Comparing hedging methods for wind power: Using pumped storage hydro units vs. options purchasing,” in _2006 International Conference on Probabilistic Methods Applied to Power Systems_. IEEE, 2006, pp. 1–6.
  * [18] H. Verdejo, A. Awerkin, E. Saavedra, W. Kliemann, and L. Vargas, “Stochastic modeling to represent wind power generation and demand in electric power system based on real data,” _Applied Energy_ , vol. 173, pp. 283–295, 2016\.
  * [19] M. Olsson, M. Perninge, and L. Söder, “Modeling real-time balancing power demands in wind power systems using stochastic differential equations,” _Electric Power Systems Research_ , vol. 80, no. 8, pp. 966–974, 2010.
  * [20] M. B. Shadmand and R. S. Balog, “Multi-objective optimization and design of photovoltaic-wind hybrid system for community smart dc microgrid,” _IEEE Transactions on Smart Grid_ , vol. 5, no. 5, pp. 2635–2643, 2014.
  * [21] L. Olatomiwa, S. Mekhilef, M. S. Ismail, and M. Moghavvemi, “Energy management strategies in hybrid renewable energy systems: A review,” _Renewable and Sustainable Energy Reviews_ , vol. 62, pp. 821–835, 2016.
  * [22] F. Black and M. Scholes, “The pricing of options and corporate liabilities,” _Journal of political economy_ , vol. 81, no. 3, pp. 637–654, 1973.
  * [23] J. C. Cox, S. A. Ross, and M. Rubinstein, “Option pricing: A simplified approach,” _Journal of financial Economics_ , vol. 7, no. 3, pp. 229–263, 1979.
  * [24] B. B. Authority, “Wind generation and total load in the bpa balancing authority,” 2020, [Accessed 1 August 2020]. [Online]. Available: https://transmission.bpa.gov/business/operations/wind/
  * [25] M. Natrella _et al._ , “Nist/sematech e-handbook of statistical methods,” _Nist/Sematech_ , vol. 49, 2010.
  * [26] M. Hollander, D. A. Wolfe, and E. Chicken, _Nonparametric statistical methods_. John Wiley & Sons, 2013, vol. 751.
  * [27] C. Gardiner, _Stochastic methods_. Springer Berlin, 2009, vol. 4.
  * [28] L. C. Evans, _Partial differential equations_. American Mathematical Soc., 2010, vol. 19.