Skip to content

Commit 3b0af92

Browse files
committed
Add canonical
1 parent 75eaa7e commit 3b0af92

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/Utilities/functions.jl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,32 @@ function canonical(f::MOI.AbstractFunction)
10561056
return g
10571057
end
10581058

1059+
# Workaround: both `is_canonical` and `canonicalize!` would be slow otherwise
1060+
canonical(f::MOI.ScalarNonlinearFunction) = f
1061+
1062+
# This is maybe the right fix, but commented out to be sure to isolate
1063+
# JuMP-side of profiling in https://github.com/jump-dev/JuMP.jl/pull/4032
1064+
# We still need to figure out what's the right fix here anyway
1065+
#function canonical(f::MOI.ScalarNonlinearFunction)
1066+
# cache = Dict{MOI.AbstractScalarFunction,MOI.AbstractScalarFunction}()
1067+
# # Don't use recursion here. This gets called for all scalar nonlinear
1068+
# # constraints.
1069+
# stack = Any[arg for arg in f.args]
1070+
# while !isempty(stack)
1071+
# arg = pop!(stack)
1072+
# if arg isa MOI.ScalarNonlinearFunction
1073+
# for a in arg.args
1074+
# push!(stack, a)
1075+
# end
1076+
# else
1077+
# if !is_canonical(arg)
1078+
# return false
1079+
# end
1080+
# end
1081+
# end
1082+
# return true
1083+
#end
1084+
10591085
canonicalize!(f::Union{MOI.VectorOfVariables,MOI.VariableIndex}) = f
10601086

10611087
"""

0 commit comments

Comments
 (0)