-
Notifications
You must be signed in to change notification settings - Fork 518
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
contrib.piecewise: Adding nonlinear-to-piecewise-linear transformation #3333
Conversation
…ause the space isn't full-dimensional
…r to GDP transformations
…ts and Objectives, fixing a few bugs
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3333 +/- ##
==========================================
+ Coverage 88.55% 88.60% +0.04%
==========================================
Files 877 878 +1
Lines 99262 99591 +329
==========================================
+ Hits 87906 88238 +332
+ Misses 11356 11353 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Oops, I think this is failing coverage because we don't have |
If this passes tests, it is ready for review! |
Yes - I think so. Because you added I think the resolution is to add |
Oooof, now I broke everything? |
@emma58 GitHub was having issues yesterday so I just kicked off the GHA tests again to see if that fixes things. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this looks pretty good. One thing that should be changed, though (defer the construction of the visitor, or move it to an instance attribute)
_quadratic_repn_visitor = QuadraticRepnVisitor( | ||
subexpression_cache={}, var_map={}, var_order={}, sorter=None | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gets instantiated upon module import (which will happen as part of pyomo.environ
. It would be better to put this in a getter:
def visitor():
if visitor._instance is None:
visitor._instance = QuadraticRepnVisitor(
subexpression_cache={}, var_map={}, var_order={}, sorter=None
)
return vistor._instance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put it on the transformation instance.
Fixes # .
Summary/Motivation:
This PR adds a transformation that takes a MINLP model and automatically generated a piecewise-linear approximation of the model that can then be transformed to MILP using the other transformations in contrib.piecewise.
Changes proposed in this PR:
contrib.piecewise.nonlinear_to_pwl
transformationLegal Acknowledgement
By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution: