Separate Linear Terms in Nonlinear to Piecewise Linear Transformation#3814
Separate Linear Terms in Nonlinear to Piecewise Linear Transformation#3814michaelbynum wants to merge 8 commits intoPyomo:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3814 +/- ##
==========================================
- Coverage 89.45% 89.44% -0.01%
==========================================
Files 905 905
Lines 105467 105492 +25
==========================================
+ Hits 94341 94361 +20
- Misses 11126 11131 +5
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.
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.
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.
I don't think it matters to me.
There was a problem hiding this comment.
I'm going to leave this just for consistency with QuadraticRepn.
| if repn.multiplier_flag(repn.multiplier) != 1: | ||
| linear *= repn.multiplier | ||
| nonlinear *= repn.multiplier |
There was a problem hiding this comment.
@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.
I just copied the to_expression code from the QuadraticRepn class and modified it slightly...
There was a problem hiding this comment.
which is to say that I have no idea. I'll take a look, though.
There was a problem hiding this comment.
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. |
|
Okay, assuming tests pass, this should be good to go. |
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: