MPCComponents ​
Documentation for MPCComponents.
MPCComponents is a library of model-predictive control components implemented in the Dyad language. Linear MPC is backed by LinearMPC.jl, nonlinear MPC by acados, nonlinear state estimation by LowLevelParticleFilters.jl, and a purely discrete model built from these components can be exported as standalone C code.
The controllers and observers are clocked components: they are connected to a continuous-time plant through samplers and holds from DiscreteComponents, and a closed-loop model is simulated like any other Dyad model.
| Component | Description |
|---|---|
LinearMPCController | Linear MPC as one clocked component: state observer and condensed QP. |
LinearMPCObserver, LinearMPCOptimizer | The two parts of LinearMPCController, also usable on their own. |
PIDEquivalentMPCController | Reproduces DiscreteComponents.DiscretePIDStandard exactly while no constraint is active, so that constraints and preview can be added to a tuned PID controller. |
ACADOSMPC | Nonlinear MPC for ODE, semi-explicit index-1 DAE and discrete-time prediction models. |
UKFObserver | Unscented Kalman filter for a nonlinear prediction model, as one clocked component. |
DelayLine | Tapped delay line, used to assemble preview vectors. |
The analysis CCodeExport exports a model containing these components to C.
Installation ​
Install MPCComponents from the Dyad registry with
import Pkg
Pkg.add("MPCComponents")acados is provided by acados_jll; neither a C compiler nor Python or CasADi is needed to simulate.
Getting started ​
Model-predictive control: the receding-horizon principle, the signals of an MPC loop, a comparison with PID and LQR control, and the choice between linear and nonlinear MPC.
Linear MPC: the prediction model, cost function, constraints, horizons and Kalman filter of
LinearMPCController, with a reference-tracking example.Nonlinear MPC: the prediction model, discretization, cost function, constraints, solver and state estimation of
ACADOSMPC, with a pendulum example.
Tutorials ​
The tutorials are translations of the MPC tutorials of DyadControlSystems.
MPC with quadratic cost functions: nonlinear MPC with
ACADOSMPCof a pendulum on a cart, with input bounds and an LQR terminal cost.Cart-pole MPC with a penalty on the control increments: regulation of the full state of a pendulum on a cart to the origin with
ACADOSMPC, with a hard force bound and a soft angular-velocity bound.Disturbance modeling and rejection: rejection of a load disturbance with
LinearMPCControlleron a first-order plant, without a disturbance model and with an input-disturbance model in the Kalman filter at two estimation speeds.MPC with binary or integer variables (MINLP): a double integrator whose control is restricted to
, solved as a mixed-integer QP by LinearMPCOptimizer, with a shortened integer horizon.MPC control of a Continuously Stirred Tank Reactor (CSTR): nonlinear MPC with
ACADOSMPCof a reactor with hard input bounds and soft temperature bounds, and the effect of a plant-model mismatch.Autonomous lane changes: nonlinear MPC with
ACADOSMPCof a kinematic bicycle model that changes lanes, with a smooth lateral reference, bounds on the state and the inputs, and an increment penalty.Economic MPC for residential HVAC:
LinearMPCControllerminimizes the electricity cost of a house heated by a heat pump, using 24 h forecasts of the electricity price and the outdoor temperature, compared with a controller that only maintains comfort.Control design for a quadruple-tank system: linear MPC (
LinearMPCControllerwith a Kalman filter) and nonlinear MPC (ACADOSMPC) of a non-minimum-phase process with bounds on the pump voltages and the tank levels.
The component reference at the bottom of the sidebar lists every component, type, analysis and example of the library.