@@ -43,23 +43,13 @@ function MOI.initialize(d::NLPEvaluator, requested_features::Vector{Symbol})
4343 d. want_hess = :Hess in requested_features
4444 want_hess_storage = (:HessVec in requested_features) || d. want_hess
4545 coloring_storage = Coloring. IndexedSet (N)
46- #
4746 max_expr_length = 0
4847 max_expr_with_sub_length = 0
49- max_chunk = 1
50- main_expressions = Vector{Nonlinear . Node}[ ]
48+ #
49+ main_expressions = [c . expression . nodes for (_, c) in d . data . constraints ]
5150 if d. data. objective != = nothing
52- objective = something (d. data. objective)
53- max_expr_length = max (max_expr_length, length (objective. nodes))
54- max_chunk = max (max_chunk, size (objective. seed_matrix, 2 ))
55- push! (main_expressions, objective. nodes)
56- end
57- for (_, c) in d. data. constraints
58- max_expr_length = max (max_expr_length, length (c. expression. nodes))
59- max_chunk = max (max_chunk, size (c. expression. seed_matrix, 2 ))
60- push! (main_expressions, c. expression. nodes)
51+ pushfirst! (main_expressions, something (d. data. objective). nodes)
6152 end
62- max_chunk = min (max_chunk, MAX_CHUNK)
6353 d. subexpression_order, individual_order = _order_subexpressions (
6454 main_expressions,
6555 [expr. nodes for expr in d. data. expressions],
@@ -79,7 +69,7 @@ function MOI.initialize(d::NLPEvaluator, requested_features::Vector{Symbol})
7969 d. data. expressions[k],
8070 d. subexpression_linearity,
8171 moi_index_to_consecutive_index,
82- zeros (max_chunk * length (d . data . expressions[k] . nodes)) ,
72+ Float64[] ,
8373 d. want_hess,
8474 )
8575 d. subexpressions[k] = subex
@@ -111,12 +101,12 @@ function MOI.initialize(d::NLPEvaluator, requested_features::Vector{Symbol})
111101 subexpression_edgelist[k] = edgelist
112102 end
113103 end
114- shared_partials_storage_ϵ = zeros (max_chunk * max_expr_length)
104+ max_chunk = 1
105+ shared_partials_storage_ϵ = Float64[]
115106 if d. data. objective != = nothing
116107 objective = _FunctionStorage (
117108 _SubexpressionStorage (
118109 something (d. data. objective),
119- d. data. expressions[k],
120110 d. subexpression_linearity,
121111 moi_index_to_consecutive_index,
122112 shared_partials_storage_ϵ,
@@ -130,6 +120,8 @@ function MOI.initialize(d::NLPEvaluator, requested_features::Vector{Symbol})
130120 subexpression_edgelist,
131121 subexpression_variables,
132122 )
123+ max_expr_length = max (max_expr_length, length (objective. nodes))
124+ max_chunk = max (max_chunk, size (objective. seed_matrix, 2 ))
133125 d. objective = objective
134126 end
135127 for (k, (_, constraint)) in enumerate (d. data. constraints)
@@ -156,11 +148,14 @@ function MOI.initialize(d::NLPEvaluator, requested_features::Vector{Symbol})
156148 max_expr_length = max (max_expr_length, length (d. constraints[end ]. nodes))
157149 max_chunk = max (max_chunk, size (d. constraints[end ]. seed_matrix, 2 ))
158150 end
151+ max_chunk = min (max_chunk, MAX_CHUNK)
159152 max_expr_with_sub_length = max (max_expr_with_sub_length, max_expr_length)
160153 if d. want_hess || want_hess_storage
161154 d. input_ϵ = zeros (max_chunk * N)
162155 d. output_ϵ = zeros (max_chunk * N)
163156 #
157+ resize! (shared_partials_storage_ϵ, max_chunk * max_expr_length)
158+ fill! (shared_partials_storage_ϵ, 0.0 )
164159 d. storage_ϵ = zeros (max_chunk * max_expr_with_sub_length)
165160 #
166161 len = max_chunk * length (d. subexpressions)
0 commit comments