Skip to content

Commit c4c9672

Browse files
committed
debug: correctly initialize mhe.D0 window
1 parent 7c0a70a commit c4c9672

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/estimator/mhe/construct.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ struct MovingHorizonEstimator{
179179
D0, De = fill(NT(NaN), nd*(He+1)), fill(NT(NaN), nd*(He+1))
180180
= fill(NT(NaN), nx̂*He)
181181
X̂0_old = fill(NT(NaN), nx̂*He)
182+
D0[1:nd] .= 0 # D0 start with d0(-1) and it should not be NaN
182183
x̂0arr_old = zeros(NT, nx̂)
183184
P̂arr_old = copy(cov.P̂_0)
184185
Nk = [0]

src/estimator/mhe/execute.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ function init_estimate_cov!(estim::MovingHorizonEstimator, y0m, d0, u0)
1818
estim.con.Fx̂ .= 0
1919
if estim.direct
2020
# add y0m(-1) to the extended data window (custom NL constraints):
21-
estim.Yem[1:model.ny] .= y0m .+ @views model.yop[estim.i_ym]
21+
estim.Yem[1:ny] .= y0m .+ @views yop[estim.i_ym]
2222
# add u0(-1) to the two data windows:
23-
estim.U0[1:model.nu] .= u0
24-
estim.Ue[1:model.nu] .= u0 .+ model.uop
23+
estim.U0[1:nu] .= u0
24+
estim.Ue[1:nu] .= u0 .+ uop
2525
# add d0(-1) to the extended data window (custom NL constraints):
26-
model.nd > 0 && (estim.De[1:model.nd] .= d0 .+ model.dop)
26+
nd > 0 && (estim.De[1:nd] .= d0 .+ dop)
2727
end
28-
model.nd > 0 && (estim.D0[1:model.nd] .= d0) # add d0(-1) to the data window
28+
nd > 0 && (estim.D0[1:nd] .= d0) # add d0(-1) to the data window
2929
estim.lastu0 .= u0
3030
# estim.cov.P̂_0 is P̂(-1|-1) if estim.direct==false, else P̂(-1|0)
3131
invert_cov!(estim, estim.cov.P̂_0)
@@ -462,6 +462,7 @@ function initpred!(estim::MovingHorizonEstimator, model::LinModel)
462462
H̃_data .= Ñ_Nk
463463
mul!(H̃_data, ẼZ̃', M_Nk_ẼZ̃, 1, 1)
464464
lmul!(2, H̃_data)
465+
println(q̃)
465466
JuMP.set_objective_function(optim, obj_quadprog(Z̃var, H̃, q̃))
466467
return nothing
467468
end

0 commit comments

Comments
 (0)