Skip to content

Commit 0ad6caa

Browse files
authored
Update mathoptinterface_api.jl
1 parent 7e9c6cb commit 0ad6caa

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Nonlinear/ReverseAD/mathoptinterface_api.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ function MOI.initialize(d::NLPEvaluator, requested_features::Vector{Symbol})
4444
want_hess_storage = (:HessVec in requested_features) || d.want_hess
4545
coloring_storage = Coloring.IndexedSet(N)
4646
max_expr_length = 0
47+
max_expr_with_sub_length = 0
4748
#
4849
main_expressions = [c.expression.nodes for (_, c) in d.data.constraints]
4950
if d.data.objective !== nothing
@@ -71,6 +72,8 @@ function MOI.initialize(d::NLPEvaluator, requested_features::Vector{Symbol})
7172
)
7273
d.subexpressions[k] = subex
7374
d.subexpression_linearity[k] = subex.linearity
75+
max_expr_with_sub_length =
76+
max(max_expr_with_sub_length, length(subex.nodes))
7477
if d.want_hess
7578
empty!(coloring_storage)
7679
_compute_gradient_sparsity!(coloring_storage, subex.nodes)
@@ -138,10 +141,8 @@ function MOI.initialize(d::NLPEvaluator, requested_features::Vector{Symbol})
138141
end
139142
# 10 is hardcoded upper bound to avoid excess memory allocation
140143
max_chunk = min(max_chunk, 10)
141-
max_expr_with_sub_length = max(
142-
max_expr_length,
143-
maximum(x -> length(x.nodes), d.subexpressions; init = 0),
144-
)
144+
max_expr_with_sub_length =
145+
max(max_expr_with_sub_length, max_expr_length)
145146
if d.want_hess || want_hess_storage
146147
d.input_ϵ = zeros(max_chunk * N)
147148
d.output_ϵ = zeros(max_chunk * N)

0 commit comments

Comments
 (0)