@@ -5,16 +5,18 @@ struct AnalysisResults{O, C}
55 constraints:: C
66end
77
8- struct OptimizationCache{F, RC, LB, UB, LC, UC, S, O, P, C, M} < :
8+ struct OptimizationCache{
9+ O, IIP, F <: SciMLBase.AbstractOptimizationFunction{IIP} ,
10+ RC, LB, UB, LC, UC, S, P, C, M} < :
911 SciMLBase. AbstractOptimizationCache
12+ opt:: O
1013 f:: F
1114 reinit_cache:: RC
1215 lb:: LB
1316 ub:: UB
1417 lcons:: LC
1518 ucons:: UC
1619 sense:: S
17- opt:: O
1820 progress:: P
1921 callback:: C
2022 manifold:: M
@@ -46,13 +48,13 @@ function OptimizationCache(prob::SciMLBase.OptimizationProblem, opt;
4648 prob. f. adtype isa AutoZygote) &&
4749 (SciMLBase. requireshessian (opt) || SciMLBase. requiresconshess (opt) ||
4850 SciMLBase. requireslagh (opt))
49- @warn " The selected optimization algorithm requires second order derivatives, but `SecondOrder` ADtype was not provided.
50- So a `SecondOrder` with $(prob. f. adtype) for both inner and outer will be created, this can be suboptimal and not work in some cases so
51+ @warn " The selected optimization algorithm requires second order derivatives, but `SecondOrder` ADtype was not provided.
52+ So a `SecondOrder` with $(prob. f. adtype) for both inner and outer will be created, this can be suboptimal and not work in some cases so
5153 an explicit `SecondOrder` ADtype is recommended."
5254 elseif prob. f. adtype isa AutoZygote &&
5355 (SciMLBase. requiresconshess (opt) || SciMLBase. requireslagh (opt) ||
5456 SciMLBase. requireshessian (opt))
55- @warn " The selected optimization algorithm requires second order derivatives, but `AutoZygote` ADtype was provided.
57+ @warn " The selected optimization algorithm requires second order derivatives, but `AutoZygote` ADtype was provided.
5658 So a `SecondOrder` with `AutoZygote` for inner and `AutoForwardDiff` for outer will be created, for choosing another pair
5759 an explicit `SecondOrder` ADtype is recommended."
5860 end
@@ -71,11 +73,10 @@ function OptimizationCache(prob::SciMLBase.OptimizationProblem, opt;
7173 cons_res = nothing
7274 end
7375
74- return OptimizationCache (f, reinit_cache_passedon, prob. lb, prob. ub, prob. lcons,
76+ return OptimizationCache (opt, f, reinit_cache_passedon, prob. lb, prob. ub, prob. lcons,
7577 prob. ucons, prob. sense,
76- opt, progress, callback, manifold, AnalysisResults (obj_res, cons_res),
77- merge ((; maxiters, maxtime, abstol, reltol),
78- NamedTuple (kwargs)))
78+ progress, callback, manifold, AnalysisResults (obj_res, cons_res),
79+ merge ((; maxiters, maxtime, abstol, reltol), NamedTuple (kwargs)))
7980end
8081
8182function SciMLBase. __init (prob:: SciMLBase.OptimizationProblem , opt;
@@ -91,6 +92,8 @@ function SciMLBase.__init(prob::SciMLBase.OptimizationProblem, opt;
9192 kwargs... )
9293end
9394
95+ SciMLBase. isinplace (:: OptimizationCache{o, iip} ) where {o, iip} = iip
96+
9497# Wrapper for fields that may change in `reinit!(cache)` of a cache.
9598mutable struct ReInitCache{uType, P}
9699 u0:: uType
0 commit comments