# Development and Evaluation of an Online Home Energy Management Strategy for
Load Coordination in Smart Homes with Renewable Energy Sources

Xiaoling Chen  Cory Miller  Mithun Goutham  Prasad Dev Hanumalagutti  Rachel
Blaser  Stephanie Stockar<EMAIL_ADDRESS>Center for Automotive Research,
The Ohio State University, Columbus, OH 43210, USA  The Ford Motor Company,
Dearborn, MI 48126, USA

###### Abstract

In this paper, a real time implementable load coordination strategy is
developed for the optimization of electric demands in a smart home. The
strategy minimizes the electricity cost to the home owner, while limiting the
disruptions associated with the deferring of flexible power loads. A multi-
objective nonlinear mixed integer programming is formulated as a sequential
model predictive control, which is then solved using genetic algorithm. The
load shifting benefits obtained by deploying an advanced coordination strategy
are compared against a baseline controller for various home characteristics,
such as location, size and equipment. The simulation study shows that the
deployment of the smart home energy management strategy achieves approximately
5% reduction in grid cost compared to a baseline strategy. This is achieved by
deferring approximately 50% of the flexible loads, which is possible due to
the use of the stationary energy storage.

###### keywords:

Home Energy Management Strategy, Load Coordination, Renewable Energy,
Decentralized Model Predictive Control

##  1 Introduction

The global energy demand is predicted to have a remarkable increase for the
next two decades [1], and the residential energy usage constitutes almost 40%
of the overall electricity consumption [2]. The growing power demand makes it
challenging for grid reliability, which is ensured by keeping a balance
between grid power generation and residential energy demand [3]. Moreover, the
power demand of the residential sector is characterized by fluctuating and
unpredictable demands due in part to the growing presence of local renewable
energy sources [4], and increasing adoption of electric vehicles [5]. Among
the smart grid infrastructure, demand-side management (DSM) is one of the most
common strategies adopted to help curb grid reliability issues [6, 7].
Specifically, time of use (TOU) and real time pricing schemes [8] have been
used for shaping the power demand and increasing the residential demand
predictability. These pricing schemes encourage home owners with cost
incentives to use less electricity during high demand times to flatten the
peak power curve. In this context, a home energy management (HEM) strategy
automates the scheduling by controlling flexible loads, such as laundry and
dishwasher operation, heating ventilation and air conditioning, renewable
energy sources and energy storage systems [9]. Online HEM approaches do not
require a-priori knowledge of future power demands, such as the ambient
temperature or appliance oprations, and are therefore suited for practical
deployment. In this scenario, Model Predictive Control (MPC) is often utilized
due to its ability to account for the dynamics of the system, input and state
constraints, uncertainties in the system and ability to minimize a performance
metric [10]. In the area of smart home technology, MPC has been proven to
achieve satisfactory performance in heating [11], cooling [12] and ventilation
[13]. However, due to the size of the problem and nonlinear dynamics of a
smart home, using exact approaches for optimal load coordination is often
computationally intractable [10]. For this reason, many online approaches for
load coordination rely on heuristic and meta-heuristic algorithms [14, 15, 16,
17, 18].

For example, [19] presents an MPC with genetic algorithm (GA) to reduce the
electricity cost and peak to average ratio by optimizing HVAC, laundry,
dishwasher and non-deferrable loads. The uncertain nature of integrated
renewable energy sources is considered in [20, 21, 22], where the load
scheduler optimizes the charge-discharge strategy of a coupled energy storage
system using a GA. More comprehensive studies on load coordination using meta-
heuristic approaches are presented, for example in [16] where genetic
algorithm was applied for the selection of temperature set points of the
residential heating, ventilation, and air conditioning (HVAC) unit to reduce
the electricity bills together with peak load. The controlled appliances are
extended in [18] to include laundry and dishwasher, and their delay in
activation. However, all these strategies were implemented offline, where all
user requests were known a-priori. In summary, current HEM strategies either
focus on specific appliances and can be implemented online or consider
multiple loads and renewable sources, but are only applicable offline. Hence,
there is a lack of a comprehensive online implementable HEM strategy that
coordinates all flexible loads.

Moreover, many studies analyzing different HEM strategy performance use case
specific evaluation metrics [23, 24, 10, 25, 26]. The lack of generalizability
of the performance metrics, makes it impossible to perform a comprehensive
evaluation of benefits from home energy management strategy under different
conditions, such as house location and seasonality. To evaluate the controller
performance in a variety of scenarios, a more general performance metric,
namely the deferral efficiency, is first introduced in this paper.

This paper presents a novel online scheduling strategy based on MPC that is
used to realize the DSM by managing load coordination in the presence of both
local renewable generation and an energy storage. Specifically, the smart home
is assumed to include an HVAC system, plug-in and battery electric vehicle
(xEV) charging, laundry and dishwasher, solar panels, and a stationary energy
storage system. The online implementable strategy is developed using a
hierarchical structure, where the optimization problems are solved using a
meta-heuristic approach. This structure achieves faster-than-real-time
computation time and near-optimal solutions also under large variations in the
home features and equipment. The performance of the controller is evaluated by
conducting year-long simulations with significant variations in the household
characteristics.

Results show that, the deployment of the smart HEM strategy achieves at least
5% reduction in grid cost compared to the baseline strategy. The absolute
savings are largely affected by the specific pricing scheme considered. In
fact, the proposed HEM strategy is capable of deferring approximately 50% of
the flexible loads. This is accomplished through a more frequent utilization
of energy storage to benefit from low grid electricity cost, and a more
effective utilization of renewable sources.

The remainder of the paper is structured as follows. First, the smart home
plant model is described and a baseline control is presented. Then, the
development of the new HEM strategy is discussed, together with the
application of the sequential scheme and GA integration. Next, a comprehensive
simulation campaign is conducted to investigate the performance of the real
time controller under different plant model settings. Finally, the results of
the simulation study are summarized and discussed with future steps.

##  2 Home Plant Model

Figure 1: Home Plant Model

The residential power consumption is determined by predicting controllable
household appliance loads, such as HVAC, smart devices, and xEV charging;
together with base user activities, such as cooking, cleaning, leisure [27,
28]. The household power sources are the electric grid and local renewable
generation from solar panels. or the discharge. The household model and
components are shown in Figure 1. The associated household power balance is:

$P_{Grid}+P_{Solar}+P_{ES}=P_{HVAC}+P_{xEV}+P_{D}+P_{ND}$ (1)

where $P_{Grid}$ is the grid power, $P_{Solar}$ is the power generated
locally, $P_{ES}$ is battery power, $P_{HVAC}$ is the power for the operation
of HVAC, $P_{xEV}$ is the power to charge the vehicle, $P_{D}$ is the power
load from controllable appliances, and $P_{ND}$ is the non-deferrable power.
It is worth noting that in the above formulation of power balance, a positive
energy storage power $P_{ES}$ corresponds to discharging the battery.

###  2.1 Photovoltaic System

The power generated by the photovoltaic panels is calculated using:

$P_{Solar}(t)=G(t)\cdot A_{PV}\cdot\eta_{PV}$ (2)

where $G(t)$ is the useful solar irradiation power density, $A_{PV}$ is the
total area of the solar panels, and $\eta_{PV}$ is the efficiency of the solar
panel, which is assumed to be a function of the ambient and panel temperature,
[29]. The useful solar irradiation power density, $G(t)$ is mapped based on
location, season, and panel tilt [28].

###  2.2 Residential Energy Storage

The power associated with the stationary energy storage is:

$P_{ES}(t)=\begin{cases}V_{ES}(t)\cdot I_{ES}(t)\cdot\eta_{ES}&I_{ES}(t)>0\\\
V_{ES}(t)\cdot I_{ES}(t)/\eta_{ES}&I_{ES}(t)<0\\\ \end{cases}$ (3)

where $\eta_{ES}$ is the constant battery charging and discharging efficiency,
$V_{ES}$ is the pack voltage, and $I_{ES}$ is the pack current.

The energy storage voltage is:

$V_{ES}(t)=V_{ES,cell}(t)\cdot N_{ES,series}$ (4)

where $N_{ES,s}$ is the number of cells in series, $V_{ES,cell}$ is the cell
voltage determined using a 0th-order equivalent circuit model [30]:

$\begin{split}V_{ES,cell}(t)=V_{OC}&(SOC_{ES},T_{ES})-R_{0}(SOC_{ES},T_{ES})\cdot
I_{ES,cell}(t)\end{split}$ (5)

where $I_{ES,cell}$ is the current applied to individual cells, $R_{0}$ is the
internal resistance of each cell which is a function of state of charge (SOC)
and temperature of the pack, and $V_{OC}$ is the open-circuit voltage, which
is function of SOC and pack temperature. Internal resistance and open circuit
voltage are mapped using [30]. The pack temperature is assumed to be either
the same as ambient temperature if stored outside, or the same as the house
temperature if stored inside. The cell current is calculated as:

$I_{ES,cell}(t)=\frac{I_{ES}(t)}{N_{ES,p}}$ (6)

Where $N_{ES,p}$ is the number of cells in the pack in parallel. Finally, the
SOC is determined us

$\frac{dSOC_{ES}(t)}{dt}=-\frac{I_{ES,cell}(t)}{Q_{cell}}$ (7)

where $Q_{Cell}$ is the nominal cell capacity.In this paper, it is assumed
that the ES starts empty, hence the initial SOC is 20%. The number of cells in
series and parallel are selected to meet the desired pack capacity
$Q_{ES,des}$ and voltage $V_{ES,des}$:

$Cells_{ES,parallel}=\frac{Q_{ES,des}}{Q_{cell}}$ (8)
$Cells_{ES,series}=\frac{V_{ES,des}}{V_{cell}}$ (9)

In this paper, the nominal ES size is 13.5kWh, 50V. Depending on the size of
the house, multiple energy storage units are added [28].

###  2.3 HVAC

The power of the HVAC is calculated for each season:

$P_{HVAC}(t)=\begin{cases}P_{heat}+P_{fan}&T_{\infty}\leq T_{ref}\\\
P_{cool}+P_{fan}&T_{\infty}>T_{ref}\\\ \end{cases}$ (10)

where $T_{\infty}$ is the environment temperature, and $T_{ref}$ is a
threshold temperature that determines whether the HVAC operates in heating or
cooling mode [27]. The power consumption is given by:

$\displaystyle P_{heat}$ $\displaystyle=\frac{\dot{m}_{HVAC}\cdot\pi(t)\cdot
c_{p}\cdot\Delta T}{COP(\Delta T)}$ (11) $\displaystyle\Delta T$
$\displaystyle=T_{HVAC}-T_{\infty}$ (12)

and

$\displaystyle P_{cool}$ $\displaystyle=\frac{\dot{m}_{HVAC}\cdot\pi(t)\cdot
c_{p}\cdot\Delta T}{SHR\cdot COP(\Delta T)}$ (13) $\displaystyle\Delta T$
$\displaystyle=T_{\infty}-T_{HVAC}$ (14)

