@@ -171,7 +171,24 @@ function to_varmap(vals, varlist::Vector)
171171 check_eqs_u0 (varlist, varlist, vals)
172172 vals = vec (varlist) .=> vec (vals)
173173 end
174- return anydict (unwrap (k) => unwrap (v) for (k, v) in anydict (vals))
174+ return recursive_unwrap (anydict (vals))
175+ end
176+
177+ """
178+ $(TYPEDSIGNATURES)
179+
180+ Recursively call `Symbolics.unwrap` on `x`. Useful when `x` is an array of (potentially)
181+ symbolic values, all of which need to be unwrapped. Specializes when `x isa AbstractDict`
182+ to unwrap keys and values, returning an `AnyDict`.
183+ """
184+ function recursive_unwrap (x:: AbstractArray )
185+ symbolic_type (x) == ArraySymbolic () ? unwrap (x) : recursive_unwrap .(x)
186+ end
187+
188+ recursive_unwrap (x) = unwrap (x)
189+
190+ function recursive_unwrap (x:: AbstractDict )
191+ return anydict (unwrap (k) => recursive_unwrap (v) for (k, v) in x)
175192end
176193
177194"""
@@ -262,7 +279,7 @@ function better_varmap_to_vars(varmap::AbstractDict, vars::Vector;
262279 end
263280 vals = map (x -> varmap[x], vars)
264281
265- if container_type <: Union{AbstractDict, Tuple, Nothing}
282+ if container_type <: Union{AbstractDict, Tuple, Nothing, SciMLBase.NullParameters }
266283 container_type = Array
267284 end
268285
@@ -410,7 +427,7 @@ function process_SciMLProblem(
410427 u0map = to_varmap (u0map, dvs)
411428 _pmap = pmap
412429 pmap = to_varmap (pmap, ps)
413- defs = add_toterms (defaults (sys))
430+ defs = add_toterms (recursive_unwrap ( defaults (sys) ))
414431 cmap, cs = get_cmap (sys)
415432 kwargs = NamedTuple (kwargs)
416433
@@ -433,9 +450,14 @@ function process_SciMLProblem(
433450 solvablepars = [p
434451 for p in parameters (sys)
435452 if is_parameter_solvable (p, pmap, defs, guesses)]
453+ has_dependent_unknowns = any (unknowns (sys)) do sym
454+ val = get (op, sym, nothing )
455+ val === nothing && return false
456+ return symbolic_type (val) != NotSymbolic () || is_array_of_symbolics (val)
457+ end
436458 if build_initializeprob &&
437459 (((implicit_dae || has_observed_u0s || ! isempty (missing_unknowns) ||
438- ! isempty (solvablepars)) &&
460+ ! isempty (solvablepars) || has_dependent_unknowns ) &&
439461 get_tearing_state (sys) != = nothing ) ||
440462 ! isempty (initialization_equations (sys))) && t != = nothing
441463 initializeprob = ModelingToolkit. InitializationProblem (
0 commit comments