Skip to content

Commit 91b8d46

Browse files
committed
doc: add prediction matrices for MultipleShooting
1 parent 9c500a3 commit 91b8d46

File tree

3 files changed

+40
-8
lines changed

3 files changed

+40
-8
lines changed

docs/src/internals/predictive_control.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ ModelPredictiveControl.relaxterminal
2323
ModelPredictiveControl.init_quadprog
2424
ModelPredictiveControl.init_stochpred
2525
ModelPredictiveControl.init_matconstraint_mpc
26+
ModelPredictiveControl.init_nonlincon!
2627
```
2728

2829
## Update Quadratic Optimization
2930

3031
```@docs
3132
ModelPredictiveControl.initpred!(::PredictiveController, ::LinModel, ::Any, ::Any, ::Any, ::Any)
3233
ModelPredictiveControl.linconstraint!(::PredictiveController, ::LinModel)
34+
ModelPredictiveControl.linconstrainteq!
3335
```
3436

3537
## Solve Optimization Problem

src/controller/nonlinmpc.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,13 @@ function get_optim_functions(mpc::NonLinMPC, ::JuMP.GenericModel{JNT}) where JNT
585585
return Jfunc, gfuncs
586586
end
587587

588+
"""
589+
init_nonlincon!(mpc::NonLinMPC, model::LinModel, ::TranscriptionMethod, gfuncs)
590+
591+
Init nonlinear constraints for [`LinModel`](@ref).
592+
593+
The only nonlinear constraints are the custom inequality constraints `gc`.
594+
"""
588595
function init_nonlincon!(
589596
mpc::NonLinMPC, ::LinModel, ::TranscriptionMethod, gfuncs::Vector{<:Function}
590597
)
@@ -600,6 +607,14 @@ function init_nonlincon!(
600607
return nothing
601608
end
602609

610+
"""
611+
init_nonlincon!(mpc::NonLinMPC, model::NonLinModel, ::MultipleShooting, gfuncs)
612+
613+
Init nonlinear constraints for [`NonLinModel`](@ref) and [`MultipleShooting`](@ref).
614+
615+
The nonlinear constraints are the output prediction `Ŷ` bounds, the custom inequality
616+
constraints `gc` and the zero defect `Ŝ` equality constraints.
617+
"""
603618
function init_nonlincon!(
604619
mpc::NonLinMPC, ::NonLinModel, ::MultipleShooting, gfuncs::Vector{<:Function}
605620
)
@@ -625,6 +640,14 @@ function init_nonlincon!(
625640
return nothing
626641
end
627642

643+
"""
644+
init_nonlincon!(mpc::NonLinMPC, model::NonLinModel, ::SingleShooting, gfuncs)
645+
646+
Init nonlinear constraints for [`NonLinModel`](@ref) and [`SingleShooting`](@ref).
647+
648+
The nonlinear constraints are the custom inequality constraints `gc`, the output
649+
prediction `Ŷ` bounds and the terminal state `x̂end` bounds.
650+
"""
628651
function init_nonlincon!(
629652
mpc::NonLinMPC, ::NonLinModel, ::SingleShooting, gfuncs::Vector{<:Function}
630653
)

src/controller/transcription.jl

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,17 @@ Construct the prediction matrices for [`LinModel`](@ref) and [`MultipleShooting`
334334
335335
They are defined in the Extended Help section.
336336
337-
# TODO: fill the next section
338-
339337
# Extended Help
340338
!!! details "Extended Help"
341-
The matrices are computed by:
339+
They are all appropriately sized zero matrices ``\mathbf{0}``, except for:
340+
```math
341+
\begin{aligned}
342+
\mathbf{E} &= [\begin{smallmatrix}\mathbf{0} & \mathbf{E^†} \end{smallmatrix}] \\
343+
\mathbf{E^†} &= \text{diag}\mathbf{(Ĉ,Ĉ,...,Ĉ)} \\
344+
\mathbf{J} &= \text{diag}\mathbf{(D̂_d,D̂_d,...,D̂_d)} \\
345+
\mathbf{ex̂} &= [\begin{smallmatrix}\mathbf{0} & \mathbf{I}\end{smallmatrix}]
346+
\end{aligned}
347+
```
342348
"""
343349
function init_predmat(
344350
model::LinModel, estim::StateEstimator{NT}, transcription::MultipleShooting, Hp, Hc
@@ -432,10 +438,10 @@ matrices ``\mathbf{E_ŝ, G_ŝ, J_ŝ, K_ŝ, V_ŝ, B_ŝ}`` are defined in th
432438
```math
433439
\begin{aligned}
434440
\mathbf{E_ŝ} &= \begin{bmatrix}
435-
\mathbf{B̂_u} & \mathbf{0} & \cdots & \mathbf{0} & -\mathbf{I} & \mathbf{0} & \cdots & \mathbf{0} \\
436-
\mathbf{B̂_u} & \mathbf{B̂_u} & \cdots & \mathbf{0} & \mathbf{Â} & -\mathbf{I} & \cdots & \mathbf{0} \\
437-
\vdots & \vdots & \ddots & \vdots & \vdots & \vdots & \ddots & \vdots \\
438-
\mathbf{B̂_u} & \mathbf{B̂_u} & \cdots & \mathbf{B̂_u} & \mathbf{0} & \mathbf{0} & \cdots & -\mathbf{I} \end{bmatrix} \\
441+
\mathbf{B̂_u} & \mathbf{0} & \cdots & \mathbf{0} & -\mathbf{I} & \mathbf{0} & \cdots & \mathbf{0} & \mathbf{0} \\
442+
\mathbf{B̂_u} & \mathbf{B̂_u} & \cdots & \mathbf{0} & \mathbf{Â} & -\mathbf{I} & \cdots & \mathbf{0} & \mathbf{0} \\
443+
\vdots & \vdots & \ddots & \vdots & \vdots & \vdots & \ddots & \vdots & \vdots \\
444+
\mathbf{B̂_u} & \mathbf{B̂_u} & \cdots & \mathbf{B̂_u} & \mathbf{0} & \mathbf{0} & \cdots & \mathbf{Â} & -\mathbf{I} \end{bmatrix} \\
439445
\mathbf{G_ŝ} &= \begin{bmatrix}
440446
\mathbf{B̂_d} \\ \mathbf{0} \\ \vdots \\ \mathbf{0} \end{bmatrix} \\
441447
\mathbf{J_ŝ} &= \begin{bmatrix}
@@ -582,7 +588,8 @@ It warm-starts the solver at:
582588
\end{bmatrix}
583589
```
584590
where ``\mathbf{x̂_0}(k+j|k-1)`` is the predicted state for time ``k+j`` computed at the
585-
last control period ``k-1``, expressed as a deviation from the operating point ``x̂_{op}``.
591+
last control period ``k-1``, expressed as a deviation from the operating point
592+
``\mathbf{x̂_{op}}``.
586593
"""
587594
function set_warmstart!(mpc::PredictiveController, transcription::MultipleShooting, Z̃var)
588595
nu, nx̂, Hp, Hc, Z̃0 = mpc.estim.model.nu, mpc.estim.nx̂, mpc.Hp, mpc.Hc, mpc.buffer.

0 commit comments

Comments
 (0)