Major changes
Full customization of the MPC or MHE optimization problem is now possible.
Instead of using ``MPC.setup()`` to finalize the MPC optimization problem, an alternative two step process is now possible:
- ``MPC.prepare_nlp()``
- ``MPC.create_nlp()``
In between these two calls, users can add custom constraints and terms to the cost function using state, input etc. variables from different time-steps, collocation points or scenarios.
A typical example would be to constrain changes of inputs or two enforce a cyclic behavior over the course of the horizon.
The new feature is fully documented and we suggest to have a look at the API reference for the MPC or MHE object.
Backend
Model
Internal functions in ``do_mpc.model.Model`` class have now properly named inputs and outputs. These inputs/outputs were previously automatically named ``i0, i1, ...``. They are now name e.g. ``_x, _u, _z ...``.
Here is an example (from the backend):
python
self._rhs_fun = Function('rhs_fun',
[_x, _u, _z, _tvp, _p, _w], [self._rhs], variables
["_x", "_u", "_z", "_tvp", "_p", "_w"], ["_rhs"]) names
This may help for debugging because we now have that:
python
model = do_mpc.model.Model("continuous")
....
model.setup()
print(model._rhs_fun)
Returns
Function(rhs_fun:(_x[6],_u,_z[3],_tvp,_p[2],_w[0])->(_rhs[6]) SXFunction)