We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1694a00 commit 4c98be5Copy full SHA for 4c98be5
1 file changed
src/Utilities/vector_of_constraints.jl
@@ -103,7 +103,14 @@ function MOI.get(
103
) where {F,S}
104
MOI.throw_if_not_valid(v, ci)
105
f, _ = v.constraints[ci]::Tuple{F,S}
106
- return copy(f)
+ # Since `MA.mutability(MOI.ScalarNonlinearFunction)` is `MA.IsNotMutable`,
107
+ # this does not copy `MOI.ScalarNonlinearFunction`. This is important if the
108
+ # function share aliases of the same subexpression at different parts of
109
+ # it's expression graph or the expression graph of other functions of the
110
+ # model. If we `copy`, they won't be aliases of the same subexpression
111
+ # anymore hence `MOI.Nonlinear.ReverseAD` won't detect them as common
112
+ # subexpressions.
113
+ return MA.copy_if_mutable(f)
114
end
115
116
function MOI.get(
0 commit comments