where $\dot{m}_{HVAC}$ is the mass flow rate, $\pi$ is the fan command,
$c_{p}$ is the air specific heat at constant pressure, $\Delta T$ is the
temperature difference between the HVAC supply air temperature $T_{HVAC}$ and
ambient temperature, COP is the Coefficient of Performance, and SHR is the
Sensible Heat Ratio [27]. For heating mode, the fan command $\pi$ can only be
on or off, while in cooling mode, the fan command $\pi$ can be on, off, or
half load. The fan regulation power is:

$P_{fan}=\frac{\dot{m}_{HVAC}\cdot\Delta P}{\eta_{fan}\cdot\rho_{air}}$ (15)

where $\Delta P$ is the static pressure drop, $\eta_{fan}$ is the constant
efficiency of the fan, and $\rho_{air}$ is the air density.

The household temperature dynamics is

$\begin{split}m_{a}c_{v}\frac{d}{dt}T_{a}(t)=\pi(t)\cdot\dot{m}_{HVAC}\cdot
c_{p}[&T_{HVAC}-T_{a}(t)]-\frac{T_{a}(t)-T_{\infty}}{R_{tot}}\end{split}$ (16)

where $m_{a}$ is the mass of the air inside the house, $c_{v}$ is the air
specific heat capacity at constant volume, $T_{a}$ is the air temperature
inside the house, and $R_{tot}$ is the equivalent thermal resistance [31].

###  2.4 Plug-in Electric and Electric Vehicle Charging

The power required to charge the vehicle is

$P_{xEV}(t)=\frac{V_{xEV}(t)\cdot I_{xEV}(t)}{\eta_{xEV}}$ (17)

Where $\eta_{xEV}$ is the constant charge efficiency, $I_{xEV}$ is the
current, and $V_{xEV}$ is the pack voltage:

$V_{xEV}(t)=V_{xEV,cell}(t)\cdot N_{xEV,s}$ (18)

where $N_{xEV,s}$ is the number of cells in the pack in series. The cell
voltage $V_{xEV,cell}$ determined using a 0th order equivalent circuit model
[30]:

$V_{xEV,cell}(t)=V_{OC}(SOC_{xEV})-R_{0}(SOC_{xEV})\cdot I_{xEV,cell}(t)$ (19)

Where $I_{xEV,cell}$ is the current applied to individual cells, $R_{0}$ is
the internal resistance of each cell and $V_{OC}$ is the open-circuit voltage.
Both open circuit voltage and internal resistance are SOC dependent [30]. The
cell current is defined as

$I_{xEV,cell}(t)=\frac{I_{xEV}(t)}{N_{xEV,p}}$ (20)

Where $N_{ES,p}$ is the number of cells in the pack in parallel. Finally, the
SOC is

$\frac{dSOC_{xEV}(t)}{dt}=-\frac{I_{xEV,cell}(t)}{Q_{cell}(t)}$ (21)

where $Q_{cell}$ is the nominal cell capacity.

The number of cells in series and parallel are selected to meet the total pack
capacity $Q_{xEV,des}$ and voltage $V_{xEV,des}$ of a specific vehicle , which
is an input to the residential power demand model [28]. The initial SOC of the
vehicle at plug-in is determined as a function of vehicle efficiency and miles
traveled, which are randomized together with the time of plug-in. The vehicle
is charged using a standard level 2 charger with constant 7.56 kW and
following a constant-current constant-voltage protocol.

###  2.5 User Activities

A number of user activities associated with non-negligible power demand are
considered in this model. The user activity subsystem uses a statistical
approach and reproduces the ATUS census data [31, 8]. User activities are
divided among deferrable and non-deferrable loads. The non-controllable
activities include sleeping, no-power activity, cleaning, cooking, and
leisure. The power request associated with each non-controllable activity is
summarized in Table 1.

Table 1: Operating Power of Non-Controllable Activities

Activity | Power $P_{Act,NC}$ [W]
---|---
Sleeping | 0
No-Power Activity | 0
Cleaning | 1250
Cooking | 1225
Leisure | 300

Similarly, activities related to the utilization of smart appliances have been
incorporated. For laundry, an all-in-one machine is considered in which washer
and dryer are combined in a single unit. The power demands associated with
deferrable loads are summarized in Table 2.

Table 2: Operating Power and Duration of Controllable Appliances

Appliance | Power [W] | Duration [min]
---|---|---
Washer | 425 | 30
Dryer | 3400 | 30
Dishwasher | 1800 | 60

##  3 Baseline Control

To simulate the household model, a baseline controller is implemented to
reproduce the scenario of no load coordination. The strategy includes a dead-
band control for the HVAC and an energy storage controller that charges the
battery when there is solar surplus and discharges when the power demand is
not met directly from local generation. The other demands are fulfilled as
soon as requested, with no deferral.

###  3.1 HVAC Dead-Band Control

The baseline thermostat control of HVAC aims to keep the household temperature
$T_{a}$ within a desired bound. When the ambient temperature is above a
certain temperature threshold, the HVAC is set to cooling operation and will
turn on following:

$\pi_{cool}=\begin{cases}0&\text{if $T_{a}$ $\leq$ $T_{des,c}$ - $\Delta
T_{band}$}\\\ 1&\text{if $T_{a}$ $>$ $T_{des,c}$ + $\Delta T_{band}$}\\\
\end{cases}$ (22)

where $2\Delta T_{band}$ is the tolerance band, and $T_{des,c}$ is the desired
temperature for cooling.Conversely, when the ambient temperature is below a
threshold value, the HVAC is on the heating mode and activated using:

$\pi_{heat}=\begin{cases}1&\text{if $T_{a}$ $<$ $T_{des,h}$ - $\Delta
T_{band}$}\\\ 0&\text{if $T_{a}$ $\geq$ $T_{des,h}$ + $\Delta T_{band}$}\\\
\end{cases}$ (23)

where $T_{des,h}$ is the heating setpoint.

###  3.2 Energy Storage Charge and Discharge Control

The stationary energy storage is controlled based on the power balance of Eq.
1) and the availability of surplus solar energy. The baseline controller
utilizes the solar power to meet the instantaneous household power demand. If
the generation is greater than the demand and the SOC is less than 90%, the
surplus power is used to charge the battery. When the solar generation is less
than the total demand and the SOC of the battery is higher than 20%, power is
drawn from the energy storage system. Any additional power deficit is then
covered by drawing from the electrical grid:

$\pi_{ES}=\begin{cases}1&\text{if $SOC_{ES}$ $<$ $0.9$ \& $P_{Solar}$ $\leq$
$P_{Household}$}\\\ -1&\text{if $SOC_{ES}$ $>$ 0.2 \& $P_{Solar}$ $>$
$P_{Household}$}\\\ 0&\text{else}\\\ \end{cases}$ (24)

where $P_{Household}$ is the right hand side of Eq. (1).

##  4 Real Time Control

###  4.1 Optimization Problem Formulation

The objective of the smart home energy management algorithm is to coordinate
the scheduling of smart appliances, vehicle charging and operate the HVAC to
minimize the electricity cost in response to a TOU pricing scheme, and to
minimize the associated discomforts to the user. Resident discomforts are
formulated as a deferral cost associated with a delay in meeting a load demand
after it was requested, and as a temperature discomfort cost associated with
the temperature deviation from a desired set point. For the smart home
considered in this paper, the global optimal control problem is formulated in
discrete form as:

$\displaystyle\min_{u}J(x,u,w)=\sum_{k=0}^{N-1}$ $\displaystyle
c_{e,k}P_{Grid,k}+c_{d,k}\left[E(w_{k})-u_{k}\right]+c_{t,k}\left[T_{a,k}-T_{set}\right]^{2}$
(25a) $\displaystyle\text{Subject}~{}\text{to}\quad\quad\quad x_{k+1}$
$\displaystyle=f_{k}(x_{k},u_{k},w_{k})$ (25b) $\displaystyle x_{min}$
$\displaystyle\leq x_{k}\leq x_{max}$ (25c) $\displaystyle u_{HVAC,k}$
$\displaystyle\in\\{0,0.5,1\\}$ (25d) $\displaystyle 0$ $\displaystyle\leq
u_{xEV,k}\leq u_{max}$ (25e) $\displaystyle u_{min}$ $\displaystyle\leq
u_{ES,k}\leq u_{max}$ (25f) $\displaystyle u_{D/L,k}$
$\displaystyle\in\\{0,1\\}$ (25g) $\displaystyle u_{D/L/xEV,k}$
$\displaystyle=0~{}\forall k<E(w_{k})$ (25h) $\displaystyle u_{D/L/xEV,k}$
$\displaystyle=0~{}\forall k>D(w_{k})$ (25i)
$\displaystyle\sum_{k=0}^{N-1}u_{D/L/xEV,k}$ $\displaystyle=C$ (25j)
$\displaystyle u_{L/D,k}$ $\displaystyle\leq 1-s_{L/D,k}$ (25k) $\displaystyle
u_{L/D,k-1}-u_{L/D,k}$ $\displaystyle\leq 1-s_{L/D,k}$ (25l) $\displaystyle
s_{L/D,k}$ $\displaystyle\leq s_{L/D,k-1}$ (25m) $\displaystyle
P_{D,k}+P_{L,k}+P_{xEV,k}$
$\displaystyle+P_{HVAC,k}+P_{ND,k}=P_{Grid,k}+P_{ES,k}+P_{Solar,k}$ (25n)
$\displaystyle P_{Grid,k}$ $\displaystyle\leq P_{cap,k}$ (25o)

where $J(x,u,w)$ is the objective function, $k$ is the time step, $c_{e,k}$ is
the electricity price, $c_{d,k}$ is the deferral cost that penalizes the delay
in activation of an appliance after it was requested by the user, $T_{set}$ is
the temperature set point and $c_{t,k}$ is the cost associated with a
temperature deviation. The values of $c_{d,k}$ and $c_{t,k}$ are calibrated by
the user based on their tolerance of the associated discomfort. In this paper,
the electricity price is based on a TOU pricing scheme with $c_{e,k}$ as
defined in Figure 2. The deferral cost $c_{d,k}$ is constant at $6e^{-7}$
while $c_{t,k}$ is a time varying parameter that depends on real time ambient
and home temperatures.

Figure 2: TOU pricing scheme

The state vector is denoted as $x$, $u$ is the control vector, and $w$ is the
external inputs vector, which are defined as:

$\displaystyle x_{k}$ $\displaystyle=[T_{a,k},SOC_{xEV,k},SOC_{ES,k}]^{T}$
(26a) $\displaystyle u_{k}$
$\displaystyle=\left[u_{HVAC,k},u_{xEV,k},u_{D,k},u_{L,k},u_{ES,k}\right]^{T}$
(26b) $\displaystyle w_{k}$
$\displaystyle=\left[T_{\infty,k},P_{ND,k},SOC_{xEV,0},P_{Solar,k}\right]^{T}$
(26c)

