Skip to content

Commit 92e6ff3

Browse files
authored
Accept only full-accuracy AL stages as converged (#99)
The KKT residual of `_abslog2_auglag` measures constraint violation, not how well a stage minimized its objective, so a stage solved at the loosest LSQR tolerance could be reported converged while its products were not covariant under a change of units (0.7% on Bai/bwm2000). `converged` now requires the accepting stage's last solve at the full-accuracy tolerance; an inexact stage that meets the test is followed by a stage at the floor tolerance. Within a stage, a full step that leaves the active pattern unchanged drops the tolerance to the floor, since the solve error is then the only remaining error; a fixed inexact tolerance dithers at its noise floor instead (40 solves on bwm2000, now 4). Iteration counts on sparse lognormal matrices at n = 31623 are within 5% of the previous ones. Adds a covariance test on the Brusselator Jacobian (Bai/bwm200) under power-of-two row scaling. Assisted-by: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 87395a7 commit 92e6ff3

2 files changed

Lines changed: 41 additions & 5 deletions

File tree

‎src/minimal_covers.jl‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,10 +1300,14 @@ const LSQR_FILL_BUDGET = 1 << 30
13001300
# LSQR iterations of spanning-forest preconditioning.
13011301
const LSQR_FLOP_BUDGET = 8.0e3
13021302

1303-
# The Newton steps of the multiplier iteration need only inexact solves: each
1304-
# stage runs LSQR with tolerance `LSQR_FORCING` times the KKT residual of the previous
1305-
# update, capped at `LSQR_ATOL_MAX` and floored at the full-accuracy tolerance
1306-
# `_lsqr_atol`.
1303+
# The Newton steps of the multiplier iteration need only inexact solves while
1304+
# the active pattern is still changing. A stage starts LSQR at tolerance
1305+
# `LSQR_FORCING` times the KKT residual of the previous update, capped at
1306+
# `LSQR_ATOL_MAX` and floored at the full-accuracy tolerance `_lsqr_atol`. Once
1307+
# a full step leaves the pattern unchanged, the only remaining error is the
1308+
# solve's, so the stage finishes at full accuracy; a fixed inexact tolerance
1309+
# would instead dither at its noise floor. A stage is accepted as the solution
1310+
# only if its last solve ran at full accuracy.
13071311
const LSQR_ATOL_MAX = 1e-6
13081312
const LSQR_FORCING = 1e-3
13091313

@@ -1852,6 +1856,7 @@ function _abslog2_auglag(sys::SupportSystem{T}, x0;
18521856
nzeroing = 0 # direct zeroings of slack multipliers since `vbest` was set
18531857
nzeroed = 0
18541858
nslow = 0 # consecutive slow updates at the penalty cap
1859+
inexact() = use_lsqr && lsqratol[] > _lsqr_atol(T)
18551860
for _ in 1:maxouter
18561861
lsqratol[] = clamp(T(LSQR_FORCING) * vprev, _lsqr_atol(T), T(LSQR_ATOL_MAX))
18571862
sscale = inv(2 * κcur)
@@ -1879,6 +1884,8 @@ function _abslog2_auglag(sys::SupportSystem{T}, x0;
18791884
x = xt
18801885
drop = (fcur - fnew) / max(fcur, one(T))
18811886
# For exact inner solves, an unchanged active set ends the descent.
1887+
# LSQR solves instead repeat until the objective stops decreasing,
1888+
# which refines the solution of the piece that holds.
18821889
if !use_lsqr && stable
18831890
exit = :stable
18841891
break
@@ -1888,13 +1895,18 @@ function _abslog2_auglag(sys::SupportSystem{T}, x0;
18881895
break
18891896
end
18901897
fcur = fnew
1898+
stable && (lsqratol[] = _lsqr_atol(T))
18911899
end
18921900
push!(exits, exit)
18931901
push!(drops, drop)
18941902
push!(κtrace, κcur)
18951903
v, κdrain = _update_multipliers!(λ, x, κcur, zdrain, supp, symmetric)
18961904
push!(viols, v)
1897-
if v <= vtol
1905+
# Only a stage minimized at full accuracy can be the solution: the KKT
1906+
# residual measures constraint violation, not how well the stage
1907+
# objective was minimized. An inexact stage that meets the test is
1908+
# followed by a stage at the floor tolerance, which `v <= vtol` selects.
1909+
if v <= vtol && !inexact()
18981910
converged = true
18991911
break
19001912
end

‎test/transversal.jl‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ function logproduct_gap(a, b, a2, b2, A)
2828
return g
2929
end
3030

31+
# Jacobian of the Brusselator reaction-diffusion model on a line of `n ÷ 2` grid
32+
# points, linearized at its homogeneous steady state (the Bai/bwm* matrices of the
33+
# SuiteSparse collection): tridiagonal diffusion blocks coupled by diagonal reaction terms.
34+
function brusselator_jacobian(n; δ1=0.008, δ2=0.004, α=2.0, β=5.45, L=0.51302)
35+
N = n ÷ 2
36+
τ1, τ2 = (δ1, δ2) ./ (L / (N + 1))^2
37+
T = spdiagm(-1 => ones(N - 1), 0 => fill(-2.0, N), 1 => ones(N - 1))
38+
return [τ1 * T + (β - 1) * I α^2 * I;
39+
-β * I τ2 * T - α^2 * I]
40+
end
41+
3142
@testset "maximum-product transversal" begin
3243
for (_, A) in general_matrices[1:400]
3344
Af = Float64.(A)
@@ -124,6 +135,19 @@ end
124135
@test iscover(a, b, A)
125136
@test isbalanced(a, b, A)
126137
end
138+
# A cover reported as converged is covariant under a change of units to
139+
# well within the accuracy of the sparse linear solves, including when the
140+
# multiplier iteration meets its tolerance within its first stages.
141+
for n in (200, 400)
142+
J = brusselator_jacobian(n)
143+
d = 2.0 .^ rand(StableRNG(2), -10:10, n)
144+
for f in (cover_transversal, cover_min)
145+
a, b, st = f(J)
146+
ã, b̃, st̃ = f(d .* J)
147+
@test st.converged && st̃.converged
148+
@test logproduct_gap(ã ./ d, b̃, a, b, J) <= 1e-8
149+
end
150+
end
127151

128152
# Entries (i,j) and (k,σ(i)) with j = σ(k) join the same pair of rows, so the
129153
# preconditioner pattern must merge them.

0 commit comments

Comments
 (0)