Functions: PredictiveController Internals
The prediction methodology of this module is mainly based on Maciejowski textbook [1].
Controller Construction
#
ModelPredictiveControl.init_ΔUtoU
— Function
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:
#
ModelPredictiveControl.init_predmat
— Function
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
Return empty matrices if model
is not a LinModel
#
ModelPredictiveControl.relaxU
— Function
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 init_ΔUtoU
. It also returns the
#
ModelPredictiveControl.relaxΔU
— Function
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
#
ModelPredictiveControl.relaxŶ
— Function
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
Return empty matrices if model is not a LinModel
#
ModelPredictiveControl.relaxterminal
— Function
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
Return empty matrices if model is not a LinModel
#
ModelPredictiveControl.init_quadprog
— Function
init_quadprog(model::LinModel, Ẽ, S, M_Hp, N_Hc, L_Hp) -> H̃, q̃, p
Init the quadratic programming optimization matrix H̃
and q̃
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 initpred!
compute the real values).
Return empty matrices if model
is not a LinModel
.
#
ModelPredictiveControl.init_stochpred
— Function
init_stochpred(estim::InternalModel, Hp) -> Ks, Ps
Init the stochastic prediction matrices for InternalModel
.
Ks
and Ps
matrices are defined as:
Current stochastic outputs
Return empty matrices if estim
is not a InternalModel
.
#
ModelPredictiveControl.init_matconstraint_mpc
— Function
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 i_g
is a similar vector but for the indices of model
is a LinModel
). The method also returns the 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
#
ModelPredictiveControl.initpred!
— Method
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:
#
ModelPredictiveControl.linconstraint!
— Method
linconstraint!(mpc::PredictiveController, model::LinModel)
Set b
vector for the linear model inequality constraints (
Also init init_predmat
.
Solve Optimization Problem
#
ModelPredictiveControl.optim_objective!
— Function
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 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 init_quadprog
.