Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
6d7ab9c
initial commit
mantepse Oct 18, 2022
6149eb2
make the linter happier
mantepse Oct 18, 2022
9d4bfb9
remove useless assignment
mantepse Oct 18, 2022
6ee34e1
make initialisation more efficient
mantepse Oct 18, 2022
1a14bcf
consistently name variable
mantepse Oct 18, 2022
0901ec7
slightly improve documentation
mantepse Oct 19, 2022
c39d653
non-copying intersection, to save memory when there are almost no res…
mantepse Nov 2, 2022
2f0bb0e
Merge branch 'develop' of trac.sagemath.org:sage into t/33238/a_bijec…
mantepse Dec 5, 2022
321ba43
start to cache solutions
mantepse Dec 5, 2022
306395c
finish implementation of cache
mantepse Dec 21, 2022
1a8e564
Merge branch 'develop' of trac.sagemath.org:sage into t/33238/a_bijec…
mantepse Dec 21, 2022
1ac0978
add some documentation and doctests, slightly simplify code
mantepse Dec 21, 2022
47945ac
add missing documentation in table of contents
mantepse Dec 22, 2022
19c3d8f
mark doctests as long, slightly simplify logic
mantepse Dec 22, 2022
eca857e
slightly simplify, more doctests
mantepse Dec 22, 2022
a04d146
doctest _find_counter_example
mantepse Dec 22, 2022
3508426
doctest add_distribution_constraints and add_intertwing_relation_cons…
mantepse Dec 22, 2022
0ac618c
doctest _preprocess_intertwining_relations, _solution, _show_bmilp, _…
mantepse Dec 22, 2022
d50b62c
expand docstring of main class
mantepse Dec 23, 2022
288e391
copy milp instead of adding and removing constraints
mantepse Dec 23, 2022
d57c8e5
derandomize a test, mark example as random
mantepse Dec 23, 2022
7353fb5
correct typo, remove useless assignment
mantepse Dec 23, 2022
db850f0
add and remove constraints instead of copying the whole program
mantepse Dec 23, 2022
ec3271c
fix problem with SCIP, add timings
mantepse Dec 23, 2022
dfdc6ba
use convert for MixedIntegerLinearProgram.get_values
mantepse Dec 24, 2022
d0836cb
include information on MILP also in public documentation
mantepse Dec 25, 2022
563af98
remove unnecessary copy
mantepse Dec 25, 2022
590bae2
add possibility to constrain to involutions
mantepse Dec 26, 2022
da0655b
correct indentation
mantepse Dec 26, 2022
03b1fb8
better handling of empty constraints
mantepse Dec 29, 2022
a3364de
move _show to the _BijectionistMILP class
mantepse Dec 29, 2022
9d83a6c
remove unused code for backends that do not support removing constraints
mantepse Dec 30, 2022
864029d
make _solution a public method of _BijectionistMILP, simplify solve
mantepse Dec 30, 2022
64101a8
eliminate _initialize_new_bmilp
mantepse Dec 30, 2022
2d34911
slightly simplify logic of _forced_constant_blocks, use defaultdict
mantepse Dec 30, 2022
c2f0062
slight simplification
mantepse Dec 30, 2022
78968ae
copy (instead of deepcopy) should be correct
mantepse Dec 31, 2022
6ddaeae
slightly simplify _preprocess_intertwining_relations
mantepse Dec 31, 2022
60286e6
slightly improve non_copying_intersection
mantepse Dec 31, 2022
c38f5b9
add some internal documentation
mantepse Dec 31, 2022
6fb06f0
untangle _preprocess_intertwining_relations
mantepse Jan 2, 2023
706056e
add possibility to require a homomesy
mantepse Jan 2, 2023
d8a0663
Merge branch 'u/mantepse/mixedintegerlinearprogram_add_constraint__re…
mantepse Jan 2, 2023
4e90280
Merge branch 'u/mantepse/allow_to_remove_no_constraints' of trac.sage…
mantepse Jan 2, 2023
65b0c4a
preserve the cache of solutions after computing the optimal constant …
mantepse Jan 2, 2023
21cb54f
make _BijectionistMILP.solution the only entrypoint
mantepse Jan 3, 2023
a573bb4
remove unnecessary calls to list in doctests
mantepse Jan 3, 2023
6868261
move iterator over all solutions to _BijectionistMILP
mantepse Jan 3, 2023
61e97bc
merge _solve, solution and __iter__
mantepse Jan 4, 2023
db8947b
pycodestyle stuff
mantepse Jan 4, 2023
9678717
Merge branch 'develop' of trac.sagemath.org:sage into t/33238/a_bijec…
mantepse Jan 20, 2023
53506aa
rename pseudo_inverse to quadratic
mantepse Jan 20, 2023
d61c630
Merge branch 'u/mantepse/a_bijectionist_s_toolkit' of https://github.…
mantepse Feb 10, 2023
fefe54a
Merge branch 'develop' of github.com:sagemath/sage into develop
mantepse Feb 10, 2023
31bfb69
fix docstrings, simplify some tests
mantepse Feb 11, 2023
24e4084
change lambda to def
mantepse Feb 11, 2023
e7e063d
Merge branch 'develop' into develop
mantepse Feb 13, 2023
dc3009a
reviewer's suggestions
mantepse Feb 13, 2023
a457b99
Merge branch 'develop' of github.com:mantepse/sage into develop
mantepse Feb 13, 2023
6a738b6
Merge branch 'develop' into develop
mantepse Feb 13, 2023
cb2c82a
Merge branch 'develop' into develop
mantepse Feb 20, 2023
109f9e4
Merge branch 'develop' into develop
mantepse Mar 11, 2023
f87c437
sort result of doctest to avoid random failures
mantepse Mar 11, 2023
a72bd65
Merge pull request #1 from mantepse/bijectionist
mantepse Mar 11, 2023
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
Prev Previous commit
Next Next commit
remove unnecessary calls to list in doctests
  • Loading branch information
