Skip to content

Add update_model utility to utils.py for updating suffix values in Pyomo.DoE #3650

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

sscini
Copy link
Contributor

@sscini sscini commented Jun 27, 2025

Fixes # .

Summary/Motivation:

Currently, there is no way internally to update values for a suffix in a labeled model for parmest or DoE. This PR adds a new utility function to update suffix values when provided the model, the suffix, and the new values.

Changes proposed in this PR:

  • Addition of a utility function for Pyomo.DoE to update model suffix values.

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.

@sscini
Copy link
Contributor Author

sscini commented Jun 27, 2025

@adowling2 @djlaky @blnicho
Hello, this PR is ready for initial review. Currently I have only added the new function, working on an example and tests currently to add as well. All feedback appreciated.

@sscini sscini moved this from Development to Ready for design review in ParmEst & Pyomo.DoE Development Jun 27, 2025
@sscini
Copy link
Contributor Author

sscini commented Jun 27, 2025

This PR adds a new functionality that will be used in other PRs currently being drafted (#3575, #3639).
Early next week I plan to start adding:

Examples

  • Parmest example for modifying unknown parameters and experiment outputs
  • DoE example for modifying experiment inputs, experiment outputs, and measurement error

Testing

  • Tests for new examples
  • Test to show value is changed with each of 4 suffix names
  • Test to show suffix itself maintains its original value
  • Tests for all errors

Copy link

codecov bot commented Jun 29, 2025

Codecov Report

Attention: Patch coverage is 7.14286% with 13 lines in your changes missing coverage. Please review.

Project coverage is 88.92%. Comparing base (fe163bf) to head (a3504f8).
Report is 22 commits behind head on main.

Files with missing lines Patch % Lines
pyomo/contrib/doe/utils.py 7.14% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3650      +/-   ##
==========================================
- Coverage   88.93%   88.92%   -0.02%     
==========================================
  Files         889      889              
  Lines      102486   102500      +14     
==========================================
+ Hits        91144    91146       +2     
- Misses      11342    11354      +12     
Flag Coverage Δ
builders 26.67% <7.14%> (+<0.01%) ⬆️
default 85.51% <7.14%> (?)
expensive 34.02% <7.14%> (?)
linux 86.73% <7.14%> (-1.96%) ⬇️
linux_other 86.73% <7.14%> (-0.02%) ⬇️
osx 83.03% <7.14%> (-0.02%) ⬇️
win 84.93% <7.14%> (-0.02%) ⬇️
win_other 84.93% <7.14%> (-0.02%) ⬇️

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

@mrmundt mrmundt left a comment

Choose a reason for hiding this comment

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

I approved and then thought more about it. This doesn't have any tests. Could you please add a few, even if they are just minimal gut checks?

@sscini
Copy link
Contributor Author

sscini commented Jul 1, 2025

@mrmundt Absolutely, I'm working on a small example and adding checks to show it works and make sure it catches all the errors. Thank you!

@sscini sscini moved this from Ready for design review to Testing in ParmEst & Pyomo.DoE Development Jul 1, 2025
@sscini
Copy link
Contributor Author

sscini commented Jul 1, 2025

Main talking points for meeting 7/1:

  • Main utility made
  • Use strings or an Enum to provide function?

Finished example using unknown parameters, are more needed?
Working on tests as we speak

@sscini
Copy link
Contributor Author

sscini commented Jul 1, 2025

Action items from July 1 meeting:

  • Simplify input to just provide the model.suffix directly
  • Modify example to reflect this
  • Add tests

@sscini
Copy link
Contributor Author

sscini commented Jul 2, 2025

@blnicho @mrmundt @djlaky @adowling2

Context: I developed the utility in doe/utils.py, and added tests to the doe/tests folder.

Problem: DoE tests are failing with current example for experiment outputs and measurement error, says they are uninitialized.

Proposed Solution: I made an additional example (with a parmest model) to show it works with unknown parameters, experiment outputs, and measurement_error.

Question: Would it be better for me to keep everything in contrib/doe, or can I add testing and an example in parmest using a function from doe? Trying to minimize new imports needed. Thoughts?

TLDR: Does it matter if I add items to doe and parmest contrib folders in same PR? Imports will overlap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Reviewer Approved
Development

Successfully merging this pull request may close these issues.

4 participants