diff --git a/common/nlls_problem_workloads.jl b/common/nlls_problem_workloads.jl deleted file mode 100644 index 0d7c0f7ef..000000000 --- a/common/nlls_problem_workloads.jl +++ /dev/null @@ -1,26 +0,0 @@ -using SciMLBase: NonlinearLeastSquaresProblem, NonlinearFunction, NoSpecialize - -nonlinear_functions = ( - (NonlinearFunction{false, NoSpecialize}((u, p) -> (u .^ 2 .- p)[1:1]), [0.1, 0.0]), - ( - NonlinearFunction{false, NoSpecialize}((u, p) -> vcat(u .* u .- p, u .* u .- p)), - [0.1, 0.1] - ), - ( - NonlinearFunction{true, NoSpecialize}( - (du, u, p) -> du[1] = u[1] * u[1] - p, resid_prototype = zeros(1) - ), - [0.1, 0.0] - ), - ( - NonlinearFunction{true, NoSpecialize}( - (du, u, p) -> du .= vcat(u .* u .- p, u .* u .- p), resid_prototype = zeros(4) - ), - [0.1, 0.1] - ) -) - -nlls_problems = NonlinearLeastSquaresProblem[] -for (fn, u0) in nonlinear_functions - push!(nlls_problems, NonlinearLeastSquaresProblem(fn, u0, 2.0)) -end diff --git a/common/nonlinear_problem_workloads.jl b/common/nonlinear_problem_workloads.jl deleted file mode 100644 index 43d0de29a..000000000 --- a/common/nonlinear_problem_workloads.jl +++ /dev/null @@ -1,12 +0,0 @@ -using SciMLBase: NonlinearProblem, NonlinearFunction, NoSpecialize - -nonlinear_functions = ( - (NonlinearFunction{false, NoSpecialize}((u, p) -> u .* u .- p), 0.1), - (NonlinearFunction{false, NoSpecialize}((u, p) -> u .* u .- p), [0.1]), - (NonlinearFunction{true, NoSpecialize}((du, u, p) -> du .= u .* u .- p), [0.1]) -) - -nonlinear_problems = NonlinearProblem[] -for (fn, u0) in nonlinear_functions - push!(nonlinear_problems, NonlinearProblem(fn, u0, 2.0)) -end diff --git a/lib/NonlinearSolveFirstOrder/src/NonlinearSolveFirstOrder.jl b/lib/NonlinearSolveFirstOrder/src/NonlinearSolveFirstOrder.jl index b611b9051..145468122 100644 --- a/lib/NonlinearSolveFirstOrder/src/NonlinearSolveFirstOrder.jl +++ b/lib/NonlinearSolveFirstOrder/src/NonlinearSolveFirstOrder.jl @@ -22,7 +22,9 @@ using NonlinearSolveBase: NonlinearSolveBase, AbstractNonlinearSolveAlgorithm, update_trace!, L2_NORM, NewtonDescent, DampedNewtonDescent, GeodesicAcceleration, Dogleg -using SciMLBase: SciMLBase, AbstractNonlinearProblem, NLStats, ReturnCode, NonlinearFunction +using SciMLBase: SciMLBase, AbstractNonlinearProblem, NLStats, ReturnCode, + NonlinearFunction, + NonlinearLeastSquaresProblem, NonlinearProblem, NoSpecialize using SciMLJacobianOperators: VecJacOperator, JacVecOperator, StatefulJacobianOperator using FiniteDiff: FiniteDiff # Default Finite Difference Method @@ -37,8 +39,41 @@ include("pseudo_transient.jl") include("solve.jl") @setup_workload begin - include("../../../common/nonlinear_problem_workloads.jl") - include("../../../common/nlls_problem_workloads.jl") + nonlinear_functions = ( + (NonlinearFunction{false, NoSpecialize}((u, p) -> u .* u .- p), 0.1), + (NonlinearFunction{false, NoSpecialize}((u, p) -> u .* u .- p), [0.1]), + (NonlinearFunction{true, NoSpecialize}((du, u, p) -> du .= u .* u .- p), [0.1]) + ) + + nonlinear_problems = NonlinearProblem[] + for (fn, u0) in nonlinear_functions + push!(nonlinear_problems, NonlinearProblem(fn, u0, 2.0)) + end + + nonlinear_functions = ( + (NonlinearFunction{false, NoSpecialize}((u, p) -> (u .^ 2 .- p)[1:1]), [0.1, 0.0]), + ( + NonlinearFunction{false, NoSpecialize}((u, p) -> vcat(u .* u .- p, u .* u .- p)), + [0.1, 0.1] + ), + ( + NonlinearFunction{true, NoSpecialize}( + (du, u, p) -> du[1] = u[1] * u[1] - p, resid_prototype = zeros(1) + ), + [0.1, 0.0] + ), + ( + NonlinearFunction{true, NoSpecialize}( + (du, u, p) -> du .= vcat(u .* u .- p, u .* u .- p), resid_prototype = zeros(4) + ), + [0.1, 0.1] + ) + ) + + nlls_problems = NonlinearLeastSquaresProblem[] + for (fn, u0) in nonlinear_functions + push!(nlls_problems, NonlinearLeastSquaresProblem(fn, u0, 2.0)) + end nlp_algs = [NewtonRaphson(), TrustRegion(), LevenbergMarquardt()] nlls_algs = [GaussNewton(), TrustRegion(), LevenbergMarquardt()] diff --git a/lib/NonlinearSolveQuasiNewton/src/NonlinearSolveQuasiNewton.jl b/lib/NonlinearSolveQuasiNewton/src/NonlinearSolveQuasiNewton.jl index 3b63615e8..02bbc865f 100644 --- a/lib/NonlinearSolveQuasiNewton/src/NonlinearSolveQuasiNewton.jl +++ b/lib/NonlinearSolveQuasiNewton/src/NonlinearSolveQuasiNewton.jl @@ -20,7 +20,8 @@ using NonlinearSolveBase: NonlinearSolveBase, AbstractNonlinearSolveAlgorithm, AbstractApproximateJacobianUpdateRuleCache, Utils, InternalAPI, get_timer_output, @static_timeit, update_trace!, L2_NORM, NewtonDescent -using SciMLBase: SciMLBase, AbstractNonlinearProblem, NLStats, ReturnCode +using SciMLBase: SciMLBase, AbstractNonlinearProblem, NLStats, ReturnCode, + NonlinearProblem, NonlinearFunction, NoSpecialize using SciMLOperators: AbstractSciMLOperator include("reset_conditions.jl") @@ -34,7 +35,16 @@ include("klement.jl") include("solve.jl") @setup_workload begin - include("../../../common/nonlinear_problem_workloads.jl") + nonlinear_functions = ( + (NonlinearFunction{false, NoSpecialize}((u, p) -> u .* u .- p), 0.1), + (NonlinearFunction{false, NoSpecialize}((u, p) -> u .* u .- p), [0.1]), + (NonlinearFunction{true, NoSpecialize}((du, u, p) -> du .= u .* u .- p), [0.1]) + ) + + nonlinear_problems = NonlinearProblem[] + for (fn, u0) in nonlinear_functions + push!(nonlinear_problems, NonlinearProblem(fn, u0, 2.0)) + end algs = [Broyden(), Klement()] diff --git a/lib/NonlinearSolveSpectralMethods/src/NonlinearSolveSpectralMethods.jl b/lib/NonlinearSolveSpectralMethods/src/NonlinearSolveSpectralMethods.jl index 8872fce35..49949e438 100644 --- a/lib/NonlinearSolveSpectralMethods/src/NonlinearSolveSpectralMethods.jl +++ b/lib/NonlinearSolveSpectralMethods/src/NonlinearSolveSpectralMethods.jl @@ -11,14 +11,24 @@ using MaybeInplace: @bb using NonlinearSolveBase: NonlinearSolveBase, AbstractNonlinearSolveAlgorithm, AbstractNonlinearSolveCache, Utils, InternalAPI, get_timer_output, @static_timeit, update_trace! -using SciMLBase: SciMLBase, AbstractNonlinearProblem, NLStats, ReturnCode +using SciMLBase: SciMLBase, AbstractNonlinearProblem, NLStats, ReturnCode, + NonlinearProblem, NonlinearFunction, NoSpecialize include("dfsane.jl") include("solve.jl") @setup_workload begin - include("../../../common/nonlinear_problem_workloads.jl") + nonlinear_functions = ( + (NonlinearFunction{false, NoSpecialize}((u, p) -> u .* u .- p), 0.1), + (NonlinearFunction{false, NoSpecialize}((u, p) -> u .* u .- p), [0.1]), + (NonlinearFunction{true, NoSpecialize}((du, u, p) -> du .= u .* u .- p), [0.1]) + ) + + nonlinear_problems = NonlinearProblem[] + for (fn, u0) in nonlinear_functions + push!(nonlinear_problems, NonlinearProblem(fn, u0, 2.0)) + end algs = [DFSane()] diff --git a/src/NonlinearSolve.jl b/src/NonlinearSolve.jl index 7d6ac7b09..a3e8bb6ca 100644 --- a/src/NonlinearSolve.jl +++ b/src/NonlinearSolve.jl @@ -16,8 +16,9 @@ using NonlinearSolveBase: NonlinearSolveBase, InternalAPI, AbstractNonlinearSolv enable_timer_outputs, disable_timer_outputs using Preferences: set_preferences! -using SciMLBase: SciMLBase, NLStats, ReturnCode, AbstractNonlinearProblem, NonlinearProblem, - NonlinearLeastSquaresProblem +using SciMLBase: SciMLBase, NLStats, ReturnCode, AbstractNonlinearProblem, + NonlinearFunction, + NonlinearProblem, NonlinearLeastSquaresProblem, NoSpecialize using SymbolicIndexingInterface: SymbolicIndexingInterface using StaticArraysCore: StaticArray @@ -63,8 +64,41 @@ const ALL_SOLVER_TYPES = [ include("forward_diff.jl") @setup_workload begin - include("../common/nonlinear_problem_workloads.jl") - include("../common/nlls_problem_workloads.jl") + nonlinear_functions = ( + (NonlinearFunction{false, NoSpecialize}((u, p) -> u .* u .- p), 0.1), + (NonlinearFunction{false, NoSpecialize}((u, p) -> u .* u .- p), [0.1]), + (NonlinearFunction{true, NoSpecialize}((du, u, p) -> du .= u .* u .- p), [0.1]) + ) + + nonlinear_problems = NonlinearProblem[] + for (fn, u0) in nonlinear_functions + push!(nonlinear_problems, NonlinearProblem(fn, u0, 2.0)) + end + + nonlinear_functions = ( + (NonlinearFunction{false, NoSpecialize}((u, p) -> (u .^ 2 .- p)[1:1]), [0.1, 0.0]), + ( + NonlinearFunction{false, NoSpecialize}((u, p) -> vcat(u .* u .- p, u .* u .- p)), + [0.1, 0.1] + ), + ( + NonlinearFunction{true, NoSpecialize}( + (du, u, p) -> du[1] = u[1] * u[1] - p, resid_prototype = zeros(1) + ), + [0.1, 0.0] + ), + ( + NonlinearFunction{true, NoSpecialize}( + (du, u, p) -> du .= vcat(u .* u .- p, u .* u .- p), resid_prototype = zeros(4) + ), + [0.1, 0.1] + ) + ) + + nlls_problems = NonlinearLeastSquaresProblem[] + for (fn, u0) in nonlinear_functions + push!(nlls_problems, NonlinearLeastSquaresProblem(fn, u0, 2.0)) + end @compile_workload begin @sync begin