Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select output type of sparsity pattern #14

Open
Vaibhavdixit02 opened this issue Apr 10, 2024 · 4 comments
Open

Select output type of sparsity pattern #14

Vaibhavdixit02 opened this issue Apr 10, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@Vaibhavdixit02
Copy link

I am not 100% sure this would make sense, thinking out loud here - in some scenarios, for example 10*10 hessian, instead of always returning the sparse form of the pattern having a more structured like diagonal, banded, triangular etc etc matrix would lend itself to nice uses downstream like one could check for such a structure and utilize it in algorithms. Looking at the code it seemed doable since the indices are collected before the sparse matrix is assembled

@adrhill
Copy link
Owner

adrhill commented Apr 10, 2024

Looking at the code it seemed doable since the indices are collected before the sparse matrix is assembled

Indeed, connectivity is just a thin abstraction layer for book-keeping that iterates over the output and writes input indices into a data structure (currently a sparse matrix).

Do you have a problem in mind in which you expect the Jacobian to have a specific structure? It would be easy to add more wrappers like connectivity.
We could also define a bring-your-own-buffer version of connectivity and dispatch on the provided data structure.

I have an idea for a second-order Tracer for sparsity detection in Hessians, which will return a sparse symmetric matrix.

@Vaibhavdixit02
Copy link
Author

Do you have a problem in mind in which you expect the Jacobian to have a specific structure? It would be easy to add more wrappers like connectivity.

Control problems sometimes have pretty nice banded structures - I am starting a class project where I plan to leverage it I will follow up with more concrete details once I start putting together code for that 😅

@adrhill
Copy link
Owner

adrhill commented Apr 25, 2024

It might also be useful to select whether a sparse CSC or CSR matrix should be returned.
CC @gdalle

@gdalle
Copy link
Collaborator

gdalle commented Apr 25, 2024

Indeed, and it would really make sense and simplify my job a lot if I could assume that the sparsity pattern and the jacobian have the same structure and type, sparse or otherwise. Typically I wanna do

jac = similar(sparsity, eltype(x))

and I don't want e.g. one to be tridiagonal and the other one sparse, even if they represent the same pattern

@adrhill adrhill changed the title Output structured matrices for smaller systems instead of sparse matrix? Select output type of pattern Apr 25, 2024
@adrhill adrhill added the enhancement New feature or request label Apr 25, 2024
@adrhill adrhill changed the title Select output type of pattern Select output type of sparsity pattern Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants