Skip to content

Improve the performance of cover_transversal - #96

Merged
timholy merged 2 commits into
mainfrom
teh/maxbalance-parametric
Oct 24, 2026
Merged

timholy merged 2 commits into
mainfrom
teh/maxbalance-parametric

Conversation

@timholy

@timholy timholy commented Oct 24, 2026

Copy link
Copy Markdown
Member

Improves cover_transversal(ϕ::PowerMean{p}, A; kwargs...) with both maxbalance=true and false.

Replace the policy iteration in _maxbalance, which found one cycle per
pass, with the minimum-balance algorithm of Young, Tarjan & Orlin
(1991), adapted to maximum cycle means by reversing signs. The algorithm
maintains a shortest-path tree for arc lengths λ - w as λ decreases,
keeps the non-tree arcs in an indexed heap keyed by the λ at which each
becomes tight, and contracts each zero-length cycle in place. Each time
an arc becomes tight, the work is proportional to the size of the
subtrees whose depths change, so the total is near-linear for most
sparse blocks and at most O(nm + n² log n).

_howard! and its tie tolerance are removed. The shifts agree with the
previous implementation to roundoff.

Assisted-by: Claude Fable 5.1 <noreply@anthropic.com>
Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
_laplacian_solve! gains rtol and refine keywords. _balanced_direction!
now solves its conjugate-gradient systems to a relative residual of
1e-4 and skips iterative refinement. The Newton direction does not need
to be accurate: every CG iterate started from zero is a descent
direction, and the reduced gradient is recomputed at each step. The
defaults keep the refinement, which the AbsLog{2} minimal-cover solver
needs to certify its KKT conditions.

_balanced_factor! also records the order and number of nonzeros of the
last pattern whose Cholesky factor exceeded the fill or flop budget.
While later patterns stay more than half that size in both, it skips
the CHOLMOD symbolic analysis and goes straight to CG; the fallback
factorization is analyzed only if CG fails.

For cover_transversal(PowerMean{2}(), A; target=1e-2) on a random
sparse 16000×16000 matrix with five entries per row, the run time
drops from 90 s to 11 s.

Assisted-by: Claude Fable 5.1 <noreply@anthropic.com>
Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.93993% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.71%. Comparing base (d38a2c7) to head (0be88ea).

Files with missing lines Patch % Lines
src/active_set.jl 88.23% 2 Missing ⚠️
src/maxbalance.jl 99.61% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #96      +/-   ##
==========================================
- Coverage   98.71%   98.71%   -0.01%     
==========================================
  Files          25       25              
  Lines        7093     7240     +147     
==========================================
+ Hits         7002     7147     +145     
- Misses         91       93       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@timholy
timholy merged commit b8c4ec4 into main Oct 24, 2026
7 checks passed
@timholy
timholy deleted the teh/maxbalance-parametric branch October 24, 2026 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant