@@ -43,6 +43,71 @@ function that is not defined, an error is thrown.
43
43
For more information on the use of automatic differentiation, see the
44
44
documentation of the `AbstractADType` types.
45
45
"""
46
+
47
+
48
+ function instantiate_function (f:: MultiObjectiveOptimizationFunction , x, :: SciMLBase.NoAD ,
49
+ p, num_cons = 0 )
50
+ jac = f. jac === nothing ? nothing : (J, x, args... ) -> f. jac (J, x, p, args... )
51
+ hess = f. hess === nothing ? nothing : [(H, x, args... ) -> h (H, x, p, args... ) for h in f. hess]
52
+ hv = f. hv === nothing ? nothing : (H, x, v, args... ) -> f. hv (H, x, v, p, args... )
53
+ cons = f. cons === nothing ? nothing : (res, x) -> f. cons (res, x, p)
54
+ cons_j = f. cons_j === nothing ? nothing : (res, x) -> f. cons_j (res, x, p)
55
+ cons_jvp = f. cons_jvp === nothing ? nothing : (res, x) -> f. cons_jvp (res, x, p)
56
+ cons_vjp = f. cons_vjp === nothing ? nothing : (res, x) -> f. cons_vjp (res, x, p)
57
+ cons_h = f. cons_h === nothing ? nothing : (res, x) -> f. cons_h (res, x, p)
58
+ hess_prototype = f. hess_prototype === nothing ? nothing :
59
+ convert .(eltype (x), f. hess_prototype)
60
+ cons_jac_prototype = f. cons_jac_prototype === nothing ? nothing :
61
+ convert .(eltype (x), f. cons_jac_prototype)
62
+ cons_hess_prototype = f. cons_hess_prototype === nothing ? nothing :
63
+ [convert .(eltype (x), f. cons_hess_prototype[i])
64
+ for i in 1 : num_cons]
65
+ expr = symbolify (f. expr)
66
+ cons_expr = symbolify .(f. cons_expr)
67
+
68
+ return MultiObjectiveOptimizationFunction {true} (f. f, SciMLBase. NoAD (); jac = jac, hess = hess,
69
+ hv = hv,
70
+ cons = cons, cons_j = cons_j, cons_jvp = cons_jvp, cons_vjp = cons_vjp, cons_h = cons_h,
71
+ hess_prototype = hess_prototype,
72
+ cons_jac_prototype = cons_jac_prototype,
73
+ cons_hess_prototype = cons_hess_prototype,
74
+ expr = expr, cons_expr = cons_expr,
75
+ sys = f. sys,
76
+ observed = f. observed)
77
+ end
78
+
79
+ function instantiate_function (f:: MultiObjectiveOptimizationFunction , cache:: ReInitCache , :: SciMLBase.NoAD ,
80
+ num_cons = 0 )
81
+ jac = f. jac === nothing ? nothing : (J, x, args... ) -> f. jac (J, x, cache. p, args... )
82
+ hess = f. hess === nothing ? nothing : [(H, x, args... ) -> h (H, x, cache. p, args... ) for h in f. hess]
83
+ hv = f. hv === nothing ? nothing : (H, x, v, args... ) -> f. hv (H, x, v, cache. p, args... )
84
+ cons = f. cons === nothing ? nothing : (res, x) -> f. cons (res, x, cache. p)
85
+ cons_j = f. cons_j === nothing ? nothing : (res, x) -> f. cons_j (res, x, cache. p)
86
+ cons_jvp = f. cons_jvp === nothing ? nothing : (res, x) -> f. cons_jvp (res, x, cache. p)
87
+ cons_vjp = f. cons_vjp === nothing ? nothing : (res, x) -> f. cons_vjp (res, x, cache. p)
88
+ cons_h = f. cons_h === nothing ? nothing : (res, x) -> f. cons_h (res, x, cache. p)
89
+ hess_prototype = f. hess_prototype === nothing ? nothing :
90
+ convert .(eltype (cache. u0), f. hess_prototype)
91
+ cons_jac_prototype = f. cons_jac_prototype === nothing ? nothing :
92
+ convert .(eltype (cache. u0), f. cons_jac_prototype)
93
+ cons_hess_prototype = f. cons_hess_prototype === nothing ? nothing :
94
+ [convert .(eltype (cache. u0), f. cons_hess_prototype[i])
95
+ for i in 1 : num_cons]
96
+ expr = symbolify (f. expr)
97
+ cons_expr = symbolify .(f. cons_expr)
98
+
99
+ return MultiObjectiveOptimizationFunction {true} (f. f, SciMLBase. NoAD (); jac = jac, hess = hess,
100
+ hv = hv,
101
+ cons = cons, cons_j = cons_j, cons_jvp = cons_jvp, cons_vjp = cons_vjp, cons_h = cons_h,
102
+ hess_prototype = hess_prototype,
103
+ cons_jac_prototype = cons_jac_prototype,
104
+ cons_hess_prototype = cons_hess_prototype,
105
+ expr = expr, cons_expr = cons_expr,
106
+ sys = f. sys,
107
+ observed = f. observed)
108
+ end
109
+
110
+
46
111
function instantiate_function (f, x, :: SciMLBase.NoAD ,
47
112
p, num_cons = 0 )
48
113
grad = f. grad === nothing ? nothing : (G, x, args... ) -> f. grad (G, x, p, args... )
@@ -113,3 +178,5 @@ function instantiate_function(f, x, adtype::ADTypes.AbstractADType,
113
178
adpkg = adtypestr[strtind: (open_brkt_ind - 1 )]
114
179
throw (ArgumentError (" The passed automatic differentiation backend choice is not available. Please load the corresponding AD package $adpkg ." ))
115
180
end
181
+
182
+
0 commit comments