Skip to content

Conversation

eslickj
Copy link
Contributor

@eslickj eslickj commented Apr 11, 2025

Fixes None

Adds option to linearly interpolate from MPC TimeSeriesData.

Summary/Motivation:

Sometimes you have time series data that doesn't line up perfectly with model time indexes. @blnicho and @jsiirola, this is part of the recent MHE work.

Changes proposed in this PR:

  • Add some linear interpolation utility functions and use them to add interpolation capbility to get data and time points not in MPC TimeSeriesData

Legal Acknowledgement

By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

@blnicho blnicho requested review from jsiirola, Robbybp and blnicho April 14, 2025 13:45
Copy link
Contributor

@Robbybp Robbybp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the addition. This is definitely functionality we were missing. I think this would be better as it's own interpolate, or get_interpolated_data, method. Would that work for your application?

There is also the question of whether to support some form of interpolation in DynamicModelInterface. (E.g., in get_data_at_time, load_data, or dedicated methods for interpolation.) I'm fine with (and think I prefer) punting for now if you don't need this for your application.

Copy link
Contributor

@Robbybp Robbybp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good once tests pass, thanks!

Copy link

codecov bot commented May 5, 2025

Codecov Report

❌ Patch coverage is 94.73684% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.67%. Comparing base (32591c1) to head (0a25e00).
⚠️ Report is 864 commits behind head on main.

Files with missing lines Patch % Lines
pyomo/contrib/mpc/data/interpolation.py 94.44% 1 Missing ⚠️
pyomo/contrib/mpc/data/series_data.py 95.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3559      +/-   ##
==========================================
- Coverage   88.75%   88.67%   -0.08%     
==========================================
  Files         890      891       +1     
  Lines      102246   102616     +370     
==========================================
+ Hits        90749    90998     +249     
- Misses      11497    11618     +121     
Flag Coverage Δ
builders 26.61% <13.15%> (-0.01%) ⬇️
default 84.87% <94.73%> (?)
expensive 34.00% <13.15%> (?)
linux 86.54% <94.73%> (-1.96%) ⬇️
linux_other 86.54% <94.73%> (+0.29%) ⬆️
osx 82.84% <94.73%> (+0.15%) ⬆️
win 84.75% <94.73%> (+0.17%) ⬆️
win_other 84.75% <94.73%> (+0.17%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

@mrmundt
Copy link
Contributor

mrmundt commented May 6, 2025

@eslickj - Please run black -S -C . on your code with the most recent version of black

@blnicho blnicho merged commit 457f436 into Pyomo:main May 7, 2025
35 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.

6 participants