# \[ANN\] ModelPredictiveControl.jl

**URL:** <https://discourse.julialang.org/t/ann-modelpredictivecontrol-jl/100147>\
**Category:** Package Announcements\
**Tags:** control, jump, controlsystems, nmpc\
**Created:** [June 10, 2023, 6:10pm UTC](https://discourse.julialang.org/t/ann-modelpredictivecontrol-jl/100147 "2023-06-10T18:10:43Z")\
**Posts on this page:** 1\
**Showing post:** 27

<div class="post-metadata">

**Author:** ![franckgaga](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/franckgaga/32/218241_2.png) [@franckgaga](https://discourse.julialang.org/u/franckgaga)\
**Post date:** [April 26, 2024, 2:42am UTC](https://discourse.julialang.org/t/ann-modelpredictivecontrol-jl/100147/27 "2024-04-26T02:42:59Z")

</div>

**`ModelPredictiveControl v.0.21.0`**

I’m super excited to announce two new major features:

1. linear model adaptation of controller/estimator at runtime
2. model linearization at non-equilibrium points

These features allow adaptive MPC based on online parameter estimation (e.g. recursive system identification). Furthermore, successive linearization MPC can now be implemented with [minimal effort](https://juliacontrol.github.io/ModelPredictiveControl.jl/dev/manual/nonlinmpc/#Adapting-the-Model-via-Successive-Linearization). It’s a great feature since e.g. MATLAB also [supports it](https://www.mathworks.com/help/mpc/ug/adaptive-mpc-control-of-nonlinear-chemical-reactor-using-successive-linearization.html), but the analytical expressions of the Jacobians are required (hidden in the “Successive Linearizer” block). This is not the case here with the AD-based `linearize` function. Also, similar functionalities are available for the `MovingHorizonEstimator`.

A massive and long refactoring of the operating points and the mathematical notation was required to support linearization at non-equilibrium points. It was totally worth it since the [successive linearization MPC on the pendulum](https://juliacontrol.github.io/ModelPredictiveControl.jl/dev/manual/nonlinmpc/#Adapting-the-Model-via-Successive-Linearization) is about 125 times faster than the NMPC counterpart, with similar closed-loop performances! It’s a great application of Julia’s AD tools and its first class linear algebra library!

**BREAKING CHANGE**  
All the keyword arguments related to initial values e.g. `σP0`, `x0` and `x̂0` now require an underscore e.g. `σP_0`, `x_0`, `x̂_0` (to clearly differentiate from deviation vectors around operating points)

- Added: `setmodel!` for runtime model adaptation of controller/estimator based on `LinModel`
- Added: `linearize` and `setop!` now support non-equilibrium points
- Added: successive linearization MPC with the new `setmodel!` and `linearize` functions
- Added: successive linearization MHE with the new `setmodel!` and `linearize` functions
- Added: `linearize!` method for in-place model linearization (to reduce allocations)
- Added: 6 args. `LinModel` constructor now support scalars (similarly to `ss` function)
- Added: `ExtendedKalmanFilter` now compute the Jacobians in-place (to reduce allocations)
- Changed: `struct` state data `x` and state estimate `x̂` renamed to `x0` and `x̂0`
- Debug: `ExplicitMPC` with non-`Float64` now works
- Debug: accept integers in `linearize` arguments
- Debug: call `empty!` on `JuMP.Model` to support re-construction of MPC instances
- Doc: new `setmodel!`, `setop!` and `linearize` function documentation
- Doc: example of model adaptation with successive linearization on the pendulum (very efficient!)

other changes, since my last post on discourse:

- Added: print info on controller and estimator constraint softening (slack var. `ϵ`)
- Added: custom estimator for the approximation of the arrival covariance in the MHE
- Added: improve performance of `LinMPC` and MHE with new JuMP batch update methods
- Various allocation reductions
- Changed: MHE now default to an `UnscentedKalmanFilter` for the arrival covariance estimation (instead of an EKF)
- Debug: MHE with `NonLinModel` update covariance with the correct state estimate

---

_[View the full topic](https://discourse.julialang.org/t/ann-modelpredictivecontrol-jl/100147)._
