Skip to content

Commit

Permalink
Merge pull request #163 from baggepinnen/detect_ip
Browse files Browse the repository at this point in the history
more robust detection of inplace measurement for MeasurementOop
  • Loading branch information
baggepinnen authored Nov 25, 2024
2 parents 1bc4337 + 99f6da8 commit 9a86fe2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LowLevelParticleFilters"
uuid = "d9d29d28-c116-5dba-9239-57a5fe23875b"
authors = ["baggepinnen <[email protected]>"]
version = "3.10.0"
version = "3.10.1"

[deps]
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Expand Down
8 changes: 4 additions & 4 deletions docs/src/neural_network.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ ukf = UnscentedKalmanFilter(dynamics, measurement, R1, R2, SimpleMvNormal(s0, 10
@time sole = forward_trajectory(ekf, data.u, data.x)
@time solu = forward_trajectory(ukf, data.u, data.x)
plot(sole, plotx=false, plotxt=false, plotyh=true, plotyht=false, plotu=false, plote=true, name="EKF", layout=(nx, 1))
plot!(solu, plotx=false, plotxt=false, plotyh=true, plotyht=false, plotu=false, plote=true, name="UKF", ploty=false, size=(1200, 1500))
plot(sole, plotx=false, plotxt=false, plotyh=true, plotyht=false, plotu=false, plote=true, name="EKF", layout=(nx, 1), size=(1200, 1500))
plot!(solu, plotx=false, plotxt=false, plotyh=true, plotyht=false, plotu=false, plote=true, name="UKF", ploty=false)
DisplayAs.PNG(Plots.current()) # hide
```

Expand Down Expand Up @@ -180,12 +180,12 @@ Performing the estimation using the Extended Kalman Filter took
```julia
using BenchmarkTools
@btime forward_trajectory(ekf, data.u, data.x);
46.034 ms (77872 allocations: 123.45 MiB)
# 46.034 ms (77872 allocations: 123.45 MiB)
```
and with the Unscented Kalman Filter
```julia
@btime forward_trajectory(ukf, data.u, data.x);
142.608 ms (2134370 allocations: 224.82 MiB)
# 142.608 ms (2134370 allocations: 224.82 MiB)
```

The EKF is a bit faster, which is to be expected. Both methods are very fast from a neural-network training perspective, but the performance will not scale favorably to very large network sizes.
Expand Down
2 changes: 1 addition & 1 deletion src/kalman.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ end
function (kfm::MeasurementOop)(x,u,p,t)
kf = kfm.kf
mfun = measurement(kf)
if has_ip(mfun)
if kf isa UnscentedKalmanFilter{<:Any,true} || kf isa ExtendedKalmanFilter{<:Any,true}
y = zeros(kf.ny)
mfun(y,x,u,p,t)
return y
Expand Down

0 comments on commit 9a86fe2

Please sign in to comment.