mantepse committed Jan 3, 2023
commit a573bb4cdb914a689e20eaaa51c43860f1e48a7d
33 changes: 15 additions & 18 deletions src/sage/combinat/bijectionist.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
`(s, wex, fix) \sim (llis, des, adj)`::

sage: N = 3
sage: As = [list(Permutations(n)) for n in range(N+1)]
sage: A = B = sum(As, [])
sage: A = B = [pi for n in range(N+1) for pi in Permutations(n)]
sage: alpha1 = lambda p: len(p.weak_excedences())

This comment was marked as resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I admit I dislike this one, it is longer and harder to read for me. Are you sure?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, although the "proper" way would be

sage: def alpha1(p):
....:     return len(p.weak_excedences())

sage: alpha2 = lambda p: len(p.fixed_points())
sage: beta1 = lambda p: len(p.descents(final_descent=True)) if p else 0
Expand Down Expand Up @@ -106,7 +105,7 @@
+-----------+---+--------+--------+--------+

sage: from sage.combinat.cyclic_sieving_phenomenon import orbit_decomposition
sage: bij.set_constant_blocks(sum([orbit_decomposition(A, rotate_permutation) for A in As], []))
sage: bij.set_constant_blocks(orbit_decomposition(A, rotate_permutation))
sage: bij.constant_blocks()
{{[1, 3, 2], [2, 1, 3], [3, 2, 1]}}
sage: next(bij.solutions_iterator())
Expand All @@ -124,9 +123,9 @@
There is no rotation invariant statistic on non crossing set partitions which is equidistributed
with the Strahler number on ordered trees::

sage: N = 8; As = [[SetPartition(d.to_noncrossing_partition()) for d in DyckWords(n)] for n in range(N)]
sage: A = sum(As, [])
sage: B = sum([list(OrderedTrees(n)) for n in range(1, N+1)], [])
sage: N = 8;
sage: A = [SetPartition(d.to_noncrossing_partition()) for n in range(N) for d in DyckWords(n)]
sage: B = [t for n in range(1, N+1) for t in OrderedTrees(n)]
sage: theta = lambda m: SetPartition([[i % m.size() + 1 for i in b] for b in m])

The following code is equivalent to ``tau = findstat(397)``::
Expand All @@ -144,7 +143,7 @@
sage: bij = Bijectionist(A, B, tau)
sage: bij.set_statistics((lambda a: a.size(), lambda b: b.node_number()-1))
sage: from sage.combinat.cyclic_sieving_phenomenon import orbit_decomposition
sage: bij.set_constant_blocks(sum([orbit_decomposition(A_n, theta) for A_n in As], []))
sage: bij.set_constant_blocks(orbit_decomposition(A, theta))
sage: list(bij.solutions_iterator())
[]

Expand Down Expand Up @@ -279,7 +278,7 @@

Constant blocks::

sage: A = B = list('abcd')
sage: A = B = 'abcd'
sage: pi = lambda p1, p2: 'abcdefgh'[A.index(p1) + A.index(p2)]
sage: rho = lambda s1, s2: (s1 + s2) % 2
sage: bij = Bijectionist(A, B, lambda x: B.index(x) % 2, P=[['a', 'c']], pi_rho=((2, pi, rho),))
Expand Down Expand Up @@ -492,7 +491,7 @@ def __init__(self, A, B, tau=None, alpha_beta=tuple(), P=[],

Check that large input sets are handled well::

sage: A = B = list(range(20000))
sage: A = B = range(20000)
sage: bij = Bijectionist(A, B) # long time
"""
# glossary of standard letters:
Expand Down Expand Up @@ -569,7 +568,7 @@ def set_constant_blocks(self, P):
current partition can be reviewed using
:meth:`constant_blocks`::

sage: A = B = list('abcd')
sage: A = B = 'abcd'
sage: bij = Bijectionist(A, B, lambda x: B.index(x) % 2)
sage: bij.constant_blocks()
{}
Expand Down Expand Up @@ -1766,7 +1765,7 @@ def possible_values(self, p=None, optimal=False):

Test an unfeasible problem::

sage: A = B = list('ab')
sage: A = B = 'ab'
sage: bij = Bijectionist(A, B, lambda x: B.index(x) % 2)
sage: bij.set_constant_blocks([['a', 'b']])
sage: bij.possible_values(p="a")
Expand Down Expand Up @@ -2147,11 +2146,11 @@ def _preprocess_intertwining_relations(self):

.. TODO::

it is not clear, whether this method makes sense
it is not clear whether this method makes sense

EXAMPLES::

sage: A = B = list('abcd')
sage: A = B = 'abcd'
sage: bij = Bijectionist(A, B, lambda x: B.index(x) % 2)
sage: pi = lambda p1, p2: 'abcdefgh'[A.index(p1) + A.index(p2)]
sage: rho = lambda s1, s2: (s1 + s2) % 2
Expand Down Expand Up @@ -2273,7 +2272,7 @@ def solutions_iterator(self):

EXAMPLES::

sage: A = B = list('abc')
sage: A = B = 'abc'
sage: bij = Bijectionist(A, B, lambda x: B.index(x) % 2, solver="GLPK")
sage: next(bij.solutions_iterator())
{'a': 0, 'b': 1, 'c': 0}
Expand Down Expand Up @@ -2362,8 +2361,7 @@ def solutions_iterator(self):
veto: x_0 + x_1 + x_3 + x_4 + x_6 + x_10 + x_14 <= 6
veto: x_0 + x_1 + x_2 + x_5 + x_6 + x_10 + x_14 <= 6

Changing or re-setting problem parameters clears the internal cache and
prints even more information::
Changing or re-setting problem parameters clears the internal cache::

sage: bij.set_constant_blocks(P)
sage: _ = list(bij.solutions_iterator())
Expand Down Expand Up @@ -2519,7 +2517,6 @@ class _BijectionistMILP():
Wrapper class for the MixedIntegerLinearProgram (MILP). This
class is used to manage the MILP, add constraints, solve the
problem and check for uniqueness of solution values.

"""
def __init__(self, bijectionist: Bijectionist, solutions=None):
r"""
Expand Down Expand Up @@ -2987,7 +2984,7 @@ def add_intertwining_relation_constraints(self):

EXAMPLES::

sage: A = B = list('abcd')
sage: A = B = 'abcd'
sage: bij = Bijectionist(A, B, lambda x: B.index(x) % 2)
sage: pi = lambda p1, p2: 'abcdefgh'[A.index(p1) + A.index(p2)]
sage: rho = lambda s1, s2: (s1 + s2) % 2
Expand Down