where $u_{HVAC}$, $u_{xEV}$, $u_{D}$, $u_{L}$ and $u_{ES}$ are the control
commands for the HVAC, xEV charging, laundry, dishwasher and energy storage
respectively. The system disturbances $w_{k}$ are the ambient temperature, the
power demand of non-deferrable activities, the initial vehicle SOC
$SOC_{xEV,0}$ and the solar power generation. The system is subject to the
discrete state dynamic defined in Eq. (25b), while the states are constrained
based on Eq. (25c). Depending on the type of appliance, the control inputs
have different constraints. Specifically, the HVAC has three discrete modes of
operation as defined in Eq. (25d), the energy storage control input is limited
by a minimum and maximum power as defined in Eq. (25f), and the laundry and
dishwasher are controlled by binary signals as defined in Eq. (25g). All the
deferrable activities can only be completed after a request from the user, Eq.
(25h); must be completed before the deadline, Eq. (25i); and the duration is
limited by the completion time, Eq. (25j). Here, $E(w_{k})$ denotes the
enabling time of each appliance, $D(w_{k})$ is the last possible completion
time of that appliance, and $C$ is the duration of each operation. For the
dishwasher and laundry only, which are activities that cannot be interrupted
and resumed once initiated, a slack variable $s$ is introduced together with
the constraints defined by Equations (25k) - (25m). The household power must
satisfy the power balance defined in Eq. (25n) and the power drawn from the
grid should also be smaller than the capping power, as defined in Eq. (25o).
The completion time $C$ and deadline $D(w_{k})$ for the deferrable appliances
are summarized in Table 3. There needs to be nine and six time steps for
laundry and dishwasher to complete operation. The completion time for charging
xEV back to the desired SOC level depends on the initial xEV SOC. All the
three appliances need to complete the operation within 48 time steps after the
enabling time.

Table 3: Completion Time and Deadline (Time Steps) for Deferrable Appliances.

Appliances | Laundry | Dishwasher | xEV
---|---|---|---
Completion Time | 9 | 6 | Depends on initial SOC
Deadline | 48 | 48 | 48

Finally, $N$ represents the number of time steps over which this problem is
evaluated and $\Delta t$ is the associated discretization step. The total
simulation time $T_{end}$ is calculated as $T_{end}=N\cdot\Delta t$. Depending
on the objective of the study and types of models used, $T_{end}$ ranges from
days to months while $\Delta t$ varies from less than one second, to several
seconds [32, 11]. The values of the state and input constraints are summarized
in following equations:

$\displaystyle T_{ref}$ $\displaystyle=20\degree\text{C}$ (27) $\displaystyle
P_{cap}$ $\displaystyle=14\text{kW}$ (28) $\displaystyle T_{set}$
$\displaystyle=\begin{cases}22\degree\text{C},~{}\text{if $T_{\infty}$ $\leq$
$T_{ref}$}\\\ 18\degree\text{C},~{}\text{if $T_{\infty}$ $>$ $T_{ref}$}\\\
\end{cases}$ (29) $\displaystyle T_{set}-1\degree\text{C}$ $\displaystyle\leq
T_{a}\leq T_{set}+1\degree\text{C}$ (30) $\displaystyle 20\%$
$\displaystyle\leq SOC_{xEV}\leq 80\%$ (31) $\displaystyle 20\%$
$\displaystyle\leq SOC_{ES}\leq 80\%$ (32) $\displaystyle 0\text{A}$
$\displaystyle\leq u_{xEV}\leq 2.5N_{xEV,s}$ (33) $\displaystyle 0\text{A}$
$\displaystyle\leq u_{ES}\leq 2.5N_{ES,s}$ (34)

The solution of the optimization problem defined in Eq. (25) requires perfect
knowledge of the external input vector $w_{k}$ for the entire duration of the
simulation, which is impossible for online implementations. To compensate for
future uncertainties and enable online implementation, the optimization
problem defined in Eq. (25) is solved using a receding horizon approach, where
the external inputs are kept constant within the horizon and the combination
of control inputs that minimizes a performance metric while satisfying the
constraint is selected [33, 34]. In this paper, the MPC is solved using a time
horizon of 8 hours, which is selected to capture the deadline of each
operation. A discretization of $\Delta t=600s$ is selected to properly capture
the dynamic of the temperature in the house.

The other advantage of a receding horizon approach is that it scales well when
the total simulation time $T_{end}$ is large. However, the nonlinear system
dynamics, both integer and continuous control variables, and the large number
of states and control inputs make the optimization problem defined in Eq. (25)
computationally expensive for real-time implementation even for a finite time
horizon $T_{H}$ [17]. In such cases, a decentralized approach permits real-
time deployment by breaking down the original large problem formulation down
into multiple smaller decoupled sub-problems that can be solved sequentially
[35]. For this reason, a decentralized model predictive controller is proposed
in this paper to achieve faster than real-time computation without
compromising the optimality for the solution.

Figure 3: Hierarchical optimization scheme for the sub-problems of the HEM
strategy at one time step

###  4.2 Sequential Scheme for Decentralized Load Coordination

The centralized optimization problem defined in Eq. (25) is divided into three
equivalent sub-problems based on the frequency of each system requests and
activation. In this case the three problems are the optimization of the HVAC
system and energy storage; the vehicle charging and energy storage; and
laundry, dishwasher and energy storage. The scheduling of laundry and
dishwasher are combined due to their similarities in constraints and input
variable types, while the energy storage system is considered in each sub-
problem because it affects the amount of energy available to the other
controlled appliances, thereby affecting their scheduling, which indirectly
couples the appliances. The other indirect coupling among the sub-problems is
the capping constraint defined in Eq. (25o), but since this capping constraint
is violated infrequently, its satisfaction is verified after the completion of
the sequence of optimizations. The structure, hierarchy and interactions
between the sub-problems is shown in Figure 3.

####  4.2.1 HVAC and Energy Storage

The first sub-problem optimizes the operation of HVAC and energy storage over
the time horizon $T_{H}$, which is divided in to $N_{H}$ equal time steps. The
global cost function defined in Eq. (25a), is then modified to consider the
electricity cost associated with the heating and cooling and the temperature
deviation only. The other appliance loads are neglected, simplifying the state
dynamics to $f_{k}^{(1)}$, state vector $x_{k}^{(1)}$, control vector
$u_{k}^{(1)}$ and limiting the number of required constraints.

The first sub-problem is:

$\min_{u}J(x,u,w)=\sum_{k=0}^{N_{H}-1}c_{e,k}P_{HVAC,k}+c_{t,k}\left[T_{a,k}-T_{set}\right]^{2}$
(35a) Subject to: $\displaystyle x_{k+1}^{(1)}$
$\displaystyle=f_{k}^{(1)}(x_{k}^{(1)},u_{k}^{(1)},w_{k}^{(1)})$ (35b)
$\displaystyle x_{min}^{(1)}$ $\displaystyle\leq x_{k}^{(1)}\leq
x_{max}^{(1)}$ (35c) $\displaystyle u_{HVAC,k}$
$\displaystyle\in\\{0,0.5,1\\}$ (35d) $\displaystyle u_{ES,min}$
$\displaystyle\leq u_{ES,k}\leq u_{ES,max}$ (35e)
$\displaystyle\begin{split}P_{HVAC,k}&+P_{ND,k}\\\
&=P_{Grid,k}+P_{ES,k}+P_{Solar,k}\end{split}$ (35f)

Solving the above sub-problem yields the control commands
$u_{HVAC}^{(1)}\in\mathbb{R}^{N_{H}}$ for HVAC and
$u_{ES}^{(1)}\in\mathbb{R}^{N_{H}}$ for ES over the time horizon $T_{H}$. The
optimal HVAC command $u_{HVAC}^{(1)}$ and associated power demand
$P_{HVAC}^{(1)}\in\mathbb{R}^{N_{H}}$ over the horizon $T_{H}$ are then fed to
the next sub-problem as external inputs.

####  4.2.2 Vehicle Charging and Energy Storage

If xEV is plugged in by the user, the second optimization sub-problem
optimizes the schedule of the xEV charging and energy storage. Conversely, if
there is not vehicle plugged in, this step is skipped as the solution is
trivial. In this optimization, HVAC command is fixed as $u_{HVAC}^{(1)}$ over
$T_{H}$ and the corresponding power demand is known $P_{HVAC}^{(1)}$ and
fixed. Similar to the prior case, the global objective function is modified to
only include the cost of electricity drawn from the grid and associated with
the vehicle charging and the deferral cost. The other appliance loads are
neglected, simplifying the state dynamics to $f_{k}^{(2)}$, state vector
$x_{k}^{(2)}$, control vector $u_{k}^{(2)}$ and limiting the number of
required constraints. The optimization problem becomes:

$\displaystyle\min_{u}J(x,u,w)$
$\displaystyle=\sum_{k=0}^{N_{H}-1}c_{e}(k)P_{Grid,k}+c_{d,k}\left[E(w_{k})-u_{xEV,k}\right]$
(36a) $\displaystyle\text{Subject~{}to}:x_{k+1}^{(2)}$
$\displaystyle=f_{k}^{(2)}(x_{k}^{(2)},u_{k}^{(2)},w_{k}^{(2)})$ (36b)
$\displaystyle x_{min}^{(2)}$ $\displaystyle\leq x_{k}^{(2)}\leq
x_{max}^{(2)}$ (36c) $\displaystyle u_{min}^{(2)}$ $\displaystyle\leq
u_{xEV,ES,k}\leq u_{max}^{(2)}$ (36d)
$\displaystyle\begin{split}P_{xEV,k}&+P_{HVAC,k}^{(1)}+P_{ND,k}\\\
&=P_{Grid,k}+P_{ES}(k)+P_{Solar,k}\end{split}$ (36e) $\displaystyle u_{xEV,k}$
$\displaystyle=0~{}\forall k<E(w_{k})$ (36f) $\displaystyle u_{xEV,k}$
$\displaystyle=0,~{}\forall k>D(w_{k})$ (36g)
$\displaystyle\sum_{k=0}^{N_{H}-1}u_{xEV}(k)$ $\displaystyle=C$ (36h)

By including the constraint in Eq. (36e), the controller will account for both
energy generation and stored when deciding to draw power from the grid. This
is the reason for using $P_{Grid,k}$ in the cost function in place of
$P_{xEV,k}$. The results of the this optimization problem is the optimal
control commands for xEV $u_{xEV}^{(2)}\in\mathbb{R}^{N_{H}}$ and energy
storage $u_{ES}^{(2)}\in\mathbb{R}^{N_{H}}$.

####  4.2.3 Laundry, Dishwasher, and Energy Storage

If laundry or dishwasher is requested by the user, the third optimization sub-
problem is solved. If the user has not requested any appliance, this problem
is skipped as the result is trivial. As for the two previous problems, the
cost function, state dynamic, control inputs, external inputs and constraints
are all modified to represent the scheduling of the two non-interruptible
appliances. In this third level of the optimization, the control commands for
the HVAC and vehicle charging over $T_{H}$ are $u_{HVAC}^{(1)}$ and xEV
$u_{xEV}^{(2)}$. The third sub-problem is:

