|
| 1 | +# @testsetup module RobustnessTesting |
| 2 | +# using NonlinearSolve, LinearAlgebra, LinearSolve, NonlinearProblemLibrary, Test |
| 3 | + |
| 4 | +# problems = NonlinearProblemLibrary.problems |
| 5 | +# dicts = NonlinearProblemLibrary.dicts |
| 6 | + |
| 7 | +# function test_on_library( |
| 8 | +# problems, dicts, alg_ops, broken_tests, ϵ = 1e-4; skip_tests = nothing) |
| 9 | +# for (idx, (problem, dict)) in enumerate(zip(problems, dicts)) |
| 10 | +# x = dict["start"] |
| 11 | +# res = similar(x) |
| 12 | +# 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 |
| 34 | +# end |
| 35 | +# end |
| 36 | +# end |
| 37 | +# end |
| 38 | +# end |
| 39 | + |
| 40 | +# export test_on_library, problems, dicts |
| 41 | +# end |
| 42 | + |
| 43 | +# @testitem "PolyAlgorithms" setup=[RobustnessTesting] tags=[:core] begin |
| 44 | +# alg_ops = (RobustMultiNewton(), FastShortcutNonlinearPolyalg()) |
| 45 | + |
| 46 | +# broken_tests = Dict(alg => Int[] for alg in alg_ops) |
| 47 | +# broken_tests[alg_ops[1]] = [] |
| 48 | +# broken_tests[alg_ops[2]] = [] |
| 49 | + |
| 50 | +# test_on_library(problems, dicts, alg_ops, broken_tests) |
| 51 | +# end |
| 52 | + |
| 53 | +# @testitem "NewtonRaphson" setup=[RobustnessTesting] tags=[:core] begin |
| 54 | +# alg_ops = (NewtonRaphson(),) |
| 55 | + |
| 56 | +# broken_tests = Dict(alg => Int[] for alg in alg_ops) |
| 57 | +# broken_tests[alg_ops[1]] = [1] |
| 58 | + |
| 59 | +# test_on_library(problems, dicts, alg_ops, broken_tests) |
| 60 | +# end |
| 61 | + |
| 62 | +# @testitem "TrustRegion" setup=[RobustnessTesting] tags=[:core] begin |
| 63 | +# alg_ops = (TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Simple), |
| 64 | +# TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Fan), |
| 65 | +# TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Hei), |
| 66 | +# TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Yuan), |
| 67 | +# TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Bastin), |
| 68 | +# TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.NLsolve)) |
| 69 | + |
| 70 | +# broken_tests = Dict(alg => Int[] for alg in alg_ops) |
| 71 | +# broken_tests[alg_ops[1]] = [11, 21] |
| 72 | +# broken_tests[alg_ops[2]] = [11, 21] |
| 73 | +# broken_tests[alg_ops[3]] = [11, 21] |
| 74 | +# broken_tests[alg_ops[4]] = [8, 11, 21] |
| 75 | +# broken_tests[alg_ops[5]] = [21] |
| 76 | +# broken_tests[alg_ops[6]] = [11, 21] |
| 77 | + |
| 78 | +# test_on_library(problems, dicts, alg_ops, broken_tests) |
| 79 | +# end |
| 80 | + |
| 81 | +# @testitem "LevenbergMarquardt" setup=[RobustnessTesting] tags=[:core] begin |
| 82 | +# using LinearSolve |
| 83 | + |
| 84 | +# alg_ops = (LevenbergMarquardt(), LevenbergMarquardt(; α_geodesic = 0.1), |
| 85 | +# LevenbergMarquardt(; linsolve = CholeskyFactorization())) |
| 86 | + |
| 87 | +# broken_tests = Dict(alg => Int[] for alg in alg_ops) |
| 88 | +# broken_tests[alg_ops[1]] = [11, 21] |
| 89 | +# broken_tests[alg_ops[2]] = [11, 21] |
| 90 | +# broken_tests[alg_ops[3]] = [11, 21] |
| 91 | + |
| 92 | +# test_on_library(problems, dicts, alg_ops, broken_tests) |
| 93 | +# end |
| 94 | + |
| 95 | +# @testitem "DFSane" setup=[RobustnessTesting] tags=[:core] begin |
| 96 | +# alg_ops = (DFSane(),) |
| 97 | + |
| 98 | +# broken_tests = Dict(alg => Int[] for alg in alg_ops) |
| 99 | +# broken_tests[alg_ops[1]] = [1, 2, 3, 5, 21] |
| 100 | + |
| 101 | +# test_on_library(problems, dicts, alg_ops, broken_tests) |
| 102 | +# end |
| 103 | + |
| 104 | +# @testitem "Broyden" setup=[RobustnessTesting] tags=[:core] begin |
| 105 | +# alg_ops = (Broyden(), Broyden(; init_jacobian = Val(:true_jacobian)), |
| 106 | +# Broyden(; update_rule = Val(:bad_broyden)), |
| 107 | +# Broyden(; init_jacobian = Val(:true_jacobian), update_rule = Val(:bad_broyden))) |
| 108 | + |
| 109 | +# broken_tests = Dict(alg => Int[] for alg in alg_ops) |
| 110 | +# if Sys.isapple() |
| 111 | +# broken_tests[alg_ops[1]] = [1, 5, 11] |
| 112 | +# broken_tests[alg_ops[2]] = [1, 5, 8, 11, 18] |
| 113 | +# broken_tests[alg_ops[3]] = [1, 5, 6, 9, 11] |
| 114 | +# broken_tests[alg_ops[4]] = [5, 6, 8, 11] |
| 115 | +# else |
| 116 | +# broken_tests[alg_ops[1]] = [1, 5, 11, 15] |
| 117 | +# broken_tests[alg_ops[2]] = [1, 5, 8, 11, 18] |
| 118 | +# broken_tests[alg_ops[3]] = [1, 5, 9, 11] |
| 119 | +# broken_tests[alg_ops[4]] = [5, 6, 8, 11] |
| 120 | +# end |
| 121 | + |
| 122 | +# test_on_library(problems, dicts, alg_ops, broken_tests, Sys.isapple() ? 1e-3 : 1e-4) |
| 123 | +# end |
| 124 | + |
| 125 | +# @testitem "Klement" setup=[RobustnessTesting] tags=[:core] begin |
| 126 | +# alg_ops = (Klement(), Klement(; init_jacobian = Val(:true_jacobian_diagonal))) |
| 127 | + |
| 128 | +# broken_tests = Dict(alg => Int[] for alg in alg_ops) |
| 129 | +# broken_tests[alg_ops[1]] = [1, 2, 4, 5, 11, 18, 22] |
| 130 | +# broken_tests[alg_ops[2]] = [2, 4, 5, 7, 18, 22] |
| 131 | + |
| 132 | +# test_on_library(problems, dicts, alg_ops, broken_tests) |
| 133 | +# end |
| 134 | + |
| 135 | +# @testitem "PseudoTransient" setup=[RobustnessTesting] tags=[:core] begin |
| 136 | +# # PT relies on the root being a stable equilibrium for convergence, so it won't work on |
| 137 | +# # most problems |
| 138 | +# alg_ops = (PseudoTransient(),) |
| 139 | + |
| 140 | +# broken_tests = Dict(alg => Int[] for alg in alg_ops) |
| 141 | +# broken_tests[alg_ops[1]] = [1, 2, 3, 11, 15, 16] |
| 142 | + |
| 143 | +# test_on_library(problems, dicts, alg_ops, broken_tests) |
| 144 | +# end |
0 commit comments