Skip to content

added: handle NaN values in measured output ym for all state estimators#404

Merged
franckgaga merged 13 commits into
mainfrom
NaN_state_estimators
Jul 18, 2026
Merged

added: handle NaN values in measured output ym for all state estimators#404
franckgaga merged 13 commits into
mainfrom
NaN_state_estimators

Conversation

@franckgaga

@franckgaga franckgaga commented Jul 17, 2026

Copy link
Copy Markdown
Member

This is an alternative to #403 essentially implementing the same feature, that is, skipping the correction step when the measured outputs is not available. The advantage compared to #403 is the simplicity in the logic, and a uniform behavior for the MovingHorizonEstimator and all the other state estimators: simply pass a ym vector with NaN values to preparestate! and updatestate! when measurements are not available. Also, assigning nothing to the ym argument in preparestate! and updatestate! functions is equivalent to a vector filled with NaN values.

To summarize, the behavior is:

  • MovingHorizonEstimator : skip all the NaN values in the objective function.
  • IntenalModel : assign a 0 value in the current estimated stochastic output $\mathbf{\hat{y}_s}(k)$ for all NaN values in ym argument.
  • All the Kalman filters and Luenberger: skip the correction step altogether if there is at least one NaN in ym argument. Note that there are other and more refine approaches to this, but skipping the correction step is a good and simple method for this.

A customize @warn is also printed to mention explicitly what is being done to the user.

This effectively implement the functionality mentioned by @baggepinnen in #89.

@franckgaga franckgaga changed the title added: handle NaN values in measured output ym for all state estimators. added: handle NaN values in measured output ym for all state estimators Jul 17, 2026
@codecov-commenter

codecov-commenter commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.38710% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 98.72%. Comparing base (bc0f8e9) to head (690296f).

Files with missing lines Patch % Lines
src/estimator/internal_model.jl 90.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #404   +/-   ##
=======================================
  Coverage   98.71%   98.72%           
=======================================
  Files          27       27           
  Lines        5703     5722   +19     
=======================================
+ Hits         5630     5649   +19     
  Misses         73       73           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

It is more natural to see `initstate!` first.
Most state estimator skip the correction step altogether, except `InternalModel` and `MovingHorizonEstimator`, supporting partial correction out-of-the-box. I choose to customize the warning message for each estimator types for this reason.
@franckgaga
franckgaga merged commit f53bbdc into main Jul 18, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants