Skip to content

Commit 4c680ca

Browse files
fix: fix ODEProblem construction during precompilation with eval_expression = true
1 parent acb124a commit 4c680ca

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/systems/problem_utils.jl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,6 @@ function maybe_build_initialization_problem(
11751175
sys, initializeprob.f.sys; p_constructor)
11761176
end
11771177

1178-
reqd_syms = parameter_symbols(initializeprob)
11791178
# we still want the `initialization_data` because it helps with `remake`
11801179
if initializeprobmap === nothing && initializeprobpmap === nothing
11811180
update_initializeprob! = nothing
@@ -1186,7 +1185,9 @@ function maybe_build_initialization_problem(
11861185
filter!(punknowns) do p
11871186
is_parameter_solvable(p, op, defs, guesses) && get(op, p, missing) === missing
11881187
end
1189-
pvals = getu(initializeprob, punknowns)(initializeprob)
1188+
# See comment below for why `getu` is not used here.
1189+
_pgetter = build_explicit_observed_function(initializeprob.f.sys, punknowns)
1190+
pvals = _pgetter(state_values(initializeprob), parameter_values(initializeprob))
11901191
for (p, pval) in zip(punknowns, pvals)
11911192
p = unwrap(p)
11921193
op[p] = pval
@@ -1198,7 +1199,13 @@ function maybe_build_initialization_problem(
11981199
end
11991200

12001201
if time_dependent_init
1201-
uvals = getu(initializeprob, collect(missing_unknowns))(initializeprob)
1202+
# We can't use `getu` here because that goes to `SII.observed`, which goes to
1203+
# `ObservedFunctionCache` which uses `eval_expression` and `eval_module`. If
1204+
# `eval_expression == true`, this then runs into world-age issues. Building an
1205+
# RGF here is fine since it is always discarded. We can't use `eval_module` for
1206+
# the RGF since the user may not have run RGF's init.
1207+
_ugetter = build_explicit_observed_function(initializeprob.f.sys, collect(missing_unknowns))
1208+
uvals = _ugetter(state_values(initializeprob), parameter_values(initializeprob))
12021209
for (v, val) in zip(missing_unknowns, uvals)
12031210
op[v] = val
12041211
end

0 commit comments

Comments
 (0)