From dc539b975dd9dd1d8e5c75f91fe793bb004a5cb1 Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Thu, 25 Apr 2024 16:21:48 -0400 Subject: [PATCH] Propagate the verbose kwarg --- src/NonlinearSolve.jl | 4 ++-- src/core/approximate_jacobian.jl | 7 ++++--- src/core/generalized_first_order.jl | 7 ++++--- src/core/spectral_methods.jl | 3 ++- src/internal/linear_solve.jl | 9 ++++++--- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/NonlinearSolve.jl b/src/NonlinearSolve.jl index 9261f259f..9b6b9ec04 100644 --- a/src/NonlinearSolve.jl +++ b/src/NonlinearSolve.jl @@ -136,10 +136,10 @@ include("default.jl") @compile_workload begin for prob in probs_nls, alg in nls_algs - solve(prob, alg; abstol = 1e-2) + solve(prob, alg; abstol = 1e-2, verbose = false) end for prob in probs_nlls, alg in nlls_algs - solve(prob, alg; abstol = 1e-2) + solve(prob, alg; abstol = 1e-2, verbose = false) end end end diff --git a/src/core/approximate_jacobian.jl b/src/core/approximate_jacobian.jl index 6e8f93ba6..ac649a107 100644 --- a/src/core/approximate_jacobian.jl +++ b/src/core/approximate_jacobian.jl @@ -114,6 +114,7 @@ end retcode::ReturnCode.T force_stop::Bool force_reinit::Bool + kwargs end store_inverse_jacobian(::ApproximateJacobianSolveCache{INV}) where {INV} = INV @@ -214,7 +215,7 @@ function SciMLBase.__init( descent_cache, linesearch_cache, trustregion_cache, update_rule_cache, reinit_rule_cache, inv_workspace, 0, 0, 0, alg.max_resets, maxiters, maxtime, alg.max_shrink_times, 0, timer, - 0.0, termination_cache, trace, ReturnCode.Default, false, false) + 0.0, termination_cache, trace, ReturnCode.Default, false, false, kwargs) end end @@ -284,10 +285,10 @@ function __step!(cache::ApproximateJacobianSolveCache{INV, GB, iip}; hasfield(typeof(cache.trustregion_cache), :trust_region) descent_result = __internal_solve!( cache.descent_cache, J, cache.fu, cache.u; new_jacobian, - trust_region = cache.trustregion_cache.trust_region) + trust_region = cache.trustregion_cache.trust_region, cache.kwargs...) else descent_result = __internal_solve!( - cache.descent_cache, J, cache.fu, cache.u; new_jacobian) + cache.descent_cache, J, cache.fu, cache.u; new_jacobian, cache.kwargs...) end end δu, descent_intermediates = descent_result.δu, descent_result.extras diff --git a/src/core/generalized_first_order.jl b/src/core/generalized_first_order.jl index 710787840..e3a4b8941 100644 --- a/src/core/generalized_first_order.jl +++ b/src/core/generalized_first_order.jl @@ -111,6 +111,7 @@ concrete_jac(::GeneralizedFirstOrderAlgorithm{CJ}) where {CJ} = CJ trace retcode::ReturnCode.T force_stop::Bool + kwargs end SymbolicIndexingInterface.state_values(cache::GeneralizedFirstOrderAlgorithmCache) = cache.u @@ -202,7 +203,7 @@ function SciMLBase.__init( return GeneralizedFirstOrderAlgorithmCache{iip, GB, maxtime !== nothing}( fu, u, u_cache, p, du, J, alg, prob, jac_cache, descent_cache, linesearch_cache, trustregion_cache, 0, 0, maxiters, maxtime, alg.max_shrink_times, - timer, 0.0, true, termination_cache, trace, ReturnCode.Default, false) + timer, 0.0, true, termination_cache, trace, ReturnCode.Default, false, kwargs) end end @@ -223,10 +224,10 @@ function __step!(cache::GeneralizedFirstOrderAlgorithmCache{iip, GB}; hasfield(typeof(cache.trustregion_cache), :trust_region) descent_result = __internal_solve!( cache.descent_cache, J, cache.fu, cache.u; new_jacobian, - trust_region = cache.trustregion_cache.trust_region) + trust_region = cache.trustregion_cache.trust_region, cache.kwargs...) else descent_result = __internal_solve!( - cache.descent_cache, J, cache.fu, cache.u; new_jacobian) + cache.descent_cache, J, cache.fu, cache.u; new_jacobian, cache.kwargs...) end end δu, descent_intermediates = descent_result.δu, descent_result.extras diff --git a/src/core/spectral_methods.jl b/src/core/spectral_methods.jl index d9d271d78..3d9a03e50 100644 --- a/src/core/spectral_methods.jl +++ b/src/core/spectral_methods.jl @@ -74,6 +74,7 @@ concrete_jac(::GeneralizedDFSane) = nothing trace retcode::ReturnCode.T force_stop::Bool + kwargs end function __reinit_internal!( @@ -150,7 +151,7 @@ function SciMLBase.__init(prob::AbstractNonlinearProblem, alg::GeneralizedDFSane return GeneralizedDFSaneCache{isinplace(prob), maxtime !== nothing}( fu, fu_cache, u, u_cache, prob.p, du, alg, prob, σ_n, T(alg.σ_min), T(alg.σ_max), linesearch_cache, 0, 0, maxiters, maxtime, - timer, 0.0, tc_cache, trace, ReturnCode.Default, false) + timer, 0.0, tc_cache, trace, ReturnCode.Default, false, kwargs) end end diff --git a/src/internal/linear_solve.jl b/src/internal/linear_solve.jl index 36d8f1928..909950a07 100644 --- a/src/internal/linear_solve.jl +++ b/src/internal/linear_solve.jl @@ -125,7 +125,8 @@ end # Use LinearSolve.jl function (cache::LinearSolverCache)(; A = nothing, b = nothing, linu = nothing, du = nothing, p = nothing, - weight = nothing, cachedata = nothing, reuse_A_if_factorization = false, kwargs...) + weight = nothing, cachedata = nothing, reuse_A_if_factorization = false, + verbose = true, kwargs...) cache.nsolve += 1 __update_A!(cache, A, reuse_A_if_factorization) @@ -164,8 +165,10 @@ function (cache::LinearSolverCache)(; # TODO: We need to guard this somehow because this will surely fail if A is on GPU # TODO: or some fancy Matrix type if !(cache.linsolve isa QRFactorization{ColumnNorm}) - @warn "Potential Rank Deficient Matrix Detected. Attempting to solve using \ - Pivoted QR Factorization." + if verbose + @warn "Potential Rank Deficient Matrix Detected. Attempting to solve using \ + Pivoted QR Factorization." + end @assert (A !== nothing)&&(b !== nothing) "This case is not yet supported. \ Please open an issue at \ https://github.com/SciML/NonlinearSolve.jl"