Implementation of blossoming trees for their bijection with Tamari intervals#41416
Implementation of blossoming trees for their bijection with Tamari intervals#41416vbraun merged 51 commits intosagemath:developfrom
Conversation
|
Salut. Tu m'autorises à faire un commit pour reparer le linter ? |
Bien sûr ! Je n'arrive pas à régler le problème en tout cas... Est-ce qu'il y a une manip que je dois faire ? J'ai déjà croché "Allowing edits by maintainers". |
|
ok, je m'en occupe |
|
Documentation preview for this PR (built with commit 1d6435b; changes) is ready! 🎉 |
I changed a few small things, in the doc.
forgot one fix
|
voila, le linter est réparé, je te repasse la main |
|
il faudrait ajouter ton nouveau fichier quelque part dans la liste dans |
|
Il y a maintenant la structure |
|
pas une bonne idee du tout de tripatouiller le fichier all.py ; ca rend les changements penibles à lire .... OK, pardon, tu as fais un roll-back, c'est correct |
fchapoton
left a comment
There was a problem hiding this comment.
looks good enough. Let's move this in
sagemathgh-41416: Implementation of blossoming trees for their bijection with Tamari intervals <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> This is an implementation of the bijection between blossoming trees and Tamari intervals in the following paper: Wenjie Fang, Éric Fusy, Philippe Nadeau, "Tamari intervals and blossoming trees". Combinatorial Theory, Volume 5, Issue 1. doi `10.5070/C65165015`. It is the implementation mentioned in the paper, but with additional "Sage-compliant" comments and tests, along with some small restructuring. More precisely, we provide four new classes. - `TamariBlossomingTree`: main class that implements blossoming trees and their bijection with Tamari intervals, along with plots and conversion to other Sage objects. - `TamariBlossomingTreeFactory`: a linear-time random generator of Tamari blossoming tree. - `SynchronizedBlossomingTreeFactory`: a linear-time random generator of synchronized blossoming trees, which are in bijection with synchronized Tamari intervals. - `ModernBlossomingTreeFactory`: a linear-time random generator of modern blossoming trees, which are in bijection with modern Tamari intervals. This implementation will allow users to explore Tamari intervals more easily with our bijection. Most notably, these classes now enables an efficient random generation of large (general, synchronized or modern) Tamari intervals, linear in the size of generated objects. Such generator exists for general Tamari intervals in TamariIntervalPosets, but it goes through triangulations, thus is much slower and more complicated. Here is a comparison of timing: ``` sage: TIP = TamariIntervalPosets(1000) sage: %time tip = TIP.random_element() CPU times: user 5.13 s, sys: 15 ms, total: 5.14 s Wall time: 5.14 s sage: TBTF = TamariBlossomingTreeFactory(1000) sage: %time B = TBTF.random_element() CPU times: user 118 ms, sys: 2.99 ms, total: 121 ms Wall time: 120 ms ``` The random generation of synchronized and modern Tamari intervals is new. As I am not familiar with the internal structure of Sagemath, these classes were written more like an external module. Advises and help for a restructuring are welcomed. Notably, I did not implement a class for the set of blossoming trees like those for other combinatorial objects. The reason is two-fold: 1. I am not familiar with the internal working of Sagemath, notably metaclasses, Parent and Element, and the documentation seems to be quite complicated. 2. I do not intend to provide exhaustive generation, which is less efficient (not linear but quadratic in object size per object). I may have changed a bit the idea for the second point, as when I look at the exhaustive generation code in the iterator of ``TamariIntervalPosets_size``, its complexity is not clear. It is not linear, but not clear whether quadratic per object. There is a possibility that the class ``IntegerListsLex`` may provide an efficient exhaustive generation of related lattice paths to make our bijection more efficient for exhaustive generation. Thanks @fchapoton for suggesting adapting my original implementation to Sagemath. By the way, I have not checked whether the documentation shows up correctly in the references, because ``sage --docbuild reference html`` fails with the error ``` Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/home/fwjmath/svn/sage/src/sage_docbuild/__main__.py", line 545, in <module> sys.exit(main()) ^^^^^^ File "/home/fwjmath/svn/sage/src/sage_docbuild/__main__.py", line 540, in main build = getattr(builder, typ) ^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'ReferenceBuilder' object has no attribute 'html' ``` ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [X] The title is concise and informative. - [X] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [X] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. URL: sagemath#41416 Reported by: fwjmath Reviewer(s): Frédéric Chapoton, fwjmath
sagemathgh-41416: Implementation of blossoming trees for their bijection with Tamari intervals <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> This is an implementation of the bijection between blossoming trees and Tamari intervals in the following paper: Wenjie Fang, Éric Fusy, Philippe Nadeau, "Tamari intervals and blossoming trees". Combinatorial Theory, Volume 5, Issue 1. doi `10.5070/C65165015`. It is the implementation mentioned in the paper, but with additional "Sage-compliant" comments and tests, along with some small restructuring. More precisely, we provide four new classes. - `TamariBlossomingTree`: main class that implements blossoming trees and their bijection with Tamari intervals, along with plots and conversion to other Sage objects. - `TamariBlossomingTreeFactory`: a linear-time random generator of Tamari blossoming tree. - `SynchronizedBlossomingTreeFactory`: a linear-time random generator of synchronized blossoming trees, which are in bijection with synchronized Tamari intervals. - `ModernBlossomingTreeFactory`: a linear-time random generator of modern blossoming trees, which are in bijection with modern Tamari intervals. This implementation will allow users to explore Tamari intervals more easily with our bijection. Most notably, these classes now enables an efficient random generation of large (general, synchronized or modern) Tamari intervals, linear in the size of generated objects. Such generator exists for general Tamari intervals in TamariIntervalPosets, but it goes through triangulations, thus is much slower and more complicated. Here is a comparison of timing: ``` sage: TIP = TamariIntervalPosets(1000) sage: %time tip = TIP.random_element() CPU times: user 5.13 s, sys: 15 ms, total: 5.14 s Wall time: 5.14 s sage: TBTF = TamariBlossomingTreeFactory(1000) sage: %time B = TBTF.random_element() CPU times: user 118 ms, sys: 2.99 ms, total: 121 ms Wall time: 120 ms ``` The random generation of synchronized and modern Tamari intervals is new. As I am not familiar with the internal structure of Sagemath, these classes were written more like an external module. Advises and help for a restructuring are welcomed. Notably, I did not implement a class for the set of blossoming trees like those for other combinatorial objects. The reason is two-fold: 1. I am not familiar with the internal working of Sagemath, notably metaclasses, Parent and Element, and the documentation seems to be quite complicated. 2. I do not intend to provide exhaustive generation, which is less efficient (not linear but quadratic in object size per object). I may have changed a bit the idea for the second point, as when I look at the exhaustive generation code in the iterator of ``TamariIntervalPosets_size``, its complexity is not clear. It is not linear, but not clear whether quadratic per object. There is a possibility that the class ``IntegerListsLex`` may provide an efficient exhaustive generation of related lattice paths to make our bijection more efficient for exhaustive generation. Thanks @fchapoton for suggesting adapting my original implementation to Sagemath. By the way, I have not checked whether the documentation shows up correctly in the references, because ``sage --docbuild reference html`` fails with the error ``` Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/home/fwjmath/svn/sage/src/sage_docbuild/__main__.py", line 545, in <module> sys.exit(main()) ^^^^^^ File "/home/fwjmath/svn/sage/src/sage_docbuild/__main__.py", line 540, in main build = getattr(builder, typ) ^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'ReferenceBuilder' object has no attribute 'html' ``` ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [X] The title is concise and informative. - [X] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [X] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. URL: sagemath#41416 Reported by: fwjmath Reviewer(s): Frédéric Chapoton, fwjmath
sagemathgh-41416: Implementation of blossoming trees for their bijection with Tamari intervals <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> This is an implementation of the bijection between blossoming trees and Tamari intervals in the following paper: Wenjie Fang, Éric Fusy, Philippe Nadeau, "Tamari intervals and blossoming trees". Combinatorial Theory, Volume 5, Issue 1. doi `10.5070/C65165015`. It is the implementation mentioned in the paper, but with additional "Sage-compliant" comments and tests, along with some small restructuring. More precisely, we provide four new classes. - `TamariBlossomingTree`: main class that implements blossoming trees and their bijection with Tamari intervals, along with plots and conversion to other Sage objects. - `TamariBlossomingTreeFactory`: a linear-time random generator of Tamari blossoming tree. - `SynchronizedBlossomingTreeFactory`: a linear-time random generator of synchronized blossoming trees, which are in bijection with synchronized Tamari intervals. - `ModernBlossomingTreeFactory`: a linear-time random generator of modern blossoming trees, which are in bijection with modern Tamari intervals. This implementation will allow users to explore Tamari intervals more easily with our bijection. Most notably, these classes now enables an efficient random generation of large (general, synchronized or modern) Tamari intervals, linear in the size of generated objects. Such generator exists for general Tamari intervals in TamariIntervalPosets, but it goes through triangulations, thus is much slower and more complicated. Here is a comparison of timing: ``` sage: TIP = TamariIntervalPosets(1000) sage: %time tip = TIP.random_element() CPU times: user 5.13 s, sys: 15 ms, total: 5.14 s Wall time: 5.14 s sage: TBTF = TamariBlossomingTreeFactory(1000) sage: %time B = TBTF.random_element() CPU times: user 118 ms, sys: 2.99 ms, total: 121 ms Wall time: 120 ms ``` The random generation of synchronized and modern Tamari intervals is new. As I am not familiar with the internal structure of Sagemath, these classes were written more like an external module. Advises and help for a restructuring are welcomed. Notably, I did not implement a class for the set of blossoming trees like those for other combinatorial objects. The reason is two-fold: 1. I am not familiar with the internal working of Sagemath, notably metaclasses, Parent and Element, and the documentation seems to be quite complicated. 2. I do not intend to provide exhaustive generation, which is less efficient (not linear but quadratic in object size per object). I may have changed a bit the idea for the second point, as when I look at the exhaustive generation code in the iterator of ``TamariIntervalPosets_size``, its complexity is not clear. It is not linear, but not clear whether quadratic per object. There is a possibility that the class ``IntegerListsLex`` may provide an efficient exhaustive generation of related lattice paths to make our bijection more efficient for exhaustive generation. Thanks @fchapoton for suggesting adapting my original implementation to Sagemath. By the way, I have not checked whether the documentation shows up correctly in the references, because ``sage --docbuild reference html`` fails with the error ``` Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/home/fwjmath/svn/sage/src/sage_docbuild/__main__.py", line 545, in <module> sys.exit(main()) ^^^^^^ File "/home/fwjmath/svn/sage/src/sage_docbuild/__main__.py", line 540, in main build = getattr(builder, typ) ^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'ReferenceBuilder' object has no attribute 'html' ``` ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [X] The title is concise and informative. - [X] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [X] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. URL: sagemath#41416 Reported by: fwjmath Reviewer(s): Frédéric Chapoton, fwjmath
sagemathgh-41416: Implementation of blossoming trees for their bijection with Tamari intervals <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> This is an implementation of the bijection between blossoming trees and Tamari intervals in the following paper: Wenjie Fang, Éric Fusy, Philippe Nadeau, "Tamari intervals and blossoming trees". Combinatorial Theory, Volume 5, Issue 1. doi `10.5070/C65165015`. It is the implementation mentioned in the paper, but with additional "Sage-compliant" comments and tests, along with some small restructuring. More precisely, we provide four new classes. - `TamariBlossomingTree`: main class that implements blossoming trees and their bijection with Tamari intervals, along with plots and conversion to other Sage objects. - `TamariBlossomingTreeFactory`: a linear-time random generator of Tamari blossoming tree. - `SynchronizedBlossomingTreeFactory`: a linear-time random generator of synchronized blossoming trees, which are in bijection with synchronized Tamari intervals. - `ModernBlossomingTreeFactory`: a linear-time random generator of modern blossoming trees, which are in bijection with modern Tamari intervals. This implementation will allow users to explore Tamari intervals more easily with our bijection. Most notably, these classes now enables an efficient random generation of large (general, synchronized or modern) Tamari intervals, linear in the size of generated objects. Such generator exists for general Tamari intervals in TamariIntervalPosets, but it goes through triangulations, thus is much slower and more complicated. Here is a comparison of timing: ``` sage: TIP = TamariIntervalPosets(1000) sage: %time tip = TIP.random_element() CPU times: user 5.13 s, sys: 15 ms, total: 5.14 s Wall time: 5.14 s sage: TBTF = TamariBlossomingTreeFactory(1000) sage: %time B = TBTF.random_element() CPU times: user 118 ms, sys: 2.99 ms, total: 121 ms Wall time: 120 ms ``` The random generation of synchronized and modern Tamari intervals is new. As I am not familiar with the internal structure of Sagemath, these classes were written more like an external module. Advises and help for a restructuring are welcomed. Notably, I did not implement a class for the set of blossoming trees like those for other combinatorial objects. The reason is two-fold: 1. I am not familiar with the internal working of Sagemath, notably metaclasses, Parent and Element, and the documentation seems to be quite complicated. 2. I do not intend to provide exhaustive generation, which is less efficient (not linear but quadratic in object size per object). I may have changed a bit the idea for the second point, as when I look at the exhaustive generation code in the iterator of ``TamariIntervalPosets_size``, its complexity is not clear. It is not linear, but not clear whether quadratic per object. There is a possibility that the class ``IntegerListsLex`` may provide an efficient exhaustive generation of related lattice paths to make our bijection more efficient for exhaustive generation. Thanks @fchapoton for suggesting adapting my original implementation to Sagemath. By the way, I have not checked whether the documentation shows up correctly in the references, because ``sage --docbuild reference html`` fails with the error ``` Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/home/fwjmath/svn/sage/src/sage_docbuild/__main__.py", line 545, in <module> sys.exit(main()) ^^^^^^ File "/home/fwjmath/svn/sage/src/sage_docbuild/__main__.py", line 540, in main build = getattr(builder, typ) ^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'ReferenceBuilder' object has no attribute 'html' ``` ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [X] The title is concise and informative. - [X] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [X] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. URL: sagemath#41416 Reported by: fwjmath Reviewer(s): Frédéric Chapoton, fwjmath
sagemathgh-41416: Implementation of blossoming trees for their bijection with Tamari intervals <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> This is an implementation of the bijection between blossoming trees and Tamari intervals in the following paper: Wenjie Fang, Éric Fusy, Philippe Nadeau, "Tamari intervals and blossoming trees". Combinatorial Theory, Volume 5, Issue 1. doi `10.5070/C65165015`. It is the implementation mentioned in the paper, but with additional "Sage-compliant" comments and tests, along with some small restructuring. More precisely, we provide four new classes. - `TamariBlossomingTree`: main class that implements blossoming trees and their bijection with Tamari intervals, along with plots and conversion to other Sage objects. - `TamariBlossomingTreeFactory`: a linear-time random generator of Tamari blossoming tree. - `SynchronizedBlossomingTreeFactory`: a linear-time random generator of synchronized blossoming trees, which are in bijection with synchronized Tamari intervals. - `ModernBlossomingTreeFactory`: a linear-time random generator of modern blossoming trees, which are in bijection with modern Tamari intervals. This implementation will allow users to explore Tamari intervals more easily with our bijection. Most notably, these classes now enables an efficient random generation of large (general, synchronized or modern) Tamari intervals, linear in the size of generated objects. Such generator exists for general Tamari intervals in TamariIntervalPosets, but it goes through triangulations, thus is much slower and more complicated. Here is a comparison of timing: ``` sage: TIP = TamariIntervalPosets(1000) sage: %time tip = TIP.random_element() CPU times: user 5.13 s, sys: 15 ms, total: 5.14 s Wall time: 5.14 s sage: TBTF = TamariBlossomingTreeFactory(1000) sage: %time B = TBTF.random_element() CPU times: user 118 ms, sys: 2.99 ms, total: 121 ms Wall time: 120 ms ``` The random generation of synchronized and modern Tamari intervals is new. As I am not familiar with the internal structure of Sagemath, these classes were written more like an external module. Advises and help for a restructuring are welcomed. Notably, I did not implement a class for the set of blossoming trees like those for other combinatorial objects. The reason is two-fold: 1. I am not familiar with the internal working of Sagemath, notably metaclasses, Parent and Element, and the documentation seems to be quite complicated. 2. I do not intend to provide exhaustive generation, which is less efficient (not linear but quadratic in object size per object). I may have changed a bit the idea for the second point, as when I look at the exhaustive generation code in the iterator of ``TamariIntervalPosets_size``, its complexity is not clear. It is not linear, but not clear whether quadratic per object. There is a possibility that the class ``IntegerListsLex`` may provide an efficient exhaustive generation of related lattice paths to make our bijection more efficient for exhaustive generation. Thanks @fchapoton for suggesting adapting my original implementation to Sagemath. By the way, I have not checked whether the documentation shows up correctly in the references, because ``sage --docbuild reference html`` fails with the error ``` Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/home/fwjmath/svn/sage/src/sage_docbuild/__main__.py", line 545, in <module> sys.exit(main()) ^^^^^^ File "/home/fwjmath/svn/sage/src/sage_docbuild/__main__.py", line 540, in main build = getattr(builder, typ) ^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'ReferenceBuilder' object has no attribute 'html' ``` ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [X] The title is concise and informative. - [X] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [X] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. URL: sagemath#41416 Reported by: fwjmath Reviewer(s): Frédéric Chapoton, fwjmath
This is an implementation of the bijection between blossoming trees and Tamari intervals in the following paper:
Wenjie Fang, Éric Fusy, Philippe Nadeau, "Tamari intervals and blossoming trees". Combinatorial Theory, Volume 5, Issue 1. doi
10.5070/C65165015.It is the implementation mentioned in the paper, but with additional "Sage-compliant" comments and tests, along with some small restructuring.
More precisely, we provide four new classes.
TamariBlossomingTree: main class that implements blossoming trees and their bijection with Tamari intervals, along with plots and conversion to other Sage objects.TamariBlossomingTreeFactory: a linear-time random generator of Tamari blossoming tree.SynchronizedBlossomingTreeFactory: a linear-time random generator of synchronized blossoming trees, which are in bijection with synchronized Tamari intervals.ModernBlossomingTreeFactory: a linear-time random generator of modern blossoming trees, which are in bijection with modern Tamari intervals.This implementation will allow users to explore Tamari intervals more easily with our bijection. Most notably, these classes now enables an efficient random generation of large (general, synchronized or modern) Tamari intervals, linear in the size of generated objects. Such generator exists for general Tamari intervals in TamariIntervalPosets, but it goes through triangulations, thus is much slower and more complicated. Here is a comparison of timing:
The random generation of synchronized and modern Tamari intervals is new.
As I am not familiar with the internal structure of Sagemath, these classes were written more like an external module. Advises and help for a restructuring are welcomed. Notably, I did not implement a class for the set of blossoming trees like those for other combinatorial objects. The reason is two-fold:
I may have changed a bit the idea for the second point, as when I look at the exhaustive generation code in the iterator of
TamariIntervalPosets_size, its complexity is not clear. It is not linear, but not clear whether quadratic per object. There is a possibility that the classIntegerListsLexmay provide an efficient exhaustive generation of related lattice paths to make our bijection more efficient for exhaustive generation.Thanks @fchapoton for suggesting adapting my original implementation to Sagemath.
By the way, I have not checked whether the documentation shows up correctly in the references, because
sage --docbuild reference htmlfails with the error📝 Checklist