@@ -18,7 +18,7 @@ The decision variable in the optimization problem is (excluding the slack ``ϵ``
1818 \v dots \\
1919 \m athbf{Δu}(k+H_c-1) \e nd{bmatrix}
2020```
21- This method generally more efficient for small control horizon ``H_c``, stable or mildly
21+ This method is generally more efficient for small control horizon ``H_c``, stable or mildly
2222nonlinear plant model/constraints.
2323"""
2424struct SingleShooting <: TranscriptionMethod end
@@ -35,15 +35,17 @@ The decision variable is (excluding ``ϵ``):
3535thus it also includes the predicted states, expressed as deviation vectors from the
3636operating point ``\m athbf{x̂_{op}}`` (see [`augment_model`](@ref)):
3737```math
38- \m athbf{X̂_0} = \b egin{bmatrix}
39- \m athbf{x̂}(k+1) - \m athbf{x̂_{op}} \\
40- \m athbf{x̂}(k+2) - \m athbf{x̂_{op}} \\
38+ \m athbf{X̂_0} = \m athbf{X̂ - X̂_{op}} \b egin{bmatrix}
39+ \m athbf{x̂}_i (k+1) - \m athbf{x̂_{op}} \\
40+ \m athbf{x̂}_i (k+2) - \m athbf{x̂_{op}} \\
4141 \v dots \\
42- \m athbf{x̂}(k+H_p) - \m athbf{x̂_{op}} \e nd{bmatrix}
42+ \m athbf{x̂}_i (k+H_p) - \m athbf{x̂_{op}} \e nd{bmatrix}
4343```
44- This method is generally more efficient for large control horizon ``H_c``, unstable or
45- highly nonlinear plant models/constraints. Sparse optimizers like `OSQP.jl` or `Ipopt.jl`
46- are recommended for large-scale problems.
44+ where ``\m athbf{x̂}_i(k+j)`` is the state prediction for time ``k+j``, estimated by the
45+ observer at time ``i=k`` or ``i=k-1`` depending on the `direct` flag. This transcription
46+ method is generally more efficient for large control horizon ``H_c``, unstable or highly
47+ nonlinear plant models/constraints. Sparse optimizers like `OSQP.jl` or `Ipopt.jl` are
48+ recommended for large-scale problems.
4749"""
4850struct MultipleShooting <: TranscriptionMethod end
4951
@@ -65,15 +67,15 @@ increments over ``H_c``, is computed by:
6567```math
6668\m athbf{ΔU} = \m athbf{P} \m athbf{Z}
6769```
68- in which ``\m athbf{P} is defined in the Extended Help section.
70+ in which ``\m athbf{P}`` is defined in the Extended Help section.
6971
7072# Extended Help
7173!!! details "Extended Help"
7274 Following the decision variable definition of the [`TranscriptionMethod`](@ref), the
7375 conversion matrix ``\m athbf{P}``, we have:
74- - ``\m athbf{P} = \m athbf{I}`` if `transcription isa SingleShooting`
75- - ``\m athbf{P} = [\b egin{smallmatrix}\m athbf{I} \m athbf{0} \e nd{smallmatrix}]`` if
76- `transcription isa MultipleShooting`
76+ - ``\m athbf{P} = \m athbf{I}`` if `transcription` is a [` SingleShooting`](@ref)
77+ - ``\m athbf{P} = [\b egin{smallmatrix}\m athbf{I} & \m athbf{0} \e nd{smallmatrix}]`` if
78+ `transcription` is a [` MultipleShooting`](@ref)
7779"""
7880function init_ZtoΔU end
7981
@@ -92,21 +94,6 @@ function init_ZtoΔU(
9294 return P
9395end
9496
95- #=
96- function init_Z̃toΔŨ(
97- estim::StateEstimator{NT}, transcription::SingleShooting, Hp, Hc
98- ) where {NT<:Real}
99- return Matrix{NT}(I, model.nu*Hc, model.nu*Hc)
100- end
101-
102- function init_Z̃toΔŨ(
103- estim::StateEstimator{NT}, transcription::MultipleShooting, Hp, Hc
104- ) where {NT<:Real}
105- I_nu_Hc = Matrix{NT}(I, model.nu*Hc, model.nu*Hc)
106- return [I_nu_Hc zeros(NT, model.nu*Hc, model.nx̂*Hp)]
107- end
108- =#
109-
11097@doc raw """
11198 init_ZtoU(estim, transcription, Hp, Hc) -> S, T
11299
@@ -146,9 +133,9 @@ The ``\mathbf{S}`` and ``\mathbf{T}`` matrices are defined in the Extended Help
146133 \m athbf{I} \e nd{bmatrix}
147134 ```
148135 and, depending on the transcription method, we have:
149- - ``\m athbf{S} = \m athbf{S^†}`` if `transcription isa SingleShooting`
150- - ``\m athbf{S} = [\b egin{smallmatrix}\m athbf{S^†} \m athbf{0} \e nd{smallmatrix}]`` if
151- `transcription isa MultipleShooting`
136+ - ``\m athbf{S} = \m athbf{S^†}`` if `transcription` is a [` SingleShooting`](@ref)
137+ - ``\m athbf{S} = [\b egin{smallmatrix}\m athbf{S^†} & \m athbf{0} \e nd{smallmatrix}]`` if
138+ `transcription` is a [` MultipleShooting`](@ref)
152139"""
153140function init_ZtoU (
154141 estim:: StateEstimator{NT} , transcription:: TranscriptionMethod , Hp, Hc
343330 model::LinModel, estim, transcription::MultipleShooting, Hp, Hc
344331 ) -> E, G, J, K, V, B, ex̂, gx̂, jx̂, kx̂, vx̂, bx̂
345332
346- Construct the prediction matrices for [`LinModel`](@ref) and [`MultipleShooting`](@ref).
333+ Construct the prediction matrices for [`LinModel`](@ref) and [`MultipleShooting`](@ref).
334+
335+ They are defined in the Extended Help section.
336+
337+ # TODO: fill the next section
338+
339+ # Extended Help
340+ !!! details "Extended Help"
341+ The matrices are computed by:
347342"""
348343function init_predmat (
349344 model:: LinModel , estim:: StateEstimator{NT} , transcription:: MultipleShooting , Hp, Hc
@@ -390,10 +385,12 @@ function init_predmat(
390385 return E, G, J, K, V, B, ex̂, gx̂, jx̂, kx̂, vx̂, bx̂
391386end
392387
393- """
388+ @doc raw """
394389 init_predmat(model::SimModel, estim, transcription::MultipleShooting, Hp, Hc)
395390
396391Return empty matrices except `ex̂` for [`SimModel`](@ref) and [`MultipleShooting`](@ref).
392+
393+ The matrix is ``\m athbf{ex̂} = [\b egin{smallmatrix}\m athbf{0} & \m athbf{I}\e nd{smallmatrix}]``.
397394"""
398395function init_predmat (
399396 model:: SimModel , estim:: StateEstimator{NT} , transcription:: MultipleShooting , Hp, Hc
@@ -456,7 +453,6 @@ matrices ``\mathbf{E_ŝ, G_ŝ, J_ŝ, K_ŝ, V_ŝ, B_ŝ}`` are defined in th
456453 \m athbf{E_ŝ} &= \b egin{bmatrix}
457454 \m athbf{B̂_u} & \m athbf{0} & \c dots & \m athbf{0} & -\m athbf{I} & \m athbf{0} & \c dots & \m athbf{0} \\
458455 \m athbf{B̂_u} & \m athbf{B̂_u} & \c dots & \m athbf{0} & \m athbf{Â} & -\m athbf{I} & \c dots & \m athbf{0} \\
459- \m athbf{B̂_u} & \m athbf{B̂_u} & \c dots & \m athbf{0} & \m athbf{0} & \m athbf{Â} & \c dots & \m athbf{0} \\
460456 \v dots & \v dots & \d dots & \v dots & \v dots & \v dots & \d dots & \v dots \\
461457 \m athbf{B̂_u} & \m athbf{B̂_u} & \c dots & \m athbf{B̂_u} & \m athbf{0} & \m athbf{0} & \c dots & -\m athbf{I} \e nd{bmatrix} \\
462458 \m athbf{G_ŝ} &= \b egin{bmatrix}
@@ -556,16 +552,16 @@ If supported by `mpc.optim`, it warm-starts the solver at:
556552```math
557553\m athbf{ΔŨ} =
558554\b egin{bmatrix}
559- \m athbf{Δu}_{k-1} (k+0) \\
560- \m athbf{Δu}_{k-1} (k+1) \\
555+ \m athbf{Δu}(k+0|k-1) \\
556+ \m athbf{Δu}(k+1|k-1) \\
561557 \v dots \\
562- \m athbf{Δu}_{k-1} (k+H_c-2) \\
558+ \m athbf{Δu}(k+H_c-2|k-1) \\
563559 \m athbf{0} \\
564- ϵ_{ k-1}
560+ ϵ( k-1)
565561\e nd{bmatrix}
566562```
567- where ``\m athbf{Δu}_{k-1} (k+j)`` is the input increment for time ``k+j`` computed at the
568- last control period ``k-1``, and ``ϵ_{ k-1} ``, the slack variable of the last control period.
563+ where ``\m athbf{Δu}(k+j|k-1 )`` is the input increment for time ``k+j`` computed at the
564+ last control period ``k-1``, and ``ϵ( k-1) ``, the slack variable of the last control period.
569565"""
570566function set_warmstart! (mpc:: PredictiveController , transcription:: SingleShooting , Z̃var)
571567 nu, Hc, Z̃0 = mpc. estim. model. nu, mpc. Hc, mpc. buffer. Z̃
@@ -587,20 +583,20 @@ It warm-starts the solver at:
587583```math
588584\m athbf{ΔŨ} =
589585\b egin{bmatrix}
590- \m athbf{Δu}_{k-1} (k+0) \\
591- \m athbf{Δu}_{k-1} (k+1) \\
586+ \m athbf{Δu}(k+0|k-1) \\
587+ \m athbf{Δu}(k+1|k-1) \\
592588 \v dots \\
593- \m athbf{Δu}_{k-1} (k+H_c-1) \\
589+ \m athbf{Δu}(k+H_c-2|k-1) \\
594590 \m athbf{0} \\
595- \m athbf{x̂_0}_{k-1} (k+1) \\
596- \m athbf{x̂_0}_{k-1} (k+2) \\
591+ \m athbf{x̂_0}(k+1|k-1) \\
592+ \m athbf{x̂_0}(k+2|k-1) \\
597593 \v dots \\
598- \m athbf{x̂_0}_{k-1} (k+H_p-1) \\
599- \m athbf{x̂_0}_{k-1} (k+H_p-1) \\
600- ϵ_{ k-1}
594+ \m athbf{x̂_0}(k+H_p-1|k-1) \\
595+ \m athbf{x̂_0}(k+H_p-1|k-1) \\
596+ ϵ( k-1)
601597\e nd{bmatrix}
602598```
603- where ``\m athbf{x̂_0}_{k-1} (k+j)`` is the predicted state for time ``k+j`` computed at the
599+ where ``\m athbf{x̂_0}(k+j|k-1 )`` is the predicted state for time ``k+j`` computed at the
604600last control period ``k-1``, expressed as a deviation from the operating point ``x̂_{op}``.
605601"""
606602function set_warmstart! (mpc:: PredictiveController , transcription:: MultipleShooting , Z̃var)
0 commit comments