Skip to content

Commit 55373a8

Browse files
Added constructor to MOOFunction scimlfunctions.jl
I have added the constructor for the MultiObjectiveOptimizationFunction struct.
1 parent a52e1d8 commit 55373a8

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

src/scimlfunctions.jl

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3837,6 +3837,62 @@ function OptimizationFunction{iip}(f, adtype::AbstractADType = NoAD();
38373837
cons_hess_colorvec, lag_hess_colorvec)
38383838
end
38393839

3840+
# Function call operator for MultiObjectiveOptimizationFunction
3841+
(f::MultiObjectiveOptimizationFunction)(args...) = f.f(args...)
3842+
3843+
# Convenience constructor
3844+
MultiObjectiveOptimizationFunction(args...; kwargs...) = MultiObjectiveOptimizationFunction{true}(args...; kwargs...)
3845+
3846+
# Constructor with keyword arguments
3847+
function MultiObjectiveOptimizationFunction{iip}(f, adtype::AbstractADType = NoAD();
3848+
jac = nothing, hess = Vector{nothing}(undef, 0), hv = nothing,
3849+
cons = nothing, cons_j = nothing, cons_jvp = nothing,
3850+
cons_vjp = nothing, cons_h = nothing,
3851+
hess_prototype = nothing,
3852+
cons_jac_prototype = __has_jac_prototype(f) ?
3853+
f.jac_prototype : nothing,
3854+
cons_hess_prototype = nothing,
3855+
syms = nothing,
3856+
paramsyms = nothing,
3857+
observed = __has_observed(f) ? f.observed :
3858+
DEFAULT_OBSERVED_NO_TIME,
3859+
expr = nothing, cons_expr = nothing,
3860+
sys = __has_sys(f) ? f.sys : nothing,
3861+
lag_h = nothing, lag_hess_prototype = nothing,
3862+
hess_colorvec = __has_colorvec(f) ? f.colorvec : nothing,
3863+
cons_jac_colorvec = __has_colorvec(f) ? f.colorvec :
3864+
nothing,
3865+
cons_hess_colorvec = __has_colorvec(f) ? f.colorvec :
3866+
nothing,
3867+
lag_hess_colorvec = nothing) where {iip}
3868+
isinplace(f, 2; has_two_dispatches = false, isoptimization = true)
3869+
sys = sys_or_symbolcache(sys, syms, paramsyms)
3870+
MultiObjectiveOptimizationFunction{iip, typeof(adtype), typeof(f), typeof(jac), typeof(hess),
3871+
typeof(hv),
3872+
typeof(cons), typeof(cons_j), typeof(cons_jvp),
3873+
typeof(cons_vjp), typeof(cons_h),
3874+
typeof(hess_prototype),
3875+
typeof(cons_jac_prototype), typeof(cons_hess_prototype),
3876+
typeof(observed),
3877+
typeof(expr), typeof(cons_expr), typeof(sys), typeof(lag_h),
3878+
typeof(lag_hess_prototype), typeof(hess_colorvec),
3879+
typeof(cons_jac_colorvec), typeof(cons_hess_colorvec),
3880+
typeof(lag_hess_colorvec)
3881+
}(f, adtype, jac, hess,
3882+
hv, cons, cons_j, cons_jvp,
3883+
cons_vjp, cons_h,
3884+
hess_prototype, cons_jac_prototype,
3885+
cons_hess_prototype, observed, expr, cons_expr, sys,
3886+
lag_h, lag_hess_prototype, hess_colorvec, cons_jac_colorvec,
3887+
cons_hess_colorvec, lag_hess_colorvec)
3888+
end
3889+
3890+
# Placeholder functions for __has_jac_prototype, __has_observed, __has_sys, and __has_colorvec
3891+
__has_jac_prototype(f) = false
3892+
__has_observed(f) = false
3893+
__has_sys(f) = false
3894+
__has_colorvec(f) = false
3895+
38403896
function BVPFunction{iip, specialize, twopoint}(f, bc;
38413897
mass_matrix = __has_mass_matrix(f) ? f.mass_matrix : I,
38423898
analytic = __has_analytic(f) ? f.analytic : nothing,

0 commit comments

Comments
 (0)