I published my original repository on MPC for building energy controls some months ago. And I already stated my plan to update this. And I have done so. Since 2028/08/20, version 4 of the repository is available both at github and zenodo.
What has changed? Actually, quite a few things:
- The simulation no longer optimizes energy consumption, but also explicit flexibility. I follow a Dual-path approach, largely based on my keynote lecture in Splitech 2025.
- Optimization is switched from setpoints (real-type variable) to modes (the building selects between a set of 5-7 choices on HVAC operation modes). This resulted in a more robust and efficient optimization.
- The current optimization is fully in-line with market structure, with 15’ market slots; day-ahead, Intra-day and Continuous Intra-day markets, anticipated market clearance, and execution-time balancing mismatch between forecasted and real energy flows.
- The optimizer is redefined to take decisions specific for each market, with a Marginal Cost(Benefit) approach. This is, assuming that previously traded energy is available/committed free of cost/revenue. And differential costs/revenues associated with differential energy/flexibility flows/commitments are defined.
- We optimize for the future, but forecasting performance has some uncertainty. I have introduced some forecasting errors on purpose.
- A lot of code-re-structuration makes the current code more extendable and scalable (I already have plans for V5-V7).
- An impressive number of bug corrections (these just keep appearing).
Listing these changes is more complex than just making a bold statement: The optimizer now works substantially closer to how a real market-bound optimization should look like:
- It keeps the priority to deliver comfort (stable since V1)
- Participation in (secondary…) flexibility markets is possible (since V2 and improved in V4)
- The current simulation framework considers operation over concurrent markets in line with the market structure in Europe (since V3).
- A choice is given for optimizations in each market to focus on Energy Costs, Flexibility revenues…or just adjusting for forecast inaccuracy.
I believe that this is an interesting progress in our project STUNNED as it aims at optimizing the energy performance of buildings in such a way that they can participate in energy markets.
I typically paste some figures in my posts to make it nicer for the audience. But I just discovered that I did not create any (new) nice figure. So I will leave it for V5…
So, what may come next:
- The code currently only simulates downward flexibility (load reduction). I aim at allowing also for load stimulation and upward flexibility.
- The code currently only commits flexibility, but it should incorporate also the execution of flexibility.
- Multi-asset optimization (i.e. Building + Battery + PV) shall be incorporated by developing simulators for these and integrating these into the optimization.
Hopefully these and some others may be available by the end of 2026.
The repository is available here: Roberto Garay-Martinez, Model Predictive Control for Buildings, 2026, https://github.com/robgaray/Model-Predictive-Control-in-Buildings, https://doi.org/10.5281/zenodo.18030578
If you are curious, have some feedback, are facing a similar problem… please contact me.