Skip to content

MPC Load Data Ignore Expressions#3868

Open
eslickj wants to merge 9 commits intoPyomo:mainfrom
eslickj:mpc_load_expr
Open

MPC Load Data Ignore Expressions#3868
eslickj wants to merge 9 commits intoPyomo:mainfrom
eslickj:mpc_load_expr

Conversation

@eslickj
Copy link
Contributor

@eslickj eslickj commented Mar 6, 2026

Fixes None

Summary/Motivation:

When loading MPC data into a model, if a data key is an Expression, the model will get messed up because the expression will be replaced. This PR makes loading MPC data into a model ignore expressions.

Changes proposed in this PR:

  • Ignore expressions when loading MPC data into a model
  • When interpolating MPC data if a data point is None make the interpolated value None

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.

@codecov
Copy link

codecov bot commented Mar 6, 2026

Codecov Report

❌ Patch coverage is 85.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.67%. Comparing base (7ad143c) to head (bee3b23).

Files with missing lines Patch % Lines
pyomo/contrib/mpc/interfaces/load_data.py 80.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3868   +/-   ##
=======================================
  Coverage   89.67%   89.67%           
=======================================
  Files         908      908           
  Lines      106735   106750   +15     
=======================================
+ Hits        95717    95732   +15     
  Misses      11018    11018           
Flag Coverage Δ
builders 29.07% <15.00%> (-0.02%) ⬇️
default 85.96% <85.00%> (?)
expensive 35.51% <15.00%> (?)
linux 87.13% <85.00%> (-2.03%) ⬇️
linux_other 87.13% <85.00%> (-0.01%) ⬇️
oldsolvers 28.01% <15.00%> (+0.01%) ⬆️
osx 82.47% <85.00%> (+0.42%) ⬆️
win 85.55% <85.00%> (-0.01%) ⬇️
win_other 85.55% <85.00%> (-0.01%) ⬇️

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.

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.

I imagine this is coming up because, on one side, you're saving data with include_named_expressions=True, then later loading that data into the model gives an error?

What do you mean by this?

the model will get messed up because the expression will be replaced

Can you provide an example?

Handling None like this for interpolation makes sense to me.

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, thanks for this fix.

Copy link
Member

@jsiirola jsiirola left a comment

Choose a reason for hiding this comment

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

Some super-minor changes; otherwise LGTM.

eslickj and others added 4 commits March 13, 2026 07:44
Co-authored-by: John Siirola <jsiirola@users.noreply.github.com>
Co-authored-by: John Siirola <jsiirola@users.noreply.github.com>
Co-authored-by: John Siirola <jsiirola@users.noreply.github.com>
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