$\displaystyle\min_{u}J(x,u,w)=\sum_{k=0}^{N_{H}-1}$ $\displaystyle
c_{e,k}P_{Grid,k}+c_{d,k}\left[E(w_{k})-u_{D/L,k}\right]$ (37a)
$\displaystyle\text{Subject}~{}\text{to}:x_{k+1}^{(3)}$
$\displaystyle=f_{k}^{(3)}(x_{k}^{(3)},u_{k}^{(3)},w_{k}^{(3)})$ (37b)
$\displaystyle x_{min}^{(3)}$ $\displaystyle\leq x_{k}^{(3)}\leq
x_{max}^{(3)}$ (37c) $\displaystyle u_{D/L,k}$ $\displaystyle\in\\{0,1\\}$
(37d) $\displaystyle u_{D/L,k}$ $\displaystyle=0~{}\forall k<E(w_{k})$ (37e)
$\displaystyle u_{D/L,k}$ $\displaystyle=0~{}\forall k>D(w_{k})$ (37f)
$\displaystyle\sum_{k=0}^{N_{H}-1}u_{D/L,k}$ $\displaystyle=C$ (37g)
$\displaystyle u_{L/D,k}$ $\displaystyle\leq 1-s_{L/D,k}$ (37h) $\displaystyle
u_{L/D,k-1}-u_{L/D,k}$ $\displaystyle\leq 1-s_{L/D,k}$ (37i) $\displaystyle
s_{L/D,k}$ $\displaystyle\leq s_{L/D,k-1}$ (37j)
$\displaystyle\begin{split}P_{D,k}+P_{L,k}+P_{xEV,k}^{(2)}&+P_{HVAC,k}^{(1)}+P_{ND,k}\\\
=P_{Grid,k}+P_{ES,k}&+P_{Solar,k}\end{split}$ (37k)

The solution provides the optimal control commands for laundry
$u_{L}^{(3)}\in\mathbb{R}^{N_{H}}$, dishwasher
$u_{D}^{(3)}\in\mathbb{R}^{N_{H}}$, and energy storage
$u_{ES}^{(3)}\in\mathbb{R}^{N_{H}}$. Again, the total grid power is used
instead of the power associated with the appliances so that the effect of the
energy storage and local generation is caputred.

####  4.2.4 Power Capping Check

After determining the optimal control commands for HVAC $u_{HVAC}^{(1)}$,
vehicle charging $u_{xEV}^{(2)}$, laundry $u_{L}^{(3)}$, dishwasher
$u_{D}^{(3)}$ and energy storage $u_{ES}^{(3)}$ using the sequential scheme,
the total power request from the grid is calculated using Eq. (25n) and its
value is compared against the maximum allowable grid power defined in Eq.
(25o). If the constraint is violated at any time $k$ in $N_{H}-1$, the
algorithm finds the appliance with largest power demand during the constraint
violation window. This appliance is referred to as the Tabu Appliance in
Figure 3. The sequential optimization is performed again, but this time an
additional constraint is added to the sub-problem associated with the Tabu
Appliance that prevents the specific appliance to be utilized during those
time steps. The sequential optimization is repeated until the constraint is
satisfied.

The finalized optimal control commands are denoted as

$\begin{bmatrix}u_{HVAC}^{*},~{}u_{xEV}^{*},~{}u_{L}^{*},~{}u_{D}^{*},~{}u_{ES}^{*}\end{bmatrix}\in\mathbb{R}^{5\times
N_{H}}$ (38)

.

####  4.2.5 Shrinking Horizon Implementation

A shrinking time horizon ensures that every demanded activity is completed
within the simulation time [36]. Thus, as the simulation progresses towards
the final time step $T_{end}$, specifically when $T(k)+T_{H}>T_{end}$, the
time horizon is shrunk by replacing $T_{H}$ with $T_{H,Sh}$:

$T_{H,Sh}=T_{end}-T(k),\text{if}~{}T(k)+T_{H}>T_{end}$ (39)

###  4.3 Solution via Genetic Algorithm

Solving the sub-problems of the sequential controller to obtain the optimal
solution over the horizon $T_{H}$ requires significant computational effort.
To ensure that the computation is performed faster than real time, a meta-
heuristic algorithm is used. Among meta-heuristic approaches, GA provides near
optimal solutions in problems with integer commands [37]. For each sub-problem
described in section 4.2, a population of feasible control commands is first
initialized, where each individual in the population represents a candidate
solution for the appliance command over $T_{H}$ [38]. The objective value of
all individuals is then evaluated and the individuals are ranked in order of
lowest cost. The next population of candidate solutions is initialized with a
fixed number of lowest cost individuals. These parent individuals are then
modified, using both mutation and crossover, to generate the children and
compose the new generation. The fraction of new children constructed by
mutation and crossover are predefined parameters in the GA algorithm, as
summarized in Table 4.

Table 4: GA Settings for Sub-Problem Optimization

GA Options | HVAC | xEV | L/D
---|---|---|---
Summer | Winter
Maximum generation | 500 | 500 | 500 | 500
Maximum stalled generation | 50 | 50 | 50 | 50
Elite count | 10 | 10 | 15 | 20
Objective tolerance | 1e-2 | 1e-3 | 1e-4 | 1e-3
Time limit [s] | 30 | 30 | 30 | 30
Population size | 100 | 50 | 250 | 250
Crossover fraction | 0.4 | 0.2 | 0.4 | 0.2

Algorithm 1 Genetic Algorithm for HVAC Sub-Problem

1: Inputs

2: Obtain parameters: electricity price $c_{e,k}$, multi-objective function
weights $c_{d,k}$ and $c_{t,k}$.

3: Non-controllable user activities, external inputs including environment and
household characteristics, limits and constraints on states and inputs.

4: Select GA parameters based on appliance being optimized, using Table 4.

5: Initialization

6: Randomly generate the initial population of appliance commands
$[u_{HVAC,k}^{T},u_{ES,k}^{T}]$ based on selected creation function, $k$ is
the time step and $1\leq k\leq T_{H,Sh}$.

7: generation count := 1

8: Iteration

9: while “termination criteria of GA is not met” do

10: Evaluation

11: Evaluate the ﬁtness value for each individual of the population. This
involves the trade-off between grid electricity cost, delay cost, and
temperature discomfort cost, $J(x,u_{HVAC,k}^{T},u_{ES,k}^{T},w)$ using Eq.
(35a).

12: Evolution

13: selection function: assign parents as elite individuals of the current
generation.

14: crossover function: generate next generation children by crossover between
parents.

15: mutation function: generate next generation children by mutation of
parent.

16: end while

17: Select command $u_{HVAC}^{(1)},u_{ES}^{(1)}$ with the best fitness value
in the final population.

Population evolution is repeated until a defined stopping criteria is met
based on the time limit, number of generations, and number of “stalled”
generations where there was no improvement in objective value. For the three
sub-problems and depending on seasonality, the parameters are as summarized in
Table 4 and the GA is summarized in Algorithm 1.

In the HVAC and ES optimization sub-problem, each GA individual represents
their respective control commands given by $[u_{HVAC,k}^{T},u_{ES,k}^{T}]$
with a command vector length of $2N_{H}$. When the convergence criteria is
met, the individual with the lowest objective function value is saved and the
vector entries of this individual are assigned as the control commands for
HVAC $u_{HVAC}^{(1)}$ and energy storage $u_{ES}^{(1)}$.

To reduce the dimension of the xEV charge scheduling sub-problem, each
individual in the population represents the ES command and the time of xEV
charging instead of the xEV commands for the entire time horizon. The times of
activation vector $v_{xEV,GA}$ stores the $C$ discrete time steps
$\\{k_{1},k_{2},...,k_{C}\\}$ in the time horizon when the xEV charging
command is “on”. $C$ is calculated to satisfy the state constraint (36c), SOC
limit constraint (36c), enabling constraint (36f) and completion constraint
(36h). The commands are “off” at the other $N_{H}-C$ time steps. Through this
change of variable, the total length of the individual for the vehicle and
energy storage charging is reduced from $2N_{H}$ to $N_{H}+C$.

$\displaystyle v_{xEV,GA}=[k_{1},k_{2},\dotsc,k_{C}]^{T}$ (40a)
$u_{xEV,k}=\begin{cases}1,~{}\forall k\in v_{xEV,GA}\\\ 0,~{}\forall k\notin
v_{xEV,GA}\\\ \end{cases}$ (40b)

Finally, in the laundry and dishwasher sub-problem, a similar transformation
to the xEV is used for the appliance commands:

$v_{L,GA}=k_{L}$ (41a)
$u_{L}(k)=\begin{cases}1,~{}k\in\\{k_{L},k_{L}+1,...,k_{L}+C_{L}-1\\}\\\
0,~{}k\notin\\{k_{L},k_{L}+1,...,k_{L}+C_{L}-1\\}\\\ \end{cases}$ (41b) which
allows the use of a horizon of length $N_{H}+2$. $v_{D,GA}=k_{D}$ (41c)
$u_{D}(k)=\begin{cases}1,~{}k\in\\{k_{D},k_{D}+1,...,k_{D}+C_{D}-1\\}\\\
0,~{}k\notin\\{k_{D},k_{D}+1,...,k_{D}+C_{D}-1\\}\\\ \end{cases}$ (41d)

The GA individuals $v_{L,GA}$ and $v_{D,GA}$ for laundry and dishwasher store
the activation time steps of the two appliances and once initialized, they
remain active for following $C_{L}$ and $C_{D}$ time steps, which are the
completion time steps for laundry and dishwasher, as defined in Table 3.

##  5 Simulation Scenarios and Metrics

###  5.1 Case Studies

An extensive simulation campaign is conducted to study the performance of the
HEM strategy under variations of house location, seasonality, house size,
electric vehicle and energy storage battery sizes. A summary of the considered
locations, house sizes, xEV and ES battery sizes are summarized in Table 5.

Table 5: Case Studies Summary

Case | Location |  House Size (ft2) |  xEV Battery Size (kWh) |  ES Battery Size (kWh) |  ES Temp. Control
---|---|---|---|---|---
1 | Columbus | 1500-2500 | 60 | 14 | Yes
2 |  | 500-1500 |  | 14 |
3 |  | 2500-3500 |  | 14 |
4 | Columbus | 3500-4500 | 60 | 28 | Yes
5 | Los Angeles |  |  |  |
6 | San Antonio |  |  |  |
7 | Boston | 1500-2500 | 60 | 14 | Yes
8 |  |  | 25 |  |
9 | Columbus | 1500-2500 | 100 | 14 | Yes
10 |  | 2500-3500 |  | 28 |
11 | Columbus | 3500-4500 | 60 | 14 | Yes
12 | Columbus | 1500-2500 | 60 | 14 | No

###  5.2 Metrics

The performance evaluation of the HEM strategy against the baseline controller
is performed using the following metrics.

####  5.2.1 Cumulative Performance Metrics

First, the yearly operation of the HEMS is evaluated considering the
objectives in the optimization problem, namely the overall grid cost, the
temperature discomfort and the appliance delay time as defined in Eq. (25a).
These metrics are computed to understand the benefits to the user, while
providing a quantification of the discomfort. Moreover, they provide an
empirical verification on the optimality of the solution.

