-
Notifications
You must be signed in to change notification settings - Fork 505
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
Add ParameterizedQuadraticRepn
and corresponding expression walker
#3324
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. |
…o into quadratic-walker-wrt
…o into quadratic-walker-wrt
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 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.
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
ParameterizedQuadraticRepn
object that has the same structure as the existingQuadraticRepn
(of #2823), and an accompanying expression walker that extends the behavior of theQuadraticRepnVisitor
andParameterizedLinearRepnVisitor
(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 thewrt
argument to theParameterizedQuadraticRepnVisitor
constructor.Changes proposed in this PR:
ParameterizedQuadraticRepn
class that inherits fromQuadraticRepn
but re-implements all methods/attributes that assume that constants and coefficients are numbers rather than expressions.ParameterizedQuadraticRepnVisitor
that inherits fromParameterizedLinearRepnVisitor
and features:exitNode
handlers for products of linear expressions and products of quadratic/nonlinear expressionsfinalizeResult
methodLegal Acknowledgement
By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution: