[Paper Review] Tsnnls: A solver for large sparse least squares problems with non-negative variables
tsnnls is a freely available, high-performance C implementation of the block pivoting algorithm for solving large sparse non-negative least-squares (NNLS) problems. It outperforms MATLAB-based implementations like Matstoms' snnls by up to 10x on sparse matrices and matches the accuracy of MATLAB's lsqnonneg, using optimized sparse Cholesky factorization and LSQR for unconstrained solves.
The solution of large, sparse constrained least-squares problems is a staple in scientific and engineering applications. However, currently available codes for such problems are proprietary or based on MATLAB. We announce a freely available C implementation of the fast block pivoting algorithm of Portugal, Judice, and Vicente. Our version is several times faster than Matstoms' MATLAB implementation of the same algorithm. Further, our code matches the accuracy of MATLAB's built-in lsqnonneg function.
Motivation & Objective
- Address the lack of freely available, high-performance solvers for large sparse non-negative least-squares (NNLS) problems.
- Develop a lightweight, portable C implementation that avoids the overhead of MATLAB or proprietary libraries.
- Achieve superior performance over existing MATLAB-based implementations like snnls while maintaining numerical accuracy.
- Handle numerical degeneracy in sparse problems by zeroing variables near machine precision (≤10⁻¹²).
Proposed method
- Formulate the NNLS problem as a linear complementarity problem (LCP) using the Karush-Kuhn-Tucker (KKT) conditions.
- Apply a modified block principal pivoting algorithm that iteratively exchanges infeasible variables between active and inactive sets.
- Use sparse Cholesky factorization of $A^T A$ to solve the unconstrained subproblems efficiently.
- Employ LSQR as a faster alternative to MATLAB's backslash for solving the unconstrained least-squares subproblems.
- Implement caching to avoid redundant matrix multiplications during pivot updates.
- Apply a numerical stabilization strategy by setting variables in the solution below $10^{-12}$ to zero to prevent cycling in degenerate cases.
Experimental results
Research questions
- RQ1Can a freely available, C-based implementation of the block pivoting algorithm for NNLS outperform MATLAB-based implementations in speed and scalability?
- RQ2How does the performance of tsnnls compare to snnls and MATLAB’s lsqnonneg on large sparse and dense matrices?
- RQ3What is the impact of using LSQR versus MATLAB’s backslash for solving unconstrained subproblems in the algorithm?
- RQ4How effective is the $10^{-12}$ threshold strategy in preventing numerical cycling in degenerate problems?
- RQ5Why does tsnnls show a disproportionately larger speedup on sparse matrices despite similar pivot counts?
Key findings
- tsnnls is up to 10 times faster than snnls on sparse matrices of density 0.01, with a constant of proportionality that decreases with sparsity.
- For dense matrices, tsnnls is several times faster than snnls due to optimized caching that eliminates redundant matrix multiplications.
- The final unconstrained solve step consumes only 5% of total runtime in tsnnls (using LSQR), compared to nearly 50% in snnls (using MATLAB’s backslash).
- tsnnls matches the accuracy of MATLAB’s built-in lsqnonneg function, which is significantly slower and unsuitable for large problems.
- On a 500×490 dense matrix, lsqnonneg took over 100 seconds, while both tsnnls and snnls completed in under one second.
- The performance advantage of tsnnls on sparse problems is primarily due to the efficient use of LSQR, not pivot count differences, as pivot counts remained stable across densities.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.