Engee documentation

Functions: PredictiveController Internals

The prediction methodology of this module is mainly based on Maciejowski textbook [1].

Controller Construction

init_ΔUtoU(model, Hp, Hc) -> S, T

Init manipulated input increments to inputs conversion matrices.

The conversion from the input increments to manipulated inputs over are calculated by:

init_predmat(estim, ::LinModel, Hp, Hc) -> E, G, J, K, V, ex̂, fx̂, gx̂, jx̂, kx̂, vx̂

Construct the prediction matrices for LinModel model.

The linear model predictions are evaluated by :

where the predicted outputs and measured disturbances are from to . Input increments are from to . The vector is the state estimated at the last control period. The method also computes similar matrices but for the predicted terminal states at :

Operating points on , and are omitted in above equations.

Extended Help

Using the augmented matrices in estim and the function , the prediction matrices are computed by :

For the terminal constraints, the matrices are computed with the function and:

Return empty matrices if model is not a LinModel

relaxU(model, C, C_umin, C_umax, S) -> A_Umin, A_Umax, S̃

Augment manipulated inputs constraints with slack variable ϵ for softening.

Denoting the input increments augmented with the slack variable ], it returns the augmented conversion matrix , similar to the one described at init_ΔUtoU. It also returns the matrices for the inequality constraints:

relaxΔU(
    model, C, C_Δumin, C_Δumax, ΔUmin, ΔUmax, N_Hc
) -> A_ΔŨmin, A_ΔŨmax, ΔŨmin, ΔŨmax, Ñ_Hc

Augment input increments constraints with slack variable ϵ for softening.

Denoting the input increments augmented with the slack variable ], it returns the augmented input increment weights (that incorporate ). It also returns the augmented constraints and and the matrices for the inequality constraints:

relaxŶ(::LinModel, C, C_ymin, C_ymax, E) -> A_Ymin, A_Ymax, Ẽ

Augment linear output prediction constraints with slack variable ϵ for softening.

Denoting the input increments augmented with the slack variable ], it returns the matrix that appears in the linear model prediction equation , and the matrices for the inequality constraints:

Return empty matrices if model is not a LinModel

relaxterminal(::LinModel, C, c_x̂min, c_x̂max, ex̂) -> A_x̂min, A_x̂max, ẽx̂

Augment terminal state constraints with slack variable ϵ for softening.

Denoting the input increments augmented with the slack variable ], it returns the matrix that appears in the terminal state equation , and the matrices for the inequality constraints:

Return empty matrices if model is not a LinModel

init_quadprog(model::LinModel, Ẽ, S, M_Hp, N_Hc, L_Hp) -> H̃, q̃, p

Init the quadratic programming optimization matrix and and scalar p for MPC.

The matrices appear in the quadratic general form :

The Hessian matrix is constant if the model and weights are linear and time invariant (LTI):

The vector and scalar need recalculation each control period (init with zeros, the method initpred! compute the real values). does not impact the minima position. It is thus useless at optimization but required to evaluate the minimal value.

Return empty matrices if model is not a LinModel.

init_stochpred(estim::InternalModel, Hp) -> Ks, Ps

Init the stochastic prediction matrices for InternalModel.

Ks and Ps matrices are defined as:

Current stochastic outputs comprises the measured outputs and unmeasured . See [2].

Return empty matrices if estim is not a InternalModel.

init_matconstraint_mpc(model::LinModel,
    i_Umin, i_Umax, i_ΔŨmin, i_ΔŨmax, i_Ymin, i_Ymax, i_x̂min, i_x̂max, args...
) -> i_b, i_g, A

Init i_b, i_g and A matrices for the linear and nonlinear inequality constraints.

The linear and nonlinear inequality constraints are respectively defined as:

i_b is a BitVector including the indices of that are finite numbers. i_g is a similar vector but for the indices of (empty if model is a LinModel). The method also returns the matrix if args is provided. In such a case, args needs to contain all the inequality constraint matrices: A_Umin, A_Umax, A_ΔŨmin, A_ΔŨmax, A_Ymin, A_Ymax, A_x̂min, A_x̂max.

Init i_b, A without outputs and terminal constraints if model is not a LinModel.

Update Quadratic Optimization

initpred!(mpc, model::LinModel, d, ym, D̂, R̂y, R̂u) -> nothing

Init linear model prediction matrices F, q̃, p and current estimated output .

See init_predmat and init_quadprog for the definition of the matrices. They are computed with:

linconstraint!(mpc::PredictiveController, model::LinModel)

Set b vector for the linear model inequality constraints ( ).

Also init vector for the terminal constraints, see init_predmat.

Solve Optimization Problem

optim_objective!(mpc::PredictiveController) -> ΔŨ

Optimize the objective function of mpc PredictiveController and return the solution ΔŨ.

If supported by mpc.optim, it warm-starts the solver at:

where is the input increment for time computed at the last control period . It then calls JuMP.optimize!(mpc.optim) and extract the solution. A failed optimization prints an @error log in the REPL and returns the warm-start value.

optim_objective!(mpc::ExplicitMPC) -> ΔŨ

Analytically solve the optimization problem for ExplicitMPC.

The solution is , see init_quadprog.


1. Maciejowski, J. 2000, "Predictive control : with constraints", 1st ed., Prentice Hall, ISBN 978-0201398236.
2. Desbiens, A., D. Hodouin & É. Plamondon. 2000, "Global predictive control : a unified control structure for decoupling setpoint tracking, feedforward compensation and disturbance rejection dynamics", IEE Proceedings - Control Theory and Applications, vol. 147, no 4, https://doi.org/10.1049/ip-cta:20000443, p. 465—​475, ISSN 1350-2379.