Skip to content

Commit 58a47ab

Browse files
feat: add fast path for constructing MTKParameters in process_SciMLProblem
1 parent 0948934 commit 58a47ab

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/systems/parameter_buffer.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ the default behavior).
2929
function MTKParameters(
3030
sys::AbstractSystem, op; tofloat = false,
3131
t0 = nothing, substitution_limit = 1000, floatT = nothing,
32-
p_constructor = identity)
32+
p_constructor = identity, fast_path = false)
3333
ic = if has_index_cache(sys) && get_index_cache(sys) !== nothing
3434
get_index_cache(sys)
3535
else
@@ -49,9 +49,12 @@ function MTKParameters(
4949

5050
u0map = anydict()
5151
pmap = anydict()
52-
missing_unknowns, missing_pars = build_operating_point!(sys, op,
53-
u0map, pmap, defs, dvs, ps)
54-
52+
if fast_path
53+
missing_pars = missingvars(op, ps)
54+
else
55+
_, missing_pars = build_operating_point!(sys, op,
56+
u0map, pmap, defs, dvs, ps)
57+
end
5558
if t0 !== nothing
5659
op[get_iv(sys)] = t0
5760
end

src/systems/problem_utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,7 @@ function process_SciMLProblem(
13971397
if !(pType <: AbstractArray)
13981398
pType = Array
13991399
end
1400-
p = MTKParameters(sys, op; floatT = floatT, p_constructor)
1400+
p = MTKParameters(sys, op; floatT = floatT, p_constructor, fast_path = true)
14011401
else
14021402
p = p_constructor(varmap_to_vars(op, ps; tofloat, container_type = pType))
14031403
end

0 commit comments

Comments
 (0)