From 3fbb0f86797b849018f9dc3c3c0197c33d69febb Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Thu, 14 Nov 2024 09:21:17 -0100 Subject: [PATCH 01/26] Create SCCNonlinearSolve --- lib/SCCNonlinearSolve/LICENSE | 21 +++++ lib/SCCNonlinearSolve/Project.toml | 48 +++++++++++ .../src/SCCNonlinearSolve.jl | 39 +++++++++ lib/SCCNonlinearSolve/test/core_tests.jl | 80 +++++++++++++++++++ lib/SCCNonlinearSolve/test/qa_tests.jl | 22 +++++ lib/SCCNonlinearSolve/test/runtests.jl | 25 ++++++ 6 files changed, 235 insertions(+) create mode 100644 lib/SCCNonlinearSolve/LICENSE create mode 100644 lib/SCCNonlinearSolve/Project.toml create mode 100644 lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl create mode 100644 lib/SCCNonlinearSolve/test/core_tests.jl create mode 100644 lib/SCCNonlinearSolve/test/qa_tests.jl create mode 100644 lib/SCCNonlinearSolve/test/runtests.jl diff --git a/lib/SCCNonlinearSolve/LICENSE b/lib/SCCNonlinearSolve/LICENSE new file mode 100644 index 000000000..abb594d1e --- /dev/null +++ b/lib/SCCNonlinearSolve/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 SciML + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/lib/SCCNonlinearSolve/Project.toml b/lib/SCCNonlinearSolve/Project.toml new file mode 100644 index 000000000..2ade8a788 --- /dev/null +++ b/lib/SCCNonlinearSolve/Project.toml @@ -0,0 +1,48 @@ +name = "SCCNonlinearSolve" +uuid = "9dfe8606-65a1-4bb3-9748-cb89d1561431" +authors = ["Avik Pal and contributors"] +version = "1.0.0" + +[deps] +CommonSolve = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2" +MaybeInplace = "bb5d69b7-63fc-4a16-80bd-7e42200c7bdb" +NonlinearSolveBase = "be0214bd-f91f-a760-ac4e-3421ce2b2da0" +PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" +Reexport = "189a3867-3050-52da-a836-e630ba90ab69" +SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462" + +[compat] +Aqua = "0.8" +BenchmarkTools = "1.5.0" +CommonSolve = "0.2.4" +ExplicitImports = "1.5" +Hwloc = "3" +InteractiveUtils = "<0.0.1, 1" +MaybeInplace = "0.1.4" +NonlinearProblemLibrary = "0.1.2" +NonlinearSolveBase = "1.1" +Pkg = "1.10" +PrecompileTools = "1.2" +ReTestItems = "1.24" +Reexport = "1" +SciMLBase = "2.58" +StableRNGs = "1" +StaticArrays = "1.9.8" +Test = "1.10" +julia = "1.10" + +[extras] +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" +BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" +ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" +Hwloc = "0e44f5e4-bd66-52a0-8798-143a42290a1d" +InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" +NonlinearProblemLibrary = "b7050fa9-e91f-4b37-bcee-a89a063da141" +Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" +ReTestItems = "817f1d60-ba6b-4fd5-9520-3cf149f6a823" +StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" +StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[targets] +test = ["Aqua", "BenchmarkTools", "ExplicitImports", "Hwloc", "InteractiveUtils", "NonlinearProblemLibrary", "Pkg", "ReTestItems", "StableRNGs", "StaticArrays", "Test"] diff --git a/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl b/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl new file mode 100644 index 000000000..22e7f69f1 --- /dev/null +++ b/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl @@ -0,0 +1,39 @@ +module SCCNonlinearSolve + +import SciMLBase + +function SciMLBase.solve(prob::SciMLBase.SCCNonlinearProblem, alg; kwargs...) + numscc = length(prob.probs) + sols = [SciMLBase.build_solution(prob, nothing, prob.u0, convert(eltype(prob.u0),NaN)*prob.u0) for prob in prob.probs] + u = reduce(vcat,[prob.u0 for prob in prob.probs]) + resid = copy(u) + + earlyexit = false + lasti = 1 + for i in 1:numscc + prob.explictfuns![i](prob.probs[i].p[1],sols) + sol = SciMLBase.solve(prob.probs[i], alg; kwargs...) + _sol = SciMLBase.build_solution(prob.probs[i], nothing, sol.u, sol.resid, retcode = sol.retcode) + sols[i] = _sol + + if !SciMLBase.successful_retcode(_sol) + earlyexit = true + lasti = i + break + end + end + + # TODO: fix allocations with a lazy concatenation + u .= reduce(vcat,sols) + resid .= reduce(vcat,getproperty.(sols,:resid)) + + if earlyexit + retcode = sols[lasti].retcode + else + retcode = SciMLBase.ReturnCode.Success + end + + SciMLBase.build_solution(prob, alg, u, resid; retcode, original = sols) +end + +end \ No newline at end of file diff --git a/lib/SCCNonlinearSolve/test/core_tests.jl b/lib/SCCNonlinearSolve/test/core_tests.jl new file mode 100644 index 000000000..f24a2d91c --- /dev/null +++ b/lib/SCCNonlinearSolve/test/core_tests.jl @@ -0,0 +1,80 @@ +@testsetup module CoreRootfindTesting + +include("../../../common/common_rootfind_testing.jl") + +end + +@testitem "Manual SCC" setup=[CoreRootfindTesting] tags=[:core] begin + function f(du,u,p) + du[1] = cos(u[2]) - u[1] + du[2] = sin(u[1] + u[2]) + u[2] + du[3] = 2u[4] + u[3] + 1.0 + du[4] = u[5]^2 + u[4] + du[5] = u[3]^2 + u[5] + du[6] = u[1] + u[2] + u[3] + u[4] + u[5] + 2.0u[6] + 2.5u[7] + 1.5u[8] + du[7] = u[1] + u[2] + u[3] + 2.0u[4] + u[5] + 4.0u[6] - 1.5u[7] + 1.5u[8] + du[8] = u[1] + 2.0u[2] + 3.0u[3] + 5.0u[4] + 6.0u[5] + u[6] - u[7] - u[8] + end + prob = NonlinearProblem(f, zeros(8)) + sol = solve(prob) + + u0 = zeros(2) + cache = zeros(3) + + function f1(du,u,(cache,p)) + du[1] = cos(u[2]) - u[1] + du[2] = sin(u[1] + u[2]) + u[2] + end + explicitfun1(cache,sols) = nothing + prob1 = NonlinearProblem(NonlinearFunction{true, SciMLBase.NoSpecialize}(f1), zeros(2),(cache,nothing)) + sol1 = solve(prob1, NewtonRaphson()) + + function f2(du,u,(cache,p)) + du[1] = 2u[2] + u[1] + 1.0 + du[2] = u[3]^2 + u[2] + du[3] = u[1]^2 + u[3] + end + explicitfun2(cache,sols) = nothing + prob2 = NonlinearProblem(NonlinearFunction{true, SciMLBase.NoSpecialize}(f2), zeros(3),(cache,nothing)) + sol2 = solve(prob2, NewtonRaphson()) + + function f3(du,u,(cache,p)) + du[1] = cache[1] + 2.0u[1] + 2.5u[2] + 1.5u[3] + du[2] = cache[2] + 4.0u[1] - 1.5u[2] + 1.5u[3] + du[3] = cache[3] + + u[1] - u[2] - u[3] + end + prob3 = NonlinearProblem(NonlinearFunction{true, SciMLBase.NoSpecialize}(f3), zeros(3),(cache,nothing)) + function explicitfun3(cache,sols) + cache[1] = sols[1][1] + sols[1][2] + sols[2][1] + sols[2][2] + sols[2][3] + cache[2] = sols[1][1] + sols[1][2] + sols[2][1] + 2.0sols[2][2] + sols[2][3] + cache[3] = sols[1][1] + 2.0sols[1][2] + 3.0sols[2][1] + 5.0sols[2][2] + 6.0sols[2][3] + end + explicitfun3(cache,[sol1,sol2]) + sol3 = solve(prob3, NewtonRaphson()) + manualscc = [sol1; sol2; sol3] + + function SciMLBase.solve(prob::SciMLBase.SCCNonlinearProblem, alg; kwargs...) + numscc = length(prob.probs) + sols = [SciMLBase.build_solution(prob, nothing, prob.u0, convert(eltype(u0),NaN)*prob.u0) for prob in prob.probs] + u = reduce(vcat,[prob.u0 for prob in prob.probs]) + resid = copy(u) + + for i in 1:numscc + prob.explictfuns![i](prob.probs[i].p[1],sols) + sol = solve(prob.probs[i], alg) + _sol = SciMLBase.build_solution(prob.probs[i], nothing, sol.u, sol.resid, retcode = sol.retcode) + sols[i] = _sol + end + + # TODO: fix allocations with a lazy concatenation + u .= reduce(vcat,sols) + resid .= reduce(vcat,getproperty.(sols,:resid)) + + SciMLBase.build_solution(prob, alg, u, resid, original = sols) + end + + sccprob = SciMLBase.SCCNonlinearProblem([prob1,prob2,prob3], SciMLBase.Void{Any}.([explicitfun1,explicitfun2,explicitfun3])) + scc_sol = solve(sccprob, NewtonRaphson()) + sol ≈ manualscc ≈ scc_sol + +end \ No newline at end of file diff --git a/lib/SCCNonlinearSolve/test/qa_tests.jl b/lib/SCCNonlinearSolve/test/qa_tests.jl new file mode 100644 index 000000000..219fea638 --- /dev/null +++ b/lib/SCCNonlinearSolve/test/qa_tests.jl @@ -0,0 +1,22 @@ +@testitem "Aqua" tags=[:core] begin + using Aqua, SCCNonlinearSolve + + Aqua.test_all( + SCCNonlinearSolve; + piracies = false, ambiguities = false, stale_deps = false, deps_compat = false + ) + Aqua.test_stale_deps(SCCNonlinearSolve; ignore = [:SciMLJacobianOperators]) + Aqua.test_deps_compat(SCCNonlinearSolve; ignore = [:SciMLJacobianOperators]) + Aqua.test_piracies(SCCNonlinearSolve) + Aqua.test_ambiguities(SCCNonlinearSolve; recursive = false) +end + +@testitem "Explicit Imports" tags=[:core] begin + using ExplicitImports, SCCNonlinearSolve + + @test check_no_implicit_imports( + SCCNonlinearSolve; skip = (Base, Core, SciMLBase) + ) === nothing + @test check_no_stale_explicit_imports(SCCNonlinearSolve) === nothing + @test check_all_qualified_accesses_via_owners(SCCNonlinearSolve) === nothing +end diff --git a/lib/SCCNonlinearSolve/test/runtests.jl b/lib/SCCNonlinearSolve/test/runtests.jl new file mode 100644 index 000000000..451760225 --- /dev/null +++ b/lib/SCCNonlinearSolve/test/runtests.jl @@ -0,0 +1,25 @@ +using ReTestItems, SCCNonlinearSolve, Hwloc, InteractiveUtils, Pkg + +@info sprint(InteractiveUtils.versioninfo) + +const GROUP = lowercase(get(ENV, "GROUP", "All")) + +const RETESTITEMS_NWORKERS = parse( + Int, get(ENV, "RETESTITEMS_NWORKERS", + string(min(ifelse(Sys.iswindows(), 0, Hwloc.num_physical_cores()), 4)) + ) +) +const RETESTITEMS_NWORKER_THREADS = parse(Int, + get( + ENV, "RETESTITEMS_NWORKER_THREADS", + string(max(Hwloc.num_virtual_cores() ÷ max(RETESTITEMS_NWORKERS, 1), 1)) + ) +) + +@info "Running tests for group: $(GROUP) with $(RETESTITEMS_NWORKERS) workers" + +ReTestItems.runtests( + SCCNonlinearSolve; tags = (GROUP == "all" ? nothing : [Symbol(GROUP)]), + nworkers = RETESTITEMS_NWORKERS, nworker_threads = RETESTITEMS_NWORKER_THREADS, + testitem_timeout = 3600 +) From 777b85a8b5e0aeff6b4cdf4390711bbb44b754c3 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 08:45:34 -0100 Subject: [PATCH 02/26] Update lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl Co-authored-by: Aayush Sabharwal --- lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl b/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl index 22e7f69f1..9fd7ce2f6 100644 --- a/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl +++ b/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl @@ -1,8 +1,9 @@ module SCCNonlinearSolve import SciMLBase +import CommonSolve -function SciMLBase.solve(prob::SciMLBase.SCCNonlinearProblem, alg; kwargs...) +function CommonSolve.solve(prob::SciMLBase.SCCNonlinearProblem, alg; kwargs...) numscc = length(prob.probs) sols = [SciMLBase.build_solution(prob, nothing, prob.u0, convert(eltype(prob.u0),NaN)*prob.u0) for prob in prob.probs] u = reduce(vcat,[prob.u0 for prob in prob.probs]) From a2a98748803587057e996f2c7fe40b70536575fa Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 08:46:15 -0100 Subject: [PATCH 03/26] Update lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl Co-authored-by: Aayush Sabharwal --- lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl b/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl index 9fd7ce2f6..248a516a0 100644 --- a/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl +++ b/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl @@ -9,17 +9,14 @@ function CommonSolve.solve(prob::SciMLBase.SCCNonlinearProblem, alg; kwargs...) u = reduce(vcat,[prob.u0 for prob in prob.probs]) resid = copy(u) - earlyexit = false lasti = 1 for i in 1:numscc prob.explictfuns![i](prob.probs[i].p[1],sols) sol = SciMLBase.solve(prob.probs[i], alg; kwargs...) _sol = SciMLBase.build_solution(prob.probs[i], nothing, sol.u, sol.resid, retcode = sol.retcode) sols[i] = _sol - + lasti = i if !SciMLBase.successful_retcode(_sol) - earlyexit = true - lasti = i break end end @@ -28,11 +25,7 @@ function CommonSolve.solve(prob::SciMLBase.SCCNonlinearProblem, alg; kwargs...) u .= reduce(vcat,sols) resid .= reduce(vcat,getproperty.(sols,:resid)) - if earlyexit retcode = sols[lasti].retcode - else - retcode = SciMLBase.ReturnCode.Success - end SciMLBase.build_solution(prob, alg, u, resid; retcode, original = sols) end From c1a0c508e49e8d44cec637639c5773bcb9ac7efb Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 08:46:35 -0100 Subject: [PATCH 04/26] Update lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl Co-authored-by: Aayush Sabharwal --- lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl b/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl index 248a516a0..82c0d6137 100644 --- a/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl +++ b/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl @@ -11,7 +11,7 @@ function CommonSolve.solve(prob::SciMLBase.SCCNonlinearProblem, alg; kwargs...) lasti = 1 for i in 1:numscc - prob.explictfuns![i](prob.probs[i].p[1],sols) + prob.explictfuns![i](parameter_values(prob.probs[i])[1],sols) sol = SciMLBase.solve(prob.probs[i], alg; kwargs...) _sol = SciMLBase.build_solution(prob.probs[i], nothing, sol.u, sol.resid, retcode = sol.retcode) sols[i] = _sol From 1fb625ef9997b12126e4a2bd5cd9b1ee79df6075 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 08:47:06 -0100 Subject: [PATCH 05/26] Update lib/SCCNonlinearSolve/test/core_tests.jl Co-authored-by: Aayush Sabharwal --- lib/SCCNonlinearSolve/test/core_tests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/SCCNonlinearSolve/test/core_tests.jl b/lib/SCCNonlinearSolve/test/core_tests.jl index f24a2d91c..7ae278baa 100644 --- a/lib/SCCNonlinearSolve/test/core_tests.jl +++ b/lib/SCCNonlinearSolve/test/core_tests.jl @@ -75,6 +75,6 @@ end sccprob = SciMLBase.SCCNonlinearProblem([prob1,prob2,prob3], SciMLBase.Void{Any}.([explicitfun1,explicitfun2,explicitfun3])) scc_sol = solve(sccprob, NewtonRaphson()) - sol ≈ manualscc ≈ scc_sol + @test sol ≈ manualscc ≈ scc_sol end \ No newline at end of file From b328dccca8da9baa385c0f4408148f42422df8c1 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 08:51:41 -0100 Subject: [PATCH 06/26] format scc --- .../src/SCCNonlinearSolve.jl | 39 +++++++------ lib/SCCNonlinearSolve/test/core_tests.jl | 55 +++++++++++-------- 2 files changed, 52 insertions(+), 42 deletions(-) diff --git a/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl b/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl index 82c0d6137..fd9edb48a 100644 --- a/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl +++ b/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl @@ -4,30 +4,33 @@ import SciMLBase import CommonSolve function CommonSolve.solve(prob::SciMLBase.SCCNonlinearProblem, alg; kwargs...) - numscc = length(prob.probs) - sols = [SciMLBase.build_solution(prob, nothing, prob.u0, convert(eltype(prob.u0),NaN)*prob.u0) for prob in prob.probs] - u = reduce(vcat,[prob.u0 for prob in prob.probs]) - resid = copy(u) + numscc = length(prob.probs) + sols = [SciMLBase.build_solution( + prob, nothing, prob.u0, convert(eltype(prob.u0), NaN) * prob.u0) + for prob in prob.probs] + u = reduce(vcat, [prob.u0 for prob in prob.probs]) + resid = copy(u) lasti = 1 - for i in 1:numscc - prob.explictfuns![i](parameter_values(prob.probs[i])[1],sols) - sol = SciMLBase.solve(prob.probs[i], alg; kwargs...) - _sol = SciMLBase.build_solution(prob.probs[i], nothing, sol.u, sol.resid, retcode = sol.retcode) - sols[i] = _sol - lasti = i + for i in 1:numscc + prob.explictfuns![i](parameter_values(prob.probs[i])[1], sols) + sol = SciMLBase.solve(prob.probs[i], alg; kwargs...) + _sol = SciMLBase.build_solution( + prob.probs[i], nothing, sol.u, sol.resid, retcode = sol.retcode) + sols[i] = _sol + lasti = i if !SciMLBase.successful_retcode(_sol) break end - end - - # TODO: fix allocations with a lazy concatenation - u .= reduce(vcat,sols) - resid .= reduce(vcat,getproperty.(sols,:resid)) + end - retcode = sols[lasti].retcode + # TODO: fix allocations with a lazy concatenation + u .= reduce(vcat, sols) + resid .= reduce(vcat, getproperty.(sols, :resid)) - SciMLBase.build_solution(prob, alg, u, resid; retcode, original = sols) + retcode = sols[lasti].retcode + + SciMLBase.build_solution(prob, alg, u, resid; retcode, original = sols) end -end \ No newline at end of file +end diff --git a/lib/SCCNonlinearSolve/test/core_tests.jl b/lib/SCCNonlinearSolve/test/core_tests.jl index 7ae278baa..07b04205e 100644 --- a/lib/SCCNonlinearSolve/test/core_tests.jl +++ b/lib/SCCNonlinearSolve/test/core_tests.jl @@ -5,13 +5,13 @@ include("../../../common/common_rootfind_testing.jl") end @testitem "Manual SCC" setup=[CoreRootfindTesting] tags=[:core] begin - function f(du,u,p) + function f(du, u, p) du[1] = cos(u[2]) - u[1] du[2] = sin(u[1] + u[2]) + u[2] du[3] = 2u[4] + u[3] + 1.0 du[4] = u[5]^2 + u[4] du[5] = u[3]^2 + u[5] - du[6] = u[1] + u[2] + u[3] + u[4] + u[5] + 2.0u[6] + 2.5u[7] + 1.5u[8] + du[6] = u[1] + u[2] + u[3] + u[4] + u[5] + 2.0u[6] + 2.5u[7] + 1.5u[8] du[7] = u[1] + u[2] + u[3] + 2.0u[4] + u[5] + 4.0u[6] - 1.5u[7] + 1.5u[8] du[8] = u[1] + 2.0u[2] + 3.0u[3] + 5.0u[4] + 6.0u[5] + u[6] - u[7] - u[8] end @@ -21,60 +21,67 @@ end u0 = zeros(2) cache = zeros(3) - function f1(du,u,(cache,p)) + function f1(du, u, (cache, p)) du[1] = cos(u[2]) - u[1] du[2] = sin(u[1] + u[2]) + u[2] end - explicitfun1(cache,sols) = nothing - prob1 = NonlinearProblem(NonlinearFunction{true, SciMLBase.NoSpecialize}(f1), zeros(2),(cache,nothing)) + explicitfun1(cache, sols) = nothing + prob1 = NonlinearProblem( + NonlinearFunction{true, SciMLBase.NoSpecialize}(f1), zeros(2), (cache, nothing)) sol1 = solve(prob1, NewtonRaphson()) - function f2(du,u,(cache,p)) + function f2(du, u, (cache, p)) du[1] = 2u[2] + u[1] + 1.0 du[2] = u[3]^2 + u[2] du[3] = u[1]^2 + u[3] end - explicitfun2(cache,sols) = nothing - prob2 = NonlinearProblem(NonlinearFunction{true, SciMLBase.NoSpecialize}(f2), zeros(3),(cache,nothing)) + explicitfun2(cache, sols) = nothing + prob2 = NonlinearProblem( + NonlinearFunction{true, SciMLBase.NoSpecialize}(f2), zeros(3), (cache, nothing)) sol2 = solve(prob2, NewtonRaphson()) - function f3(du,u,(cache,p)) + function f3(du, u, (cache, p)) du[1] = cache[1] + 2.0u[1] + 2.5u[2] + 1.5u[3] du[2] = cache[2] + 4.0u[1] - 1.5u[2] + 1.5u[3] - du[3] = cache[3] + + u[1] - u[2] - u[3] + du[3] = cache[3] + +u[1] - u[2] - u[3] end - prob3 = NonlinearProblem(NonlinearFunction{true, SciMLBase.NoSpecialize}(f3), zeros(3),(cache,nothing)) - function explicitfun3(cache,sols) + prob3 = NonlinearProblem( + NonlinearFunction{true, SciMLBase.NoSpecialize}(f3), zeros(3), (cache, nothing)) + function explicitfun3(cache, sols) cache[1] = sols[1][1] + sols[1][2] + sols[2][1] + sols[2][2] + sols[2][3] cache[2] = sols[1][1] + sols[1][2] + sols[2][1] + 2.0sols[2][2] + sols[2][3] - cache[3] = sols[1][1] + 2.0sols[1][2] + 3.0sols[2][1] + 5.0sols[2][2] + 6.0sols[2][3] + cache[3] = sols[1][1] + 2.0sols[1][2] + 3.0sols[2][1] + 5.0sols[2][2] + + 6.0sols[2][3] end - explicitfun3(cache,[sol1,sol2]) + explicitfun3(cache, [sol1, sol2]) sol3 = solve(prob3, NewtonRaphson()) manualscc = [sol1; sol2; sol3] function SciMLBase.solve(prob::SciMLBase.SCCNonlinearProblem, alg; kwargs...) numscc = length(prob.probs) - sols = [SciMLBase.build_solution(prob, nothing, prob.u0, convert(eltype(u0),NaN)*prob.u0) for prob in prob.probs] - u = reduce(vcat,[prob.u0 for prob in prob.probs]) + sols = [SciMLBase.build_solution( + prob, nothing, prob.u0, convert(eltype(u0), NaN) * prob.u0) + for prob in prob.probs] + u = reduce(vcat, [prob.u0 for prob in prob.probs]) resid = copy(u) for i in 1:numscc - prob.explictfuns![i](prob.probs[i].p[1],sols) + prob.explictfuns![i](prob.probs[i].p[1], sols) sol = solve(prob.probs[i], alg) - _sol = SciMLBase.build_solution(prob.probs[i], nothing, sol.u, sol.resid, retcode = sol.retcode) + _sol = SciMLBase.build_solution( + prob.probs[i], nothing, sol.u, sol.resid, retcode = sol.retcode) sols[i] = _sol end - + # TODO: fix allocations with a lazy concatenation - u .= reduce(vcat,sols) - resid .= reduce(vcat,getproperty.(sols,:resid)) + u .= reduce(vcat, sols) + resid .= reduce(vcat, getproperty.(sols, :resid)) SciMLBase.build_solution(prob, alg, u, resid, original = sols) end - sccprob = SciMLBase.SCCNonlinearProblem([prob1,prob2,prob3], SciMLBase.Void{Any}.([explicitfun1,explicitfun2,explicitfun3])) + sccprob = SciMLBase.SCCNonlinearProblem([prob1, prob2, prob3], + SciMLBase.Void{Any}.([explicitfun1, explicitfun2, explicitfun3])) scc_sol = solve(sccprob, NewtonRaphson()) @test sol ≈ manualscc ≈ scc_sol - -end \ No newline at end of file +end From 5789fe8088ee90cd857f54ca58df76ec14e8bce1 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 08:52:58 -0100 Subject: [PATCH 07/26] just use params --- .../src/SCCNonlinearSolve.jl | 2 +- lib/SCCNonlinearSolve/test/core_tests.jl | 41 ++++--------------- 2 files changed, 8 insertions(+), 35 deletions(-) diff --git a/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl b/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl index fd9edb48a..72669e9f1 100644 --- a/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl +++ b/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl @@ -13,7 +13,7 @@ function CommonSolve.solve(prob::SciMLBase.SCCNonlinearProblem, alg; kwargs...) lasti = 1 for i in 1:numscc - prob.explictfuns![i](parameter_values(prob.probs[i])[1], sols) + prob.explictfuns![i](parameter_values(prob.probs[i]), sols) sol = SciMLBase.solve(prob.probs[i], alg; kwargs...) _sol = SciMLBase.build_solution( prob.probs[i], nothing, sol.u, sol.resid, retcode = sol.retcode) diff --git a/lib/SCCNonlinearSolve/test/core_tests.jl b/lib/SCCNonlinearSolve/test/core_tests.jl index 07b04205e..07dae29b8 100644 --- a/lib/SCCNonlinearSolve/test/core_tests.jl +++ b/lib/SCCNonlinearSolve/test/core_tests.jl @@ -25,9 +25,8 @@ end du[1] = cos(u[2]) - u[1] du[2] = sin(u[1] + u[2]) + u[2] end - explicitfun1(cache, sols) = nothing - prob1 = NonlinearProblem( - NonlinearFunction{true, SciMLBase.NoSpecialize}(f1), zeros(2), (cache, nothing)) + explicitfun1(cache,sols) = nothing + prob1 = NonlinearProblem(NonlinearFunction{true, SciMLBase.NoSpecialize}(f1), zeros(2), cache) sol1 = solve(prob1, NewtonRaphson()) function f2(du, u, (cache, p)) @@ -35,9 +34,8 @@ end du[2] = u[3]^2 + u[2] du[3] = u[1]^2 + u[3] end - explicitfun2(cache, sols) = nothing - prob2 = NonlinearProblem( - NonlinearFunction{true, SciMLBase.NoSpecialize}(f2), zeros(3), (cache, nothing)) + explicitfun2(cache,sols) = nothing + prob2 = NonlinearProblem(NonlinearFunction{true, SciMLBase.NoSpecialize}(f2), zeros(3), cache) sol2 = solve(prob2, NewtonRaphson()) function f3(du, u, (cache, p)) @@ -45,9 +43,8 @@ end du[2] = cache[2] + 4.0u[1] - 1.5u[2] + 1.5u[3] du[3] = cache[3] + +u[1] - u[2] - u[3] end - prob3 = NonlinearProblem( - NonlinearFunction{true, SciMLBase.NoSpecialize}(f3), zeros(3), (cache, nothing)) - function explicitfun3(cache, sols) + prob3 = NonlinearProblem(NonlinearFunction{true, SciMLBase.NoSpecialize}(f3), zeros(3), cache) + function explicitfun3(cache,sols) cache[1] = sols[1][1] + sols[1][2] + sols[2][1] + sols[2][2] + sols[2][3] cache[2] = sols[1][1] + sols[1][2] + sols[2][1] + 2.0sols[2][2] + sols[2][3] cache[3] = sols[1][1] + 2.0sols[1][2] + 3.0sols[2][1] + 5.0sols[2][2] + @@ -57,31 +54,7 @@ end sol3 = solve(prob3, NewtonRaphson()) manualscc = [sol1; sol2; sol3] - function SciMLBase.solve(prob::SciMLBase.SCCNonlinearProblem, alg; kwargs...) - numscc = length(prob.probs) - sols = [SciMLBase.build_solution( - prob, nothing, prob.u0, convert(eltype(u0), NaN) * prob.u0) - for prob in prob.probs] - u = reduce(vcat, [prob.u0 for prob in prob.probs]) - resid = copy(u) - - for i in 1:numscc - prob.explictfuns![i](prob.probs[i].p[1], sols) - sol = solve(prob.probs[i], alg) - _sol = SciMLBase.build_solution( - prob.probs[i], nothing, sol.u, sol.resid, retcode = sol.retcode) - sols[i] = _sol - end - - # TODO: fix allocations with a lazy concatenation - u .= reduce(vcat, sols) - resid .= reduce(vcat, getproperty.(sols, :resid)) - - SciMLBase.build_solution(prob, alg, u, resid, original = sols) - end - - sccprob = SciMLBase.SCCNonlinearProblem([prob1, prob2, prob3], - SciMLBase.Void{Any}.([explicitfun1, explicitfun2, explicitfun3])) + sccprob = SciMLBase.SCCNonlinearProblem([prob1,prob2,prob3], SciMLBase.Void{Any}.([explicitfun1,explicitfun2,explicitfun3])) scc_sol = solve(sccprob, NewtonRaphson()) @test sol ≈ manualscc ≈ scc_sol end From e26cd99aecb1437b7a2015ab15d2a866b3d68513 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 08:53:21 -0100 Subject: [PATCH 08/26] re format --- lib/SCCNonlinearSolve/test/core_tests.jl | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/SCCNonlinearSolve/test/core_tests.jl b/lib/SCCNonlinearSolve/test/core_tests.jl index 07dae29b8..0321a87a8 100644 --- a/lib/SCCNonlinearSolve/test/core_tests.jl +++ b/lib/SCCNonlinearSolve/test/core_tests.jl @@ -25,8 +25,9 @@ end du[1] = cos(u[2]) - u[1] du[2] = sin(u[1] + u[2]) + u[2] end - explicitfun1(cache,sols) = nothing - prob1 = NonlinearProblem(NonlinearFunction{true, SciMLBase.NoSpecialize}(f1), zeros(2), cache) + explicitfun1(cache, sols) = nothing + prob1 = NonlinearProblem( + NonlinearFunction{true, SciMLBase.NoSpecialize}(f1), zeros(2), cache) sol1 = solve(prob1, NewtonRaphson()) function f2(du, u, (cache, p)) @@ -34,8 +35,9 @@ end du[2] = u[3]^2 + u[2] du[3] = u[1]^2 + u[3] end - explicitfun2(cache,sols) = nothing - prob2 = NonlinearProblem(NonlinearFunction{true, SciMLBase.NoSpecialize}(f2), zeros(3), cache) + explicitfun2(cache, sols) = nothing + prob2 = NonlinearProblem( + NonlinearFunction{true, SciMLBase.NoSpecialize}(f2), zeros(3), cache) sol2 = solve(prob2, NewtonRaphson()) function f3(du, u, (cache, p)) @@ -43,8 +45,9 @@ end du[2] = cache[2] + 4.0u[1] - 1.5u[2] + 1.5u[3] du[3] = cache[3] + +u[1] - u[2] - u[3] end - prob3 = NonlinearProblem(NonlinearFunction{true, SciMLBase.NoSpecialize}(f3), zeros(3), cache) - function explicitfun3(cache,sols) + prob3 = NonlinearProblem( + NonlinearFunction{true, SciMLBase.NoSpecialize}(f3), zeros(3), cache) + function explicitfun3(cache, sols) cache[1] = sols[1][1] + sols[1][2] + sols[2][1] + sols[2][2] + sols[2][3] cache[2] = sols[1][1] + sols[1][2] + sols[2][1] + 2.0sols[2][2] + sols[2][3] cache[3] = sols[1][1] + 2.0sols[1][2] + 3.0sols[2][1] + 5.0sols[2][2] + @@ -54,7 +57,8 @@ end sol3 = solve(prob3, NewtonRaphson()) manualscc = [sol1; sol2; sol3] - sccprob = SciMLBase.SCCNonlinearProblem([prob1,prob2,prob3], SciMLBase.Void{Any}.([explicitfun1,explicitfun2,explicitfun3])) + sccprob = SciMLBase.SCCNonlinearProblem([prob1, prob2, prob3], + SciMLBase.Void{Any}.([explicitfun1, explicitfun2, explicitfun3])) scc_sol = solve(sccprob, NewtonRaphson()) @test sol ≈ manualscc ≈ scc_sol end From 0a4380289814321ea5394fbaa65295e10c846a28 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 09:24:14 -0100 Subject: [PATCH 09/26] SII --- lib/SCCNonlinearSolve/Project.toml | 3 ++- lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/SCCNonlinearSolve/Project.toml b/lib/SCCNonlinearSolve/Project.toml index 2ade8a788..1da92190b 100644 --- a/lib/SCCNonlinearSolve/Project.toml +++ b/lib/SCCNonlinearSolve/Project.toml @@ -10,6 +10,7 @@ NonlinearSolveBase = "be0214bd-f91f-a760-ac4e-3421ce2b2da0" PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462" +SymbolicIndexingInterface = "2efcf032-c050-4f8e-a9bb-153293bab1f5" [compat] Aqua = "0.8" @@ -25,7 +26,7 @@ Pkg = "1.10" PrecompileTools = "1.2" ReTestItems = "1.24" Reexport = "1" -SciMLBase = "2.58" +SciMLBase = "2.60" StableRNGs = "1" StaticArrays = "1.9.8" Test = "1.10" diff --git a/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl b/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl index 72669e9f1..c50e32ff4 100644 --- a/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl +++ b/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl @@ -2,6 +2,7 @@ module SCCNonlinearSolve import SciMLBase import CommonSolve +import SymbolicIndexingInterface function CommonSolve.solve(prob::SciMLBase.SCCNonlinearProblem, alg; kwargs...) numscc = length(prob.probs) @@ -13,7 +14,7 @@ function CommonSolve.solve(prob::SciMLBase.SCCNonlinearProblem, alg; kwargs...) lasti = 1 for i in 1:numscc - prob.explictfuns![i](parameter_values(prob.probs[i]), sols) + prob.explictfuns![i](SymbolicIndexingInterface.parameter_values(prob.probs[i]), sols) sol = SciMLBase.solve(prob.probs[i], alg; kwargs...) _sol = SciMLBase.build_solution( prob.probs[i], nothing, sol.u, sol.resid, retcode = sol.retcode) From de219e94006ecec4c725640115eb92ca3d49b6a5 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 09:37:25 -0100 Subject: [PATCH 10/26] fix CI --- .github/workflows/CI_SCCNonlinearSolve.yml | 109 +++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 .github/workflows/CI_SCCNonlinearSolve.yml diff --git a/.github/workflows/CI_SCCNonlinearSolve.yml b/.github/workflows/CI_SCCNonlinearSolve.yml new file mode 100644 index 000000000..a00e938e6 --- /dev/null +++ b/.github/workflows/CI_SCCNonlinearSolve.yml @@ -0,0 +1,109 @@ +name: CI (SCCNonlinearSolve) + +on: + pull_request: + branches: + - master + paths: + - "lib/SCCNonlinearSolve/**" + - ".github/workflows/CI_SCCNonlinearSolve.yml" + - "lib/NonlinearSolveBase/**" + - "lib/SciMLJacobianOperators/**" + push: + branches: + - master + +concurrency: + # Skip intermediate builds: always. + # Cancel intermediate builds: only if it is a pull request build. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + version: + - "1.10" + - "1" + os: + - ubuntu-latest + - macos-latest + - windows-latest + steps: + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v2 + with: + version: ${{ matrix.version }} + - uses: actions/cache@v4 + env: + cache-name: cache-artifacts + with: + path: ~/.julia/artifacts + key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} + restore-keys: | + ${{ runner.os }}-test-${{ env.cache-name }}- + ${{ runner.os }}-test- + ${{ runner.os }}- + - name: "Install Dependencies and Run Tests" + run: | + import Pkg + Pkg.Registry.update() + # Install packages present in subdirectories + dev_pks = Pkg.PackageSpec[] + for path in ("lib/SciMLJacobianOperators", "lib/NonlinearSolveBase") + push!(dev_pks, Pkg.PackageSpec(; path)) + end + Pkg.develop(dev_pks) + Pkg.instantiate() + Pkg.test(; coverage="user") + shell: julia --color=yes --code-coverage=user --depwarn=yes --project=lib/SCCNonlinearSolve {0} + - uses: julia-actions/julia-processcoverage@v1 + with: + directories: lib/SCCNonlinearSolve/src,lib/NonlinearSolveBase/src,lib/NonlinearSolveBase/ext,lib/SciMLJacobianOperators/src + - uses: codecov/codecov-action@v4 + with: + file: lcov.info + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true + fail_ci_if_error: false + + downgrade: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + version: + - "1.10" + steps: + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v2 + with: + version: ${{ matrix.version }} + - uses: julia-actions/julia-downgrade-compat@v1 + with: + skip: NonlinearSolveBase, SciMLJacobianOperators + - name: "Install Dependencies and Run Tests" + run: | + import Pkg + Pkg.Registry.update() + # Install packages present in subdirectories + dev_pks = Pkg.PackageSpec[] + for path in ("lib/SciMLJacobianOperators", "lib/NonlinearSolveBase") + push!(dev_pks, Pkg.PackageSpec(; path)) + end + Pkg.develop(dev_pks) + Pkg.instantiate() + Pkg.test(; coverage="user") + shell: julia --color=yes --code-coverage=user --depwarn=yes --project=lib/SCCNonlinearSolve {0} + - uses: julia-actions/julia-processcoverage@v1 + with: + directories: lib/SCCNonlinearSolve/src,lib/NonlinearSolveBase/src,lib/NonlinearSolveBase/ext,lib/SciMLJacobianOperators/src + - uses: codecov/codecov-action@v4 + with: + file: lcov.info + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true + fail_ci_if_error: false From c69a4a795aaec87e7f8dabe98f6e6d8eea01ce06 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 12:00:23 -0100 Subject: [PATCH 11/26] Update lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl b/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl index c50e32ff4..3c8cc8691 100644 --- a/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl +++ b/lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl @@ -14,7 +14,8 @@ function CommonSolve.solve(prob::SciMLBase.SCCNonlinearProblem, alg; kwargs...) lasti = 1 for i in 1:numscc - prob.explictfuns![i](SymbolicIndexingInterface.parameter_values(prob.probs[i]), sols) + prob.explictfuns![i]( + SymbolicIndexingInterface.parameter_values(prob.probs[i]), sols) sol = SciMLBase.solve(prob.probs[i], alg; kwargs...) _sol = SciMLBase.build_solution( prob.probs[i], nothing, sol.u, sol.resid, retcode = sol.retcode) From 76287406a7ddb163cf3a252034a47bee9f07cc8e Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 12:34:26 -0100 Subject: [PATCH 12/26] fix up test setup --- lib/SCCNonlinearSolve/test/core_tests.jl | 1 + lib/SCCNonlinearSolve/test/qa_tests.jl | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/SCCNonlinearSolve/test/core_tests.jl b/lib/SCCNonlinearSolve/test/core_tests.jl index 0321a87a8..c19b8907e 100644 --- a/lib/SCCNonlinearSolve/test/core_tests.jl +++ b/lib/SCCNonlinearSolve/test/core_tests.jl @@ -5,6 +5,7 @@ include("../../../common/common_rootfind_testing.jl") end @testitem "Manual SCC" setup=[CoreRootfindTesting] tags=[:core] begin + using NonlinearSolve function f(du, u, p) du[1] = cos(u[2]) - u[1] du[2] = sin(u[1] + u[2]) + u[2] diff --git a/lib/SCCNonlinearSolve/test/qa_tests.jl b/lib/SCCNonlinearSolve/test/qa_tests.jl index 219fea638..764e8cebd 100644 --- a/lib/SCCNonlinearSolve/test/qa_tests.jl +++ b/lib/SCCNonlinearSolve/test/qa_tests.jl @@ -12,7 +12,7 @@ end @testitem "Explicit Imports" tags=[:core] begin - using ExplicitImports, SCCNonlinearSolve + using ExplicitImports, SciMLBase, SCCNonlinearSolve @test check_no_implicit_imports( SCCNonlinearSolve; skip = (Base, Core, SciMLBase) From 20e833fb41fb4f7e22eae8d460e6d6399710fc1a Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 13:40:53 -0100 Subject: [PATCH 13/26] Update Project.toml --- lib/SCCNonlinearSolve/Project.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/SCCNonlinearSolve/Project.toml b/lib/SCCNonlinearSolve/Project.toml index 1da92190b..d51e831e3 100644 --- a/lib/SCCNonlinearSolve/Project.toml +++ b/lib/SCCNonlinearSolve/Project.toml @@ -38,6 +38,7 @@ BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" Hwloc = "0e44f5e4-bd66-52a0-8798-143a42290a1d" InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" +NonlinearSolveFirstOrder = "5959db7a-ea39-4486-b5fe-2dd0bf03d60d" NonlinearProblemLibrary = "b7050fa9-e91f-4b37-bcee-a89a063da141" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" ReTestItems = "817f1d60-ba6b-4fd5-9520-3cf149f6a823" @@ -46,4 +47,4 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Aqua", "BenchmarkTools", "ExplicitImports", "Hwloc", "InteractiveUtils", "NonlinearProblemLibrary", "Pkg", "ReTestItems", "StableRNGs", "StaticArrays", "Test"] +test = ["Aqua", "BenchmarkTools", "ExplicitImports", "Hwloc", "InteractiveUtils", "NonlinearSolveFirstOrder", "NonlinearProblemLibrary", "Pkg", "ReTestItems", "StableRNGs", "StaticArrays", "Test"] From 48bf3de607d8778d0c47790c5cd9dca51b090043 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 13:42:52 -0100 Subject: [PATCH 14/26] Update core_tests.jl --- lib/SCCNonlinearSolve/test/core_tests.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/SCCNonlinearSolve/test/core_tests.jl b/lib/SCCNonlinearSolve/test/core_tests.jl index c19b8907e..14ae81efa 100644 --- a/lib/SCCNonlinearSolve/test/core_tests.jl +++ b/lib/SCCNonlinearSolve/test/core_tests.jl @@ -5,7 +5,8 @@ include("../../../common/common_rootfind_testing.jl") end @testitem "Manual SCC" setup=[CoreRootfindTesting] tags=[:core] begin - using NonlinearSolve + using NonlinearSolveFirstOrder + function f(du, u, p) du[1] = cos(u[2]) - u[1] du[2] = sin(u[1] + u[2]) + u[2] From ff5a4b147ea1a186d70a0c2e7d6048d1bcc9457a Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 13:49:33 -0100 Subject: [PATCH 15/26] Update lib/SCCNonlinearSolve/test/core_tests.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- lib/SCCNonlinearSolve/test/core_tests.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/SCCNonlinearSolve/test/core_tests.jl b/lib/SCCNonlinearSolve/test/core_tests.jl index 14ae81efa..34b3b9fae 100644 --- a/lib/SCCNonlinearSolve/test/core_tests.jl +++ b/lib/SCCNonlinearSolve/test/core_tests.jl @@ -6,7 +6,6 @@ end @testitem "Manual SCC" setup=[CoreRootfindTesting] tags=[:core] begin using NonlinearSolveFirstOrder - function f(du, u, p) du[1] = cos(u[2]) - u[1] du[2] = sin(u[1] + u[2]) + u[2] From d737b8495def8685fffd193546d85f6d2251acd9 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 15:15:03 -0100 Subject: [PATCH 16/26] Update lib/SCCNonlinearSolve/test/core_tests.jl --- lib/SCCNonlinearSolve/test/core_tests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/SCCNonlinearSolve/test/core_tests.jl b/lib/SCCNonlinearSolve/test/core_tests.jl index 34b3b9fae..1884e6661 100644 --- a/lib/SCCNonlinearSolve/test/core_tests.jl +++ b/lib/SCCNonlinearSolve/test/core_tests.jl @@ -17,7 +17,7 @@ end du[8] = u[1] + 2.0u[2] + 3.0u[3] + 5.0u[4] + 6.0u[5] + u[6] - u[7] - u[8] end prob = NonlinearProblem(f, zeros(8)) - sol = solve(prob) + sol = solve(prob, NewtonRaphson()) u0 = zeros(2) cache = zeros(3) From bf3c193f8c0a4b49f5a425859c355b5449a87f1a Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 16:20:59 -0100 Subject: [PATCH 17/26] Update core_tests.jl --- lib/SCCNonlinearSolve/test/core_tests.jl | 26 ++++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/SCCNonlinearSolve/test/core_tests.jl b/lib/SCCNonlinearSolve/test/core_tests.jl index 1884e6661..039173f93 100644 --- a/lib/SCCNonlinearSolve/test/core_tests.jl +++ b/lib/SCCNonlinearSolve/test/core_tests.jl @@ -20,7 +20,7 @@ end sol = solve(prob, NewtonRaphson()) u0 = zeros(2) - cache = zeros(3) + p = zeros(3) function f1(du, u, (cache, p)) du[1] = cos(u[2]) - u[1] @@ -28,30 +28,30 @@ end end explicitfun1(cache, sols) = nothing prob1 = NonlinearProblem( - NonlinearFunction{true, SciMLBase.NoSpecialize}(f1), zeros(2), cache) + NonlinearFunction{true, SciMLBase.NoSpecialize}(f1), zeros(2), p) sol1 = solve(prob1, NewtonRaphson()) - function f2(du, u, (cache, p)) + function f2(du, u, p) du[1] = 2u[2] + u[1] + 1.0 du[2] = u[3]^2 + u[2] du[3] = u[1]^2 + u[3] end explicitfun2(cache, sols) = nothing prob2 = NonlinearProblem( - NonlinearFunction{true, SciMLBase.NoSpecialize}(f2), zeros(3), cache) + NonlinearFunction{true, SciMLBase.NoSpecialize}(f2), zeros(3), p) sol2 = solve(prob2, NewtonRaphson()) - function f3(du, u, (cache, p)) - du[1] = cache[1] + 2.0u[1] + 2.5u[2] + 1.5u[3] - du[2] = cache[2] + 4.0u[1] - 1.5u[2] + 1.5u[3] - du[3] = cache[3] + +u[1] - u[2] - u[3] + function f3(du, u, p) + du[1] = p[1] + 2.0u[1] + 2.5u[2] + 1.5u[3] + du[2] = p[2] + 4.0u[1] - 1.5u[2] + 1.5u[3] + du[3] = p[3] + +u[1] - u[2] - u[3] end prob3 = NonlinearProblem( - NonlinearFunction{true, SciMLBase.NoSpecialize}(f3), zeros(3), cache) - function explicitfun3(cache, sols) - cache[1] = sols[1][1] + sols[1][2] + sols[2][1] + sols[2][2] + sols[2][3] - cache[2] = sols[1][1] + sols[1][2] + sols[2][1] + 2.0sols[2][2] + sols[2][3] - cache[3] = sols[1][1] + 2.0sols[1][2] + 3.0sols[2][1] + 5.0sols[2][2] + + NonlinearFunction{true, SciMLBase.NoSpecialize}(f3), zeros(3), p) + function explicitfun3(p, sols) + p[1] = sols[1][1] + sols[1][2] + sols[2][1] + sols[2][2] + sols[2][3] + p[2] = sols[1][1] + sols[1][2] + sols[2][1] + 2.0sols[2][2] + sols[2][3] + p[3] = sols[1][1] + 2.0sols[1][2] + 3.0sols[2][1] + 5.0sols[2][2] + 6.0sols[2][3] end explicitfun3(cache, [sol1, sol2]) From 358b5afb9b526f6b9471e99f2e1d94ac72f72da4 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 16:28:05 -0100 Subject: [PATCH 18/26] Update lib/SCCNonlinearSolve/test/core_tests.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- lib/SCCNonlinearSolve/test/core_tests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/SCCNonlinearSolve/test/core_tests.jl b/lib/SCCNonlinearSolve/test/core_tests.jl index 039173f93..0cfc7f0e3 100644 --- a/lib/SCCNonlinearSolve/test/core_tests.jl +++ b/lib/SCCNonlinearSolve/test/core_tests.jl @@ -52,7 +52,7 @@ end p[1] = sols[1][1] + sols[1][2] + sols[2][1] + sols[2][2] + sols[2][3] p[2] = sols[1][1] + sols[1][2] + sols[2][1] + 2.0sols[2][2] + sols[2][3] p[3] = sols[1][1] + 2.0sols[1][2] + 3.0sols[2][1] + 5.0sols[2][2] + - 6.0sols[2][3] + 6.0sols[2][3] end explicitfun3(cache, [sol1, sol2]) sol3 = solve(prob3, NewtonRaphson()) From 4c35749ffff560d301c4b9302d81d15051547790 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 17:35:32 -0100 Subject: [PATCH 19/26] Update core_tests.jl --- lib/SCCNonlinearSolve/test/core_tests.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/SCCNonlinearSolve/test/core_tests.jl b/lib/SCCNonlinearSolve/test/core_tests.jl index 0cfc7f0e3..92843421d 100644 --- a/lib/SCCNonlinearSolve/test/core_tests.jl +++ b/lib/SCCNonlinearSolve/test/core_tests.jl @@ -22,11 +22,11 @@ end u0 = zeros(2) p = zeros(3) - function f1(du, u, (cache, p)) + function f1(du, u, p) du[1] = cos(u[2]) - u[1] du[2] = sin(u[1] + u[2]) + u[2] end - explicitfun1(cache, sols) = nothing + explicitfun1(p, sols) = nothing prob1 = NonlinearProblem( NonlinearFunction{true, SciMLBase.NoSpecialize}(f1), zeros(2), p) sol1 = solve(prob1, NewtonRaphson()) @@ -36,7 +36,7 @@ end du[2] = u[3]^2 + u[2] du[3] = u[1]^2 + u[3] end - explicitfun2(cache, sols) = nothing + explicitfun2(p, sols) = nothing prob2 = NonlinearProblem( NonlinearFunction{true, SciMLBase.NoSpecialize}(f2), zeros(3), p) sol2 = solve(prob2, NewtonRaphson()) @@ -54,7 +54,7 @@ end p[3] = sols[1][1] + 2.0sols[1][2] + 3.0sols[2][1] + 5.0sols[2][2] + 6.0sols[2][3] end - explicitfun3(cache, [sol1, sol2]) + explicitfun3(p, [sol1, sol2]) sol3 = solve(prob3, NewtonRaphson()) manualscc = [sol1; sol2; sol3] From dc8050ec90d9c445b0b2dec605d3e99666be1c81 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 18:48:22 -0100 Subject: [PATCH 20/26] Update Project.toml --- lib/SCCNonlinearSolve/Project.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/SCCNonlinearSolve/Project.toml b/lib/SCCNonlinearSolve/Project.toml index d51e831e3..7c44f14a4 100644 --- a/lib/SCCNonlinearSolve/Project.toml +++ b/lib/SCCNonlinearSolve/Project.toml @@ -22,6 +22,7 @@ InteractiveUtils = "<0.0.1, 1" MaybeInplace = "0.1.4" NonlinearProblemLibrary = "0.1.2" NonlinearSolveBase = "1.1" +NonlinearSolveFirstOrder = "1" Pkg = "1.10" PrecompileTools = "1.2" ReTestItems = "1.24" @@ -29,6 +30,7 @@ Reexport = "1" SciMLBase = "2.60" StableRNGs = "1" StaticArrays = "1.9.8" +SymbolicIndexingInterface = "0.3.30" Test = "1.10" julia = "1.10" From 649e09a7802ab35d77c02cc6ab0cc8fee0cbbfe4 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 18:51:06 -0100 Subject: [PATCH 21/26] Update lib/SCCNonlinearSolve/test/qa_tests.jl --- lib/SCCNonlinearSolve/test/qa_tests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/SCCNonlinearSolve/test/qa_tests.jl b/lib/SCCNonlinearSolve/test/qa_tests.jl index 764e8cebd..c87f6002a 100644 --- a/lib/SCCNonlinearSolve/test/qa_tests.jl +++ b/lib/SCCNonlinearSolve/test/qa_tests.jl @@ -7,7 +7,7 @@ ) Aqua.test_stale_deps(SCCNonlinearSolve; ignore = [:SciMLJacobianOperators]) Aqua.test_deps_compat(SCCNonlinearSolve; ignore = [:SciMLJacobianOperators]) - Aqua.test_piracies(SCCNonlinearSolve) + Aqua.test_piracies(SCCNonlinearSolve; treat_as_own = [SCCNonlinearSolve.SciMLBase.solve]) Aqua.test_ambiguities(SCCNonlinearSolve; recursive = false) end From df1dcaf5428817478bcd9923cdd2998e85ca53d0 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 19:30:36 -0100 Subject: [PATCH 22/26] Update lib/SCCNonlinearSolve/test/qa_tests.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- lib/SCCNonlinearSolve/test/qa_tests.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/SCCNonlinearSolve/test/qa_tests.jl b/lib/SCCNonlinearSolve/test/qa_tests.jl index c87f6002a..c5a85a6c5 100644 --- a/lib/SCCNonlinearSolve/test/qa_tests.jl +++ b/lib/SCCNonlinearSolve/test/qa_tests.jl @@ -7,7 +7,8 @@ ) Aqua.test_stale_deps(SCCNonlinearSolve; ignore = [:SciMLJacobianOperators]) Aqua.test_deps_compat(SCCNonlinearSolve; ignore = [:SciMLJacobianOperators]) - Aqua.test_piracies(SCCNonlinearSolve; treat_as_own = [SCCNonlinearSolve.SciMLBase.solve]) + Aqua.test_piracies( + SCCNonlinearSolve; treat_as_own = [SCCNonlinearSolve.SciMLBase.solve]) Aqua.test_ambiguities(SCCNonlinearSolve; recursive = false) end From ea8e982e48d3ffb64b26114c25d5cc19e8b05767 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 19:33:04 -0100 Subject: [PATCH 23/26] Update Project.toml --- lib/SCCNonlinearSolve/Project.toml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/SCCNonlinearSolve/Project.toml b/lib/SCCNonlinearSolve/Project.toml index 7c44f14a4..389323487 100644 --- a/lib/SCCNonlinearSolve/Project.toml +++ b/lib/SCCNonlinearSolve/Project.toml @@ -5,8 +5,6 @@ version = "1.0.0" [deps] CommonSolve = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2" -MaybeInplace = "bb5d69b7-63fc-4a16-80bd-7e42200c7bdb" -NonlinearSolveBase = "be0214bd-f91f-a760-ac4e-3421ce2b2da0" PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462" @@ -19,9 +17,7 @@ CommonSolve = "0.2.4" ExplicitImports = "1.5" Hwloc = "3" InteractiveUtils = "<0.0.1, 1" -MaybeInplace = "0.1.4" NonlinearProblemLibrary = "0.1.2" -NonlinearSolveBase = "1.1" NonlinearSolveFirstOrder = "1" Pkg = "1.10" PrecompileTools = "1.2" From f0386c205732f3e3c66c15c0b2fb78b5df2e659e Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 19:42:05 -0100 Subject: [PATCH 24/26] Update qa_tests.jl --- lib/SCCNonlinearSolve/test/qa_tests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/SCCNonlinearSolve/test/qa_tests.jl b/lib/SCCNonlinearSolve/test/qa_tests.jl index c5a85a6c5..7e4686120 100644 --- a/lib/SCCNonlinearSolve/test/qa_tests.jl +++ b/lib/SCCNonlinearSolve/test/qa_tests.jl @@ -5,7 +5,7 @@ SCCNonlinearSolve; piracies = false, ambiguities = false, stale_deps = false, deps_compat = false ) - Aqua.test_stale_deps(SCCNonlinearSolve; ignore = [:SciMLJacobianOperators]) + Aqua.test_stale_deps(SCCNonlinearSolve; ignore = [:SciMLJacobianOperators, :NonlinearSolveBase]) Aqua.test_deps_compat(SCCNonlinearSolve; ignore = [:SciMLJacobianOperators]) Aqua.test_piracies( SCCNonlinearSolve; treat_as_own = [SCCNonlinearSolve.SciMLBase.solve]) From fde2bf5f8c98616cf926278f6ca602a4430e02e8 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 22:57:42 -0100 Subject: [PATCH 25/26] Update lib/SCCNonlinearSolve/test/qa_tests.jl --- lib/SCCNonlinearSolve/test/qa_tests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/SCCNonlinearSolve/test/qa_tests.jl b/lib/SCCNonlinearSolve/test/qa_tests.jl index 7e4686120..3337b6bc3 100644 --- a/lib/SCCNonlinearSolve/test/qa_tests.jl +++ b/lib/SCCNonlinearSolve/test/qa_tests.jl @@ -6,7 +6,7 @@ piracies = false, ambiguities = false, stale_deps = false, deps_compat = false ) Aqua.test_stale_deps(SCCNonlinearSolve; ignore = [:SciMLJacobianOperators, :NonlinearSolveBase]) - Aqua.test_deps_compat(SCCNonlinearSolve; ignore = [:SciMLJacobianOperators]) + Aqua.test_deps_compat(SCCNonlinearSolve; ignore = [:SciMLJacobianOperators, :NonlinearSolveBase]) Aqua.test_piracies( SCCNonlinearSolve; treat_as_own = [SCCNonlinearSolve.SciMLBase.solve]) Aqua.test_ambiguities(SCCNonlinearSolve; recursive = false) From 714687ea365d11c5663097517cca87674e6ccdea Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 15 Nov 2024 23:18:26 -0100 Subject: [PATCH 26/26] Update lib/SCCNonlinearSolve/test/qa_tests.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- lib/SCCNonlinearSolve/test/qa_tests.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/SCCNonlinearSolve/test/qa_tests.jl b/lib/SCCNonlinearSolve/test/qa_tests.jl index 3337b6bc3..93111c1cc 100644 --- a/lib/SCCNonlinearSolve/test/qa_tests.jl +++ b/lib/SCCNonlinearSolve/test/qa_tests.jl @@ -5,8 +5,10 @@ SCCNonlinearSolve; piracies = false, ambiguities = false, stale_deps = false, deps_compat = false ) - Aqua.test_stale_deps(SCCNonlinearSolve; ignore = [:SciMLJacobianOperators, :NonlinearSolveBase]) - Aqua.test_deps_compat(SCCNonlinearSolve; ignore = [:SciMLJacobianOperators, :NonlinearSolveBase]) + Aqua.test_stale_deps( + SCCNonlinearSolve; ignore = [:SciMLJacobianOperators, :NonlinearSolveBase]) + Aqua.test_deps_compat( + SCCNonlinearSolve; ignore = [:SciMLJacobianOperators, :NonlinearSolveBase]) Aqua.test_piracies( SCCNonlinearSolve; treat_as_own = [SCCNonlinearSolve.SciMLBase.solve]) Aqua.test_ambiguities(SCCNonlinearSolve; recursive = false)