Skip to content

Commit 4354511

Browse files
committed
test: centralize the 23 test problem testing
1 parent a7a5f1e commit 4354511

File tree

3 files changed

+71
-146
lines changed

3 files changed

+71
-146
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ NonlinearSolveFirstOrder = "1"
9494
NonlinearSolveQuasiNewton = "1"
9595
NonlinearSolveSpectralMethods = "1"
9696
OrdinaryDiffEqTsit5 = "1.1.0"
97-
PETSc = "0.2"
97+
PETSc = "0.3"
9898
Pkg = "1.10"
9999
PrecompileTools = "1.2"
100100
Preferences = "1.4"

lib/SimpleNonlinearSolve/test/core/23_test_problems_tests.jl

Lines changed: 0 additions & 106 deletions
This file was deleted.

test/23_test_problems_tests.jl

Lines changed: 70 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,25 @@ function test_on_library(
1010
x = dict["start"]
1111
res = similar(x)
1212
nlprob = NonlinearProblem(problem, copy(x))
13-
@testset "$idx: $(dict["title"])" begin
14-
for alg in alg_ops
15-
try
16-
sol = solve(nlprob, alg; maxiters = 10000)
17-
problem(res, sol.u, nothing)
18-
19-
skip = skip_tests !== nothing && idx in skip_tests[alg]
20-
if skip
21-
@test_skip norm(res, Inf) ϵ
22-
continue
23-
end
24-
broken = idx in broken_tests[alg] ? true : false
25-
@test norm(res, Inf)ϵ broken=broken
26-
catch err
27-
@error err
28-
broken = idx in broken_tests[alg] ? true : false
29-
if broken
30-
@test false broken=true
31-
else
32-
@test 1 == 2
33-
end
13+
@testset "$idx: $(dict["title"]) | alg #$(alg_id)" for (alg_id, alg) in enumerate(alg_ops)
14+
try
15+
sol = solve(nlprob, alg; maxiters = 10000)
16+
problem(res, sol.u, nothing)
17+
18+
skip = skip_tests !== nothing && idx in skip_tests[alg]
19+
if skip
20+
@test_skip norm(res, Inf) ϵ
21+
continue
22+
end
23+
broken = idx in broken_tests[alg] ? true : false
24+
@test norm(res, Inf)ϵ broken=broken
25+
catch err
26+
@error err
27+
broken = idx in broken_tests[alg] ? true : false
28+
if broken
29+
@test false broken=true
30+
else
31+
@test 1 == 2
3432
end
3533
end
3634
end
@@ -40,7 +38,7 @@ end
4038
export test_on_library, problems, dicts
4139
end
4240

43-
@testitem "PolyAlgorithms" setup=[RobustnessTesting] tags=[:core] begin
41+
@testitem "23 Test Problems: PolyAlgorithms" setup=[RobustnessTesting] tags=[:core] begin
4442
alg_ops = (RobustMultiNewton(), FastShortcutNonlinearPolyalg())
4543

4644
broken_tests = Dict(alg => Int[] for alg in alg_ops)
@@ -50,23 +48,41 @@ end
5048
test_on_library(problems, dicts, alg_ops, broken_tests)
5149
end
5250

53-
@testitem "NewtonRaphson" setup=[RobustnessTesting] tags=[:core] begin
54-
alg_ops = (NewtonRaphson(),)
51+
@testitem "23 Test Problems: NewtonRaphson" setup=[RobustnessTesting] tags=[:core] begin
52+
alg_ops = (
53+
NewtonRaphson(),
54+
SimpleNewtonRaphson()
55+
)
5556

5657
broken_tests = Dict(alg => Int[] for alg in alg_ops)
5758
broken_tests[alg_ops[1]] = [1]
5859

5960
test_on_library(problems, dicts, alg_ops, broken_tests)
6061
end
6162

62-
@testitem "TrustRegion" setup=[RobustnessTesting] tags=[:core] begin
63+
@testitem "23 Test Problems: Halley" setup=[RobustnessTesting] tags=[:core] begin
64+
alg_ops = (SimpleHalley(; autodiff = AutoForwardDiff()),)
65+
66+
broken_tests = Dict(alg => Int[] for alg in alg_ops)
67+
if Sys.isapple()
68+
broken_tests[alg_ops[1]] = [1, 5, 11, 15, 16, 18]
69+
else
70+
broken_tests[alg_ops[1]] = [1, 5, 15, 16, 18]
71+
end
72+
73+
test_on_library(problems, dicts, alg_ops, broken_tests)
74+
end
75+
76+
@testitem "23 Test Problems: TrustRegion" setup=[RobustnessTesting] tags=[:core] begin
6377
alg_ops = (
6478
TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Simple),
6579
TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Fan),
6680
TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Hei),
6781
TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Yuan),
6882
TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Bastin),
69-
TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.NLsolve)
83+
TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.NLsolve),
84+
SimpleTrustRegion(),
85+
SimpleTrustRegion(; nlsolve_update_rule = Val(true))
7086
)
7187

