Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions benchmark/2_bench_state_estim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ UNIT_ESTIM["ExtendedKalmanFilter"]["evaloutput"]["NonLinModel"] =

mhe_lin_curr = MovingHorizonEstimator(linmodel, He=10, direct=true)
mhe_lin_pred = MovingHorizonEstimator(linmodel, He=10, direct=false)
mhe_lin_skf = MovingHorizonEstimator(linmodel, He=10, covestim=SteadyKalmanFilter(linmodel))
mhe_nonlin_curr = MovingHorizonEstimator(nonlinmodel, He=10, direct=true)
mhe_nonlin_pred = MovingHorizonEstimator(nonlinmodel, He=10, direct=false)

Expand All @@ -161,6 +162,12 @@ UNIT_ESTIM["MovingHorizonEstimator"]["updatestate!"]["LinModel"]["Current form"]
setup=preparestate!($mhe_lin_curr, $y, $d),
samples=samples, evals=evals, seconds=seconds,
)
UNIT_ESTIM["MovingHorizonEstimator"]["updatestate!"]["LinModel"]["Constant arr. cov."] =
@benchmarkable(
updatestate!($mhe_lin_skf, $u, $y, $d),
setup=preparestate!($mhe_lin_skf, $y, $d),
samples=samples, evals=evals, seconds=seconds,
)
UNIT_ESTIM["MovingHorizonEstimator"]["preparestate!"]["LinModel"]["Prediction form"] =
@benchmarkable(
preparestate!($mhe_lin_pred, $y, $d),
Expand Down
2 changes: 2 additions & 0 deletions check_syntax.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import JuliaFormatter
include("src/estimator/mhe/execute.jl")
17 changes: 15 additions & 2 deletions src/estimator/mhe/execute.jl
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ function correct_cov!(estim::MovingHorizonEstimator)
correct_estimate!(estim.covestim, y0marr, d0arr)
all(isfinite, estim.covestim.cov.P̂) || error("Arrival covariance P̄ is not finite")
estim.P̂arr_old .= estim.covestim.cov.
invert_cov!(estim, estim.P̂arr_old)
update_arrival_cov!(estim)
catch err
if err isa PosDefException
@error("Arrival covariance P̄ is not positive definite: keeping the old one")
Expand All @@ -736,7 +736,7 @@ function update_cov!(estim::MovingHorizonEstimator)
update_estimate!(estim.covestim, y0marr, d0arr, u0arr)
all(isfinite, estim.covestim.cov.P̂) || error("Arrival covariance P̄ is not finite")
estim.P̂arr_old .= estim.covestim.cov.
invert_cov!(estim, estim.P̂arr_old)
update_arrival_cov!(estim)
catch err
if err isa PosDefException
@error("Arrival covariance P̄ is not positive definite: keeping the old one")
Expand Down Expand Up @@ -764,6 +764,19 @@ function invert_cov!(estim::MovingHorizonEstimator, P̄)
return nothing
end

"Update the arrival covariance matrix at the next time step based on the covariance estimator type."
function update_arrival_cov!(estim::MovingHorizonEstimator)
_update_arrival_cov!(estim, estim.covestim)
end

function _update_arrival_cov!(estim::MovingHorizonEstimator, ::StateEstimator)
invert_cov!(estim, estim.P̂arr_old)
end

function _update_arrival_cov!(estim::MovingHorizonEstimator, ::SteadyKalmanFilter)
return nothing
end

"""
obj_nonlinprog(estim::MovingHorizonEstimator, ::LinModel, _ , _ , _ , Z̃)
Expand Down
Loading