-
-
Notifications
You must be signed in to change notification settings - Fork 400
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 @nonlinear macro for modifying how expressions are parsed #3732
Conversation
In this case yes, but this performance issue could be hit in cases where a quadratic expression is the desired typed. |
Exactly. Which is why this It's not really about this specific performance issue. Even if |
I don't see any objection then, I can see this being useful. About the naming, once we drop the legacy nonlinear interface, what would be left of the |
Yeah I have no strong opinions on the name. I don't like |
Bikeshed
If we use The error would catch things like:
where the |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3732 +/- ##
==========================================
- Coverage 98.42% 98.40% -0.02%
==========================================
Files 43 44 +1
Lines 5825 5842 +17
==========================================
+ Hits 5733 5749 +16
- Misses 92 93 +1 ☔ View full report in Codecov by Sentry. |
This could use a review. I've updated to |
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.
Looks good to me.
@odow Is it expected that @force_nonlinear does not work when the quadratic expression comes from a user-defined function?
|
Yes, because the macro cannot rewrite the expressions inside We considered automatically converting the result, but decided against it. You should modify |
x-ref #3498
x-ref #3729
A core problem is that @mitchphillipson's models from #3729 contain
(x * (1 + y)) / c
, which creates an AffExpr1 + y
, a QuadExprx * (1 + y)
, and then a new QuadExpr(x * (1 + y)) / 2
(because/(::Quad, ::Real)
is not in-place.Since everything is about to be converted to
NonlinearExpr
anyway, it'd be nicer if we just kept things asNonlinearExpr
.cc @Downsite