@@ -173,15 +173,54 @@ function is_parameter_solvable(p, pmap, defs, guesses)
173
173
# either (missing is a default or was passed to the ODEProblem) or (nothing was passed to
174
174
# the ODEProblem and it has a default and a guess)
175
175
return ((_val1 === missing || _val2 === missing ) ||
176
- (_val1 === nothing && _val2 != = nothing )) && _val3 != = nothing
176
+ (_val1 === nothing && _val2 != = nothing )) && _val3 != = nothing
177
177
end
178
178
179
179
function SciMLBase. remake_initializeprob (sys:: ODESystem , odefn, u0, t0, p)
180
- if (u0 === missing || ! (eltype (u0) <: Pair ) || isempty (u0)) &&
181
- (p === missing || ! (eltype (p) <: Pair ) || isempty (p))
180
+ if u0 === missing && p === missing
182
181
return odefn. initializeprob, odefn. update_initializeprob!, odefn. initializeprobmap,
183
182
odefn. initializeprobpmap
184
183
end
184
+ if ! (eltype (u0) <: Pair ) && ! (eltype (p) <: Pair )
185
+ oldinitprob = odefn. initializeprob
186
+ if oldinitprob === nothing || ! SciMLBase. has_sys (oldinitprob. f) ||
187
+ ! (oldinitprob. f. sys isa NonlinearSystem)
188
+ return oldinitprob, odefn. update_initializeprob!, odefn. initializeprobmap,
189
+ odefn. initializeprobpmap
190
+ end
191
+ pidxs = ParameterIndex[]
192
+ pvals = []
193
+ u0idxs = Int[]
194
+ u0vals = []
195
+ for sym in variable_symbols (oldinitprob)
196
+ if is_variable (sys, sym)
197
+ u0 != = missing || continue
198
+ idx = variable_index (oldinitprob, sym)
199
+ push! (u0idxs, idx)
200
+ push! (u0vals, eltype (u0)(state_values (oldinitprob, idx)))
201
+ else
202
+ p != = missing || continue
203
+ idx = variable_index (oldinitprob, sym)
204
+ push! (u0idxs, idx)
205
+ push! (u0vals, typeof (getp (sys, sym)(p))(state_values (oldinitprob, idx)))
206
+ end
207
+ end
208
+ if p != = missing
209
+ for sym in parameter_symbols (oldinitprob)
210
+ push! (pidxs, parameter_index (oldinitprob, sym))
211
+ if isequal (sym, get_iv (sys))
212
+ push! (pvals, t0)
213
+ else
214
+ push! (pvals, getp (sys, sym)(p))
215
+ end
216
+ end
217
+ end
218
+ newu0 = remake_buffer (oldinitprob. f. sys, state_values (oldinitprob), u0idxs, u0vals)
219
+ newp = remake_buffer (oldinitprob. f. sys, parameter_values (oldinitprob), pidxs, pvals)
220
+ initprob = remake (oldinitprob; u0 = newu0, p = newp)
221
+ return initprob, odefn. update_initializeprob!, odefn. initializeprobmap,
222
+ odefn. initializeprobpmap
223
+ end
185
224
if u0 === missing || isempty (u0)
186
225
u0 = Dict ()
187
226
elseif ! (eltype (u0) <: Pair )
0 commit comments