Implementing a two staged MPC

Hi all!

acados is a great tool, that I am using for my research project where I am implementing a building heating controller that is able to achieve certain optimization goals. I have been following the discussions in this forum for some time and I also found some posts very helpful . However, I have observed that most topics are adressing the tool itself and not MPC in general. In this topic I would like to talk about an unusual approach.

I have been thinking about a two staged controller and I would like to know your opionion on that.

The idea is, that one solves a first optimal control problem (ocp1) and uses the optimal control trajectory of ocp1 as a parameter vector for the second optimal control problem (ocp2).

What would the use case look like?
One can use weather forecasts as an input to ocp1 to predict a building’s heating demand. Let us assume that the building is equiped with a thermal storage and that energy costs are time varying. In this case the solution of ocp2 would tell how to load the thermal storage cost efficiently so that the heating demand determinded by ocp1 can be met.

What do you think? Is this approach worth a try? Another approach could be to expand the system’s differential equation and solve a single ocp.

Best,
Christian

Hi Christian,

I think such topics can enrich the forum, so I made another category for broader MPC discussions.

I think, these kinds of two/multi stage MPC controllers are quite useful in practice.
For example in the field of autonomous driving, it is common to have a path planner and a controller that tracks the planned trajectory.

Such controllers are especially useful if the problem can be distributed naturally into subproblems that can be solved with different frequencies.
This way the most low-level controller, has to solve a relatively low-dimensional problem, that is often also more linear, since nonlinearities are handled on a higher level. Overall this allows for faster feedback and to compute things that are changing on a slower time-scale (like the heating demand in your case) less often.

Overall, this seems to be a promising approach for your kind of problem.
Good luck! I am interested to hear more about how it goes.

Best,
Jonathan

Hey Jonathan,

that is a good idea to create a new category. Hopefully this will encourage poeple to exchange their “special tricks” that made their MPC applications work even better. :slight_smile:

Thanks for your reference to automous driving and solving the OCP in different time scales. It makes totally sense to use the MPC in the same cascaded way as in classical control loops.

My idea to solve two different OCPs arises from the limitations that come from using a simple least squares cost function. What I want to achive is to preheat the building or the thermal storage during periods of low energy prices, so that the heat demand during high-price periods is lower. My very first approach was in the form of J = (T_setpoint-T_indoor)^2 + Energy_costs^2. Of course this form has the limitation, that the optimal solution will not result in heating the building above the setpoint significantly.

@FreyJo: Your feedback encourages me to try the two staged approach. If I have any first results, I will post them.

For the interested reader: My model is implemented in Matlab/Simulink and I use the generated s-function. For the two staged MPC one needs the full horizon control sequence. Therefore the s-function has to be modified as discussed in this topic:

If anyone else has any hints: those are very welcome! :slight_smile:

Best,
Christian