@@ -113,3 +113,78 @@ function instantiate_function(f, x, adtype::ADTypes.AbstractADType,
113
113
adpkg = adtypestr[strtind: (open_brkt_ind - 1 )]
114
114
throw (ArgumentError (" The passed automatic differentiation backend choice is not available. Please load the corresponding AD package $adpkg ." ))
115
115
end
116
+
117
+ function instantiate_function (f:: MultiObjectiveOptimizationFunction , x, :: SciMLBase.NoAD ,
118
+ p, num_cons = 0 )
119
+ jac = f. jac === nothing ? nothing : (J, x, args... ) -> f. jac (J, x, p, args... )
120
+ hess = f. hess === nothing ? nothing : [(H, x, args... ) -> h (H, x, p, args... ) for h in f. hess]
121
+ hv = f. hv === nothing ? nothing : (H, x, v, args... ) -> f. hv (H, x, v, p, args... )
122
+ cons = f. cons === nothing ? nothing : (res, x) -> f. cons (res, x, p)
123
+ cons_j = f. cons_j === nothing ? nothing : (res, x) -> f. cons_j (res, x, p)
124
+ cons_jvp = f. cons_jvp === nothing ? nothing : (res, x) -> f. cons_jvp (res, x, p)
125
+ cons_vjp = f. cons_vjp === nothing ? nothing : (res, x) -> f. cons_vjp (res, x, p)
126
+ cons_h = f. cons_h === nothing ? nothing : (res, x) -> f. cons_h (res, x, p)
127
+ hess_prototype = f. hess_prototype === nothing ? nothing :
128
+ convert .(eltype (x), f. hess_prototype)
129
+ cons_jac_prototype = f. cons_jac_prototype === nothing ? nothing :
130
+ convert .(eltype (x), f. cons_jac_prototype)
131
+ cons_hess_prototype = f. cons_hess_prototype === nothing ? nothing :
132
+ [convert .(eltype (x), f. cons_hess_prototype[i])
133
+ for i in 1 : num_cons]
134
+ expr = symbolify (f. expr)
135
+ cons_expr = symbolify .(f. cons_expr)
136
+
137
+ return MultiObjectiveOptimizationFunction {true} (f. f, SciMLBase. NoAD (); jac = jac, hess = hess,
138
+ hv = hv,
139
+ cons = cons, cons_j = cons_j, cons_jvp = cons_jvp, cons_vjp = cons_vjp, cons_h = cons_h,
140
+ hess_prototype = hess_prototype,
141
+ cons_jac_prototype = cons_jac_prototype,
142
+ cons_hess_prototype = cons_hess_prototype,
143
+ expr = expr, cons_expr = cons_expr,
144
+ sys = f. sys,
145
+ observed = f. observed)
146
+ end
147
+
148
+ function instantiate_function (f:: MultiObjectiveOptimizationFunction , x, adtype:: ADTypes.AbstractADType ,
149
+ p, num_cons = 0 )
150
+ adtypestr = string (adtype)
151
+ _strtind = findfirst (' .' , adtypestr)
152
+ strtind = isnothing (_strtind) ? 5 : _strtind + 5
153
+ open_nrmlbrkt_ind = findfirst (' (' , adtypestr)
154
+ open_squigllybrkt_ind = findfirst (' {' , adtypestr)
155
+ open_brkt_ind = isnothing (open_squigllybrkt_ind) ? open_nrmlbrkt_ind :
156
+ min (open_nrmlbrkt_ind, open_squigllybrkt_ind)
157
+ adpkg = adtypestr[strtind: (open_brkt_ind - 1 )]
158
+ throw (ArgumentError (" The passed automatic differentiation backend choice is not available. Please load the corresponding AD package $adpkg ." ))
159
+ end
160
+
161
+ function instantiate_function (f:: MultiObjectiveOptimizationFunction , cache:: ReInitCache , :: SciMLBase.NoAD ,
162
+ num_cons = 0 )
163
+ jac = f. jac === nothing ? nothing : (J, x, args... ) -> f. jac (J, x, cache. p, args... )
164
+ hess = f. hess === nothing ? nothing : [(H, x, args... ) -> h (H, x, cache. p, args... ) for h in f. hess]
165
+ hv = f. hv === nothing ? nothing : (H, x, v, args... ) -> f. hv (H, x, v, cache. p, args... )
166
+ cons = f. cons === nothing ? nothing : (res, x) -> f. cons (res, x, cache. p)
167
+ cons_j = f. cons_j === nothing ? nothing : (res, x) -> f. cons_j (res, x, cache. p)
168
+ cons_jvp = f. cons_jvp === nothing ? nothing : (res, x) -> f. cons_jvp (res, x, cache. p)
169
+ cons_vjp = f. cons_vjp === nothing ? nothing : (res, x) -> f. cons_vjp (res, x, cache. p)
170
+ cons_h = f. cons_h === nothing ? nothing : (res, x) -> f. cons_h (res, x, cache. p)
171
+ hess_prototype = f. hess_prototype === nothing ? nothing :
172
+ convert .(eltype (cache. u0), f. hess_prototype)
173
+ cons_jac_prototype = f. cons_jac_prototype === nothing ? nothing :
174
+ convert .(eltype (cache. u0), f. cons_jac_prototype)
175
+ cons_hess_prototype = f. cons_hess_prototype === nothing ? nothing :
176
+ [convert .(eltype (cache. u0), f. cons_hess_prototype[i])
177
+ for i in 1 : num_cons]
178
+ expr = symbolify (f. expr)
179
+ cons_expr = symbolify .(f. cons_expr)
180
+
181
+ return MultiObjectiveOptimizationFunction {true} (f. f, SciMLBase. NoAD (); jac = jac, hess = hess,
182
+ hv = hv,
183
+ cons = cons, cons_j = cons_j, cons_jvp = cons_jvp, cons_vjp = cons_vjp, cons_h = cons_h,
184
+ hess_prototype = hess_prototype,
185
+ cons_jac_prototype = cons_jac_prototype,
186
+ cons_hess_prototype = cons_hess_prototype,
187
+ expr = expr, cons_expr = cons_expr,
188
+ sys = f. sys,
189
+ observed = f. observed)
190
+ end
0 commit comments