diff --git a/Project.toml b/Project.toml index a37763388..819a5f2c1 100644 --- a/Project.toml +++ b/Project.toml @@ -104,14 +104,14 @@ NonlinearSolveSpectralMethods = "1.1" OrdinaryDiffEqTsit5 = "1.1.0" PETSc = "0.3" Pkg = "1.10" -PolyesterForwardDiff = "0.1" +PolyesterForwardDiff = "0.1.3" PrecompileTools = "1.2" Preferences = "1.4" Random = "1.10" ReTestItems = "1.24" Reexport = "1.2" SIAMFANLEquations = "1.0.1" -SciMLBase = "2.58" +SciMLBase = "2.68.1" SimpleNonlinearSolve = "2.1" SparseArrays = "1.10" SparseConnectivityTracer = "0.6.5" @@ -121,7 +121,7 @@ StableRNGs = "1" StaticArrays = "1.9" StaticArraysCore = "1.4" Sundials = "4.23.1" -SymbolicIndexingInterface = "0.3.31" +SymbolicIndexingInterface = "0.3.36" Test = "1.10" Zygote = "0.6.69, 0.7" julia = "1.10" diff --git a/docs/Project.toml b/docs/Project.toml index b76f0feab..2264ea99d 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -54,7 +54,7 @@ OrdinaryDiffEqTsit5 = "1.1.0" PETSc = "0.3" Plots = "1" Random = "1.10" -SciMLBase = "2.58" +SciMLBase = "2.68.1" SciMLJacobianOperators = "0.1" SimpleNonlinearSolve = "2" SparseConnectivityTracer = "0.6.5" diff --git a/lib/BracketingNonlinearSolve/Project.toml b/lib/BracketingNonlinearSolve/Project.toml index 9c938207f..2dae2db0c 100644 --- a/lib/BracketingNonlinearSolve/Project.toml +++ b/lib/BracketingNonlinearSolve/Project.toml @@ -30,7 +30,7 @@ InteractiveUtils = "<0.0.1, 1" NonlinearSolveBase = "1.1" PrecompileTools = "1.2" Reexport = "1.2" -SciMLBase = "2.58" +SciMLBase = "2.68.1" Test = "1.10" TestItemRunner = "1" julia = "1.10" diff --git a/lib/NonlinearSolveBase/Project.toml b/lib/NonlinearSolveBase/Project.toml index 4071d55e6..0783805dc 100644 --- a/lib/NonlinearSolveBase/Project.toml +++ b/lib/NonlinearSolveBase/Project.toml @@ -1,7 +1,7 @@ name = "NonlinearSolveBase" uuid = "be0214bd-f91f-a760-ac4e-3421ce2b2da0" authors = ["Avik Pal and contributors"] -version = "1.5.2" +version = "1.5.3" [deps] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" @@ -70,11 +70,11 @@ Printf = "1.10" RecursiveArrayTools = "3" SciMLBase = "2.68.1" SciMLJacobianOperators = "0.1.1" -SciMLOperators = "0.3.10" +SciMLOperators = "0.3.13" SparseArrays = "1.10" SparseMatrixColorings = "0.4.5" StaticArraysCore = "1.4" -SymbolicIndexingInterface = "0.3.31" +SymbolicIndexingInterface = "0.3.36" Test = "1.10" TimerOutputs = "0.5.23" julia = "1.10" diff --git a/lib/NonlinearSolveBase/src/termination_conditions.jl b/lib/NonlinearSolveBase/src/termination_conditions.jl index e6ab4a579..3cfe57a2f 100644 --- a/lib/NonlinearSolveBase/src/termination_conditions.jl +++ b/lib/NonlinearSolveBase/src/termination_conditions.jl @@ -49,11 +49,11 @@ function CommonSolve.init( if mode isa AbstractSafeNonlinearTerminationMode if mode isa AbsNormSafeTerminationMode || mode isa AbsNormSafeBestTerminationMode - initial_objective = Linf_NORM(du) + initial_objective = Utils.apply_norm(mode.internalnorm, du) u0_norm = nothing else - initial_objective = Linf_NORM(du) / - (Utils.nonallocating_maximum(+, du, u) + eps(TT)) + initial_objective = Utils.apply_norm(mode.internalnorm, du) / + (Utils.apply_norm(mode.internalnorm, du, u) + eps(reltol)) u0_norm = mode.max_stalled_steps === nothing ? nothing : L2_NORM(u) end objectives_trace = Vector{TT}(undef, mode.patience_steps) @@ -107,10 +107,10 @@ function SciMLBase.reinit!( if mode isa AbstractSafeNonlinearTerminationMode if mode isa AbsNormSafeTerminationMode || mode isa AbsNormSafeBestTerminationMode - cache.initial_objective = Linf_NORM(du) + cache.initial_objective = Utils.apply_norm(mode.internalnorm, du) else - cache.initial_objective = Linf_NORM(du) / - (Utils.nonallocating_maximum(+, du, u) + eps(TT)) + cache.initial_objective = Utils.apply_norm(mode.internalnorm, du) / + (Utils.apply_norm(mode.internalnorm, du, u) + eps(TT)) cache.max_stalled_steps !== nothing && (cache.u0_norm = L2_NORM(u)) end cache.best_objective_value = cache.initial_objective diff --git a/lib/NonlinearSolveFirstOrder/Project.toml b/lib/NonlinearSolveFirstOrder/Project.toml index 4bbe4fe7f..bbbef93f8 100644 --- a/lib/NonlinearSolveFirstOrder/Project.toml +++ b/lib/NonlinearSolveFirstOrder/Project.toml @@ -53,7 +53,7 @@ PrecompileTools = "1.2" Random = "1.10" ReTestItems = "1.24" Reexport = "1" -SciMLBase = "2.58" +SciMLBase = "2.68.1" SciMLJacobianOperators = "0.1.0" Setfield = "1.1.1" SparseArrays = "1.10" diff --git a/lib/NonlinearSolveQuasiNewton/Project.toml b/lib/NonlinearSolveQuasiNewton/Project.toml index e8aa7f3b7..ccf6d3550 100644 --- a/lib/NonlinearSolveQuasiNewton/Project.toml +++ b/lib/NonlinearSolveQuasiNewton/Project.toml @@ -52,8 +52,8 @@ Pkg = "1.10" PrecompileTools = "1.2" ReTestItems = "1.24" Reexport = "1" -SciMLBase = "2.58" -SciMLOperators = "0.3.11" +SciMLBase = "2.68.1" +SciMLOperators = "0.3.13" StableRNGs = "1" StaticArrays = "1.9.8" StaticArraysCore = "1.4.3" diff --git a/lib/NonlinearSolveSpectralMethods/Project.toml b/lib/NonlinearSolveSpectralMethods/Project.toml index 0df037184..15dd869d9 100644 --- a/lib/NonlinearSolveSpectralMethods/Project.toml +++ b/lib/NonlinearSolveSpectralMethods/Project.toml @@ -41,7 +41,7 @@ Pkg = "1.10" PrecompileTools = "1.2" ReTestItems = "1.24" Reexport = "1" -SciMLBase = "2.58" +SciMLBase = "2.68.1" StableRNGs = "1" StaticArrays = "1.9.8" Test = "1.10" diff --git a/lib/SCCNonlinearSolve/Project.toml b/lib/SCCNonlinearSolve/Project.toml index dcc607ca5..2ec8bcfaa 100644 --- a/lib/SCCNonlinearSolve/Project.toml +++ b/lib/SCCNonlinearSolve/Project.toml @@ -24,10 +24,10 @@ Pkg = "1.10" PrecompileTools = "1.2" ReTestItems = "1.24" Reexport = "1" -SciMLBase = "2.60" +SciMLBase = "2.68.1" StableRNGs = "1" StaticArrays = "1.9.8" -SymbolicIndexingInterface = "0.3.30" +SymbolicIndexingInterface = "0.3.36" Test = "1.10" julia = "1.10" diff --git a/lib/SciMLJacobianOperators/Project.toml b/lib/SciMLJacobianOperators/Project.toml index 9999bfde1..0ffd2ce2d 100644 --- a/lib/SciMLJacobianOperators/Project.toml +++ b/lib/SciMLJacobianOperators/Project.toml @@ -29,8 +29,8 @@ ForwardDiff = "0.10.36, 1" InteractiveUtils = "<0.0.1, 1" LinearAlgebra = "1.10" ReverseDiff = "1.15" -SciMLBase = "2.58" -SciMLOperators = "0.3" +SciMLBase = "2.68.1" +SciMLOperators = "0.3.13" Test = "1.10" TestItemRunner = "1" Tracker = "0.2.35" diff --git a/lib/SimpleNonlinearSolve/Project.toml b/lib/SimpleNonlinearSolve/Project.toml index bedcd42c3..bb727d58b 100644 --- a/lib/SimpleNonlinearSolve/Project.toml +++ b/lib/SimpleNonlinearSolve/Project.toml @@ -61,12 +61,12 @@ MaybeInplace = "0.1.4" NonlinearProblemLibrary = "0.1.2" NonlinearSolveBase = "1.4" Pkg = "1.10" -PolyesterForwardDiff = "0.1" +PolyesterForwardDiff = "0.1.3" PrecompileTools = "1.2" Random = "1.10" Reexport = "1.2" ReverseDiff = "1.15" -SciMLBase = "2.58" +SciMLBase = "2.68.1" Setfield = "1.1.1" StaticArrays = "1.9" StaticArraysCore = "1.4.3" diff --git a/test/issue_tests.jl b/test/issue_tests.jl new file mode 100644 index 000000000..bee44398e --- /dev/null +++ b/test/issue_tests.jl @@ -0,0 +1,20 @@ +@testitem "Correct Best Solution: #565" tags=[:core] begin + using NonlinearSolve, StableRNGs + + x = collect(0:0.1:10) + + line_fct(x, p) = p[1] .+ p[2] .* x + + y_line = line_fct(x, [1, 3]) + y_line_n = line_fct(x, [1, 3]) + randn(StableRNG(0), length(x)) + + res(β, (x, y)) = line_fct(x, β) .- y + + prob = NonlinearLeastSquaresProblem(res, [1, 3], p = (x, y_line_n)) + sol1 = solve(prob; maxiters = 1000) + + prob = NonlinearLeastSquaresProblem(res, [1, 5], p = (x, y_line_n)) + sol2 = solve(prob; maxiters = 1000) + + @test sol1.u ≈ sol2.u +end