feat: Improve memory performance for derangement#244
Open
limakzi wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the magma derangement-induction check to reduce peak memory usage by avoiding construction of the full set of partitions at once, instead iterating over partitions grouped by number of blocks.
Changes:
- Refactors
IsLeftDerangementInductedto iteratek = 1..Size(M)and callPartitionsSet(Elements(M), k)perk(rather thanPartitionsSet(Elements(M))). - Minor formatting-only change at the end of
DigraphOfDiagonal.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+265
to
+268
| ForAny(PartitionsSet(Elements(M), k), p -> | ||
| ForAny(Derangements(p), d -> | ||
| ForAll([1 .. Size(p)], i -> | ||
| ForAll(p[i], m -> IsSubset(d[i], Unique(m * Elements(M)))))))); |
Collaborator
Author
There was a problem hiding this comment.
@copilot apply changes based on this feedback
Contributor
There was a problem hiding this comment.
Done in commit 696b2d7. Elements(M) is now stored in a local variable elms before the loops, so it is computed only once and reused in both PartitionsSet(elms, k) and Unique(m * elms).
Agent-Logs-Url: https://github.com/gap-packages/smallantimagmas/sessions/de5b0389-33cc-45a6-90c3-a2a1d1e68912 Co-authored-by: limakzi <50334623+limakzi@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.