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

Prevent multiple applications of the scaling transform #2979

Merged
merged 5 commits into from
Aug 31, 2023

Conversation

jsiirola
Copy link
Member

Fixes # .

Summary/Motivation:

@andrewlee94 noted that the scaling transform caused problems because the scaling_factor Suffix was not deactivated after applying the transformation, which caused the resulting model to be doubly-scaled when written out to Ipopt. This updates the transformation to deactivate the scaling_factor Suffixes on the transformed model at the conclusion of the transformation.

In addition, this PR refactors the logic for finding the suffixes into a general-purpose pyomo.core.base.suffix.SuffixFinder class (so that it can easily be reused elsewhere, e.g. in GDP). It also removes the require ment that the scaling factor suffix values are forcibly converted to floats so that clients can use other data structures (in particular, mutable Params).

Changes proposed in this PR:

  • Refactor the scaling transformation to promote the suffix finder as a general utility
  • Deactivate scaling_factor suffixes after the transformation
  • Remove the restriction that all scaling factors are casted to float before using them to update constraints.

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

@andrewlee94 andrewlee94 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.

@codecov
Copy link

codecov bot commented Aug 30, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.01% ⚠️

Comparison is base (a6834b1) 88.08% compared to head (ffaed83) 88.08%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2979      +/-   ##
==========================================
- Coverage   88.08%   88.08%   -0.01%     
==========================================
  Files         769      769              
  Lines       89464    89468       +4     
==========================================
+ Hits        78804    78806       +2     
- Misses      10660    10662       +2     
Flag Coverage Δ
linux 85.17% <100.00%> (+<0.01%) ⬆️
osx 74.98% <100.00%> (+<0.01%) ⬆️
other 85.35% <100.00%> (+<0.01%) ⬆️
win 82.43% <100.00%> (-0.01%) ⬇️

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

Files Changed Coverage Δ
pyomo/core/base/suffix.py 88.37% <100.00%> (+1.52%) ⬆️
pyomo/core/plugins/transform/scaling.py 91.66% <100.00%> (-0.12%) ⬇️

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jsiirola jsiirola requested a review from mrmundt August 31, 2023 04:24
@mrmundt mrmundt merged commit 1764336 into Pyomo:main Aug 31, 2023
30 checks passed
@jsiirola jsiirola deleted the scaling-transform-rework branch August 31, 2023 14:14
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.

3 participants