####  5.2.2 Appliance Load Deferral

The main limitation in using the overall cost savings as a metric for the HEMS
is that the improvements are subject to the specific pricing scheme
considered. To understand the ability of the HEMS to schedule flexible loads
independently of the relative costs, two new metrics are introduced for the
first time in this paper. First, the total deferred power $P_{Def,actual}$ is
defined by calculating how much of the requested flexible power has been
deferred. An example of this metric is shown in Figure 4 for the example of a
dishwasher operation and where $P_{Def}$ is the flexible power needed to
complete the operation.

Figure 4: Example Dishwasher Deferred Power

The second metric that is also related to the scheduling performance of the
HEMS is the deferral efficiency $\eta_{Def}$, defined as the percentage of the
actually deferred loads $P_{Def,actual}$ in the total deferrable loads
$P_{Def}$:

$\eta_{Def}=\dfrac{P_{Def,actual}}{P_{Def}}\cdot 100\%$ (42)

These two metrics will provide an insight on how much load the HEMS is able to
shift.

####  5.2.3 Solar Power Utilization and Energy Storage

Finally, to evaluate the effect of the presence of the stationary energy
storage system on the HEMS performance, the renewable energy split is
analyzed. In this case, the split consists in how much of the renewable energy
generation is used to instantaneously meet the household power demand, and how
much is instead stored in the stationary battery.

##  6 Simulation Results

###  6.1 Effect of House Size on Controller Performance

The effect of house size on the HEMS performance is analyzed for cases 1 to 4
of Table 5, where the same location is considered. The cumulative performance
metrics as function of house size are shown in Figure
LABEL:Fig:EffectHouseSize_CumulativePerformance. Results show that the average
total grid cost savings obtained by HEMS compared to the baseline controller
is approximately 6% and is insensitive to house size. As expected, the HEM
strategy obtains improved temperature control in smaller houses, which are
characterized by a faster temperature dynamics and therefore a predictive
strategy is effective compared to a rule-based approach. Moreover, there is a
consistent time delay in the operation of appliance and vehicle charging.

(a)

(b)

Figure 5: Effect of household size

The appliance load deferral metrics are shown in Figure
LABEL:Fig:EffectHouseSize_PowerDeferral. The results indicate that smaller
homes have a higher deferral efficiency compared to larger households. This is
because smaller homes have a larger relative xEV load, as the total power in
these homes is limited. On the other hand, the deferral efficiency tends to
decrease with larger house sizes. This is because larger house sizes require
more power to operate the HVAC, which reduces the load flexibility, as shown
in power summary for individual appliances in Table 7. Independently from
house size the HEMS deferral efficiency is always larger than 43%, showing
that the optimal strategy is delaying a large portion of the flexible power
demand. A summary of the deferring performance as function of home size over
one year of operation is shown in Table 6.

Table 6: Summary of the Annual Deferrable Power Demand Depending on Size of
the Household.

House Size [ft2] | 500-1500 | 1500-2500 | 2500-3500 | 3500-4500
---|---|---|---|---
Vehicle Charging [MWh] | 24.09 | 24.09 | 24.09 | 22.89
Laundry [MWh] | 0.49 | 0.49 | 0.49 | 0.49
Dishwasher [MWh] | 0.20 | 0.20 | 0.20 | 0.20
Total Deferrable [MWh] | 24.77 | 24.77 | 24.77 | 23.58
Deferred [MWh] | 12.16 | 11.43 | 11.24 | 10.29
Deferral Efficiency [%] | 49.08 | 46.16 | 45.38 | 43.64

Table 7: Summary of the Annual Power Demand Depending on Size of the
Household.

House Size [ft2] | 500-1500 | 1500-2500 | 2500-3500 | 3500-4500
---|---|---|---|---
HVAC [MWh] | 2.86 | 4.57 | 4.86 | 8.04
Non-Controllable Act [MWh] | 7.92 | 7.92 | 7.92 | 7.92
Total Non-Deferrable [MWh] | 10.78 | 12.49 | 12.78 | 15.96
Total Deferrable [MWh] | 24.77 | 24.77 | 24.77 | 23.58
Total Power [MWh] | 35.55 | 37.26 | 37.55 | 39.54

Finally, the energy storage utilization and power split metrics are shown in
Figure 6. The baseline controller uses the majority of the solar generation to
meet the power demand instantaneously. Conversely, because the HEM strategy
includes a prediction of future states, constraints and costs, a larger
portion of the solar power is stored in the battery compared to the baseline
controller.

(a)

(b)

Figure 6: Solar Power Utilization and Energy Storage Depending on Size of the
Household

Compared to baseline control, the solar power stored in the stationary energy
storage increases for increasing house size increases. Moreover, Figure
LABEL:SubFig:ESbeh shows that HEMS results in higher average SOC in smaller
homes.

Figures LABEL:SubFig:Case1_ES_SOC and LABEL:SubFig:Case4_ES_SOC illustrate the
SOC of the energy storage for the mid-sized home at 1606 ft2 and the largest
house size at 4252 ft2 respectively for a single day.

(a)

(b)

Figure 7: Energy Storage SOC in Two Controls and Two Household Sizes

For both house sizes, the frequency of charge and discharge events is higher
for the HEM strategy compared to the baseline control. However, for the larger
house, the average SOC appears to be lower for both baseline and HEM strategy
controllers. This is because the size of the stationary battery depends on the
house size. Hence, the SOC changing rate is lower in the largest house. When
comparing the absolute ampere-hour throughput of the two scenarios, the larger
house size still achieves a higher overall utilization of the energy storage,
as illustrated in Table 8.

Table 8: Total (1-Year) Ah-Throughput for Two Controls in Two Household Sizes

| 1606 ft2 | 4252 ft2
---|---|---
Baseline | 385 Ah | 343 Ah
HEM | 405 Ah | 480 Ah
Relative change | 5.2% | 40%

It is understood that as the house size increase, the relative power required
to the HVAC operation drastically increases, as shown in Figure 8. In this
figure, the percentage of the HVAC power relative to the total amount of power
is denoted as the numbers over the bar plot. In the larger house, the
increased HVAC relative power will result in greater discharge events of the
energy storage for larger house sizes. Additionally, the frequency of HVAC
operation is much higher for the HEM strategy compared to the baseline
operation which utilizes dead-band control.Therefore, there is a correlation
between increase in house size increases, and increased utilization of the
energy storage.

Figure 8: HVAC Power and Relative Percentage of Total Power

(a)

(b)

Figure 9: Effect of household location

###  6.2 Effect of House Location on Controller Performance

The effects of house locations on both HEM strategy and baseline controller
performance are analyzed by comparing cases 1, 5, 6, and 7 defined in Table 5.

As shown in Figure LABEL:Fig:EffectLocation_Cost, for all the house locations,
the average total grid cost savings of using the HEM strategy is 5.4% compared
to the baseline controller. It is also observed that the total energy saving
is almost insensitive to the house locations. On the other hand, Figure
LABEL:Fig:EffectLocation_Cost shows that the HEM strategy only obtains better
temperature control in Columbus compared to the other three locations,
especially for Los Angeles and San Antonio.

For locations with consistent higher ambient temperatures and due to the
structure of the HEMS temperature control, the resulting optimal home
temperature will be close to its upper bound. This strategy decreases the
overall HVAC power requirement, but leads to a higher overall temperature
difference. Conversely, for locations with either lower ambient temperatures
or more variability in ambient temperature over a year, the HEM strategy tends
to cycle the home temperature. As a result, the largest improvement in
temperature tracking compared to the baseline controller are observed in
Columbus.

The deferred power metrics in Figure LABEL:Fig:EffectLocation_PowerDeferral
show that there are variations of both total and individual deferred appliance
power among different locations. This is attributed to the fact that the house
sizes are different for the four locations even though the house size range is
the same, as between 1500 ft2 and 2500 ft2. The house sizes for the four
locations are listed in the first row of Table 9. As addressed in the
discussion on the effect of house size, larger house size requires greater
power to operate the HVAC. As a result, San Antonio has the lowest deferrable
power efficiency, as shown in Figure LABEL:Fig:EffectLocation_PowerDeferral.
The effects of house location on the house deferral efficiency are summarized
in the same figure. The deferral efficiency surpasses 42% for every presented
case, validating that the HEM strategy is effective. The power distribution
within the four house locations is summarized in Table 10.

Table 9: Summary of the Annual Deferrable Power Demand Depending on Location
and Size of the Household.

Location | Columbus | Los Angeles | San Antonio | Boston
---|---|---|---|---
Size | 1606 [ft2] | 1710 [ft2] | 2410 [ft2] | 2183 [ft2]
Vehicle Charging [MWh] | 24.09 | 22.37 | 20.74 | 24.94
Laundry [MWh] | 0.49 | 0.49 | 0.49 | 0.49
Dishwasher [MWh] | 0.20 | 0.20 | 0.20 | 0.20
Total Deferrable [MWh] | 24.77 | 24.97 | 25.85 | 29.64
Deferred [MWh] | 12.11 | 12.47 | 10.96 | 13.78
Deferral Efficiency [%] | 48.89 | 49.94 | 42.40 | 46.49

Table 10: Summary of the Annual Power Demand Depending on Location and Size of
the Household.

Location | Columbus | Los Angeles | San Antonio | Boston
---|---|---|---|---
Size | 1606 [ft2] | 1710 [ft2] | 2410 [ft2] | 2183 [ft2]
HVAC [MWh] | 2.86 | 1.91 | 4.43 | 4.01
Non-Controllable Act [MWh] | 7.92 | 7.85 | 7.89 | 7.93
Total Non-Deferrable [MWh] | 10.78 | 9.76 | 12.32 | 11.94
Total Deferrable [MWh] | 24.77 | 24.97 | 25.85 | 29.64
Total Power [MWh] | 35.55 | 34.73 | 38.17 | 41.58

Finally, Figure LABEL:Fig:EffectLocation_SolarEnergyStorage confirms that in
certain cases the HEM strategy is able to utilize the solar power more
efficiently by leveraging the energy storage system to lower the grid cost.
Even if the deferral efficiency is the lowest in San Antonio, the utilization
of the solar power to increase the energy storage SOC is the most significant
in this location. Hence, it is the non-deferrable power, typically HVAC, that
drives the split between storing the locally generated power or utilizing it
to meet the instantaneous demand. The utilization of the energy storage
relative to the baseline is in fact much larger in San Antonio than in any
other location, as shown in Figure LABEL:SubFig:Location_SolarUt.

(a)

(b)

Figure 10: Solar Power Utilization and Energy Storage Depending on Location of
the Household

##  7 Conclusions

This paper presents the development and comprehensive evaluation of an online
HEM strategy for the coordination of loads in a smart home. Compared to a
baseline strategy, the proposed HEM strategy succeeds in minimizing both grid
electricity cost in response to a TOU schedule and and user discomfort by
operation of deferrals. The evaluation of the HEM performance is conducted
based on the definition of systematic performance metrics, over multiple
simulations with one year duration and different household characteristics.

