A Predictive Controller Learned From Data

A district heating network with a combined heat and power plant, pipes and buildings

Open the District Heating Network app

Advanced Control Exercise 28 of 30 in Uncertainty and Machine Learning · All exercises · Time: 15 minutes

Hot water sent into a district heating network arrives at a building when the flow says it will, an hour or more later. A centralized MPC times the supply against that delay and the plant's costs. Then one building's model is replaced by a matrix of its own past inputs and outputs, a predictor learned from data with no physics in it. This exercise measures what the data model predicts and what planning on it costs.

Learning Outcomes

  • Explain how a Hankel matrix of past inputs and outputs can stand in for a state-space model in prediction.
  • State the persistency-of-excitation condition that a data predictor needs.
  • Compare a physics model and a data model of the same building by prediction error and the cost of planning on each.

Book Chapter

Model Predictive Control and Economic Optimization (Volume 9), Chapter 6, Pricing Heat in a District Heating Network Whose Delay Follows the Flow. Read the chapter, open the PDF, or watch the lecture slides.

Theory in Brief

Stack a record of inputs `u` and outputs `y` into a block Hankel matrix with `L` rows per signal:

$$H_L(w) = \begin{bmatrix} w_1 & w_2 & \cdots & w_{T-L+1} \\ w_2 & w_3 & \cdots & w_{T-L+2} \\ \vdots & & & \vdots \\ w_L & w_{L+1} & \cdots & w_T \end{bmatrix}$$

For a linear system, if the input is persistently exciting of order `L + n` (the Hankel matrix of `u` with depth `L+n` has full row rank), every trajectory of length `L` is a combination of the columns. Split the rows into a past window `p` and a future `f`; a future trajectory is predicted by finding `g` with

$$\begin{bmatrix} U_p \\ Y_p \\ U_f \end{bmatrix} g = \begin{bmatrix} u_{ini} \\ y_{ini} \\ u \end{bmatrix}, \qquad \hat y = Y_f\, g$$

where `u_{ini}, y_{ini}` are the latest measured window and `u` the planned inputs. With noisy data a regularizer `\lambda\|g\|` keeps `g` small. DeePC puts this predictor inside the MPC in place of `x_{k+1} = Ax_k + Bu_k`. Like an LSTM or a transformer forecast, it is a model fitted to windows of records; unlike them, it is exact for noise-free linear data and needs no training beyond collecting the matrix.

Model: Physics-based network with transport delays; one building is modeled either by two thermal capacities or by a Hankel matrix of its own records.
Decision: Supply temperature and heat sources, from a centralized MPC or from local plans agreeing on a price of heat.
Learning: The Hankel predictor is learned from a day and a half of the building's own data; no parameters are fitted.

Exercise

Read 2 min · Predict 1 min · Run 7 min · Explain 3 min · Check your AI 2 min.

Predict. A predictor learned from a day and a half of one building's data replaces its two-capacity physics model. Will it predict the building's temperature 6 h ahead as well as the physics? What will planning on it cost?

Run the District Heating Network app. Use the fastest speed, 0.25 h/s, and press Run again to pause at the times in each step.

  1. Open 4 · Centralized MPC: when to send heat (Centralized MPC). Press Run to the pause at 18 h and watch when the MPC raises and lowers the supply temperature. Read Fuel cost and Fuel cost, stores valued.
  2. Open 8 · A building learned from its own data. Run to midnight (24 h), set Apartments 1 model to Hankel (data) (Advanced), and run to 48 h. Read Prediction, 6 h ahead (Apartments 1) and Fuel cost.
  3. Reload the case (↻), keep the two-capacity model, and run to 48 h. Read the same tiles.

Explain.

  1. When does the centralized MPC raise the supply temperature, and why then rather than when the demand arrives?
  2. The data model predicts worse than the physics, yet the cost difference is small. What does that say about when data models are good enough?

Generative AI Learning

"Explain data-enabled predictive control (DeePC): how a Hankel matrix of past data replaces a state-space model, and what persistency of excitation means. When would it predict worse than a physics model?"

Check the answer against your run: A good answer writes the Hankel prediction equations, defines persistency of excitation as a rank condition, and names noise, nonlinearity and too little excitation as reasons for error. Your step 2 prediction tile is the test. The assistant is your tutor and reviewer; you answer for every claim you turn in.

What to Turn In

A table with fuel cost and the 6-hour prediction error for the Hankel and two-capacity models, your written prediction, and three sentences that answer the two questions.

The centralized MPC charges the network in the evening, when the CHP has heat to spare, and lets the supply fall at the morning peak; Fuel cost reads $9696 · CHP 239.0 MWh · boiler 19.4 MWh and with the stores valued $9953 · stores −1.5 MWh (tank −3.2 · pipes −4.3 · buildings +6.0). Heat sent now arrives an hour or more later, so the plan sends it while it is cheap and lets the pipes and buildings carry it to the peak.

Planning Apartments 1 on the Hankel predictor, the prediction tile reads Hankel 0.50 K · two-capacity 0.15 K · 57 columns and the two days' Fuel cost $26188 · CHP 627.7 MWh · boiler 65.3 MWh. With the two-capacity model throughout, the tile reads Hankel 0.36 K · two-capacity 0.15 K · 57 columns and the cost $26141 · CHP 634.4 MWh · boiler 59.2 MWh. The data model predicts several times worse than the physics model, which has the building's own structure and constants, a bound no fitted model reaches. It still plans well enough that the bill differs by well under one percent: the case text reports that the block's own thermostat guard added heat for some hours where the learned model under-predicted, which kept comfort at a small cost. The app dithers the block's setpoint on purpose to keep the data exciting. A data model is good enough when its errors cost less than building the physics would.

Measured with the app build of December 3, 2026 by a scripted replay of the steps above. Numbers that no tile shows come from the replay's record; your readings from the trends will be close. A later app release may move the last digit.

LSTM Forecast and Transformer Forecast fit neural forecasts. Export this run's CSV, build a Hankel predictor for Apartments 1 in Python with `numpy.linalg.lstsq`, and train an LSTM on the same first day and a half. Compare their 6-hour errors on the second day.

Related

References

  1. Hedengren, J. D. (ed.), Model Predictive Control and Economic Optimization, Volume 9 of Interactive Control Engineering, Chapter 6, "Pricing Heat in a District Heating Network Whose Delay Follows the Flow", pp. 125–148, Advanced Process Solutions, 2026. PDF (CC BY 4.0).
  2. Coulson, J., Lygeros, J., Dörfler, F., Data-enabled predictive control: in the shallows of the DeePC, European Control Conference, 307–312, 2019.
  3. Willems, J. C., Rapisarda, P., Markovsky, I., De Moor, B. L. M., A note on persistency of excitation, Systems & Control Letters 54(4), 325–329, 2005.

Course Information

TCLab

Project

Applications

Advanced Control Exercises

Exams

Modeling

Machine Learning

Estimation

Control

Reinforcement Learning

Related Courses

Admin