-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: fix more of NonlinearSolve tests
- Loading branch information
Showing
34 changed files
with
756 additions
and
764 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
version: | ||
- "lts" | ||
- "1.10" | ||
- "1" | ||
os: | ||
- ubuntu-latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
version: | ||
- "lts" | ||
- "1.10" | ||
- "1" | ||
os: | ||
- ubuntu-latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
version: | ||
- "lts" | ||
- "1.10" | ||
- "1" | ||
os: | ||
- ubuntu-latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
version: | ||
- "lts" | ||
- "1.10" | ||
- "1" | ||
os: | ||
- ubuntu-latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
version: | ||
- "lts" | ||
- "1.10" | ||
- "1" | ||
os: | ||
- ubuntu-latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
version: | ||
- "lts" | ||
- "1.10" | ||
- "1" | ||
os: | ||
- ubuntu-latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,6 @@ jobs: | |
group: | ||
- Core | ||
- Downstream | ||
- Misc | ||
- Wrappers | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +0,0 @@ | ||
""" | ||
enable_timer_outputs() | ||
Enable `TimerOutput` for all `NonlinearSolve` algorithms. This is useful for debugging | ||
but has some overhead, so it is disabled by default. | ||
""" | ||
function enable_timer_outputs() | ||
set_preferences!(NonlinearSolveBase, "enable_timer_outputs" => true; force = true) | ||
@info "Timer Outputs Enabled. Restart the Julia session for this to take effect." | ||
end | ||
|
||
""" | ||
disable_timer_outputs() | ||
Disable `TimerOutput` for all `NonlinearSolve` algorithms. This should be used when | ||
`NonlinearSolve` is being used in performance-critical code. | ||
""" | ||
function disable_timer_outputs() | ||
set_preferences!(NonlinearSolveBase, "enable_timer_outputs" => false; force = true) | ||
@info "Timer Outputs Disabled. Restart the Julia session for this to take effect." | ||
end | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
# @testsetup module RobustnessTesting | ||
# using NonlinearSolve, LinearAlgebra, LinearSolve, NonlinearProblemLibrary, Test | ||
|
||
# problems = NonlinearProblemLibrary.problems | ||
# dicts = NonlinearProblemLibrary.dicts | ||
|
||
# function test_on_library( | ||
# problems, dicts, alg_ops, broken_tests, ϵ = 1e-4; skip_tests = nothing) | ||
# for (idx, (problem, dict)) in enumerate(zip(problems, dicts)) | ||
# x = dict["start"] | ||
# res = similar(x) | ||
# nlprob = NonlinearProblem(problem, copy(x)) | ||
# @testset "$idx: $(dict["title"])" begin | ||
# for alg in alg_ops | ||
# try | ||
# sol = solve(nlprob, alg; maxiters = 10000) | ||
# problem(res, sol.u, nothing) | ||
|
||
# skip = skip_tests !== nothing && idx in skip_tests[alg] | ||
# if skip | ||
# @test_skip norm(res, Inf) ≤ ϵ | ||
# continue | ||
# end | ||
# broken = idx in broken_tests[alg] ? true : false | ||
# @test norm(res, Inf)≤ϵ broken=broken | ||
# catch err | ||
# @error err | ||
# broken = idx in broken_tests[alg] ? true : false | ||
# if broken | ||
# @test false broken=true | ||
# else | ||
# @test 1 == 2 | ||
# end | ||
# end | ||
# end | ||
# end | ||
# end | ||
# end | ||
|
||
# export test_on_library, problems, dicts | ||
# end | ||
|
||
# @testitem "PolyAlgorithms" setup=[RobustnessTesting] tags=[:core] begin | ||
# alg_ops = (RobustMultiNewton(), FastShortcutNonlinearPolyalg()) | ||
|
||
# broken_tests = Dict(alg => Int[] for alg in alg_ops) | ||
# broken_tests[alg_ops[1]] = [] | ||
# broken_tests[alg_ops[2]] = [] | ||
|
||
# test_on_library(problems, dicts, alg_ops, broken_tests) | ||
# end | ||
|
||
# @testitem "NewtonRaphson" setup=[RobustnessTesting] tags=[:core] begin | ||
# alg_ops = (NewtonRaphson(),) | ||
|
||
# broken_tests = Dict(alg => Int[] for alg in alg_ops) | ||
# broken_tests[alg_ops[1]] = [1] | ||
|
||
# test_on_library(problems, dicts, alg_ops, broken_tests) | ||
# end | ||
|
||
# @testitem "TrustRegion" setup=[RobustnessTesting] tags=[:core] begin | ||
# alg_ops = (TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Simple), | ||
# TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Fan), | ||
# TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Hei), | ||
# TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Yuan), | ||
# TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Bastin), | ||
# TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.NLsolve)) | ||
|
||
# broken_tests = Dict(alg => Int[] for alg in alg_ops) | ||
# broken_tests[alg_ops[1]] = [11, 21] | ||
# broken_tests[alg_ops[2]] = [11, 21] | ||
# broken_tests[alg_ops[3]] = [11, 21] | ||
# broken_tests[alg_ops[4]] = [8, 11, 21] | ||
# broken_tests[alg_ops[5]] = [21] | ||
# broken_tests[alg_ops[6]] = [11, 21] | ||
|
||
# test_on_library(problems, dicts, alg_ops, broken_tests) | ||
# end | ||
|
||
# @testitem "LevenbergMarquardt" setup=[RobustnessTesting] tags=[:core] begin | ||
# using LinearSolve | ||
|
||
# alg_ops = (LevenbergMarquardt(), LevenbergMarquardt(; α_geodesic = 0.1), | ||
# LevenbergMarquardt(; linsolve = CholeskyFactorization())) | ||
|
||
# broken_tests = Dict(alg => Int[] for alg in alg_ops) | ||
# broken_tests[alg_ops[1]] = [11, 21] | ||
# broken_tests[alg_ops[2]] = [11, 21] | ||
# broken_tests[alg_ops[3]] = [11, 21] | ||
|
||
# test_on_library(problems, dicts, alg_ops, broken_tests) | ||
# end | ||
|
||
# @testitem "DFSane" setup=[RobustnessTesting] tags=[:core] begin | ||
# alg_ops = (DFSane(),) | ||
|
||
# broken_tests = Dict(alg => Int[] for alg in alg_ops) | ||
# broken_tests[alg_ops[1]] = [1, 2, 3, 5, 21] | ||
|
||
# test_on_library(problems, dicts, alg_ops, broken_tests) | ||
# end | ||
|
||
# @testitem "Broyden" setup=[RobustnessTesting] tags=[:core] begin | ||
# alg_ops = (Broyden(), Broyden(; init_jacobian = Val(:true_jacobian)), | ||
# Broyden(; update_rule = Val(:bad_broyden)), | ||
# Broyden(; init_jacobian = Val(:true_jacobian), update_rule = Val(:bad_broyden))) | ||
|
||
# broken_tests = Dict(alg => Int[] for alg in alg_ops) | ||
# if Sys.isapple() | ||
# broken_tests[alg_ops[1]] = [1, 5, 11] | ||
# broken_tests[alg_ops[2]] = [1, 5, 8, 11, 18] | ||
# broken_tests[alg_ops[3]] = [1, 5, 6, 9, 11] | ||
# broken_tests[alg_ops[4]] = [5, 6, 8, 11] | ||
# else | ||
# broken_tests[alg_ops[1]] = [1, 5, 11, 15] | ||
# broken_tests[alg_ops[2]] = [1, 5, 8, 11, 18] | ||
# broken_tests[alg_ops[3]] = [1, 5, 9, 11] | ||
# broken_tests[alg_ops[4]] = [5, 6, 8, 11] | ||
# end | ||
|
||
# test_on_library(problems, dicts, alg_ops, broken_tests, Sys.isapple() ? 1e-3 : 1e-4) | ||
# end | ||
|
||
# @testitem "Klement" setup=[RobustnessTesting] tags=[:core] begin | ||
# alg_ops = (Klement(), Klement(; init_jacobian = Val(:true_jacobian_diagonal))) | ||
|
||
# broken_tests = Dict(alg => Int[] for alg in alg_ops) | ||
# broken_tests[alg_ops[1]] = [1, 2, 4, 5, 11, 18, 22] | ||
# broken_tests[alg_ops[2]] = [2, 4, 5, 7, 18, 22] | ||
|
||
# test_on_library(problems, dicts, alg_ops, broken_tests) | ||
# end | ||
|
||
# @testitem "PseudoTransient" setup=[RobustnessTesting] tags=[:core] begin | ||
# # PT relies on the root being a stable equilibrium for convergence, so it won't work on | ||
# # most problems | ||
# alg_ops = (PseudoTransient(),) | ||
|
||
# broken_tests = Dict(alg => Int[] for alg in alg_ops) | ||
# broken_tests[alg_ops[1]] = [1, 2, 3, 11, 15, 16] | ||
|
||
# test_on_library(problems, dicts, alg_ops, broken_tests) | ||
# end |
Oops, something went wrong.