@@ -692,42 +692,50 @@ end
692
692
# --- GeneralBroyden tests ---
693
693
694
694
@testset " GeneralBroyden" begin
695
- function benchmark_nlsolve_oop (f, u0, p = 2.0 ; linesearch = nothing )
695
+ function benchmark_nlsolve_oop (f, u0, p = 2.0 ; linesearch = nothing ,
696
+ init_jacobian = Val (:identity ), update_rule = Val (:good_broyden ))
696
697
prob = NonlinearProblem {false} (f, u0, p)
697
- return solve (prob, GeneralBroyden (; linesearch), abstol = 1e-9 )
698
+ return solve (prob, GeneralBroyden (; linesearch, init_jacobian, update_rule);
699
+ abstol = 1e-9 )
698
700
end
699
701
700
- function benchmark_nlsolve_iip (f, u0, p = 2.0 ; linesearch = nothing )
702
+ function benchmark_nlsolve_iip (f, u0, p = 2.0 ; linesearch = nothing ,
703
+ init_jacobian = Val (:identity ), update_rule = Val (:good_broyden ))
701
704
prob = NonlinearProblem {true} (f, u0, p)
702
- return solve (prob, GeneralBroyden (; linesearch), abstol = 1e-9 )
705
+ return solve (prob, GeneralBroyden (; linesearch, init_jacobian, update_rule);
706
+ abstol = 1e-9 )
703
707
end
704
708
705
- @testset " LineSearch: $(_nameof (lsmethod)) LineSearch AD: $(_nameof (ad)) " for lsmethod in (Static (),
709
+ @testset " LineSearch: $(_nameof (lsmethod)) LineSearch AD: $(_nameof (ad)) Init Jacobian: $(init_jacobian) Update Rule: $(update_rule) " for lsmethod in (Static (),
706
710
StrongWolfe (), BackTracking (), HagerZhang (), MoreThuente (),
707
711
LiFukushimaLineSearch ()),
708
- ad in (AutoFiniteDiff (), AutoZygote ())
712
+ ad in (AutoFiniteDiff (), AutoZygote ()),
713
+ init_jacobian in (Val (:identity ), Val (:true_jacobian )),
714
+ update_rule in (Val (:good_broyden ), Val (:bad_broyden ), Val (:diagonal ))
709
715
710
716
linesearch = LineSearch (; method = lsmethod, autodiff = ad)
711
717
u0s = ([1.0 , 1.0 ], @SVector [1.0 , 1.0 ], 1.0 )
712
718
713
719
@testset " [OOP] u0: $(typeof (u0)) " for u0 in u0s
714
- sol = benchmark_nlsolve_oop (quadratic_f, u0; linesearch)
720
+ sol = benchmark_nlsolve_oop (quadratic_f, u0; linesearch, update_rule,
721
+ init_jacobian)
715
722
@test SciMLBase. successful_retcode (sol)
716
723
@test all (abs .(sol. u .* sol. u .- 2 ) .< 1e-9 )
717
724
718
725
cache = init (NonlinearProblem {false} (quadratic_f, u0, 2.0 ),
719
- GeneralBroyden (; linesearch), abstol = 1e-9 )
726
+ GeneralBroyden (; linesearch, update_rule, init_jacobian ), abstol = 1e-9 )
720
727
@test (@ballocated solve! ($ cache)) < 200
721
728
end
722
729
723
730
@testset " [IIP] u0: $(typeof (u0)) " for u0 in ([1.0 , 1.0 ],)
724
731
ad isa AutoZygote && continue
725
- sol = benchmark_nlsolve_iip (quadratic_f!, u0; linesearch)
732
+ sol = benchmark_nlsolve_iip (quadratic_f!, u0; linesearch, update_rule,
733
+ init_jacobian)
726
734
@test SciMLBase. successful_retcode (sol)
727
735
@test all (abs .(sol. u .* sol. u .- 2 ) .< 1e-9 )
728
736
729
737
cache = init (NonlinearProblem {true} (quadratic_f!, u0, 2.0 ),
730
- GeneralBroyden (; linesearch), abstol = 1e-9 )
738
+ GeneralBroyden (; linesearch, update_rule, init_jacobian ), abstol = 1e-9 )
731
739
@test (@ballocated solve! ($ cache)) ≤ 64
732
740
end
733
741
end
0 commit comments