@@ -64,16 +64,16 @@ for this transcription method.
6464struct MultipleShooting <: ShootingMethod end
6565
6666@doc raw """
67- TrapezoidalCollocation(nh ::Int=0)
67+ TrapezoidalCollocation(h ::Int=0)
6868
69- Construct an implicit trapezoidal [`TranscriptionMethod`](@ref) with `nh `th order hold.
69+ Construct an implicit trapezoidal [`TranscriptionMethod`](@ref) with `h `th order hold.
7070
7171This is the simplest collocation method. It supports continuous-time [`NonLinModel`](@ref)s
7272only. The decision variables are the same as for [`MultipleShooting`](@ref), hence similar
73- computational costs. The `nh ` argument is `0` or `1`, for piecewise constant or linear
74- manipulated inputs ``\m athbf{u}`` (`nh =1` is slightly less expensive). Note that the various
75- [`DiffSolver`](@ref) assume zero-order hold, so `nh =1` will induce a mismatch if the plant
76- is simulated using these solvers.
73+ computational costs. The `h ` argument is `0` or `1`, for piecewise constant or linear
74+ manipulated inputs ``\m athbf{u}`` (`h =1` is slightly less expensive). Note that the various
75+ [`DiffSolver`](@ref) here assume zero-order hold, so `h =1` will induce a plant-model
76+ mismatch if the plant is simulated with these solvers.
7777
7878This transcription computes the predictions by calling the continuous-time model in the
7979equality constraint function and by using the implicit trapezoidal rule. It can handle
@@ -94,14 +94,14 @@ transcription method.
9494 for more details.
9595"""
9696struct TrapezoidalCollocation <: CollocationMethod
97- nh :: Int
97+ h :: Int
9898 nc:: Int
99- function TrapezoidalCollocation (nh :: Int = 0 )
100- if ! (nh == 0 || nh == 1 )
101- throw (ArgumentError (" nh argument must be 0 or 1 for TrapezoidalCollocation." ))
99+ function TrapezoidalCollocation (h :: Int = 0 )
100+ if ! (h == 0 || h == 1 )
101+ throw (ArgumentError (" h argument must be 0 or 1 for TrapezoidalCollocation." ))
102102 end
103103 nc = 2 # 2 collocation points per interval for trapezoidal rule
104- return new (nh , nc)
104+ return new (h , nc)
105105 end
106106end
107107
@@ -1382,11 +1382,11 @@ extracted from the decision variables `Z̃`. The ``\mathbf{k}`` coefficients are
13821382evaluated from the continuous-time function `model.f!` and:
13831383```math
13841384\b egin{aligned}
1385- \m athbf{k}_1 &= \m athbf{f}\B ig(\m athbf{x_0}(k), \m athbf{û_0}(k), \m athbf{d_0}(k) \B ig) \\
1386- \m athbf{k}_2 &= \m athbf{f}\B ig(\m athbf{x_0}(k+1), \m athbf{û_0}(k), \m athbf{d_0}(k+1)\B ig)
1385+ \m athbf{k}_1 &= \m athbf{f}\B ig(\m athbf{x_0}(k), \m athbf{û_0}(k), \m athbf{d_0}(k) \B ig) \\
1386+ \m athbf{k}_2 &= \m athbf{f}\B ig(\m athbf{x_0}(k+1), \m athbf{û_0}(k+h ), \m athbf{d_0}(k+1)\B ig)
13871387\e nd{aligned}
13881388```
1389- and the input of the augmented model is:
1389+ in which ``h`` is the hold order `transcription.h` and the disturbed input is:
13901390```math
13911391\m athbf{û_0}(k) = \m athbf{u_0}(k) + \m athbf{C_{s_u} x_s}(k)
13921392```
@@ -1397,7 +1397,7 @@ function con_nonlinprogeq!(
13971397 mpc:: PredictiveController , model:: NonLinModel , transcription:: TrapezoidalCollocation ,
13981398 U0, Z̃
13991399)
1400- nu, nx̂, nd, nx, nh = model. nu, mpc. estim. nx̂, model. nd, model. nx, transcription. nh
1400+ nu, nx̂, nd, nx, h = model. nu, mpc. estim. nx̂, model. nd, model. nx, transcription. h
14011401 Hp, Hc = mpc. Hp, mpc. Hc
14021402 nΔU, nX̂ = nu* Hc, nx̂* Hp
14031403 Ts, p = model. Ts, model. p
@@ -1407,7 +1407,7 @@ function con_nonlinprogeq!(
14071407 X̂0_Z̃ = @views Z̃[(nΔU+ 1 ): (nΔU+ nX̂)]
14081408 x̂0 = @views mpc. estim. x̂0[1 : nx̂]
14091409 d0 = @views mpc. d0[1 : nd]
1410- if ! iszero (nh )
1410+ if ! iszero (h )
14111411 k1, u0, û0 = @views K0[1 : nx], U0[1 : nu], Û0[1 : nu]
14121412 x0, xs = @views x̂0[1 : nx], x̂0[nx+ 1 : end ]
14131413 mul! (û0, Cs_u, xs)
@@ -1431,7 +1431,7 @@ function con_nonlinprogeq!(
14311431 mul! (xsnext, As, xs)
14321432 ssnext .= @. xsnext - xsnext_Z̃
14331433 # ----------------- deterministic defects --------------------------------------
1434- if iszero (nh ) # piecewise constant manipulated inputs u:
1434+ if iszero (h ) # piecewise constant manipulated inputs u:
14351435 u0 = @views U0[(1 + nu* (j- 1 )): (nu* j)]
14361436 û0 = @views Û0[(1 + nu* (j- 1 )): (nu* j)]
14371437 mul! (û0, Cs_u, xs) # ys_u(k) = Cs_u*xs(k)
@@ -1452,7 +1452,7 @@ function con_nonlinprogeq!(
14521452 x̂0 = x̂0next_Z̃ # using states in Z̃ for next iteration (allow parallel for)
14531453 d0 = d0next
14541454 end
1455- if ! iszero (nh )
1455+ if ! iszero (h )
14561456 # j = Hp special case: u(k+Hp-1) = u(k+Hp) since Hc ≤ Hp implies Δu(k+Hp)=0
14571457 x̂0, x̂0next_Z̃ = @views X̂0_Z̃[end - 2 nx̂+ 1 : end - nx̂], X̂0_Z̃[end - nx̂+ 1 : end ]
14581458 k1, k2 = @views K0[end - 2 nx+ 1 : end - nx], K0[end - nx+ 1 : end ] # k1 already filled
0 commit comments