Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions src/minimal_covers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1300,10 +1300,14 @@ const LSQR_FILL_BUDGET = 1 << 30
# LSQR iterations of spanning-forest preconditioning.
const LSQR_FLOP_BUDGET = 8.0e3

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

Expand Down Expand Up @@ -1852,6 +1856,7 @@ function _abslog2_auglag(sys::SupportSystem{T}, x0;
nzeroing = 0 # direct zeroings of slack multipliers since `vbest` was set
nzeroed = 0
nslow = 0 # consecutive slow updates at the penalty cap
inexact() = use_lsqr && lsqratol[] > _lsqr_atol(T)
for _ in 1:maxouter
lsqratol[] = clamp(T(LSQR_FORCING) * vprev, _lsqr_atol(T), T(LSQR_ATOL_MAX))
sscale = inv(2 * κcur)
Expand Down Expand Up @@ -1879,6 +1884,8 @@ function _abslog2_auglag(sys::SupportSystem{T}, x0;
x = xt
drop = (fcur - fnew) / max(fcur, one(T))
# For exact inner solves, an unchanged active set ends the descent.
# LSQR solves instead repeat until the objective stops decreasing,
# which refines the solution of the piece that holds.
if !use_lsqr && stable
exit = :stable
break
Expand All @@ -1888,13 +1895,18 @@ function _abslog2_auglag(sys::SupportSystem{T}, x0;
break
end
fcur = fnew
stable && (lsqratol[] = _lsqr_atol(T))
end
push!(exits, exit)
push!(drops, drop)
push!(κtrace, κcur)
v, κdrain = _update_multipliers!(λ, x, κcur, zdrain, supp, symmetric)
push!(viols, v)
if v <= vtol
# Only a stage minimized at full accuracy can be the solution: the KKT
# residual measures constraint violation, not how well the stage
# objective was minimized. An inexact stage that meets the test is
# followed by a stage at the floor tolerance, which `v <= vtol` selects.
if v <= vtol && !inexact()
converged = true
break
end
Expand Down
24 changes: 24 additions & 0 deletions test/transversal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ function logproduct_gap(a, b, a2, b2, A)
return g
end

# Jacobian of the Brusselator reaction-diffusion model on a line of `n ÷ 2` grid
# points, linearized at its homogeneous steady state (the Bai/bwm* matrices of the
# SuiteSparse collection): tridiagonal diffusion blocks coupled by diagonal reaction terms.
function brusselator_jacobian(n; δ1=0.008, δ2=0.004, α=2.0, β=5.45, L=0.51302)
N = n ÷ 2
τ1, τ2 = (δ1, δ2) ./ (L / (N + 1))^2
T = spdiagm(-1 => ones(N - 1), 0 => fill(-2.0, N), 1 => ones(N - 1))
return [τ1 * T + (β - 1) * I α^2 * I;
-β * I τ2 * T - α^2 * I]
end

@testset "maximum-product transversal" begin
for (_, A) in general_matrices[1:400]
Af = Float64.(A)
Expand Down Expand Up @@ -124,6 +135,19 @@ end
@test iscover(a, b, A)
@test isbalanced(a, b, A)
end
# A cover reported as converged is covariant under a change of units to
# well within the accuracy of the sparse linear solves, including when the
# multiplier iteration meets its tolerance within its first stages.
for n in (200, 400)
J = brusselator_jacobian(n)
d = 2.0 .^ rand(StableRNG(2), -10:10, n)
for f in (cover_transversal, cover_min)
a, b, st = f(J)
ã, b̃, st̃ = f(d .* J)
@test st.converged && st̃.converged
@test logproduct_gap(ã ./ d, b̃, a, b, J) <= 1e-8
end
end

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