ITADN

Convergence tolerance is more demanding when using warm-start

#1076Opentimholy 创建于 2026-02-24
T
timholycommented
I'd noticed that supplying a good starting guess did not always reduce the number of iterations required, and indeed sometimes increased it. This is despite verifying that the guess was excellent in the appropriate norm (e.g., returning the previous solution as the initial guess and re-running the solver). I finally tracked it down to the fact that the tolerance is computed from the residuals, and the residuals are computed incorporating the initial guess. Thus, the automatically-chosen tolerance is inconsistent between the two, which I believe accounts for the puzzling performance. Demo: with the following diff, ```diff tim@kenzo:~/.julia/dev/Krylov$ git diff diff --git a/src/trimr.jl b/src/trimr.jl index e8107f172..128383577 100644 --- a/src/trimr.jl +++ b/src/trimr.jl @@ -269,6 +269,7 @@ kwargs_trimr = (:M, :N, :ldiv, :spd, :snd, :flip, :sp, :τ, :ν, :atol, :rtol, : rNorm = sqrt(γₖ^2 + βₖ^2) history && push!(rNorms, rNorm) ε = atol + rtol * rNorm + @show ε (verbose > 0) && @printf(iostream, "%5s %7s %7s %7s %5s\n", "k", "‖rₖ‖", "βₖ₊₁", "γₖ₊₁", "timer") kdisplay(iter, verbose) && @printf(iostream, "%5d %7.1e %7.1e %7.1e %.2fs\n", iter, rNorm, βₖ, γₖ, start_time |> ktimer) diff --git a/test/test_warm_start.jl b/test/test_warm_start.jl index f2e6a57a5..1f28c4b60 100644 --- a/test/test_warm_start.jl +++ b/test/test_warm_start.jl @@ -115,7 +115,9 @@ function test_warm_start(FC) resid = norm(r) / norm([b; b]) @test(resid ≤ tol) + print("without warm start: ") x30, y20, _ = trimr(A3x2, b3, c2) + print("with warm start: ") x3, y2, stats = trimr(A3x2, b3, c2, x30, y20) @test x3 ≈ x30 atol=1e-12 @test y2 ≈ y20 atol=1e-12 ``` I get ``` julia> include("test_warm_start.jl") ε = 4.3737995974229237e-7 without warm start: ε = 4.822117056697294e-8 with warm start: ε = 1.490116119384767e-8 ε = 4.3737995974229237e-7 ε = 1.4901161193847656e-8 ε = 4.3737995974229237e-7 without warm start: ε = 4.822117056697294e-8 with warm start: ε = 1.490116119384767e-8 ε = 4.3737995974229237e-7 ε = 1.4901161193847656e-8 ```
0 条评论