# ModelPredictiveControl.jl vs JuliaSimControl

**URL:** <https://discourse.julialang.org/t/modelpredictivecontrol-jl-vs-juliasimcontrol/119496>\
**Category:** Modelling & Simulations\
**Created:** [September 17, 2024, 1:22pm UTC](https://discourse.julialang.org/t/modelpredictivecontrol-jl-vs-juliasimcontrol/119496 "2024-09-17T13:22:37Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bart\_van\_de\_Lint](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bart_van_de_lint/32/212161_2.png) [@Bart\_van\_de\_Lint](https://discourse.julialang.org/u/Bart_van_de_Lint)\
**Post date:** [September 17, 2024, 1:22pm UTC](https://discourse.julialang.org/t/modelpredictivecontrol-jl-vs-juliasimcontrol/119496/1 "2024-09-17T13:22:37Z")

</div>

What would be the advantages / disadvantages of using [ModelPredictiveControl.jl](https://github.com/JuliaControl/ModelPredictiveControl.jl) over [JuliaSimControl](https://juliacomputing.github.io/JuliaSimControl.jl/stable/mpc/)? I am trying to decide which one to use, and these were the first two packages I found.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [September 17, 2024, 1:40pm UTC](https://discourse.julialang.org/t/modelpredictivecontrol-jl-vs-juliasimcontrol/119496/2 "2024-09-17T13:40:18Z")

</div>

For JuliaSimControl you need to be a registered user of JuliaHub (if I am not mistaken), [ModePredictiveControl.jl](https://github.com/JuliaControl/ModelPredictiveControl.jl) is freely available.

---

<div class="post-metadata">

**Author:** ![Bart\_van\_de\_Lint](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bart_van_de_lint/32/212161_2.png) [@Bart\_van\_de\_Lint](https://discourse.julialang.org/u/Bart_van_de_Lint)\
**Post date:** [September 17, 2024, 1:48pm UTC](https://discourse.julialang.org/t/modelpredictivecontrol-jl-vs-juliasimcontrol/119496/3 "2024-09-17T13:48:09Z")

</div>

And the functionality is similar?

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [September 17, 2024, 1:49pm UTC](https://discourse.julialang.org/t/modelpredictivecontrol-jl-vs-juliasimcontrol/119496/4 "2024-09-17T13:49:00Z")

</div>

JuliaSimControl might be better integrated with ModelingToolkit.

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [September 17, 2024, 4:00pm UTC](https://discourse.julialang.org/t/modelpredictivecontrol-jl-vs-juliasimcontrol/119496/5 "2024-09-17T16:00:37Z")

</div>

I’m the author of JuliaSimControl and a co-contributor (more of a cheerful by stander, @franckgaga deserves 99.9% of the cred) for ModelPredictiveControl.jl

Here are some differences to help you choose

### ModelPredictiveControl.jl

- Is based on JuMP.jl and is thus blazingly fast for linear and simple nonlinear MPC
- Has good compilation performance
- Supports moving horizon estimation (in addition to lots of other observers)
- Has well worked-through support for disturbance feedforward
- Is slightly easier to use
- Has MIT license

### JuliaSimControl

- Is based on Optimization.jl with custom autodiff, this allows it to handle arbitrary vector-valued dynamics that may cause JuMP to perform poorly, but JuMP (and thus MPC.jl) is often significantly faster for simpler dynamics.
- Generally takes a long time to compile
- Supports DAE systems
- Supports discretization using collocation on finite elements and multiple shooting, which handles stiff dynamics and may make the optimization problem easier to solve
- Supports a number of robust MPC formulations
- Requires a license for professional users (not for academics)

Pros and cons, which is most suitable for you depends on your requirements

---

<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:** [September 17, 2024, 4:42pm UTC](https://discourse.julialang.org/t/modelpredictivecontrol-jl-vs-juliasimcontrol/119496/6 "2024-09-17T16:42:49Z")

</div>

That’s a excellent summary @baggepinnen. I would add these three pros and cons on ModelPredictiveControl.jl, compared to JuliaSimControl:

- Easy implementation of successive linearization MPC or moving horizon estimation, for super fast approximate solutions (see an example [here](https://juliacontrol.github.io/ModelPredictiveControl.jl/stable/manual/nonlinmpc/#Adapting-the-Model-via-Successive-Linearization)).
- Supports a control horizon H\_c different than the prediction horizon H\_p
- Supports only single-shooting for the discretization method, meaning that the optimization is less efficient on high-order or unstable systems.

---

<div class="post-metadata">

**Author:** ![Bart\_van\_de\_Lint](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bart_van_de_lint/32/212161_2.png) [@Bart\_van\_de\_Lint](https://discourse.julialang.org/u/Bart_van_de_Lint)\
**Post date:** [September 18, 2024, 6:26pm UTC](https://discourse.julialang.org/t/modelpredictivecontrol-jl-vs-juliasimcontrol/119496/7 "2024-09-18T18:26:31Z")

</div>

Thanks a lot for the summary! Blazingly fast and open source sounds very good, so I will try using ModelPredictiveControl.jl. Does ModelPredictiveControl work with ModelingToolKit models?

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [September 18, 2024, 6:29pm UTC](https://discourse.julialang.org/t/modelpredictivecontrol-jl-vs-juliasimcontrol/119496/8 "2024-09-18T18:29:16Z")

</div>

> [@Bart\_van\_de\_Lint](#):
>
> Does ModelPredictiveControl work with ModelingToolKit models?

No, it would require a number of manual steps to make work.

---

<div class="post-metadata">

**Author:** ![Bart\_van\_de\_Lint](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bart_van_de_lint/32/212161_2.png) [@Bart\_van\_de\_Lint](https://discourse.julialang.org/u/Bart_van_de_Lint)\
**Post date:** [September 24, 2024, 6:06am UTC](https://discourse.julialang.org/t/modelpredictivecontrol-jl-vs-juliasimcontrol/119496/9 "2024-09-24T06:06:37Z")

</div>

Could you give me some hints as to what I have to do to make an MTK model work with ModelPredictiveControl.jl?

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [September 24, 2024, 6:15am UTC](https://discourse.julialang.org/t/modelpredictivecontrol-jl-vs-juliasimcontrol/119496/10 "2024-09-24T06:15:35Z")

</div>

- Build a dynamics function that includes inputs, [docs here](https://docs.sciml.ai/ModelingToolkit/dev/basics/InputOutput/). Write a wrapper that changes the order of the input arguments to match the order assumed by ModelPredictiveControl.jl
- Possibly build an output function, docs on the same page
- Manually keep track of the order of state variables in the generated function

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [September 24, 2024, 6:52am UTC](https://discourse.julialang.org/t/modelpredictivecontrol-jl-vs-juliasimcontrol/119496/11 "2024-09-24T06:52:02Z")

</div>

Created an issue: [Better integration with ModellingToolkit · Issue #106 · JuliaControl/ModelPredictiveControl.jl · GitHub](https://github.com/JuliaControl/ModelPredictiveControl.jl/issues/106)
