@@ -65,12 +65,19 @@ function MOI.initialize(d::NLPEvaluator, requested_features::Vector{Symbol})
6565 for k in d. subexpression_order
6666 # Only load expressions which actually are used
6767 d. subexpression_forward_values[k] = NaN
68+ nodes = d. data. expressions[k]
69+ adj = Nonlinear. adjacency_matrix (nodes)
70+ linearity = if d. want_hess
71+ _classify_linearity (nodes, adj, d. subexpression_linearity)[1 ]
72+ else
73+ NONLINEAR
74+ end
6875 subex = _SubexpressionStorage (
6976 d. data. expressions[k],
70- d . subexpression_linearity ,
77+ adj ,
7178 moi_index_to_consecutive_index,
7279 Float64[],
73- d . want_hess ,
80+ linearity[ 1 ] ,
7481 )
7582 d. subexpressions[k] = subex
7683 d. subexpression_linearity[k] = subex. linearity
@@ -104,13 +111,20 @@ function MOI.initialize(d::NLPEvaluator, requested_features::Vector{Symbol})
104111 max_chunk = 1
105112 shared_partials_storage_ϵ = Float64[]
106113 if d. data. objective != = nothing
114+ nodes = something (d. data. objective)
115+ adj = Nonlinear. adjacency_matrix (nodes)
116+ linearity = if d. want_hess
117+ _classify_linearity (nodes, adj, d. subexpression_linearity)[1 ]
118+ else
119+ NONLINEAR
120+ end
107121 objective = _FunctionStorage (
108122 _SubexpressionStorage (
109- something (d . data . objective) ,
110- d . subexpression_linearity ,
123+ nodes ,
124+ adj ,
111125 moi_index_to_consecutive_index,
112126 shared_partials_storage_ϵ,
113- d . want_hess ,
127+ linearity[ 1 ] ,
114128 ),
115129 N,
116130 coloring_storage,
@@ -119,22 +133,30 @@ function MOI.initialize(d::NLPEvaluator, requested_features::Vector{Symbol})
119133 individual_order[1 ],
120134 subexpression_edgelist,
121135 subexpression_variables,
136+ linearity,
122137 )
123138 max_expr_length = max (max_expr_length, length (objective. nodes))
124139 max_chunk = max (max_chunk, size (objective. seed_matrix, 2 ))
125140 d. objective = objective
126141 end
127142 for (k, (_, constraint)) in enumerate (d. data. constraints)
128143 idx = d. data. objective != = nothing ? k + 1 : k
144+ nodes = main_expressions[idx]
145+ adj = Nonlinear. adjacency_matrix (nodes)
146+ linearity = if d. want_hess
147+ _classify_linearity (nodes, adj, d. subexpression_linearity)[1 ]
148+ else
149+ NONLINEAR
150+ end
129151 push! (
130152 d. constraints,
131153 _FunctionStorage (
132154 _SubexpressionStorage (
133- main_expressions[idx] ,
134- d . subexpression_linearity ,
155+ nodes ,
156+ adj ,
135157 moi_index_to_consecutive_index,
136158 shared_partials_storage_ϵ,
137- d . want_hess ,
159+ linearity[ 1 ] ,
138160 ),
139161 N,
140162 coloring_storage,
@@ -143,6 +165,7 @@ function MOI.initialize(d::NLPEvaluator, requested_features::Vector{Symbol})
143165 individual_order[idx],
144166 subexpression_edgelist,
145167 subexpression_variables,
168+ linearity,
146169 ),
147170 )
148171 max_expr_length = max (max_expr_length, length (d. constraints[end ]. nodes))
0 commit comments