Results show the non-negligible impact of location, seasonality, battery size
and home size on the HEM strategy performance. The HEM strategy saves on
average $160 of the electricity cost to the user per year compared to the
baseline case. The deferrable appliance are rescheduled by HEM controller to
simultaneously benefit from low grid prices, renewable generation and
stationary energy storage. Moreover, simulations show that the optimal
strategy consists in charging the energy storage using the renewable sources,
rather than directly using them to meet the household power demand.
Additionally, the HEM strategy is shown to provide better temperature comfort
at a lower cost, compared to the traditional dead-band controller.

In all cases it is found that the energy storage is utilized more frequently
by the HEM strategy, compared to the baseline strategy. However, the battery
size for either the electric vehicle or the energy storage has a limited
effect of the performance of the HEM strategy. Conversely, the size and
location of the household is a main factor when evaluating the controller
performance. This is due to the relationship between home size and location
with the HVAC operation, which is not completely deferrable and is associated
to a large power demand. In fact, to meet temperature constraints, the HEM
strategy is forced to operate the HVAC during high price regions. This is
further confirmed by analyzing the deferral efficiency in locations with high
HVAC requirements, such as San Antonio. In this case, the low deferral
efficiency is coupled with a more aggressive utilization of the energy storage
system in an attempt to delay the HVAC load to low price regions.

Overall, the integration of renewable energy sources in the HEM strategy
results in a lower consumer energy cost, independently on the ability of the
controller to defer the load.

Finally, the stationary energy storage is operated more frequently by the HEM
strategy compared to the baseline, which results to higher currents (C-rate)
and larger spreads in SOC. Both of these conditions can lead to non-negligible
battery capacity fade. Future work will consider the utilization of the
battery inside the optimization problem.

##  8 Acknowledgement

The authors are grateful for the support of Ford Motor Company and the Ford-
OSU Alliance Program.

## References

  * [1] J. Conti, P. Holtberg, J. Diefenderfer, A. LaRose, J. T. Turnure, L. Westfall, International energy outlook 2016 with projections to 2040, Tech. rep., USDOE Energy Information Administration (EIA), Washington, DC (United States) (2016).
  * [2] A. Shewale, A. Mokhade, N. Funde, N. D. Bokde, A survey of efficient demand-side management techniques for the residential appliance scheduling problem in smart homes, Energies 15 (8) (2022) 2863.
  * [3] E. Sarker, P. Halder, M. Seyedmahmoudian, E. Jamei, B. Horan, S. Mekhilef, A. Stojcevski, Progress on the demand side management in smart grid and optimization approaches, International Journal of Energy Research 45 (1) (2021) 36–64.
  * [4] X. Liang, Emerging power quality challenges due to integration of renewable energy sources, IEEE Transactions on Industry Applications 53 (2) (2016) 855–866.
  * [5] S. Shao, M. Pipattanasomporn, S. Rahman, Challenges of phev penetration to the residential distribution network, in: 2009 IEEE Power & Energy Society General Meeting, IEEE, 2009, pp. 1–8.
  * [6] A. Shewale, A. Mokhade, N. Funde, N. D. Bokde, An overview of demand response in smart grid and optimization techniques for efficient residential appliance scheduling problem, Energies 13 (16) (2020) 4266.
  * [7] M. Neukomm, V. Nubbe, R. Fares, Grid-interactive efficient buildings, Tech. rep., US Dept. of Energy (USDOE), Washington DC (United States); Navigant (2019).
  * [8] U.S. Bureau of Labor Statistics, American time use survey, https://www.bls.gov/tus/home.htm (2003–2009).
  * [9] G. T. Costanzo, J. Kheir, G. Zhu, Peak-load shaving in smart homes via online scheduling, in: 2011 IEEE International Symposium on Industrial Electronics, IEEE, 2011, pp. 1347–1352.
  * [10] M. Beaudin, H. Zareipour, Home energy management systems: A review of modelling and complexity, Renewable and sustainable energy reviews 45 (2015) 318–335.
  * [11] H. Karlsson, C.-E. Hagentoft, Application of model based predictive control for water-based floor heating in low energy residential buildings, Building and environment 46 (3) (2011) 556–569.
  * [12] Y. Ma, F. Borrelli, B. Hencey, A. Packard, S. Bortoff, Model predictive control of thermal energy storage in building cooling systems, in: Proceedings of the 48h IEEE Conference on Decision and Control (CDC) held jointly with 2009 28th Chinese Control Conference, IEEE, 2009, pp. 392–397.
  * [13] S. Yuan, R. Perez, Multiple-zone ventilation and temperature control of a single-duct vav system using model predictive strategy, Energy and buildings 38 (10) (2006) 1248–1261.
  * [14] R. Hassan, B. Cohanim, O. De Weck, G. Venter, A comparison of particle swarm optimization and the genetic algorithm, in: 46th AIAA/ASME/ASCE/AHS/ASC structures, structural dynamics and materials conference, 2005, p. 1897.
  * [15] M. Rahmani-Andebili, H. Shen, Energy scheduling for a smart home applying stochastic model predictive control, in: 2016 25th international conference on computer communication and networks (ICCCN), IEEE, 2016, pp. 1–6.
  * [16] M. Hu, F. Xiao, Price-responsive model-based optimal demand response control of inverter air conditioners using genetic algorithm, Applied energy 219 (2018) 151–164.
  * [17] Y. Huang, W. Wang, B. Hou, A hybrid algorithm for mixed integer nonlinear programming in residential energy management, Journal of Cleaner Production 226 (2019) 940–948.
  * [18] X. Jiang, C. Xiao, Household energy demand management strategy based on operating power by genetic algorithm, IEEE Access 7 (2019) 96414–96423.
  * [19] Z. Zhao, W. C. Lee, Y. Shin, K.-B. Song, An optimal power scheduling method for demand response in home energy management system, IEEE transactions on smart grid 4 (3) (2013) 1391–1400.
  * [20] S. Li, J. Yang, W. Song, A. Chen, A real-time electricity scheduling for residential home energy management, IEEE Internet of Things journal 6 (2) (2018) 2602–2611.
  * [21] N. Javaid, G. Hafeez, S. Iqbal, N. Alrajeh, M. S. Alabed, M. Guizani, Energy efficient integration of renewable energy sources in the smart grid for demand side management, IEEE access 6 (2018) 77077–77096.
  * [22] A. Arabali, M. Ghofrani, M. Etezadi-Amoli, M. S. Fadali, Y. Baghzouz, Genetic-algorithm-based optimization approach for energy management, IEEE Transactions on Power Delivery 28 (1) (2012) 162–170.
  * [23] B. Yildiz, J. I. Bilbao, J. Dore, A. B. Sproul, Recent advances in the analysis of residential electricity consumption and applications of smart meter data, Applied Energy 208 (2017) 402–427.
  * [24] J. M. Veras, I. R. S. Silva, P. R. Pinheiro, R. A. Rabêlo, A. F. S. Veloso, F. A. S. Borges, J. J. Rodrigues, A multi-objective demand response optimization model for scheduling loads in a home energy management system, Sensors 18 (10) (2018) 3207.
  * [25] F. Brahman, M. Honarmand, S. Jadid, Optimal electrical and thermal energy management of a residential energy hub, integrating demand response and energy storage system, Energy and Buildings 90 (2015) 65–75.
  * [26] D. Thomas, O. Deblecker, C. S. Ioakimidis, Optimal operation of an energy management system for a grid-connected smart building considering photovoltaics’ uncertainty and stochastic electric vehicles’ driving schedule, Applied Energy 210 (2018) 1188–1206.
  * [27] M. Maiorino, S. Stockar, M. Sorrentino, G. Rizzoni, Modeling and simulation of residential power demand including transportation, in: Dynamic Systems and Control Conference, Vol. 57250, American Society of Mechanical Engineers, 2015, p. V002T29A003.
  * [28] M. Goutham, Machine learning based user activity prediction for smart homes, Ph.D. thesis, The Ohio State University (2020).
  * [29] L. Cristaldi, M. Faifer, M. Rossi, F. Ponci, A simple photovoltaic panel model: Characterization procedure and evaluation of the role of environmental measurements, IEEE transactions on instrumentation and measurement 61 (10) (2012) 2632–2641.
  * [30] L. Lam, P. Bauer, E. Kelder, A practical circuit-based model for li-ion battery cells in electric vehicle applications, in: 2011 IEEE 33rd International Telecommunications Energy Conference (INTELEC), IEEE, 2011, pp. 1–9.
  * [31] M. Muratori, Dynamic management of integrated residential energy systems, The Ohio State University, 2014.
  * [32] C. Ghiaus, I. Hazyuk, Calculation of optimal thermal load of intermittently heated buildings, Energy and Buildings 42 (8) (2010) 1248–1258.
  * [33] J. Richalet, A. Rault, J. Testud, J. Papon, Model predictive heuristic control, Automatica (journal of IFAC) 14 (5) (1978) 413–428.
  * [34] J. B. Rawlings, D. Q. Mayne, M. Diehl, Model predictive control: theory, computation, and design, Vol. 2, Nob Hill Publishing Madison, WI, 2017.
  * [35] P. D. Christofides, R. Scattolini, D. M. de la Pena, J. Liu, Distributed model predictive control: A tutorial review and future research directions, Computers & Chemical Engineering 51 (2013) 21–41.
  * [36] J. Ma, J. Qin, T. Salsbury, P. Xu, Demand reduction in building energy systems based on economic model predictive control, Chemical Engineering Science 67 (1) (2012) 92–100.
  * [37] Q. Liu, X. Li, H. Liu, Z. Guo, Multi-objective metaheuristics for discrete optimization problems: A review of the state-of-the-art, Applied Soft Computing 93 (2020) 106382.
  * [38] K. M. Passino, Biomimicry for optimization, control, and automation, Springer Science & Business Media, 2005.


\begin{align*}
sp.\left([Q, P\doublecap R]; \{P\}\right).T & = P\doublecap sp. [Q, P\doublecap R].T\\
&= \begin{cases}
P\doublecap 0 &\mbox{ if } T=0\\
P\doublecap (P\doublecap R) & \mbox{ if } T\le Q \mbox{ and } T\neq 0\\
P\doublecap I & \mbox{o.w.}
\end{cases}\\
&= P\doublecap sp. [Q, R].T\\
&=sp.\left([Q, R];\{P\}\right).T
\end{align*}

where the third equality follows from the fact that $P\doublecap ( P\doublecap Q) = P\doublecap Q$.

(Spc-Asst-Cond): For simplicity, we denote $P_1 \define P$ and $P_0 \define P^\bot$. Then from the assumptions,

\begin{align*}
sp.S_i.((P_i\doublecap Q)\doublecap X) &= R\doublecap sp.S_i.((P_i\doublecap Q)\doublecap X).
\end{align*}

Thus for any projector $T$,

