Add ParameterizedQuadraticRepn and corresponding expression walker#3324
Merged
blnicho merged 35 commits intoPyomo:mainfrom Aug 20, 2024
Merged
Add ParameterizedQuadraticRepn and corresponding expression walker#3324blnicho merged 35 commits intoPyomo:mainfrom
ParameterizedQuadraticRepn and corresponding expression walker#3324blnicho merged 35 commits intoPyomo:mainfrom
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3324 +/- ##
==========================================
+ Coverage 88.52% 88.55% +0.03%
==========================================
Files 868 869 +1
Lines 98436 98687 +251
==========================================
+ Hits 87144 87396 +252
+ Misses 11292 11291 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
blnicho
reviewed
Aug 1, 2024
…o into quadratic-walker-wrt
…o into quadratic-walker-wrt
2 tasks
jsiirola
approved these changes
Aug 14, 2024
Member
jsiirola
left a comment
There was a problem hiding this comment.
This has a huge amount of repeated code (from a mix of parameterized_linear and quadratic. In the future we should refactor the walkers so that we can make better use of mixins or more general methods to clean this up.
blnicho
approved these changes
Aug 20, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary/Motivation:
With upcoming changes to the preprocessing subroutine of the contributed PyROS solver, and, in particular, the preprocessor's coefficient matching step, which requires analyzing expression trees in terms of selected variables only, this PR adds a
ParameterizedQuadraticRepnobject that has the same structure as the existingQuadraticRepn(of #2823), and an accompanying expression walker that extends the behavior of theQuadraticRepnVisitorandParameterizedLinearRepnVisitor(of #3268) to allow for collection of quadratic/bilinear terms with potentially variable coefficient expressions. As with theParameterizedLinearRepnVisitor, variables to be treated as data are specified through thewrtargument to theParameterizedQuadraticRepnVisitorconstructor.Changes proposed in this PR:
ParameterizedQuadraticRepnclass that inherits fromQuadraticRepnbut re-implements all methods/attributes that assume that constants and coefficients are numbers rather than expressions.ParameterizedQuadraticRepnVisitorthat inherits fromParameterizedLinearRepnVisitorand features:exitNodehandlers for products of linear expressions and products of quadratic/nonlinear expressionsfinalizeResultmethodLegal Acknowledgement
By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution: