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

expand and explain doctest of _preprocess_intertwining_relations #39310

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions src/sage/combinat/bijectionist.py
Original file line number Diff line number Diff line change
Expand Up @@ -2124,11 +2124,6 @@
In particular, if `P` consists only if singletons, this
method has no effect.

.. TODO::

create one test with one and one test with two
intertwining relations

.. TODO::

it is not clear whether this method makes sense
Expand All @@ -2144,6 +2139,17 @@
sage: bij._P
{{'a'}, {'b'}, {'c'}, {'d'}}

However, adding that ``'a'`` and ``'c'`` are in the same block,
we can infer that also ``'b'`` and ``'d'`` are in the same
block::

sage: bij.set_constant_blocks([['a', 'c']])
sage: bij._P
{{'a', 'c'}, {'b'}, {'d'}}
sage: bij._preprocess_intertwining_relations()
sage: bij._P
{{'a', 'c'}, {'b', 'd'}}

Let a group act on permutations::

sage: A = B = Permutations(3)
Expand All @@ -2152,6 +2158,11 @@
sage: bij._preprocess_intertwining_relations()
sage: bij._P
{{[1, 2, 3]}, {[1, 3, 2]}, {[2, 1, 3]}, {[2, 3, 1]}, {[3, 1, 2]}, {[3, 2, 1]}}

Thus, in this case we do not detect the constant blocks::

sage: bij.constant_blocks(optimal=True)
{{[1, 2, 3], [3, 2, 1]}, {[1, 3, 2], [2, 3, 1]}, {[2, 1, 3], [3, 1, 2]}}
"""
A = self._A
P = self._P
Expand Down Expand Up @@ -3119,7 +3130,7 @@
sage: bij = Bijectionist(sum(As, []), sum(Bs, []))
sage: bij.set_statistics((lambda x: x[0], lambda x: x[0]))
sage: bij.set_intertwining_relations((2, c1, c1), (1, c2, c2))
sage: l = list(bij.solutions_iterator()); len(l) # long time -- (2.7 seconds with SCIP on AMD Ryzen 5 PRO 3500U w/ Radeon Vega Mobile Gfx)

Check warning on line 3133 in src/sage/combinat/bijectionist.py

View workflow job for this annotation

GitHub Actions / test-long (src/sage/[a-f]*)

Warning: slow doctest:

slow doctest:
64

A brute force check would be difficult::
Expand Down Expand Up @@ -3147,7 +3158,7 @@
sage: A = sum(As, [])
sage: respects_c1 = lambda s: all(c1(a1, a2) not in A or s[c1(a1, a2)] == c1(s[a1], s[a2]) for a1 in A for a2 in A)
sage: respects_c2 = lambda s: all(c2(a1) not in A or s[c2(a1)] == c2(s[a1]) for a1 in A)
sage: l2 = [s for s in it if respects_c1(s) and respects_c2(s)] # long time -- (17 seconds on AMD Ryzen 5 PRO 3500U w/ Radeon Vega Mobile Gfx)

Check warning on line 3161 in src/sage/combinat/bijectionist.py

View workflow job for this annotation

GitHub Actions / test-long (src/sage/[a-f]*)

Warning: slow doctest:

slow doctest:
sage: sorted(l1, key=lambda s: tuple(s.items())) == l2 # long time
True

Expand Down
Loading