You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
CVXPY always converts a large, sparse PSD matrix (by construction) to a dense array. I identified the problem with sparsity checking code. It checks if a wrapped Expression
To Reproduce
importscipyasspfromcvxpy.atoms.affine.wrapsimportpsd_wrapfromcvxpy.utilities.linalgimportsparse_cholesky, sparfromcvxpy.expressions.expressionimportExpressionM=sp.sparse.diags(np.ones(10))
wrapped_M=Expression.cast_to_const(M) # as in first line of quad_formtype(wrapped_M) # <class 'cvxpy.expressions.constants.constant.Constant'>, not spmatrixsign, L, p=sparse_cholesky(wrapped_M) # failssign, L, p=sparse_cholesky(psd_wrap(wrapped_M)) # assume_PSD = True, fails
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
[<ipython-input-58-4708dd35074b>](https://localhost:8080/#) in <cell line: 0>()
7 wrapped_M = Expression.cast_to_const(M) # as in first line of quad_form
8 type(wrapped_M) # <class 'cvxpy.expressions.constants.constant.Constant'>, not spmatrix
----> 9 sign, L, p = sparse_cholesky(wrapped_M) # fails
10 sign, L, p = sparse_cholesky(psd_wrap(wrapped_M)) # assume_PSD = True, fails
[/usr/local/lib/python3.11/dist-packages/cvxpy/utilities/linalg.py](https://localhost:8080/#) in sparse_cholesky(A, sym_tol, assume_posdef)
207
208 if not isinstance(A, spar.spmatrix):
--> 209 raise ValueError(SparseCholeskyMessages.NOT_SPARSE)
210 if np.iscomplexobj(A):
211 raise ValueError(SparseCholeskyMessages.NOT_REAL)
ValueError: Input must be a SciPy sparse matrix.
Version
OS: Linux (Google Colab)
CVXPY Version: 1.6.0
Additional context
The text was updated successfully, but these errors were encountered:
oh nvm I think I see what you mean. In quad_form there is a try_catch that turns P into a dense array if sparse_cholesky raised a ValueError. But the snippet above shows that this value error is always being raised because P is a cvxpy Constant.
Describe the bug
CVXPY always converts a large, sparse PSD matrix (by construction) to a dense array. I identified the problem with sparsity checking code. It checks if a wrapped Expression
To Reproduce
Expected behavior
Identifies sparse matrices, Performs sparse cholesky
Output
Version
Additional context
The text was updated successfully, but these errors were encountered: