-
Notifications
You must be signed in to change notification settings - Fork 98
Add canonical #3008
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: master
Are you sure you want to change the base?
Add canonical #3008
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1056,6 +1056,32 @@ function canonical(f::MOI.AbstractFunction) | |
| return g | ||
| end | ||
|
|
||
| # Workaround: both `is_canonical` and `canonicalize!` would be slow otherwise | ||
| canonical(f::MOI.ScalarNonlinearFunction) = f | ||
|
|
||
| # This is maybe the right fix, but commented out to be sure to isolate | ||
| # JuMP-side of profiling in https://github.com/jump-dev/JuMP.jl/pull/4032 | ||
| # We still need to figure out what's the right fix here anyway | ||
| #function canonical(f::MOI.ScalarNonlinearFunction) | ||
| # cache = Dict{MOI.AbstractScalarFunction,MOI.AbstractScalarFunction}() | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The goal of this was to write a version with this cache but I first want to check that this is really necessary |
||
| # # Don't use recursion here. This gets called for all scalar nonlinear | ||
| # # constraints. | ||
| # stack = Any[arg for arg in f.args] | ||
| # while !isempty(stack) | ||
| # arg = pop!(stack) | ||
| # if arg isa MOI.ScalarNonlinearFunction | ||
| # for a in arg.args | ||
| # push!(stack, a) | ||
| # end | ||
| # else | ||
| # if !is_canonical(arg) | ||
| # return false | ||
| # end | ||
| # end | ||
| # end | ||
| # return true | ||
| #end | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete this code? It isn't correct regardless, because the function is
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not change the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the underlying problem? That we walk the expression graph?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wrote this in July 2025, I don't remember much, I will need to look at it again but let's first focus on merging jump-dev/JuMP.jl#4032, then we'll look at the MOI level |
||
|
|
||
| canonicalize!(f::Union{MOI.VectorOfVariables,MOI.VariableIndex}) = f | ||
|
|
||
| """ | ||
|
|
||
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.
Ask Claude why they would add this method when there is the one below 😆
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 did it pre-Claude actually 😅 this line is just a temporary hack to isolate things in profiling