\[eq:occupancyProjection\].[^10] The optimization is then $$\begin{aligned}\min_{u_{k}\cdots u_{k+N-1}}\quad & \sum_{j=0}^{N-1}\tilde{x}_{k+j}^{\top}{\mathbb{E}\left[\Gamma_{k+j}\mid\Gamma_{k}\right]}Q\tilde{x}_{k+j}+r\left|u_{k+j}\right|\\
\textrm{subject to\quad} & \begin{aligned}\tilde{x}_{i+1} & =\tilde{A}\tilde{x}_{i}+\tilde{B}u_{i}\quad\forall i\in\mathbb{Z}^{+}\\
0 & \le u\le u_{\max}
\end{aligned}
\end{aligned}$$ As with conventional MPC, the controller applies $u_{k}$ to the system and discards $u_{k+1}\ldots u_{k+N-1}$; the solution is repeated at each subsequent step.

The controller never reaches the setpoint $\tau$ for two reasons. First, including energy in the cost function counteracts temperature regulation, with the trade-off tuned through the ratio $\beta/r$. Second, the discomfort cost is weighted by *expected* occupancy, which never reaches 1.0. We have chosen to penalize $\left|u\right|$, rather than $u^{2}$, because quadratic cost suppresses peaks and spreads control action over time; peak suppression inhibits the full system shutdown necessary to save energy during vacancy. When high occupancy is predicted, the discomfort cost (Figure \[fig:Cost-function\]) becomes steeper and causes the temperature to more closely approach the setpoint.

![\[fig:Cost-function\]Discomfort cost for high expected occupancy (blue) and low expected occupancy (red). When high occupancy is predicted, the curve steepens and less deviation from the setpoint is permitted.](costFunction)

Comparison to Conventional Control
==================================

Experimental Setup
------------------

To demonstrate the algorithm’s advantages over conventional control, we have run a simulation under the following conditions:

-   MERL occupancy data for 