\begin{align*}
&sp.\left(\{Q\}; \iif\ P[\bar{q}]\ \then\ \{P\doublecap Q\}; S_1\ \eelse\ \{P^
\bot\doublecap Q\}; S_0\ \pend; \{R\} \right).T\\
& = R\doublecap \left(\bigvee_{i=0}^1 sp.S_i.\left((P_i\doublecap Q)\doublecap (P_i\doublecap (Q\doublecap T))\right)\right)\\
&= \bigvee_{i=0}^1  \left(R\doublecap sp.S_i.\left((P_i\doublecap Q)\doublecap (P_i\doublecap (Q\doublecap T))\right)\right)\\
&= \bigvee_{i=0}^1  sp.S_i.\left((P_i\doublecap Q)\doublecap (P_i\doublecap (Q\doublecap T))\right)\\
&= \bigvee_{i=0}^1  sp.S_i.\left(P_i\doublecap (Q\doublecap T)\right)\\
&=sp.\left(\{Q\}; \iif\ P[\bar{q}]\ \then\ S_1\ \eelse\ S_0\ \pend\right).T
\end{align*}

where the second equality follows from Lemma <ref>, and the fourth from the fact that $P_i\doublecap (Q\doublecap T) \le P_i\doublecap Q$.

(Spc-Asst-While): Let $S_n$ be defined as in the proof of Lemma <ref> <ref>,  $S'_0 \define \abort$, and
$$S'_{n+1}\define \iif\ P[\bar{q}]\ \then\  \{P\doublecap Inv\}; S; \{Inv\}; S'_n\ \eelse\ \sskip\ \pend$$
for $n\geq 0$. Then for any projector $T$,

