Skip to content

Commit 7c18482

Browse files
committed
added: print Jacobian for ExtendedKalmanFilter
1 parent 2ca708a commit 7c18482

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

src/estimator/kalman.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,10 @@ function update_estimate!(estim::ExtendedKalmanFilter{NT}, y0m, d0, u0) where NT
11771177
return predict_estimate_kf!(estim, u0, d0, F̂)
11781178
end
11791179

1180+
function print_details(io::IO, estim::ExtendedKalmanFilter)
1181+
println(io, "├ jacobian: $(backend_str(estim.jacobian))")
1182+
end
1183+
11801184
"Set `estim.cov.P̂` to `estim.cov.P̂_0` for the time-varying Kalman Filters."
11811185
function init_estimate_cov!(
11821186
estim::Union{KalmanFilter, UnscentedKalmanFilter, ExtendedKalmanFilter}, _ , _ , _

src/estimator/mhe.jl

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
11
include("mhe/construct.jl")
22
include("mhe/execute.jl")
33

4-
function Base.show(io::IO, estim::MovingHorizonEstimator)
5-
model = estim.model
6-
nu, nd = model.nu, model.nd
7-
nx̂, nym, nyu = estim.nx̂, estim.nym, estim.nyu
8-
n = maximum(ndigits.((nu, nx̂, nym, nyu, nd))) + 1
9-
println(io, "$(nameof(typeof(estim))) estimator with a sample time Ts = $(model.Ts) s:")
10-
println(io, "├ model: $(nameof(typeof(model)))")
4+
"Print optimizer and other information for `MovingHorizonEstimator`."
5+
function print_details(io::IO, estim::MovingHorizonEstimator)
116
println(io, "├ optimizer: $(JuMP.solver_name(estim.optim)) ")
12-
print_backends(io, estim, model)
13-
println(io, "└ dimensions:")
14-
print_estim_dim(io, estim, n)
7+
print_backends(io, estim, estim.model)
158
end
169

10+
"Print the differentiation backends for `SimModel`."
1711
function print_backends(io::IO, estim::MovingHorizonEstimator, ::SimModel)
1812
println(io, "├ gradient: $(backend_str(estim.gradient))")
1913
println(io, "├ jacobian: $(backend_str(estim.jacobian))")
2014
end
15+
"No differentiation backends to print for `LinModel`."
2116
print_backends(::IO, ::MovingHorizonEstimator, ::LinModel) = nothing
2217

23-
2418
"Print the overall dimensions of the MHE `estim` with left padding `n`."
2519
function print_estim_dim(io::IO, estim::MovingHorizonEstimator, n)
2620
nu, nd = estim.model.nu, estim.model.nd

src/model/nonlinmodel.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,9 @@ include("solver.jl")
315315

316316
function print_details(io::IO, model::NonLinModel{<:Real, <:RungeKutta{N}}) where N
317317
println(io, "├ solver: $(nameof(typeof(model.solver)))($N)")
318-
println(io, "linearization: $(backend_str(model.jacobian))")
318+
println(io, "jacobian: $(backend_str(model.jacobian))")
319319
end
320320
function print_details(io::IO, model::NonLinModel)
321321
println(io, "├ solver: $(nameof(typeof(model.solver)))")
322-
println(io, "linearization: $(backend_str(model.jacobian))")
322+
println(io, "jacobian: $(backend_str(model.jacobian))")
323323
end

src/state_estim.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,14 @@ function Base.show(io::IO, estim::StateEstimator)
3535
n = maximum(ndigits.((nu, nx̂, nym, nyu, nd))) + 1
3636
println(io, "$(nameof(typeof(estim))) estimator with a sample time Ts = $(model.Ts) s:")
3737
println(io, "├ model: $(nameof(typeof(estim.model)))")
38+
print_details(io, estim)
3839
println(io, "└ dimensions:")
3940
print_estim_dim(io, estim, n)
4041
end
4142

43+
"Print additional details of `estim` if any (no details by default)."
44+
print_details(::IO, ::StateEstimator) = nothing
45+
4246
"Print the overall dimensions of the state estimator `estim` with left padding `n`."
4347
function print_estim_dim(io::IO, estim::StateEstimator, n)
4448
nu, nd = estim.model.nu, estim.model.nd

0 commit comments

Comments
 (0)