Skip to content

Bisc labelled perms - #209

Open
ulfarsson wants to merge 4 commits into
developfrom
bisc-labelled-perms
Open

ulfarsson wants to merge 4 commits into
developfrom
bisc-labelled-perms

Conversation

@ulfarsson

Copy link
Copy Markdown
Member

Allows using a bitmap instead of a list of perms as input to BiSC, to save memory.

ulfarsson and others added 3 commits October 18, 2026 18:45
With a property as input, auto_bisc keeps every good and every bad
permutation up to its current length as lists of Perm objects. At length
10 the bad ones are nearly all of S_10, about 0.9 GB as a list, and runs
on sets that need length 10 grew past 8 GB.

LabelledPerms keeps the labels as one bitmap per length, in the order of
Perm.of_length (S_10 is 454 KB), made from a property, given as bitmaps,
or both. Its views good and bad stand in for auto_bisc's dictionaries of
lists: auto_bisc only iterates over a length, counts it, and asks whether
it is there, and the views do that from the bitmaps, generating a
length's permutations again when it is read, in the same order.

- auto_bisc(LabelledPerms(...)) and bisc(LabelledPerms(...)) are new
  inputs; with given bitmaps and no property, auto_bisc stops when it
  needs a length it was not given, as for a tuple of dictionaries.
- auto_bisc(prop, labels="bitmaps") wraps a property in LabelledPerms;
  labels="lists", the default, is the previous behaviour, unchanged.

The existing inputs are untouched. On stack-sortable and West-2-stack-
sortable permutations every route gives the same basis as before
(tests/bisc/test_labelled_perms.py); auto_bisc's printed output is also
identical on Av(231), Av(321), Av(2-31) and Av(132, 4321).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When auto_bisc needs a length it was not given, a LabelledPerms with a
property labels it, and one with bitmaps alone stops. Derangements in
Av(213, 231, 312), with one member at each even length, reach that step in
a fraction of a second: with bitmaps up to length 8 and no property
auto_bisc stops and says so; with a property, stopped at the first
permutation of length 9, the lists and the bitmaps have printed the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The README's BiSC section starts with `from permuta.bisc import *`, which
did not bring in LabelledPerms. It is now exported, and the section says
that bisc and auto_bisc also accept a LabelledPerms, and how auto_bisc's
labels="bitmaps" keeps a property's labels in less memory, with an example
that runs as a doctest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ulfarsson
ulfarsson requested a review from jaypantone October 18, 2026 19:44
Bit i of length n is the label of Perm.unrank(i, n), so a permutation of
length n is at its rank() less the number of shorter permutations. This is
the order Perm.of_length(n) yields, which the views still use to iterate:
it is the same order and about three times faster than unranking each
index. A test pins the order to Perm.unrank and Perm.rank.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant