Skip to content

Commit b92be59

Browse files
committed
debug: mhe.D0 contains one add. sample
1 parent 17fd2f7 commit b92be59

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

src/estimator/mhe/execute.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,6 @@ function initpred!(estim::MovingHorizonEstimator, model::LinModel)
464464
H̃_data .= Ñ_Nk
465465
mul!(H̃_data, ẼZ̃', M_Nk_ẼZ̃, 1, 1)
466466
lmul!(2, H̃_data)
467-
println(q̃)
468467
JuMP.set_objective_function(optim, obj_quadprog(Z̃var, H̃, q̃))
469468
return nothing
470469
end
@@ -481,7 +480,7 @@ Also init ``\mathbf{F_x̂ = G_x̂ U_0 + J_x̂ D_0 + B_x̂}`` vector for the stat
481480
"""
482481
function linconstraint!(estim::MovingHorizonEstimator, model::LinModel)
483482
nx̂, nŵ, nym, Nk = estim.nx̂, estim.nx̂, estim.nym, estim.Nk[]
484-
nU, nX̂, nD = model.nu*Nk, estim.nx̂*Nk, model.nd*Nk
483+
nU, nX̂, nD = model.nu*Nk, estim.nx̂*Nk, model.nd*(Nk+1)
485484
# --- truncate vector and matrices if necessary ---
486485
if Nk < estim.He
487486
# avoid views since allocations only when Nk < He and we want fast mul!:
@@ -623,7 +622,7 @@ function optim_objective!(estim::MovingHorizonEstimator{NT}) where NT<:Real
623622
estim.Ŵ[1:nŵ*Nk] .= @views estim.Z̃[nx̃+1:nx̃+nŵ*Nk] # update Ŵ with optimum for warm-start
624623
getarrival!(x̂0arr, estim, estim.Z̃)
625624
predict_mhe!(V̂, X̂0, û0, k, ŷ0, estim, model, x̂0arr, estim.Ŵ, estim.Z̃)
626-
x̂0corrORnext = @views X̂0[Nk*nx̂-nx̂+1:Nk*nx̂]
625+
x̂0corrORnext = @views X̂0[((Nk-1)*nx̂+1):(Nk*nx̂)]
627626
estim.x̂0 .= x̂0corrORnext
628627
return estim.
629628
end

0 commit comments

Comments
 (0)