Skip to content

Commit ff98434

Browse files
feat: add fast path for constructing MTKParameters in process_SciMLProblem
1 parent 4578b66 commit ff98434

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/systems/parameter_buffer.jl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ the default behavior).
2929
function MTKParameters(
3030
sys::AbstractSystem, p, u0 = Dict(); 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
@@ -50,9 +50,15 @@ function MTKParameters(
5050
is_time_dependent(sys) && add_observed!(sys, u0)
5151
add_parameter_dependencies!(sys, p)
5252

53-
op, missing_unknowns, missing_pars = build_operating_point!(sys,
54-
u0, p, defs, cmap, dvs, ps)
55-
53+
u0map = anydict()
54+
pmap = anydict()
55+
if fast_path
56+
missing_pars = missingvars(p, ps)
57+
op = p
58+
else
59+
op, _, missing_pars = build_operating_point!(sys,
60+
u0, p, defs, cmap, dvs, ps)
61+
end
5662
if t0 !== nothing
5763
op[get_iv(sys)] = t0
5864
end

src/systems/problem_utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ function process_SciMLProblem(
13711371
if !(pType <: AbstractArray)
13721372
pType = Array
13731373
end
1374-
p = MTKParameters(sys, op; floatT = floatT, p_constructor)
1374+
p = MTKParameters(sys, op; floatT = floatT, p_constructor, fast_path = true)
13751375
else
13761376
p = p_constructor(better_varmap_to_vars(op, ps; tofloat, container_type = pType))
13771377
end

0 commit comments

Comments
 (0)