Skip to content

added: handle NaN values in measured outputs ym for MovingHorizonEstimator#402

Merged
franckgaga merged 7 commits into
mainfrom
mhe_nonfinite
Jul 15, 2026
Merged

added: handle NaN values in measured outputs ym for MovingHorizonEstimator#402
franckgaga merged 7 commits into
mainfrom
mhe_nonfinite

Conversation

@franckgaga

@franckgaga franckgaga commented Jul 15, 2026

Copy link
Copy Markdown
Member

The data windows of the MovingHorizonEstimator did not handle the NaN values explicitly before this PR. The results was different from an optimizer to another e.g.: error thrown, NaN propagation, etc. This PR introduces explicit handling of NaN values.

Measured outputs ym

If a NaN value appears in the $\mathbf{y^m}$ vectors it will be ignored in the objective function. More precisely, the associated estimated sensor noise $\mathbf{\hat{v}}$ will be $\mathbf{0}$ when evaluating the objective function and a @warn will be printed. This is the natural and logical behavior, that is, treat it like a missing measurement hence no impact in the costs.

Measured disturbances d and manipulated Inputs u

However, an ArgumentError error will be thrown with an explicit throw call if a NaN value appears in the manipulated inputs $\mathbf{u}$ or measured disturbances $\mathbf{d}$ vectors, since they are arguments of the dynamic. The behavior is not as well-defined. It's better to throw an explicit error. The user can catch it and replace the values in $\mathbf{u}$ or $\mathbf{d}$ if he really want to continue the execution.

This is cleaner like this. There is no reason to silently support `Inf` values in `Y0m` (the behavior is not really defined). Non-finite values ind `D0` window should not be supported since the behavior is not clearly defined in general (since the vector is argument of the dynamics).
@codecov-commenter

codecov-commenter commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.71%. Comparing base (d2c359c) to head (e8d73f9).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #402   +/-   ##
=======================================
  Coverage   98.71%   98.71%           
=======================================
  Files          27       27           
  Lines        5691     5703   +12     
=======================================
+ Hits         5618     5630   +12     
  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.

@franckgaga franckgaga merged commit bc0f8e9 into main Jul 15, 2026
5 checks passed
@franckgaga franckgaga deleted the mhe_nonfinite branch July 15, 2026 23:08
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