Skip to content

Commit 02bcdb5

Browse files
committed
changed: hold order nh renamed to h
1 parent 4b0c849 commit 02bcdb5

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/controller/transcription.jl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,16 @@ for this transcription method.
6464
struct 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
7171
This is the simplest collocation method. It supports continuous-time [`NonLinModel`](@ref)s
7272
only. 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 ``\mathbf{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 ``\mathbf{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
7878
This transcription computes the predictions by calling the continuous-time model in the
7979
equality constraint function and by using the implicit trapezoidal rule. It can handle
@@ -94,14 +94,14 @@ transcription method.
9494
for more details.
9595
"""
9696
struct 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
106106
end
107107

@@ -1382,11 +1382,11 @@ extracted from the decision variables `Z̃`. The ``\mathbf{k}`` coefficients are
13821382
evaluated from the continuous-time function `model.f!` and:
13831383
```math
13841384
\begin{aligned}
1385-
\mathbf{k}_1 &= \mathbf{f}\Big(\mathbf{x_0}(k), \mathbf{û_0}(k), \mathbf{d_0}(k) \Big) \\
1386-
\mathbf{k}_2 &= \mathbf{f}\Big(\mathbf{x_0}(k+1), \mathbf{û_0}(k), \mathbf{d_0}(k+1)\Big)
1385+
\mathbf{k}_1 &= \mathbf{f}\Big(\mathbf{x_0}(k), \mathbf{û_0}(k), \mathbf{d_0}(k) \Big) \\
1386+
\mathbf{k}_2 &= \mathbf{f}\Big(\mathbf{x_0}(k+1), \mathbf{û_0}(k+h), \mathbf{d_0}(k+1)\Big)
13871387
\end{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
\mathbf{û_0}(k) = \mathbf{u_0}(k) + \mathbf{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-2nx̂+1:end-nx̂], X̂0_Z̃[end-nx̂+1:end]
14581458
k1, k2 = @views K0[end-2nx+1:end-nx], K0[end-nx+1:end] # k1 already filled

0 commit comments

Comments
 (0)