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

Extend valid types for PyROS solver argument uncertain_params #3439

Merged
merged 46 commits into from
Feb 5, 2025

Conversation

shermanjasonaf
Copy link
Contributor

@shermanjasonaf shermanjasonaf commented Nov 30, 2024

Summary/Motivation:

Motivated by recent user feedback, this PR adds support for the speciifcation of Var and VarData objects as (entries of) the argument uncertain_params to contrib.pyros.PyROS.solve(). Thus, the argument uncertain_params can now be a Param, ParamData, Var, or VarData instance, or an iterable sequence of such instances. All VarData objects derived from uncertain_params should be fixed by the user in advance of invoking PyROS.

Note that if uncertain_params is of type Var/VarData, or otherwise has Var or VarData entries, then there may be an appreciable computational overhead during the PyROS solver preprocessing step for models with large numbers of Constraint, Expression, and/or Objective components in which the Var/VarData objects appear.

Changes proposed in this PR:

  • Allow PyROS solver to support Var and VarData objects in uncertain_params argument

TODO (after #3434 merged)

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.

Copy link

codecov bot commented Dec 3, 2024

Codecov Report

Attention: Patch coverage is 98.27586% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.47%. Comparing base (8a50553) to head (7dec651).
Report is 47 commits behind head on main.

Files with missing lines Patch % Lines
pyomo/contrib/pyros/util.py 97.72% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3439      +/-   ##
==========================================
+ Coverage   88.19%   88.47%   +0.28%     
==========================================
  Files         880      880              
  Lines      100594   100639      +45     
==========================================
+ Hits        88715    89044     +329     
+ Misses      11879    11595     -284     
Flag Coverage Δ
linux 86.19% <98.27%> (+0.01%) ⬆️
osx 76.20% <91.37%> (+0.01%) ⬆️
other 86.71% <98.27%> (+0.01%) ⬆️
win 84.66% <98.27%> (+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.

@blnicho blnicho requested review from jsiirola and blnicho January 14, 2025 20:01
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.

One question that should probably be addressed before merging. The other two are enhancements, but not strictly necessary.

Comment on lines +1833 to +1835
if isinstance(obj, VarData):
obj.fix()
uncertain_param_var_idxs.append(idx)
Copy link
Member

Choose a reason for hiding this comment

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

Do you need to make sure that the Var has a value here? We allow Vars with lower == upper to be uncertain Params even if they don't have a current (numeric) value, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not believe we need to ensure the Var has a value here, as:

  • The nominal value of the uncertain parameter represented by the Var was already obtained (accounting for the state of the Var) in util.validate_uncertainty_specification (see line 977 @ 7dec651)
  • Immediately after this loop:
    • The previously obtained nominal value is used to initialize the newly constructed Param that is to be substituted for the Var
    • The Param is substituted for the Var, and (apart from cloning the Var when the working model is cloned) the Var is not subsequently used to set up subproblem components

Copy link
Member

Choose a reason for hiding this comment

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

Great! Thanks for clarifying

@blnicho blnicho merged commit 61e28af into Pyomo:main Feb 5, 2025
34 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.

4 participants