JuliaControl / ModelPredictiveControl.jl

An open source model predictive control package for Julia.
https://juliacontrol.github.io/ModelPredictiveControl.jl/stable
MIT License
58 stars 0 forks source link
automatic-control control-systems feedback-systems julia linear-control linear-dynamic-systems model-predictive-control nonlinear-control nonlinear-dynamics state-estimation

ModelPredictiveControl.jl

Build Status codecov doc-stable doc-dev

An open source model predictive control package for Julia.

The package depends on ControlSystemsBase.jl for the linear systems and JuMP.jl for the solving.

Installation

To install the ModelPredictiveControl package, run this command in the Julia REPL:

using Pkg; Pkg.add("ModelPredictiveControl")

Getting Started

To construct model predictive controllers (MPCs), we must first specify a plant model that is typically extracted from input-output data using system identification. The model here is linear with one input, two outputs and a large time delay in the first channel:

\mathbf{G}(s) = \frac{\mathbf{y}(s)}{\mathbf{u}(s)} = 
\begin{bmatrix}
    \frac{2e^{-20s}}{10s + 1} \\[3pt]
    \frac{10}{4s +1}
\end{bmatrix}

We first construct the plant model with a sample time $T_s = 1$ s:

using ModelPredictiveControl, ControlSystemsBase
G = [ tf( 2 , [10, 1])*delay(20)
      tf( 10, [4,  1]) ]
Ts = 1.0
model = LinModel(G, Ts)

Our goal is controlling the first output $y_1$, but the second one $y_2$ should never exceed 35:

mpc = LinMPC(model, Mwt=[1, 0], Nwt=[0.1])
mpc = setconstraint!(mpc, ymax=[Inf, 35])

The keyword arguments Mwt and Nwt are the output setpoint tracking and move suppression weights, respectively. A setpoint step change of five tests mpc controller in closed-loop. The result is displayed with Plots.jl:

using Plots
ry = [5, 0]
res = sim!(mpc, 40, ry)
plot(res, plotry=true, plotymax=true)

StepChangeResponse

See the manual for more detailed examples.

Features

Legend

Model Predictive Control Features

State Estimation Features