Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve difference between input and update #860

Merged
merged 3 commits into from
Jan 7, 2025

Conversation

mgovers
Copy link
Member

@mgovers mgovers commented Dec 18, 2024

It turns out that input data and update data are not treated exactly the same way in power sensors.

When rounding errors caused by this propagate, a difference may occur between single calculations run with measurement data provided in input data, or (batch or single) calculations with power sensor measurements provided in (batch or permanent) update data.

NOTE: similar rounding errors introduced when calculating the inverse update may also propagate to other scenarios, so the result may even differ between different orderings of batch scenarios or threading levels

  • power sensor
    • this fix works as is for the input vs update of power sensor
    • but not yet for the inverse update EDIT: as mentioned below: we do not apply the propagation of inverse update calculation in this PR. It may not be as big of an issue as one would expect.
  • voltage sensor
    • from a quick investigation, it turns out that the voltage sensor may also be prone to this, but no combination of values that reproduces this bug has been found yet EDIT: a combination of values was found and added to the unit tests.
  • other component types
    • it seems that other component types are not prone to this bug, because their input/update values are directly stored without modifications.
    • this suggests that doing so for the sensors as well provides a sustainable solution

@mgovers mgovers added the bug Something isn't working label Dec 18, 2024
@mgovers mgovers self-assigned this Dec 18, 2024
@TonyXiang8787
Copy link
Member

@mgovers what exactly is the drifting here? We do not have addition/subtraction drift right? Multiple/division usually does not cause large drift.

@mgovers
Copy link
Member Author

mgovers commented Dec 18, 2024

@mgovers what exactly is the drifting here? We do not have addition/subtraction drift right? Multiple/division usually does not cause large drift.

  • for single run vs batch run:
    • the test case in which we found this apparently is sensitive to initial conditions.
    • the small floating point difference therefore is enlarged
    • as a result, in one case, a single calculation may end up converging while a single-scenario batch calculation diverges, or vice versa
  • for the inverse update case:
    • there is also inverse update drift, which indeed is only multiplication and subtraction rounding errors
    • however, they may still accumulate for batch calculations with very many scenarios
    • similarly, accumulation is possible for repeated calculations with the same model instance
    • again, grids that are relatively sensitive to initial conditions may also enlarge these effects

@mgovers mgovers force-pushed the bugfix/propagating-rounding-errors branch from 226015e to 09d1dac Compare January 6, 2025 12:46
@mgovers mgovers marked this pull request as ready for review January 6, 2025 13:10
@mgovers mgovers requested a review from TonyXiang8787 January 6, 2025 13:10
@mgovers
Copy link
Member Author

mgovers commented Jan 6, 2025

@TonyXiang8787 I added you as a reviewer because I would like you to be the one to sign off on this change.

@mgovers mgovers enabled auto-merge January 6, 2025 13:22
@mgovers mgovers changed the title Difference between input and update Resolve difference between input and update Jan 6, 2025
@mgovers mgovers added this pull request to the merge queue Jan 7, 2025
Merged via the queue into main with commit c8865db Jan 7, 2025
28 checks passed
@mgovers mgovers deleted the bugfix/propagating-rounding-errors branch January 7, 2025 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants