Skip to content

Commit d7f0fbc

Browse files
committed
added: efficient Z̃ to ΔŨ conversion
1 parent 5c85eeb commit d7f0fbc

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/controller/transcription.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,8 +1022,14 @@ function set_warmstart!(mpc::PredictiveController, transcription::MultipleShooti
10221022
return Z̃s
10231023
end
10241024

1025-
getΔŨ!(ΔŨ, mpc::PredictiveController, ::SingleShooting, Z̃) = (ΔŨ .= Z̃) # since mpc.P̃Δu = I
1026-
getΔŨ!(ΔŨ, mpc::PredictiveController, ::TranscriptionMethod, Z̃) = mul!(ΔŨ, mpc.P̃Δu, Z̃)
1025+
getΔŨ!(ΔŨ, mpc::PredictiveController, ::SingleShooting, Z̃) = (ΔŨ .= Z̃)
1026+
function getΔŨ!(ΔŨ, mpc::PredictiveController, ::TranscriptionMethod, Z̃)
1027+
# avoid explicit matrix multiplication with mpc.P̃Δu for performance:
1028+
nΔU = mpc.Hc*mpc.estim.model.nu
1029+
ΔŨ[1:nΔU] .= @views Z̃[1:nΔU]
1030+
mpc.== 1 && (ΔŨ[end] = Z̃[end])
1031+
return ΔŨ
1032+
end
10271033
getU0!(U0, mpc::PredictiveController, Z̃) = (mul!(U0, mpc.P̃u, Z̃) .+ mpc.Tu_lastu0)
10281034

10291035
@doc raw"""

0 commit comments

Comments
 (0)