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.
To install the ModelPredictiveControl
package, run this command in the Julia REPL:
using Pkg; Pkg.add("ModelPredictiveControl")
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:
We first construct the plant model with a sample time
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
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)
See the manual for more detailed examples.
- implemented feature
- planned feature
- linear and nonlinear plant models exploiting multiple dispatch
- model linearization based on automatic differentiation (exact Jacobians)
- supported objective function terms:
- output setpoint tracking
- move suppression
- input setpoint tracking
- terminal costs
- economic costs (economic model predictive control)
- adaptive linear model predictive controller
- manual model modification
- automatic successive linearization of a nonlinear model
- objective function weights and covariance matrices modification
- explicit predictive controller for problems without constraint
- online-tunable soft and hard constraints on:
- output predictions
- manipulated inputs
- manipulated inputs increments
- terminal states to ensure nominal stability
- custom manipulated input constraints that are a function of the predictions
- supported feedback strategy:
- state estimator (see State Estimation features)
- internal model structure with a custom stochastic model
- automatic model augmentation with integrating states for offset-free tracking
- support for unmeasured model outputs
- feedforward action with measured disturbances that supports direct transmission
- custom predictions for:
- output setpoints
- measured disturbances
- easy integration with
Plots.jl
- optimization based on
JuMP.jl
:- quickly compare multiple optimizers
- nonlinear solvers relying on automatic differentiation (exact derivative)
- additional information about the optimum to ease troubleshooting
- implementation that carefully limits allocations for real-time applications
- supported state estimators/observers:
- steady-state Kalman filter
- Kalman filter
- Luenberger observer
- internal model structure
- extended Kalman filter
- unscented Kalman filter
- moving horizon estimator
- easily estimate unmeasured disturbances by adding one or more integrators at the:
- manipulated inputs
- measured outputs
- bumpless manual to automatic transfer for control with a proper initial estimate
- estimators in two possible forms:
- filter (or current) form to improve accuracy and robustness
- predictor (or delayed) form to reduce computational load
- moving horizon estimator in two formulations:
- linear plant models (quadratic optimization)
- nonlinear plant models (nonlinear optimization)
- moving horizon estimator online-tunable soft and hard constraints on:
- state estimates
- process noise estimates
- sensor noise estimates