Skip to content

Update PyROS Uncertainty Set Validation Methods #3558

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 84 commits into
base: main
Choose a base branch
from

Conversation

jas-yao
Copy link
Contributor

@jas-yao jas-yao commented Apr 11, 2025

Fixes: #2724, #3508

Summary/Motivation:

This PR provides updates to PyROS uncertainty set validation methods and related tests.
Here, a validate method replaces the is_valid method (which solves 2N bounding problems to check for set boundedness) in all uncertainty sets, with each set having its own custom validate method that efficiently checks set-specific attributes and raises informative exceptions if any issues are found.

Changes proposed in this PR:

  • Update is_bounded and is_nonempty methods in base UncertaintySet class
  • Provide a _solve_feasibility method in base UncertaintySet class
  • Replace is_valid with validate method that runs is_bounded and is_nonempty in the base UncertaintySet class
  • Override validate in subclass uncertainty sets to check set-specific attributes
  • Remove attribute setter checks in uncertainty sets that have been moved to the validate method
  • Update unit tests for is_bounded, is_nonempty, _solve_feasibility, and validate methods

TODO

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.

jas-yao added 30 commits April 7, 2025 15:31
@jas-yao
Copy link
Contributor Author

jas-yao commented Jun 30, 2025

@jsiirola @shermanjasonaf Thank you for all of your feedback! I have addressed most comments, with the remaining being mostly related to rewriting the _compute_parameter_bounds method. I will aim to finish updates for these by the end of tomorrow.

@jas-yao
Copy link
Contributor Author

jas-yao commented Jul 2, 2025

@shermanjasonaf @jsiirola I have addressed all comments.

I would appreciate further feedback on my implementations for is_bounded and _compute_exact_parameter_bounds.
I will also need to complete the final TODO to update the version number and changelog.

# check when values are not finite
cardinality_set.origin[0] = np.nan
exc_str = (
r"Entry 'nan' of the argument `origin` " r"is not a finite numeric value"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
r"Entry 'nan' of the argument `origin` " r"is not a finite numeric value"
r"Entry 'nan' of the argument `origin` is not a finite numeric value"

# check when values are not finite
a_ellipsoid_set.center[0] = np.nan
exc_str = (
r"Entry 'nan' of the argument `center` " r"is not a finite numeric value"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
r"Entry 'nan' of the argument `center` " r"is not a finite numeric value"
r"Entry 'nan' of the argument `center` is not a finite numeric value"

# check when values are not finite
ellipsoid_set.center[0] = np.nan
exc_str = (
r"Entry 'nan' of the argument `center` " r"is not a finite numeric value"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
r"Entry 'nan' of the argument `center` " r"is not a finite numeric value"
r"Entry 'nan' of the argument `center` is not a finite numeric value"

# check when values are not finite
polyhedral_set.rhs_vec[0] = np.nan
exc_str = (
r"Entry 'nan' of the argument `rhs_vec` " r"is not a finite numeric value"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
r"Entry 'nan' of the argument `rhs_vec` " r"is not a finite numeric value"
r"Entry 'nan' of the argument `rhs_vec` is not a finite numeric value"

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

Successfully merging this pull request may close these issues.

Make PyROS UncertaintySet Valid Numeric Types Mutable
5 participants