|
1 | | - |
2 | | -function Base.getproperty(cache::SciMLBase.AbstractOptimizationCache, x::Symbol) |
3 | | - if x in (:u0, :p) |
4 | | - return getfield(cache.reinit_cache, x) |
5 | | - end |
6 | | - return getfield(cache, x) |
7 | | -end |
8 | | - |
9 | | -SciMLBase.has_reinit(cache::SciMLBase.AbstractOptimizationCache) = true |
10 | | -function SciMLBase.reinit!(cache::SciMLBase.AbstractOptimizationCache; p = missing, |
11 | | - u0 = missing) |
12 | | - if p === missing && u0 === missing |
13 | | - p, u0 = cache.p, cache.u0 |
14 | | - else # at least one of them has a value |
15 | | - if p === missing |
16 | | - p = cache.p |
17 | | - end |
18 | | - if u0 === missing |
19 | | - u0 = cache.u0 |
20 | | - end |
21 | | - if (eltype(p) <: Pair && !isempty(p)) || (eltype(u0) <: Pair && !isempty(u0)) # one is a non-empty symbolic map |
22 | | - hasproperty(cache.f, :sys) && hasfield(typeof(cache.f.sys), :ps) || |
23 | | - throw(ArgumentError("This cache does not support symbolic maps with `remake`, i.e. it does not have a symbolic origin." * |
24 | | - " Please use `remake` with the `p` keyword argument as a vector of values, paying attention to parameter order.")) |
25 | | - hasproperty(cache.f, :sys) && hasfield(typeof(cache.f.sys), :states) || |
26 | | - throw(ArgumentError("This cache does not support symbolic maps with `remake`, i.e. it does not have a symbolic origin." * |
27 | | - " Please use `remake` with the `u0` keyword argument as a vector of values, paying attention to state order.")) |
28 | | - p, u0 = SciMLBase.process_p_u0_symbolic(cache, p, u0) |
29 | | - end |
30 | | - end |
31 | | - |
32 | | - cache.reinit_cache.p = p |
33 | | - cache.reinit_cache.u0 = u0 |
34 | | - |
35 | | - return cache |
36 | | -end |
37 | | - |
38 | 1 | struct OptimizationCache{F, RC, LB, UB, LC, UC, S, O, D, P, C} <: |
39 | 2 | SciMLBase.AbstractOptimizationCache |
40 | 3 | f::F |
|
0 commit comments