Skip to content

Commit f4a37a7

Browse files
committed
wip: doc of transcription methods
1 parent 8bc2a90 commit f4a37a7

3 files changed

Lines changed: 28 additions & 11 deletions

File tree

docs/src/public/transcription.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Pages = ["transcription.md"]
66

77
This page contains the documentation of the direct transcription methods used to
88
construct [`MovingHorizonEstimator`](@ref), [`LinMPC`](@ref) and [`NonLinMPC`](@ref) types.
9+
They represent ways to discretize the continuous-time optimal control or estimation problem
10+
into a finite-dimensional quadratic (QP) or nonlinear program (NLP), which can then be
11+
solved using an appropriate optimizer.
912

1013
## TranscriptionMethod
1114

src/estimator/mhe/execute.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,8 @@ function initpred!(estim::MovingHorizonEstimator, model::LinModel)
379379
# --- update H̃, q̃ and p vectors for quadratic optimization ---
380380
ẼZ̃ = @views [estim.ẽx̄[:, 1:nZ̃]; estim.Ẽ[1:nYm, 1:nZ̃]]
381381
FZ̃ = @views [estim.fx̄; estim.F[1:nYm]]
382-
invQ̂_Nk = trunc_cov(estim.cov.invQ̂_He, estim.nx̂, Nk, estim.He)
383-
invR̂_Nk = trunc_cov(estim.cov.invR̂_He, estim.nym, Nk, estim.He)
382+
invQ̂_Nk = trunc_cov(invQ̂_He, estim.nx̂, Nk, estim.He)
383+
invR̂_Nk = trunc_cov(invR̂_He, estim.nym, Nk, estim.He)
384384
M_Nk = [invP̄ zeros(nx̂, nYm); zeros(nYm, nx̂) invR̂_Nk]
385385
Ñ_Nk = [fill(C, nε, nε) zeros(nε, nx̂+nŴ); zeros(nx̂, nε+nx̂+nŴ); zeros(nŴ, nε+nx̂) invQ̂_Nk]
386386
M_Nk_ẼZ̃ = M_Nk*ẼZ̃
@@ -709,7 +709,7 @@ function obj_nonlinprog!(
709709
nε, Nk = estim.nε, estim.Nk[]
710710
nYm, nŴ, nx̂, invP̄ = Nk*estim.nym, Nk*estim.nx̂, estim.nx̂, estim.cov.invP̄
711711
nx̃ =+ nx̂
712-
invQ̂_Nk = trunc_cov(estim.cov.invQ̂_He, estim.nx̂, Nk, estim.He)
712+
invQ̂_Nk = trunc_cov(estim.cov.invQ̂_He, estim.nx̂, Nk, estim.He)
713713
invR̂_Nk = trunc_cov(estim.cov.invR̂_He, estim.nym, Nk, estim.He)
714714
x̂0arr, Ŵ, V̂ = @views Z̃[nx̃-nx̂+1:nx̃], Z̃[nx̃+1:nx̃+nŴ], V̂[1:nYm]
715715
x̄ .= estim.x̂0arr_old .- x̂0arr

src/transcription.jl

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const COLLOCATION_NODE_TYPE = Float64
44
Abstract supertype of all transcription methods for the optimal control/estimation problems.
55
66
The module currently supports [`SingleShooting`](@ref), [`MultipleShooting`](@ref),
7-
[`TrapezoidalCollocation`](@ref) and [`OrthogonalCollocation`](@ref) transcription methods.
7+
[`TrapezoidalCollocation`](@ref) and [`OrthogonalCollocation`](@ref) transcriptions.
88
"""
99
abstract type TranscriptionMethod end
1010
abstract type ShootingMethod <: TranscriptionMethod end
@@ -15,19 +15,33 @@ abstract type CollocationMethod <: TranscriptionMethod end
1515
1616
Construct a direct single shooting [`TranscriptionMethod`](@ref).
1717
18-
The decision variable in the optimization problem is (excluding the slack ``ϵ`` and without
19-
any custom move blocking):
18+
For [`MovingHorizonEstimator`](@ref) objects, the decision variable in the optimization
19+
problem is (excluding the slack ``ϵ``):
20+
```math
21+
\mathbf{Z} =
22+
= \begin{bmatrix}
23+
\mathbf{x̂}_k(k-N_k+p) \\
24+
\mathbf{Ŵ} \end{bmatrix}
25+
= \begin{bmatrix}
26+
\mathbf{x̂}_k(k-N_k+p) \\
27+
\mathbf{ŵ}(k-N_k+p+0) \\
28+
\mathbf{ŵ}(k-N_k+p+1) \\
29+
\vdots \\
30+
\mathbf{ŵ}(k+p-1) \end{bmatrix}
31+
```
32+
and, for [`PredictiveController`](@ref) types (without any custom move blocking):
2033
```math
2134
\mathbf{Z} = \mathbf{ΔU} = \begin{bmatrix}
2235
\mathbf{Δu}(k+0) \\
2336
\mathbf{Δu}(k+1) \\
2437
\vdots \\
2538
\mathbf{Δu}(k+H_c-1) \end{bmatrix}
2639
```
40+
2741
This method computes the predictions by calling the augmented discrete-time model
28-
recursively over the prediction horizon ``H_p`` in the objective function, or by updating
29-
the linear coefficients of the quadratic optimization for [`LinModel`](@ref). It is
30-
generally more efficient for small control horizon ``H_c``, stable and mildly nonlinear
42+
recursively over the horizon in the objective function, or by updating the linear
43+
coefficients of the quadratic optimization for [`LinModel`](@ref). It is
44+
generally more efficient for small ``H_c`` or ``H_e`` values, stable and mildly nonlinear
3145
plant model/constraints.
3246
"""
3347
struct SingleShooting <: ShootingMethod end
@@ -103,8 +117,8 @@ transcription method.
103117
Note that the stochastic model of the unmeasured disturbances is strictly discrete-time,
104118
as described in [`ModelPredictiveControl.init_estimstoch`](@ref). Collocation methods
105119
require continuous-time dynamics. Because of this, the stochastic states are transcribed
106-
separately using a [`MultipleShooting`](@ref) method. See [`con_nonlinprogeq!`](@ref)
107-
for more details.
120+
separately using a [`MultipleShooting`](@ref) method and by exploiting its linear
121+
structure. See [`con_nonlinprogeq!`](@ref) for more details.
108122
"""
109123
struct TrapezoidalCollocation <: CollocationMethod
110124
h::Int

0 commit comments

Comments
 (0)