@@ -22,10 +22,10 @@ function initialize!(integrator, cache::IDSolveCache)
22
22
else
23
23
(u_next, p) -> f (u_next, p. u, p. p, p. t_next)
24
24
end
25
- nlls = length (f. resid_prototype) == length (integrator. u)
25
+ nlls = ! isnothing (f . resid_prototype) && ( length (f. resid_prototype) == length (integrator. u) )
26
26
27
27
prob = if nlls
28
- NonlinearLeastSquaresProblem {isinplace(f)} (_f , cache. state. u, cache. state)
28
+ NonlinearLeastSquaresProblem {isinplace(f)} (NonlinearFunction (_f; resid_prototype = f . resid_prototype) , cache. state. u, cache. state)
29
29
else
30
30
NonlinearProblem {isinplace(f)} (_f, cache. state. u, cache. state)
31
31
end
@@ -48,9 +48,10 @@ function _initialize_dae!(integrator, prob::ImplicitDiscreteProblem,
48
48
else
49
49
(u_next, p) -> f (u_next, p. u, p. p, p. t_next)
50
50
end
51
- nlls = length (f. resid_prototype) == length (integrator. u)
51
+
52
+ nlls = ! isnothing (f. resid_prototype) && (length (f. resid_prototype) == length (integrator. u))
52
53
prob = if nlls
53
- NonlinearLeastSquaresProblem {isinplace(f)} (_f , cache. state. u, cache. state)
54
+ NonlinearLeastSquaresProblem {isinplace(f)} (NonlinearFunction (_f; resid_prototype = f . resid_prototype) , cache. state. u, cache. state)
54
55
else
55
56
NonlinearProblem {isinplace(f)} (_f, cache. state. u, cache. state)
56
57
end
0 commit comments