Skip to content

feat: Improve memory performance for derangement#244

Open
limakzi wants to merge 2 commits into
mainfrom
feature/change-partitions-set-to-any
Open

feat: Improve memory performance for derangement#244
limakzi wants to merge 2 commits into
mainfrom
feature/change-partitions-set-to-any

Conversation

@limakzi
Copy link
Copy Markdown
Collaborator

@limakzi limakzi commented May 4, 2026

No description provided.

Copilot AI review requested due to automatic review settings May 4, 2026 15:13
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 IsLeftDerangementInducted to iterate k = 1..Size(M) and call PartitionsSet(Elements(M), k) per k (rather than PartitionsSet(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 thread lib/properties.gi
Comment thread lib/properties.gi Outdated
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))))))));
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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).

Copilot finished work on behalf of limakzi May 4, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants