Skip to content

Commit 0c1c064

Browse files
committed
debug: getinfo now works
1 parent ccecf56 commit 0c1c064

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/controller/execute.jl

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,22 +115,24 @@ julia> round.(getinfo(mpc)[:Ŷ], digits=3)
115115
function getinfo(mpc::PredictiveController{NT}) where NT<:Real
116116
model, transcription = mpc.estim.model, mpc.transcription
117117
nΔŨ = mpc.Hc*model.nu + mpc.
118-
nŶe, nUe = (mpc.Hp+1)*model.ny, (mpc.Hp+1)*model.nu
118+
nŶe, nUe = (mpc.Hp+1)*model.ny, (mpc.Hp+1)*model.nu
119+
nX̂0, nÛ0 = mpc.estim.nx̂*mpc.Hp, model.nu*mpc.Hp
119120
= mpc.
120121
info = Dict{Symbol, Any}()
121-
Ŷ0, u0, û0 = similar(mpc.Yop), similar(model.uop), similar(model.uop)
122-
Ŷs = similar(mpc.Yop)
123-
x̂0, x̂0next = similar(mpc.estim.x̂0), similar(mpc.estim.x̂0)
124-
Ȳ, Ū = similar(mpc.Yop), similar(mpc.Uop)
125-
ΔŨ = Vector{NT}(undef, nΔŨ)
126-
Ŷe, Ue = Vector{NT}(undef, nŶe), Vector{NT}(undef, nUe)
127-
# careful, 1st arg is Ȳ in NonLinMPC to save memory, but Ŷ0 in this func for clarity:
128-
Ŷ0, x̂0end = predict!(Ŷ0, x̂0next, x̂0, u0, û0, mpc, model, transcription, Z̃)
129-
ΔŨ, Ŷe, Ue = nonlinprog_vectors!(ΔŨ, Ŷe, Ue, Ū, mpc, Ŷ0, Z̃)
130-
J = obj_nonlinprog!(Ȳ, Ū, mpc, model, Ue, Ŷe, ΔŨ, Z̃)
131-
U, Ŷ = Ū, Ȳ
132-
U .= getU0!(U0, mpc, Z̃) .+ mpc.Uop
122+
ΔŨ = Vector{NT}(undef, nΔŨ)
123+
x̂0end = similar(mpc.estim.x̂0)
124+
Ue, Ŷe = Vector{NT}(undef, nUe), Vector{NT}(undef, nŶe)
125+
U0, Ŷ0 = similar(mpc.Uop), similar(mpc.Yop)
126+
X̂0, Û0 = Vector{NT}(undef, nX̂0), Vector{NT}(undef, nÛ0)
127+
U, Ŷ = similar(mpc.Uop), similar(mpc.Yop)
128+
Ŷs = similar(mpc.Yop)
129+
U0 = getU0!(U0, mpc, Z̃)
130+
ΔŨ = getΔŨ!(ΔŨ, mpc, mpc.transcription, Z̃)
131+
Ŷ0, x̂0end = predict!(Ŷ0, x̂0end, X̂0, Û0, mpc, model, transcription, U0, Z̃)
132+
Ue, Ŷe = extended_vectors!(Ue, Ŷe, mpc, U0, Ŷ0)
133+
U .= U0 .+ mpc.Uop
133134
Ŷ .= Ŷ0 .+ mpc.Yop
135+
J = obj_nonlinprog!(Ŷ0, U0, mpc, model, Ue, Ŷe, ΔŨ)
134136
predictstoch!(Ŷs, mpc, mpc.estim)
135137
info[:ΔU] = Z̃[1:mpc.Hc*model.nu]
136138
info[] = mpc.== 1 ? mpc.Z̃[end] : zero(NT)

0 commit comments

Comments
 (0)