Skip to content

Commit 170892a

Browse files
committed
debug: MHE LinModel uses Nk variables
1 parent a4a9a06 commit 170892a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/estimator/mhe.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,7 @@ The ``H̃`` matrix of the quadratic general form is not constant here because of
988988
time-varying ``\mathbf{P̄}`` weight (the estimation error covariance at arrival).
989989
"""
990990
function initpred!(estim::MovingHorizonEstimator, model::LinModel)
991+
optim = estim.optim
991992
nx̂, nŵ, nym, Nk = estim.nx̂, estim.nx̂, estim.nym, estim.Nk[]
992993
nYm, nŴ = nym*Nk, nŵ*Nk
993994
nZ̃ = nx̂ + nŴ
@@ -1005,10 +1006,11 @@ function initpred!(estim::MovingHorizonEstimator, model::LinModel)
10051006
Ñ_Nk = [zeros(nx̂, nZ̃); zeros(nŴ, nx̂) invQ̂_Nk]
10061007
estim.q̃[1:nZ̃] = 2(M_Nk*Ẽ_Nk)'*F_Nk
10071008
estim.p[] = dot(F_Nk, M_Nk, F_Nk)
1008-
= 2*(Ẽ_Nk'*M_Nk*Ẽ_Nk + Ñ_Nk)
1009-
estim..data[1:nZ̃, 1:nZ̃] =
1010-
Z̃var::Vector{VariableRef} = estim.optim[:Z̃var]
1011-
set_objective_function(estim.optim, obj_quadprog(Z̃var, estim.H̃, estim.q̃))
1009+
estim..data[1:nZ̃, 1:nZ̃] = 2*(Ẽ_Nk'*M_Nk*Ẽ_Nk + Ñ_Nk)
1010+
Z̃var_Nk::Vector{VariableRef} = @views optim[:Z̃var][1:nZ̃]
1011+
H̃_Nk = @views estim.H̃[1:nZ̃,1:nZ̃]
1012+
q̃_Nk = @views estim.q̃[1:nZ̃]
1013+
set_objective_function(optim, obj_quadprog(Z̃var_Nk, H̃_Nk, q̃_Nk))
10121014
return nothing
10131015
end
10141016

0 commit comments

Comments
 (0)