Skip to content

Commit 356e573

Browse files
committed
doc: comment on the stochastic model with TrapezoidalCollocation
1 parent ab55d5c commit 356e573

File tree

1 file changed

+22
-29
lines changed

1 file changed

+22
-29
lines changed

src/controller/transcription.jl

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ any custom move blocking):
2222
\vdots \\
2323
\mathbf{Δu}(k+H_c-1) \end{bmatrix}
2424
```
25-
This method is generally more efficient for small control horizon ``H_c``, stable and mildly
26-
nonlinear plant model/constraints.
25+
This method computes the predictions by calling the augmented discrete-time model
26+
recursively over the prediction horizon ``H_p`` in the objective function, or by updating
27+
the linear coefficients of the quadratic optimization for [`LinModel`](@ref). It is
28+
generally more efficient for small control horizon ``H_c``, stable and mildly nonlinear
29+
plant model/constraints.
2730
"""
2831
struct SingleShooting <: ShootingMethod end
2932

@@ -48,7 +51,11 @@ operating point ``\mathbf{x̂_{op}}`` (see [`augment_model`](@ref)):
4851
where ``\mathbf{x̂}_i(k+j)`` is the state prediction for time ``k+j``, estimated by the
4952
observer at time ``i=k`` or ``i=k-1`` depending on its `direct` flag. Note that
5053
``\mathbf{X̂_0 = X̂}`` if the operating point is zero, which is typically the case in practice
51-
for [`NonLinModel`](@ref). This transcription method is generally more efficient for large
54+
for [`NonLinModel`](@ref).
55+
56+
This transcription computes the predictions by calling the augmented discrete-time model
57+
in the equality constraint function recursively over ``H_p``, or by updating the linear
58+
equality constraint vector for [`LinModel`](@ref). It is generally more efficient for large
5259
control horizon ``H_c``, unstable or highly nonlinear plant models/constraints.
5360
5461
Sparse optimizers like `OSQP` or `Ipopt` and sparse Jacobian computations are recommended
@@ -61,34 +68,20 @@ struct MultipleShooting <: ShootingMethod end
6168
6269
Construct an implicit trapezoidal [`TranscriptionMethod`](@ref).
6370
64-
This is the simplest collocation method. It is only supported for continuous-time
65-
[`NonLinModel`](@ref)s. It can handle moderately stiff systems and is A-stable. The decision
66-
variables are the same as for [`MultipleShooting`](@ref), hence similar computational costs.
67-
However, it may not be as efficient as more advanced collocation methods for highly stiff
68-
systems. It currently assumes piecewise constant manipulated inputs (or zero-order hold)
69-
between the samples, but linear interpolation will be added in the future. See Extended Help
70-
for more details on the collocation/defect constraints.
71-
72-
# Extended Help
71+
This is the simplest collocation method. It supports continuous-time [`NonLinModel`](@ref)s
72+
only. The decision variables are the same as for [`MultipleShooting`](@ref), hence similar
73+
computational costs. It currently assumes piecewise constant manipulated inputs (or zero-
74+
order hold) between the samples, but linear interpolation will be added soon.
7375
74-
!!! details "Extended Help"
75-
The implicit trapezoidal collocation estimates the defects with:
76-
```math
77-
\mathbf{s_d}(k) = \mathbf{x_0} \frac{T_s}{2}\big(\mathbf{F̂}(k+1) + \mathbf{F̂}(k)\big)
78-
```
79-
where ``T_s`` is the sampling period, ``\mathbf{Ẽ}`` the matrix defined at
80-
[`init_defectmat`](@ref), and ``\mathbf{F̂}(k+j)`` the stacked vector of system
76+
This transcription computes the predictions by calling the continuous-time model in the
77+
equality constraint function and by using the implicit trapezoidal rule. It can handle
78+
moderately stiff systems and is A-stable. However, it may not be as efficient as more
79+
advanced collocation methods for highly stiff systems. Note that the stochastic model of the
80+
unmeasured disturbances is strictly discrete-time, it is thus transcribed separately using
81+
[`MultipleShooting`](@ref).
8182
82-
where ``\mathbf{f̂}(k+j) = \mathbf{f̂}\big(\mathbf{x̂}(k+j), \mathbf{u}(k+j), \mathbf{d}(k+j)\big)``.
83-
This leads to the following defect constraints for ``j=0`` to ``H_p-1``:
84-
```math
85-
\mathbf{ŝ}(k+j) = \mathbf{x̂}(k+j+1) - \mathbf{x̂}(k+j) - \frac{T_s}{2} \big( \mathbf{f̂}(k+j) + \mathbf{f̂}(k+j+1) \big) = 0
86-
```
87-
which are added as equality constraints in the optimization problem. The initial state
88-
``\mathbf{x̂}(k)`` is given by the state estimator, and the future states
89-
``\mathbf{x̂}(k+j+1)`` are decision variables in the optimization problem. The method
90-
requires evaluating the system dynamics at both the current and next time steps, which
91-
can increase computational complexity compared to explicit methods like single shooting.
83+
Sparse optimizers like `Ipopt` and sparse Jacobian computations are recommended for this
84+
transcription method.
9285
"""
9386
struct TrapezoidalCollocation <: CollocationMethod end
9487

0 commit comments

Comments
 (0)