-
Notifications
You must be signed in to change notification settings - Fork 562
Separate Linear Terms in Nonlinear to Piecewise Linear Transformation #3814
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3814 +/- ##
==========================================
- Coverage 89.44% 88.17% -1.28%
==========================================
Files 906 906
Lines 105444 105469 +25
==========================================
- Hits 94317 92993 -1324
- Misses 11127 12476 +1349
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
emma58
left a comment
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 think this makes sense. If you could put in a comment with the example you put in the PR description for why _separate_linear_parts is necessary, I think that would be helpful for future us. My guess is this is not currently the fastest thing we could possibly do, but for now, I'm not so concerned with that. @jsiirola, @sadavis1, @bammari, this might be worth glancing at if you have a minute.
| if x1 == x2: | ||
| nonlinear += coef * var_map[x1] ** 2 | ||
| else: | ||
| nonlinear += coef * (var_map[x1] * var_map[x2]) |
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.
Does separating these two cases matter? I mean, obviously you make a different expression tree, but do we need it?
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 don't think it matters to me.
| if repn.multiplier_flag(repn.multiplier) != 1: | ||
| linear *= repn.multiplier | ||
| nonlinear *= repn.multiplier |
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.
@jsiirola, can this happen? I have something in the back of my mind telling me multiplier is sure to be 1 at this point?
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 just copied the to_expression code from the QuadraticRepn class and modified it slightly...
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.
which is to say that I have no idea. I'll take a look, though.
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.
Oh, I can't read. This question was for @jsiirola. My bad.
|
Okay, if this does make some sense, I'll clean it up a bit. |
Summary/Motivation:
This PR modifies the
contrib.piecewise.nonlinear_to_pwltransformation so that linear parts of a constraint always get separated from the nonlinear parts, even ifadditively_decomposeisFalse. The idea is thatshould become
and not
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: