Skip to content

Commit bd3600c

Browse files
committed
added: correct E matrix implemented for LinModel
1 parent 04b1692 commit bd3600c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/controller/transcription.jl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,9 @@ each control period ``k``, see [`initpred!`](@ref) and [`linconstraint!`](@ref).
353353
\mathbf{b_x̂} &= \mathbf{W}(H_p-1)\mathbf{\big(f̂_{op} - x̂_{op}\big)}
354354
\end{aligned}
355355
```
356+
The complex structure of the ``\mathbf{E}`` and ``\mathbf{e_x̂}`` matrices is due to the
357+
move blocking implementation: the decision variable ``\mathbf{Z}`` only contains the
358+
input increment ``\mathbf{Δu}`` of the free moves.
356359
"""
357360
function init_predmat(
358361
model::LinModel, estim::StateEstimator{NT}, transcription::SingleShooting, Hp, Hc, nb
@@ -393,14 +396,15 @@ function init_predmat(
393396
nZ = get_nZ(estim, transcription, Hp, Hc)
394397
ex̂ = Matrix{NT}(undef, nx̂, nZ)
395398
E = zeros(NT, Hp*ny, nZ)
396-
for j=1:Hc # truncated with control horizon
399+
for j=1:Hc
397400
iCol = (1:nu) .+ nu*(j-1)
398-
for i=j:Hc
399-
i_Q = i == j ? 0 : nb[i-1]
400-
401+
for i=1:j
402+
i_Q = i > 1 ? nb[i-1] : 0
403+
j_Q = nb[j - i + 1]
404+
iRow = (1:ny*j_Q) .+ nu*sum(nb[1:i-1])
405+
Q = @views E[iRow, iCol]
406+
Q!(Q, i_Q, j_Q)
401407
end
402-
403-
404408
n = j > 1 ? nb[j-1] : 0
405409
ex̂[: , iCol] = W(Hp-n-1)*B̂u
406410
end

0 commit comments

Comments
 (0)