Skip to content

Commit 189b6ed

Browse files
committed
added: Q!(Q, i, j) function for move blocking
1 parent 891156c commit 189b6ed

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/controller/transcription.jl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ each control period ``k``, see [`initpred!`](@ref) and [`linconstraint!`](@ref).
332332
\mathbf{Ĉ}\mathbf{Â}^{2} \\
333333
\vdots \\
334334
\mathbf{Ĉ}\mathbf{Â}^{H_p} \end{bmatrix} \\
335-
\mathbf{V} &= Q(0, H_p) \\
335+
\mathbf{V} &= \mathbf{Q}(0, H_p) \\
336336
\mathbf{B} &= \begin{bmatrix}
337337
\mathbf{Ĉ W}(0) \\
338338
\mathbf{Ĉ W}(1) \\
@@ -376,9 +376,16 @@ function init_predmat(
376376
end
377377
# Apow_csum 3D array : Apow_csum[:,:,1] = A^0, Apow_csum[:,:,2] = A^1 + A^0, ...
378378
Âpow_csum = cumsum(Âpow, dims=3)
379-
# two helper functions to improve code clarity and be similar to eqs. in docstring:
379+
# three helper functions to improve code clarity and be similar to eqs. in docstring:
380380
getpower(array3D, power) = @views array3D[:,:, power+1]
381381
W(m) = @views Âpow_csum[:,:, m+1]
382+
function Q!(Q, i, j)
383+
for=1:j
384+
iRows = (1:ny) .+ ny*(ℓ-1)
385+
Q[iRows, :] =*W(i+-1)*B̂u
386+
end
387+
return Q
388+
end
382389
# --- current state estimates x̂0 ---
383390
kx̂ = getpower(Âpow, Hp)
384391
K = Matrix{NT}(undef, Hp*ny, nx̂)
@@ -387,7 +394,7 @@ function init_predmat(
387394
K[iRow,:] =*getpower(Âpow, j)
388395
end
389396
# --- previous manipulated inputs lastu0 ---
390-
vx̂ = W(H_p-1)*B̂u
397+
vx̂ = W(Hp-1)*B̂u
391398
V = Matrix{NT}(undef, Hp*ny, nu)
392399
for j=1:Hp
393400
iRow = (1:ny) .+ ny*(j-1)

0 commit comments

Comments
 (0)