7288
broken_tests = Dict(alg => Int[] for alg in alg_ops)
@@ -76,11 +92,13 @@ end
7692
broken_tests[alg_ops[4]] = [8, 11, 21]
7793
broken_tests[alg_ops[5]] = [21]
7894
broken_tests[alg_ops[6]] = [11, 21]
95+
broken_tests[alg_ops[7]] = [3, 15, 16, 21]
96+
broken_tests[alg_ops[8]] = [15, 16]
7997

8098
test_on_library(problems, dicts, alg_ops, broken_tests)
8199
end
82100

83-
@testitem "LevenbergMarquardt" setup=[RobustnessTesting] tags=[:core] begin
101+
@testitem "23 Test Problems: LevenbergMarquardt" setup=[RobustnessTesting] tags=[:core] begin
84102
using LinearSolve
85103

86104
alg_ops = (
@@ -97,50 +115,63 @@ end
97115
test_on_library(problems, dicts, alg_ops, broken_tests)
98116
end
99117

100-
@testitem "DFSane" setup=[RobustnessTesting] tags=[:core] begin
101-
alg_ops = (DFSane(),)
118+
@testitem "23 Test Problems: DFSane" setup=[RobustnessTesting] tags=[:core] begin
119+
alg_ops = (
120+
DFSane(),
121+
SimpleDFSane()
122+
)
102123

103124
broken_tests = Dict(alg => Int[] for alg in alg_ops)
104125
broken_tests[alg_ops[1]] = [1, 2, 3, 5, 21]
126+
if Sys.isapple()
127+
broken_tests[alg_ops[2]] = [1, 2, 3, 5, 6, 21]
128+
else
129+
broken_tests[alg_ops[2]] = [1, 2, 3, 5, 6, 11, 21]
130+
end
105131

106132
test_on_library(problems, dicts, alg_ops, broken_tests)
107133
end
108134

109-
@testitem "Broyden" setup=[RobustnessTesting] tags=[:core] retries=3 begin
135+
@testitem "23 Test Problems: Broyden" setup=[RobustnessTesting] tags=[:core] retries=3 begin
110136
alg_ops = (
111137
Broyden(),
112138
Broyden(; init_jacobian = Val(:true_jacobian)),
113139
Broyden(; update_rule = Val(:bad_broyden)),
114-
Broyden(; init_jacobian = Val(:true_jacobian), update_rule = Val(:bad_broyden))
140+
Broyden(; init_jacobian = Val(:true_jacobian), update_rule = Val(:bad_broyden)),
141+
SimpleBroyden()
115142
)
116143

117144
broken_tests = Dict(alg => Int[] for alg in alg_ops)
145+
broken_tests[alg_ops[2]] = [1, 5, 8, 11, 18]
146+
broken_tests[alg_ops[4]] = [5, 6, 8, 11]
118147
if Sys.isapple()
119148
broken_tests[alg_ops[1]] = [1, 5, 11]
120-
broken_tests[alg_ops[2]] = [1, 5, 8, 11, 18]
121149
broken_tests[alg_ops[3]] = [1, 5, 6, 9, 11]
122-
broken_tests[alg_ops[4]] = [5, 6, 8, 11, 16]
123150
else
124151
broken_tests[alg_ops[1]] = [1, 5, 11, 15]
125-
broken_tests[alg_ops[2]] = [1, 5, 8, 11, 18]
126-
broken_tests[alg_ops[3]] = [1, 5, 9, 11]
127-
broken_tests[alg_ops[4]] = [5, 6, 8, 11]
152+
broken_tests[alg_ops[3]] = [1, 5, 9, 11, 16]
128153
end
154+
broken_tests[alg_ops[5]] = [1, 5, 11]
129155

130156
test_on_library(problems, dicts, alg_ops, broken_tests, Sys.isapple() ? 1e-3 : 1e-4)
131157
end
132158

133-
@testitem "Klement" setup=[RobustnessTesting] tags=[:core] begin
134-
alg_ops = (Klement(), Klement(; init_jacobian = Val(:true_jacobian_diagonal)))
159+
@testitem "23 Test Problems: Klement" setup=[RobustnessTesting] tags=[:core] begin
160+
alg_ops = (
161+
Klement(),
162+
Klement(; init_jacobian = Val(:true_jacobian_diagonal)),
163+
SimpleKlement()
164+
)
135165

136166
broken_tests = Dict(alg => Int[] for alg in alg_ops)
137167
broken_tests[alg_ops[1]] = [1, 2, 4, 5, 11, 18, 22]
138168
broken_tests[alg_ops[2]] = [2, 4, 5, 7, 18, 22]
169+
broken_tests[alg_ops[3]] = [1, 2, 4, 5, 11, 22]
139170

140171
test_on_library(problems, dicts, alg_ops, broken_tests)
141172
end
142173

143-
@testitem "PseudoTransient" setup=[RobustnessTesting] tags=[:core] begin
174+
@testitem "23 Test Problems: PseudoTransient" setup=[RobustnessTesting] tags=[:core] begin
144175
# PT relies on the root being a stable equilibrium for convergence, so it won't work on
145176
# most problems
146177
alg_ops = (PseudoTransient(),)

0 commit comments

Comments
 (0)