\begin{align}
&sp.\left(\{Inv\}; \while\ P[\bar{q}]\ \ddo\ \{P\doublecap Inv\}; S; \{Inv\}\ \pend; \{P^\bot\doublecap Inv\} \right).T \notag\\
& = (P^\bot\doublecap Inv)\doublecap \left(\bigvee_{n\geq 0} sp.S'_n.(Inv\doublecap T)\right)\notag\\
& = \bigvee_{n\geq 0} (P^\bot\doublecap Inv)\doublecap \left(sp.S'_n.(Inv\doublecap T)\right) \tag{*}
\end{align}

where the last equality follows from Lemma <ref>.
We claim that for any $n\geq 0$ and any $X$,

\begin{equation*}
(P^\bot\doublecap Inv)\doublecap \left(sp.S'_n.(Inv\doublecap X)\right) = sp.S_n.(Inv\doublecap X).
\end{equation*}

The case where $n=0$ is easy, since $S_0 = S'_0 = \abort$. Now we compute that

\begin{align*}
&(P^\bot\doublecap Inv)\doublecap \left(sp.S'_{n+1}.(Inv\doublecap X)\right)\\
& = (P^\bot\doublecap Inv)\doublecap \left( sp.S'_n.\left[Inv\doublecap \{sp.S.\left[(P\doublecap Inv)\doublecap (P\doublecap (Inv\doublecap X))\right]\}\right]\vee \left(P^\bot \doublecap (Inv\doublecap X)\right)\right)\\
& = \left( (P^\bot\doublecap Inv)\doublecap  sp.S'_n.\left[Inv\doublecap \{sp.S.\left[(P\doublecap Inv)\doublecap (P\doublecap (Inv\doublecap X))\right]\}\right]\right)\vee \left(P^\bot \doublecap (Inv\doublecap X)\right)\\
& = sp.S_n.\left[Inv\doublecap \{sp.S.\left[(P\doublecap Inv)\doublecap (P\doublecap (Inv\doublecap X))\right]\}\right]\vee \left(P^\bot \doublecap (Inv\doublecap X)\right)\\
& = sp.S_n.\left(sp.S.\left[(P\doublecap Inv)\doublecap (P\doublecap (Inv\doublecap X))\right]\right)\vee \left(P^\bot \doublecap (Inv\doublecap X)\right)\\
& = sp.S_n.\left(sp.S.\left[P\doublecap (Inv\doublecap X)\right]\right)\vee \left(P^\bot \doublecap (Inv\doublecap X)\right)\\
& = sp.S_{n+1}.(Inv\doublecap X)
\end{align*}

where the second equality follows from Lemma <ref>, the third from the induction hypothesis, and the fourth from the assumption that $\{P\doublecap Inv\};  S \equiv \{P\doublecap Inv\}; S; \{Inv\}$.

With the claim, we have

\begin{align*}
(*)& =\bigvee_{n\geq 0} sp.S_n.(Inv\doublecap T)=sp.\left(\{Inv\}; \pwstm\right).T. \qedhere
\end{align*}

§ CONSTRUCTIONS FOR FULL QUANTUM-TO-QUANTUM BERNOULLI FACTORY

$\mathit{Sum}[S_1,\cdots, S_n]\triangleq$      $\mathit{Add}[\mathit{Add}[\cdots \mathit{Add}[S_1, S_2], \cdots], S_n]$

$\mathit{Exp}_n\triangleq$      $\underbrace{\mathit{Mul}[\mathit{Mul}[\cdots \mathit{Mul}[\mathit{Init}_p, \mathit{Init}_p], \cdots], \mathit{Init}_p]}_{\mathrm{repeat\ }n \mathrm{\ times}}$   $(n\geq 2)$

$\mathit{Poly}_g\triangleq$      $\mathit{Sum}[\mathit{Cst}_{\alpha_0}, \mathit{Mul}[\mathit{Cst}_{\alpha_1},\mathit{Init}_p], \mathit{Mul}[\mathit{Cst}_{\alpha_2},\mathit{Exp}_2], \cdots,  \mathit{Mul}[\mathit{Cst}_{\alpha_n},\mathit{Exp}_n]]$

$\mathit{Simul}_h\triangleq$      $\mathit{Add}[ \mathit{Mul}[ \mathit{Mul}[ \mathit{Poly}_{g_1}, \mathit{Inv}[\mathit{Poly}_{g_2}] ], \qcoin] , \mathit{Mul}[ \mathit{Poly}_{g_3}, \mathit{Inv}[\mathit{Poly}_{g_4}] ] ]$

Further constructs for quantum-to-quantum Bernoulli factory, where
$g(p) = \sum_i\alpha_ip^i$ with $\alpha_i\in\mathbb{C}$ is polynomial of $p$, $h(p) = \frac{g_1(p)}{g_2(p)}\sqrt{\frac{p}{1-p}} + \frac{g_3(p)}{g_4(p)}$ is any quantum-to-quantum simulable function<cit.> with $g_i$ being polynomials of $p$.

Based on the constructs presented in Fig. <ref>, we further construct the programs $\mathit{Sum}$, $\mathit{Exp}_n$, $\mathit{Poly}_g$ and $\mathit{Simul}_h$ such that

\begin{align*}
&[I, |h_1+\cdots+h_n\>]_q \le \mathit{Sum}[F_{h_1},\cdots,F_{h_n}](q)\quad
&&[I, |p^n\>]_q \le \mathit{Exp}_n(q)  \\
&[I, |g\>]_q \le \mathit{Poly}_g(q)  \quad
&&[I, |h\>]_q \le \mathit{Simul}_h(q).
\end{align*}

$\mathit{Sum}$ and $\mathit{Exp}_n$ are refined by calling $\mathit{Init}_p$, $\mathit{Mul}$ and $\mathit{Add}$ repeatedly[We can also introduce an auxiliary variable that counts the iteration number rather than repeatedly calling subroutines in program scheme. Since $n$ and $h_i$ are regarded as parameters, we keep them in these simple forms.]:

\begin{align*}
[I, |h_1+\cdots+h_n\>] &\le \mathit{Add}[\mathit{Add}[\cdots \mathit{Add}[F_{h_1}, F_{h_2}], \cdots], F_{h_n}]\\
[I, |p^n\>] &\le \mathit{Mul}[F_{p^{n-1}}, F_{p}] \le \mathit{Mul}[\mathit{Mul}[\cdots \mathit{Mul}[F_{p}, F_{p}], \cdots], F_{p}] \\
&\le \underbrace{\mathit{Mul}[\mathit{Mul}[\cdots \mathit{Mul}[\mathit{Init}_p, \mathit{Init}_p], \cdots], \mathit{Init}_p]}_{\mathrm{repeat\ }n \mathrm{\ times}}.
\end{align*}

Then for any polynomial $g(p) = \alpha_0 + \alpha_1p + \sum_{i=2}^n\alpha_{i}p^{i}$, we give $\mathit{Poly}_g$ that refines $[I, |g\>]$:

\begin{align*}
[I, |g\>] &\le \mathit{Sum}[\mathit{Cst}_{\alpha_0}, \mathit{Mul}[\mathit{Cst}_{\alpha_1},\mathit{Init}_p],
\mathit{Mul}[\mathit{Cst}_{\alpha_2},\mathit{Exp}_2], \cdots,  \mathit{Mul}[\mathit{Cst}_{\alpha_n},\mathit{Exp}_n]].
\end{align*}

Finally, we construct the program $\mathit{Simul}_h$ that refine $[I, |h\>]$, i.e., it produces $|h\>$, where $h$ is an arbitrary simulable function of the form
$h(p) = \frac{g_1(p)}{g_2(p)}\sqrt{\frac{p}{1-p}} + \frac{g_3(p)}{g_4(p)}$ with $g_i(p)$ being polynomials of $p$:

\begin{align*}
[I, |h\>] &\le \mathit{Add}[ \mathit{Mul}[ \mathit{Mul}[ \mathit{Poly}_{g_1}, \mathit{Inv}[\mathit{Poly}_{g_2}] ], \qcoin] , \mathit{Mul}[ \mathit{Poly}_{g_3}, \mathit{Inv}[\mathit{Poly}_{g_4}] ] ].
\end{align*}

Now, we finish building all the remaining ingredients presented in Fig. <ref>, as well as the final program $\mathit{Simul}_h$ that produces $|h\>$ for any simulable function $h$.

§ : RZ ROTATION EXAMPLE

This section demonstrates the refinement of the Rz rotation example in Sec. <ref>.

§.§.§ Start the server.

is operated by commands. We can either invoke its interface in Python code or start a server for interactive proving. For the latter approach, the Python boot script is as follows:

import numpy as np
from quire import quire_server, predefined
opts =  "Rz" : predefined.Rz(np.arccos(3/5))
quire_server("./code", "./output", opts)

Here the parameters  and  specify the file for  code input and the information output. The server will monitor the modifications made in  and update the  file.  is a dictionary for string-matrix pairs which introduce user-defined operators into the prover. In our example, it is the target quantum gate .

§.§.§ Construct and test operators.

We start with defining new constants in the  file. The following code constructs operators $P^{00}$ and $P^{\neq 00}$ and outputs their matrix representation.

[fill=gray!20, inner xsep=5pt, inner ysep =5pt] (box)

Def P00 := [|00$\>$]. // The projector on |00>
Def Pnot00 := P00^$\bot$.
Eval P00.

is able to calculate projective predicates and test the order between operators. As an example, the following command verifies the statement that $P^{00}_{p, q} \wedge |+\>_{p}\<+| \sqsubseteq \boldsymbol{0}$.

[fill=gray!20, inner xsep=5pt, inner ysep =5pt] (box)

Test P00[p q] $\wedge$ Pp[p] <= c0[]. // [p ... q] denotes quantum registers

§.§.§ Construct programs and proofs.

We define the program pCircuit that will be used in the refinement.

[fill=gray!20, inner xsep=5pt, inner ysep =5pt] (box)

Def pCircuit := Prog
H[q0]; H[q1];
CCX[q0 q1 t]; S[t]; CCX[q0 q1 t];
H[q0]; H[q1];
if Pnot00[q0 q1] then Z[t] else skip end.

The refinement process can also be constructed in the form of a program statement. The following command checks $[|0\>_q\<0|, |1\>_q\<1|] \sqsubseteq q \apply X$ and defines the program ex as X[q] with the history of refinement.

[fill=gray!20, inner xsep=5pt, inner ysep =5pt] (box)

Def ex := Prog < P0[q], P1[q] > <= X[q].

§.§ Stepwise refinement of

Similar to other interactive theorem provers,  supports the tactic mode for stepwise refinement. The following code refines the target prescription $[\Omega_{t,t'}, \mathcal{R}_z (\theta)_t(\Omega_{t,t'})] \equiv [\Omega_{t,t'}, R_z(\theta)_t \Omega_{t, t'} R_z(\theta)_t^\dagger]$.

[fill=gray!20, inner xsep=5pt, inner ysep =5pt] (box)

Refine pf : < Omega[t t'], Rz[t] * Omega[t t'] * Rz[t]$\dagger$ >.
Step Seq Pnot00[q0 q1] * Omega[t t'].
Step [q0 q1] :=0; X[q0].
Def Inv0 := (Pnot00[q0 q1] $\otimes$ Omega[t t']) $\vee$ (P00[q0 q1] $\otimes$ (Rz[t] * Omega[t t'] * Rz[t]$\dagger$)).
Step While Pnot00[q0 q1] Inv IQOPT Inv0.
Step Seq P00[q0 q1] $\otimes$ Omega[t t'].
Step [q0 q1] :=0.
Step proc pCircuit.

See Fig. <ref> for an illustration.
As we proceed with every step, the updated information for the current goals is shown in the output file. As in Sec. <ref>, the first step is to insert an intermediate predicate using Step Seq command.
It turns the original prescription into two subgoals.
The next step finishes the first goal using [q0 q1] :=0; X[q0]. Regarding the second goal, we define the invariant Inv0 as in Sec. <ref>, then use command Step While to refine the goal prescription to a while program according to (Spc-Pres-While). The following steps complete the goal with an initialization [q0 q1] :=0 and the subprocedure pCircuit.

In the following code, the proof  is printed, the refinement result S0 is extracted as a quantum program, and the classical simulation of $\llbracket S0 \rrbracket (|+\>_t\<+|)$ is calculated.

[fill=gray!20, inner xsep=5pt, inner ysep =5pt] (box)

Show pf.
Def S0:= Extract pf. Show S0.
Def rho := [[proc S0]](Pp[t]). Show rho.

§ DOCUMENTATION OF

This section explains the Python interface, commands and syntax of . For further details, please refer to the GitHub repository at: <https://github.com/LucianoXu/Quire>.

§.§ Python interface

Reset the prover with extra operators in , and process the  commands in the string .

Reset the prover with extra operators in , and process the  commands in the file at .

Reset the prover with extra operators in , and start an interactive server which processes  commands in the file  and outputs information in the file .

Note: Modify and save the  file to update the input, and use  to close the server.

In the following introduction of syntax, $C$ denotes an identifier for a constant, $stm$ denotes a quantum program, $qvar$ denotes a quantum register, $o$ denotes an unlabelled operator, and $oi$ denotes a labelled quantum operator.

§.§  commands.

The  tool is manipulated by a simple imperative language, which consists of a sequence of commands.

The possible commands include:

*  $\texttt{Def}\ C\ \texttt{:=}\ o \texttt{.}$

Define the constant $C$ as the unlabelled operator $o$.

*  $\texttt{Def}\ C\ \texttt{:=}\ oi \texttt{.}$

Define the constant $C$ as the labelled operator $oi$. Here and below, labelled operators mean quantum operators operating on the specified quantum systems.

*  $\texttt{Def}\ C\ \texttt{:= [[}stm \texttt{]](} oi \texttt{).} $

Define the constant $C$ as the classical simulation result of executing the quantum program $stm$ on the quantum state $oi$.

*  $\texttt{Def}\ C\ \texttt{:=}\ \texttt{Prog}\ stm \texttt{.}$

Define the constant $C$ as the quantum program $stm$.

*  $\texttt{Def}\ C_1\ \texttt{:=}\ \texttt{Extract}\ C_2 \texttt{.}$

Define the constant $C_1$ as the program extracted from the program/proof $C_2$.

*  $\texttt{Refine}\ C : pres \texttt{.}$

Define $C$ as the prescription $pres$ and start the stepwise refinement mode on it.

*  $\texttt{Step}\ stm \texttt{.}$

(refinement mode) Try to refine the current goal with the program $stm$.

*  $\texttt{Step}\ \texttt{Seq}\ oi \texttt{.}$

(refinement mode) Apply the refinement rule (Comm-Pres-Cons) $[P, Q] \sqsubseteq [P, R]; [R, Q]$ to the current goal, where $R$ is specified by $oi$.

*  $\texttt{Step}\ \texttt{If}\ oi \texttt{.}$

(refinement mode) Apply the refinement rule (Spc-Pres-Cond):

[P,Q]_{\bar{q}}\equiv \iif\ R[\bar{q}]\ \then\ [R\doublecap P, Q]_{\bar{q}}\ \eelse\ [R^\bot\doublecap P, Q]_{\bar{q}}

to the current goal, where $R$ is specified by $oi$.

*  $\texttt{Step}\ \texttt{While}\ oi_1\ \texttt{Inv}\ oi_2 \texttt{.}$

(refinement mode) Apply the refinement rule (Spc-Pres-While)

[Inv, P^\bot \doublecap Inv]_{\bar{q}}\le \while\ P[\bar{q}]\ \ddo\ [P\doublecap Inv, Inv]_{\bar{q}}\ \pend

to the current goal, where $P$, $Inv$ are specified by $oi_1$, $oi_2$ respectively.

*  $\texttt{WeakenPre}\ oi \texttt{.}$

(refinement mode) Weaken the precondition of the goal to $oi$.

*  $\texttt{StrengthenPost}\ oi \texttt{.}$

(refinement mode) Strengthen the postcondition of the goal as $oi$.

*  $\texttt{Choose}\ N \texttt{.}$

(refinement mode) Chose the $N$-th goal as the current goal.

*  $\texttt{End} \texttt{.}$

(refinement mode) Complete the refinement when all goals are clear.

*  $\texttt{Pause} \texttt{.}$

(interactive server) Pause the parsing of the input file so that the current information of the prover can be shown in the output file.

*  $\texttt{Show}\ \texttt{Def} \texttt{.}$

Print all the names of definitions in the environment.

*  $\texttt{Show}\ C \texttt{.}$

Print the definition of $C$.

*  $\texttt{Eval}\ C \texttt{.}$

Evaluate the definition $C$ (e.g. operator expressions) and print the value.

*  $\texttt{Test}\ o_1\ \texttt{=}\ o_2 \texttt{.}$

Test whether $o_1 = o_2$ for the unlabelled operators $o_1$ and $o_2$.

*  $\texttt{Test}\ o_1\ \texttt{<=}\ o_2 \texttt{.}$

Test whether $o_1 \sqsubseteq o_2$ for the unlabelled operators $o_1$ and $o_2$.

*  $\texttt{Test}\ oi_1\ \texttt{=}\ oi_2 \texttt{.}$

Test whether $oi_1 = oi_2$ for the labelled operators $o_1$ and $o_2$.

*  $\texttt{Test}\ oi_1\ \texttt{<=}\ oi_2 \texttt{.}$

Test whether $oi_1 \sqsubseteq oi_2$ for the labelled operators $o_1$ and $o_2$.

§.§ Program Syntax

A quantum program $stm$ is constructed in the following ways:

*  $\texttt{abort}$

The abort program.

*  $\texttt{skip}$

The skip program.

*  $qvar \texttt{:=0}$

The initialization program.

*  $oi$

The unitary transformation.

*  $\texttt{assert}\ oi$

The assertion program.

*  $\texttt{< } oi_1\texttt{, } oi_2 \texttt{ >}$

The program prescription.

*  $ stm_1 \texttt{; }stm_2 $

The sequential composition. Right associative.

*  $ \texttt{(} stm_1\ \texttt{[} p\ \oplus\texttt{]}\ stm_2 \texttt{)}$

$ \texttt{(} stm_1\ \texttt{[} p\ \texttt{\textbackslash oplus}\texttt{]}\ stm_2 \texttt{)}$

The probabilistic composition. $p$ is a real number.

*  $ \texttt{if}\ oi\ \texttt{then}\ stm_1\ \texttt{else}\ stm_0\ \texttt{end}$

The if program.

*  $ \texttt{while}\ oi\ \texttt{do}\ stm\ \texttt{end}$

The while program.

*  $ \texttt{proc}\ C$

The program of subprocedure $C$.

*  $ pres\ \texttt{<=}\ stm$

The program representing a refinement from prescription $prec$ to program $stm$. In other words, it is the program $stm$ with the refinement history.  An error will be reported if the refinement is not valid.

§.§ Operator Syntax

In Quire, operators are categorized into unlabelled operators and labelled ones. Calculations involving unlabelled operators are limited to those with corresponding data types (qubit numbers). Additionally, due to automatic extensions, calculations between labelled operators are always permitted.

The grammar for unlabelled operators is:

\begin{aligned}
o ::=\ &C\ |\ [v]\ |\ - o\ |\ o + o\ |\ o - o\\
& |\ c * o\ |\ c\ o\ \\
& |\ o * o\ |\ o\dagger \\
& |\ o \otimes o\ \\
& |\ o \vee o\ |\ o \wedge o\ |\ o \verb|^| \bot \\
& |\ o \rightsquigarrow o\ |\ o \Cap o.
\end{aligned}

The operator $\texttt{[} v \texttt{]}$ corresponds to the projector $|v\>\<v|$. The syntax for $v$ is:

v ::=\ \ket{\texttt{<bit string>}}\ |\ v + v\ |\ c * v\ |\ c\ v.

The grammar for labelled operators is:

\begin{aligned}
oi ::= \ & \text{\texttt{IQOPT}}\ C\ |\ o\ qvar \\
& |\ -oi\ |\ oi + oi\ |\ oi - oi\\
& |\ c*oi\ |\ c\ oi\\
& |\ oi * oi\ |\ oi\dagger\\
& |\ oi \otimes oi\\
& |\ oi \vee oi\ |\ oi \wedge oi\ |\ oi\ \verb|^|\bot\\
& |\ oi \rightsquigarrow oi\ |\ oi \Cap oi.
\end{aligned}

The Unicode characters can be replaced by ASCII strings: $\dagger$ by , $\otimes$ by , $\vee$ by , $\wedge$ by , $\bot$ by , $\rightsquigarrow$ by  and $\Cap$ by .