Skip to content

Commit 9d98446

Browse files
avik-palFHoltorf
andcommitted
Add 23 test problems test
Co-authored-by: Flemming Holtorf <[email protected]>
1 parent c17ccbf commit 9d98446

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ FiniteDiff = "2"
3535
ForwardDiff = "0.10.3"
3636
LineSearches = "7"
3737
LinearSolve = "2"
38+
NonlinearProblemLibrary = "0.1"
3839
PrecompileTools = "1"
3940
RecursiveArrayTools = "2"
4041
Reexport = "0.2, 1"
@@ -52,6 +53,7 @@ Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
5253
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
5354
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
5455
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
56+
NonlinearProblemLibrary = "b7050fa9-e91f-4b37-bcee-a89a063da141"
5557
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
5658
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
5759
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
@@ -62,4 +64,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
6264
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
6365

6466
[targets]
65-
test = ["Enzyme", "BenchmarkTools", "SafeTestsets", "Pkg", "Test", "ForwardDiff", "StaticArrays", "Symbolics", "LinearSolve", "Random", "LinearAlgebra", "Zygote", "SparseDiffTools"]
67+
test = ["Enzyme", "BenchmarkTools", "SafeTestsets", "Pkg", "Test", "ForwardDiff", "StaticArrays", "Symbolics", "LinearSolve", "Random", "LinearAlgebra", "Zygote", "SparseDiffTools", "NonlinearProblemLibrary"]

test/23_test_problems.jl

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
using NonlinearSolve, LinearAlgebra, NonlinearProblemLibrary, Test
2+
3+
problems = NonlinearProblemLibrary.problems
4+
dicts = NonlinearProblemLibrary.dicts
5+
6+
function test_on_library(problems, dicts, alg_ops, broken_tests, ϵ = 1e-5)
7+
for (idx, (problem, dict)) in enumerate(zip(problems, dicts))
8+
x = dict["start"]
9+
res = similar(x)
10+
nlprob = NonlinearProblem(problem, x)
11+
@testset "$(dict["title"])" begin
12+
for alg in alg_ops
13+
sol = solve(nlprob, alg, abstol = 1e-15, reltol = 1e-15)
14+
problem(res, sol.u, nothing)
15+
broken = idx in broken_tests[alg] ? true : false
16+
@test norm(res)ϵ broken=broken
17+
end
18+
end
19+
end
20+
end
21+
22+
# NewtonRaphson
23+
@testset "NewtonRaphson test problem library" begin
24+
alg_ops = (NewtonRaphson(),)
25+
26+
# dictionary with indices of test problems where method does not converge to small residual
27+
broken_tests = Dict(alg => Int[] for alg in alg_ops)
28+
broken_tests[alg_ops[1]] = [1, 6]
29+
30+
test_on_library(problems, dicts, alg_ops, broken_tests)
31+
end
32+
33+
@testset "TrustRegion test problem library" begin
34+
alg_ops = (TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Simple),
35+
TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Fan),
36+
TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Hei),
37+
TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Yuan),
38+
TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Bastin),
39+
TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.NLsolve))
40+
41+
# dictionary with indices of test problems where method does not converge to small residual
42+
broken_tests = Dict(alg => Int[] for alg in alg_ops)
43+
broken_tests[alg_ops[1]] = [6, 11, 21]
44+
broken_tests[alg_ops[2]] = [6, 11, 21]
45+
broken_tests[alg_ops[3]] = [1, 6, 11, 12, 15, 16, 21]
46+
broken_tests[alg_ops[4]] = [1, 6, 8, 11, 15, 16, 21, 22]
47+
broken_tests[alg_ops[5]] = [6, 21]
48+
broken_tests[alg_ops[6]] = [6, 21]
49+
50+
test_on_library(problems, dicts, alg_ops, broken_tests)
51+
end
52+
53+
@testset "TrustRegion test problem library" begin
54+
alg_ops = (LevenbergMarquardt(), LevenbergMarquardt(; α_geodesic = 0.5))
55+
56+
# dictionary with indices of test problems where method does not converge to small residual
57+
broken_tests = Dict(alg => Int[] for alg in alg_ops)
58+
broken_tests[alg_ops[1]] = [3, 6, 11, 17, 21]
59+
broken_tests[alg_ops[2]] = [3, 6, 11, 21]
60+
61+
test_on_library(problems, dicts, alg_ops, broken_tests)
62+
end

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ end
1515
if GROUP == "All" || GROUP == "Core"
1616
@time @safetestset "Basic Tests + Some AD" include("basictests.jl")
1717
@time @safetestset "Sparsity Tests" include("sparse.jl")
18+
19+
@time @safetestset "23 Test Problems" include("23_test_problems.jl")
1820
end
1921

2022
if GROUP == "GPU"

0 commit comments

Comments
 (0)