[ANN] ModelPredictiveControl.jl



I’m currently writing a model predictive control package for Julia. Here’s a quick list of the main features:

  • Both linear and nonlinear plant models are supported. The implementation exploits multiple dispatch.
  • The optimization is based on JuMP.jl, allowing to quickly compare the performances of many optimizers.
  • The nonlinear predictive controller, and also the extended Kalman Filter and the moving horizon estimator (both will be added soon), uses automatic differentiation for the Jacobian.
  • Both internal model structure (classical approach) and closed-loop state estimator (modern approach) are supported for the feedback.
  • The nonlinear predictive controller based on a linear model (e.g. economic optimization of a linear plant model) computes the prediction with matrices instead of a for loop.
  • The nonlinear predictive controller automatically designs an adequate state estimator for the feedback, contrarily to nlmpc in MATLAB.
  • etc.

Feedback is certainly welcome!

Francis Gagnon


Did you look at GitHub - infiniteopt/InfiniteOpt.jl: An intuitive modeling interface for infinite-dimensional optimization problems. and https://web.casadi.org/ ?

Both can be used to implement NMPC control systems…

And the link to your package is not working. This one should work: GitHub - franckgaga/ModelPredictiveControl.jl: A model predictive control package for Julia.


Yes, thanks! The link is modified.

I know about these two packages. They seems really powerful. My goal is to create a package that offer simpler implementations of both MPC and NMPC. You feed a plant model and you should be ready to go for quick simulations or control of a real plant (using additional DAC/ADC packages).



@odow I think I read somewhere that vector decision variables is planned in JuMP.jl. Is it true and is there any timeline for that ? I’m using the splatting syntax right now and, intuitively, there is probably some overhead that hurdles the performance of the NMPC.


Link to code example? The answer is a somewhat, maybe, it depends.

Here’s what I did. I memoized my objective and constrain functions using PreallocationTools.jl. I’m also using closure for the parameters so I applied the tip at Performance of captured variables.

ModelPredictiveControl v8.0.0

The release will be registered soon. Many features were added since the OP. Here is a short list:

  • Added: ExtendedKalmanFilter with automatic Jacobian computations using ForwardDiff.jl
  • Added: ExplicitMPC for linear predictive controllers without constraint and a small sample time
  • Added: automatic model augmentation based on observability for offset-free tracking
  • Added: support for both unmeasured disturbances at model input and output
  • Debug: only update the linear coefficients in LinMPC quadratic programming objective
  • Multiple improvements in documentation
  • Multiple other bug corrections
  • Improved coverage with many new tests

Feedback is welcome!

Francis Gagnon


Is there an MPC package that can integrate with Flux/Zygote for optimization?

1 Like

To my knowledge, I don’t think so. Mine will support the packages accordingly if the developers of JuMP.jl decide to support them. But I think it needs a lot of work on their part. (I assume you are referring to the optimization and AD tools, not the modeling part.)

This package has shaped up to become really impressive, congratulations on the nice work!


Thanks Fredrik, the compliment is truly appreciated !

I found a major bug in the estimation of the unmeasured disturbances at the model input (nint_u option). The implementation is a bit more complex than the estimation of output disturbances.

I will release a fix soon. It should work as expected now. I also added a usage example of nint_u option in the manual. I still need to add new tests that use the nint_u option.

1 Like