@@ -112,9 +112,9 @@ function generate_initializesystem(sys::AbstractSystem;
112
112
# If either of them are `missing` the parameter is an unknown
113
113
# But if the parameter is passed a value, use that as an additional
114
114
# equation in the system
115
- _val1 = get (pmap, p, nothing )
116
- _val2 = get (defs, p, nothing )
117
- _val3 = get (guesses, p, nothing )
115
+ _val1 = get_possibly_array_fallback_singletons (pmap, p)
116
+ _val2 = get_possibly_array_fallback_singletons (defs, p)
117
+ _val3 = get_possibly_array_fallback_singletons (guesses, p)
118
118
varp = tovar (p)
119
119
paramsubs[p] = varp
120
120
# Has a default of `missing`, and (either an equation using the value passed to `ODEProblem` or a guess)
@@ -139,7 +139,7 @@ function generate_initializesystem(sys::AbstractSystem;
139
139
error (" Invalid setup: parameter $(p) has no default value, initial value, or guess" )
140
140
end
141
141
# given a symbolic value to ODEProblem
142
- elseif symbolic_type (_val1) != NotSymbolic ()
142
+ elseif symbolic_type (_val1) != NotSymbolic () || is_array_of_symbolics (_val1)
143
143
push! (eqs_ics, varp ~ _val1)
144
144
push! (defs, varp => _val3)
145
145
# No value passed to `ODEProblem`, but a default and a guess are present
@@ -268,16 +268,34 @@ struct InitializationSystemMetadata
268
268
oop_reconstruct_u0_p:: Union{Nothing, ReconstructInitializeprob}
269
269
end
270
270
271
+ function get_possibly_array_fallback_singletons (varmap, p)
272
+ if haskey (varmap, p)
273
+ return varmap[p]
274
+ end
275
+ symbolic_type (p) == ArraySymbolic () || return nothing
276
+ scal = collect (p)
277
+ if all (x -> haskey (varmap, x), scal)
278
+ res = [varmap[x] for x in scal]
279
+ if any (x -> x === nothing , res)
280
+ return nothing
281
+ elseif any (x -> x === missing , res)
282
+ return missing
283
+ end
284
+ return res
285
+ end
286
+ return nothing
287
+ end
288
+
271
289
function is_parameter_solvable (p, pmap, defs, guesses)
272
290
p = unwrap (p)
273
291
is_variable_floatingpoint (p) || return false
274
- _val1 = pmap isa AbstractDict ? get (pmap, p, nothing ) : nothing
275
- _val2 = get (defs, p, nothing )
276
- _val3 = get (guesses, p, nothing )
292
+ _val1 = pmap isa AbstractDict ? get_possibly_array_fallback_singletons (pmap, p) : nothing
293
+ _val2 = get_possibly_array_fallback_singletons (defs, p)
294
+ _val3 = get_possibly_array_fallback_singletons (guesses, p)
277
295
# either (missing is a default or was passed to the ODEProblem) or (nothing was passed to
278
296
# the ODEProblem and it has a default and a guess)
279
297
return ((_val1 === missing || _val2 === missing ) ||
280
- (symbolic_type (_val1) != NotSymbolic () ||
298
+ (symbolic_type (_val1) != NotSymbolic () || is_array_of_symbolics (_val1) ||
281
299
_val1 === nothing && _val2 != = nothing )) && _val3 != = nothing
282
300
end
283
301
0 commit comments