@@ -676,6 +676,18 @@ function step!(integ::NullODEIntegrator, dt = nothing, stop_at_tdt = false)
676
676
return nothing
677
677
end
678
678
679
+ function hack_null_solution_init (prob)
680
+ if SciMLBase. has_initializeprob (prob. f) && SciMLBase. has_initializeprobpmap (prob. f)
681
+ initializeprob = prob. f. initializeprob
682
+ nlsol = solve (initializeprob)
683
+ success = SciMLBase. successful_retcode (nlsol)
684
+ @set! prob. p = prob. f. initializeprobpmap (prob, nlsol)
685
+ else
686
+ success = true
687
+ end
688
+ return prob, success
689
+ end
690
+
679
691
function build_null_solution (prob:: AbstractDEProblem , args... ;
680
692
saveat = (),
681
693
save_everystep = true ,
@@ -702,12 +714,9 @@ function build_null_solution(prob::AbstractDEProblem, args...;
702
714
703
715
timeseries = [Float64[] for i in 1 : length (ts)]
704
716
705
- if SciMLBase. has_initializeprob (prob. f) && SciMLBase. has_initializeprobpmap (prob. f)
706
- initializeprob = prob. f. initializeprob
707
- nlsol = solve (initializeprob)
708
- @set! prob. p = prob. f. initializeprobpmap (prob, nlsol)
709
- end
710
- build_solution (prob, nothing , ts, timeseries, retcode = ReturnCode. Success)
717
+ prob, success = hack_null_solution_init (prob)
718
+ retcode = success ? ReturnCode. Success : ReturnCode. InitialFailure
719
+ build_solution (prob, nothing , ts, timeseries, retcode)
711
720
end
712
721
713
722
function build_null_solution (
@@ -720,21 +729,28 @@ function build_null_solution(
720
729
saveat isa Number || prob. tspan[1 ] in saveat,
721
730
save_end = true ,
722
731
kwargs... )
732
+ prob, success = hack_null_solution_init (prob)
733
+ retcode = success ? ReturnCode. Success : ReturnCode. InitialFailure
723
734
SciMLBase. build_solution (prob, nothing , Float64[], nothing ;
724
- retcode = ReturnCode . Success )
735
+ retcode)
725
736
end
726
737
727
738
function build_null_solution (
728
739
prob:: NonlinearLeastSquaresProblem ,
729
740
args... ; abstol = 1e-6 , kwargs... )
741
+ prob, success = hack_null_solution_init (prob)
742
+ retcode = success ? ReturnCode. Success : ReturnCode. InitialFailure
743
+
730
744
if isinplace (prob)
731
745
resid = isnothing (prob. f. resid_prototype) ? Float64[] : copy (prob. f. resid_prototype)
732
746
prob. f (resid, prob. u0, prob. p)
733
747
else
734
748
resid = prob. f (prob. u0, prob. p)
735
749
end
736
750
737
- retcode = norm (resid) < abstol ? ReturnCode. Success : ReturnCode. Failure
751
+ if success
752
+ retcode = norm (resid) < abstol ? ReturnCode. Success : ReturnCode. Failure
753
+ end
738
754
739
755
SciMLBase. build_solution (prob, nothing , Float64[], resid;
740
756
retcode)
0 commit comments