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

Sparsification of Affine Equality Matrix #1625

Draft
wants to merge 255 commits into
base: master
Choose a base branch
from

Conversation

GollokG
Copy link

@GollokG GollokG commented Nov 5, 2024

This pull request contributes a sparsification of the AffineEqualityMatrix (affeq) and is based on the domain of @MartinWehking from this PR.

Following restructuring of the modules is introduced:

We added a second AffineEqualityDomain which exploits the sparsity of the affine equality matrices based on this observation by @DrMichaelPetter. A SparseMatrixFunctor and SparseVectorFunctor (as well as ArrayMatrixFunctor and ArrayVectorFunctor) were added for this purpose and replaced the general AbstractMatrix and AbstractVector. The AffineEqualityDomain is now implemented without relying on side effects.

The old AffineEqualityDomain using arrays was renamed to AffineEqualityDomainSideEffects which uses ArrayMatrixFunctor and ArrayVectorFunctor.
No new analysis was added to switch between versions. A description for how to switch between both implementations is provided in the affineEqualityAnalysis file.

The implementation of sparse matrix works as follows:

The sparse matrix is implemented in the ListMatrix module. Its type t is a list of sparseVectors representing the matrix' rows. sparseVector is implemented as an ordered list of tuples (index, value) for all non-zero entries.
Some functions are implemented for zero-preserving functions only. A function is zero-preserving iff it has a fixpoint at zero. These functions are implemented to gain performance when being used on sparseVectors.

This implementation is part of an assignment for the course Automated Bug Hunting and Beyond at TUM in the winter term 2024/25.

Co-authored-by: Michael Schwarz <[email protected]>
in
Matrix.remove_row (multiply_by_t a a_r) r, Matrix.remove_row (multiply_by_t b b_r) r, (max - 1)
)
in
let col_a, col_b = Matrix.get_col a s, Matrix.get_col b s in
let col_a, col_b = Matrix.get_col_upper_triangular a s, Matrix.get_col_upper_triangular b s in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given, that you could change the get_col.. . function to return not only the column, but also the last (idx,val) that is not zero, I think that you could get rid of a lot of calls to nth as well as rev. Especially in case_three.

Copy link
Collaborator

@DrMichaelPetter DrMichaelPetter Jan 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The more I think about case three, the more I am convinced, that you do not even necessarily have to choose the column element with the largest row index - you might as well choose the one with the smallest index. That would be easy to change, and make case three considerably more easy to implement efficiently.

Although this is valid in terms of computing the disjunction, we lose rref, if we do not choose the largest index.

@jerhard
Copy link
Member

jerhard commented Feb 3, 2025

Thanks for the PR. @GollokG To document this PR better for people who may look at it in the future , could you please add a few sentences in your top post to elaborate on your approach and what you have changed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature in progress performance Analysis time, memory usage practical-course Practical Course at TUM student-job
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Affine Equalities Mostly Contain Only Small Portions of Actual Information
8 participants