@@ -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
470469end
@@ -481,7 +480,7 @@ Also init ``\mathbf{F_x̂ = G_x̂ U_0 + J_x̂ D_0 + B_x̂}`` vector for the stat
481480"""
482481function 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. Z̃
629628end
0 commit comments