@@ -103,7 +103,7 @@ function _subexpression_and_linearity(
103103 partials_storage_ϵ:: Vector{Float64} ,
104104 d,
105105 :: Type{S} = Vector{Float64},
106- ) where {S<: AbstractVector{Float64 } }
106+ ) where {S<: AbstractVector{<:Real } }
107107 nodes = _replace_moi_variables (expr. nodes, moi_index_to_consecutive_index)
108108 adj = adjacency_matrix (nodes)
109109 linearity = if d. want_hess
@@ -114,7 +114,7 @@ function _subexpression_and_linearity(
114114 return _SubexpressionStorage (
115115 nodes,
116116 adj,
117- convert (Vector{Float64 }, expr. values),
117+ convert (Vector{eltype (S) }, expr. values),
118118 copy (expr. block_shapes),
119119 partials_storage_ϵ,
120120 linearity[1 ],
@@ -123,28 +123,28 @@ function _subexpression_and_linearity(
123123 linearity
124124end
125125
126- struct _FunctionStorage{S<: AbstractVector{Float64 } }
127- expr:: _SubexpressionStorage{S}
126+ struct _FunctionStorage{T <: Real , S<: AbstractVector{T } }
127+ expr:: _SubexpressionStorage{T, S}
128128 grad_sparsity:: Vector{Int}
129129 # Nonzero pattern of Hessian matrix
130130 hess_I:: Vector{Int}
131131 hess_J:: Vector{Int}
132132 rinfo:: Coloring.RecoveryInfo # coloring info for hessians
133- seed_matrix:: Matrix{Float64 }
133+ seed_matrix:: Matrix{T }
134134 # subexpressions which this function depends on, ordered for forward pass.
135135 dependent_subexpressions:: Vector{Int}
136136
137137 function _FunctionStorage (
138- expr:: _SubexpressionStorage{S} ,
138+ expr:: _SubexpressionStorage{T, S} ,
139139 num_variables,
140140 coloring_storage:: Coloring.IndexedSet ,
141141 want_hess:: Bool ,
142- subexpressions:: Vector{_SubexpressionStorage{S}} ,
142+ subexpressions:: Vector{_SubexpressionStorage{T, S}} ,
143143 dependent_subexpressions,
144144 subexpression_edgelist,
145145 subexpression_variables,
146146 linearity:: Vector{Linearity} ,
147- ) where {S<: AbstractVector{Float64 } }
147+ ) where {T <: Real , S<: AbstractVector{T } }
148148 empty! (coloring_storage)
149149 _compute_gradient_sparsity! (coloring_storage, expr)
150150 for k in dependent_subexpressions
@@ -166,7 +166,7 @@ struct _FunctionStorage{S<:AbstractVector{Float64}}
166166 coloring_storage,
167167 )
168168 seed_matrix = Coloring. seed_matrix (rinfo)
169- return new {S} (
169+ return new {T, S} (
170170 expr,
171171 grad_sparsity,
172172 hess_I,
@@ -176,13 +176,13 @@ struct _FunctionStorage{S<:AbstractVector{Float64}}
176176 dependent_subexpressions,
177177 )
178178 else
179- return new {S} (
179+ return new {T, S} (
180180 expr,
181181 grad_sparsity,
182182 Int[],
183183 Int[],
184184 Coloring. RecoveryInfo (),
185- Array {Float64 } (undef, 0 , 0 ),
185+ Array {T } (undef, 0 , 0 ),
186186 dependent_subexpressions,
187187 )
188188 end
@@ -305,30 +305,30 @@ interface.
305305!!! warning
306306 Before using, you must initialize the evaluator using `MOI.initialize`.
307307"""
308- mutable struct NLPEvaluator{S<: AbstractVector{Float64 } } < :
308+ mutable struct NLPEvaluator{T <: Real , S<: AbstractVector{T } } < :
309309 MOI. AbstractNLPEvaluator
310310 data:: Model
311311 ordered_variables:: Vector{MOI.VariableIndex}
312312
313- objective:: Union{Nothing,_FunctionStorage{S}}
314- residual:: Union{Nothing,_FunctionStorage{S}}
315- constraints:: Vector{_FunctionStorage{S}}
316- subexpressions:: Vector{_SubexpressionStorage{S}}
313+ objective:: Union{Nothing,_FunctionStorage{T, S}}
314+ residual:: Union{Nothing,_FunctionStorage{T, S}}
315+ constraints:: Vector{_FunctionStorage{T, S}}
316+ subexpressions:: Vector{_SubexpressionStorage{T, S}}
317317 subexpression_order:: Vector{Int}
318318 # Storage for the subexpressions in reverse-mode automatic differentiation.
319- subexpression_forward_values:: Vector{Float64 }
320- subexpression_reverse_values:: Vector{Float64 }
319+ subexpression_forward_values:: Vector{T }
320+ subexpression_reverse_values:: Vector{T }
321321 subexpression_linearity:: Vector{Linearity}
322322
323323 # A cache of the last x. This is used to guide whether we need to re-run
324324 # reverse-mode automatic differentiation.
325- last_x:: Vector{Float64 }
325+ last_x:: Vector{T }
326326
327327 # Temporary storage for computing Jacobians. This is also used as temporary
328328 # storage for the input of multivariate functions.
329- jac_storage:: Vector{Float64 }
329+ jac_storage:: Vector{T }
330330 # Temporary storage for the gradient of multivariate functions
331- user_output_buffer:: Vector{Float64 }
331+ user_output_buffer:: Vector{T }
332332
333333 # storage for computing hessians
334334 # these Float64 vectors are reinterpreted to hold multiple epsilon components
@@ -343,10 +343,10 @@ mutable struct NLPEvaluator{S<:AbstractVector{Float64}} <:
343343 hessian_sparsity:: Vector{Tuple{Int64,Int64}}
344344 max_chunk:: Int # chunk size for which we've allocated storage
345345
346- function NLPEvaluator {S} (
346+ function NLPEvaluator {T, S} (
347347 data:: Model ,
348348 ordered_variables:: Vector{MOI.VariableIndex} ,
349- ) where {S<: AbstractVector{Float64 } }
350- return new {S} (data, ordered_variables)
349+ ) where {T <: Real , S<: AbstractVector{T } }
350+ return new {T, S} (data, ordered_variables)
351351 end
352352end
0 commit comments