-
-
Notifications
You must be signed in to change notification settings - Fork 508
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
standardize the interface to TransitiveIdeal and friends #6637
Comments
comment:1
Here are some discussions related to this ticket:
|
This comment has been minimized.
This comment has been minimized.
comment:4
In a tentative to find good choices for name and so on, here is how I see this.
Now
We are interested in the subset S of X that can be generated from the S = {y : x = x1 R x2 R x3 R ... R xn = y and x in Moreover, we are interested in the enumeration of S itself and we consider depth-first and breadth-first as different and both usefull. Such a relation G = (X,R) can be seen as a directed graph. I think this remark is useful as it may provide some vocabulary. Indeed the set S is the connected components of the generators in the digraph G. I see some different cases : 1. We do not know anything more about the relation. We need to save in memory all the 2. The directed graph S is a forest with given 3. The relation is graded. By graded here I mean what I thought if (x1 R x2 R ... R xn) and (y1 R y2 R ... R ym) and (xn=ym), then (n=m). The relation is graded if all path from the origin to an element have the same length. In this case, we only need to save in memory the current level. 4. The relation is symmetric. If the relation is symmetric, we only need to keep in memory the last two level of depth. This is what I needed and coded this week. And this is why I started to look more carefully at the code in That is it for now! |
comment:5
I totally agree with the analysis! I don't know yet what would be the best name for the argument provided by the user to describe the relation. Behind the scene we are definitely modelling relation. But what the user provide is not the relation but a function that computes the (out) neighbors for this relation. If at the end of the day we choose "TransitiveClosure" as name for the main entry point, then "neighbors" would be consistent. If we go for "RecursiveSet" (or RecursiveEnumeratedSet or variant thereof) then "operators" would be consistent. Cheers, |
comment:6
I think Possibilities for successor keyword :
Possibilities for generators keyword :
|
comment:7
I like RecursiveSet. Maybe RecursiveEnumeratedSet is more related to what we do but is also longer. Some links: |
comment:8
For the above 4 cases, I would suggest arguments like the following :
|
Attachment: trac_6637_recursive_set-sl.patch.gz |
comment:9
I just added a patch. It implements the It is not ready for review, but comments are welcome to help me continue this work. Actually, my questions are :
|
Dependencies: #14052 |
Commit: |
New commits:
|
Branch: u/slabbe/6637 |
Branch pushed to git repo; I updated commit sha1. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:46
Also FTR, I liked your usage of the metaclass (and I can't check the doc until I get my docbuilder to actually work again... |
comment:47
If you agree Travis, I will try to put the metaclass use back in. Also, maybe Florent can say a word about it. He coached me on how to implement it. |
comment:48
Replying to @tscrim:
Ok, now I see what you mean. When the class is
I also saw in the doc that: "For a Cython class (not cdef since they doesn’t allows metaclasses)" |
comment:51
Looking at your commit, I don't see any benefit in using the metaclass. However I'm not opposed to the renaming, so I've just pushed that. |
comment:52
Replying to @tscrim:
Yes exactly. I needed to play with it to understand what you meant.
Well, the renaming was just an easy way for me to check that
So, we go with commit dd72bfc instead of 3191690 ? |
comment:53
If that's okay with you. |
comment:54
Replying to @tscrim:
The more I think about it, the less I like it. I think dd72bfc can be confusing for someone looking at the file for the first time. Until that person looks at the file sage/sets/all.py he will not understand how the If so, I do not know what should we do then (git question). Should we update the commit field? Should we reset the HEAD of the branch? Should we create a new branch pointing to the commit? |
comment:55
Good point. What we'll do is create a new branch which just points to the old commit (afterwards we can delete our old branches). Do you want to do this or should I? |
comment:56
Let me try. |
Changed branch from public/ticket/6637 to public/ticket/6637a |
comment:57
The following did the trick:
|
comment:58
Then let's get this in. Thanks Sébastien. |
comment:59
Thanks for the review and cython improvements! |
Changed branch from public/ticket/6637a to |
Changed commit from |
where
structure
takes values in the set[None, 'forest', 'graded', 'symmetric']
andenumeration
takes values in the set[None, 'depth', 'breadth', 'naive']
.Deprecate
TransitiveIdeal
,TransitiveIdealGraded
andSearchForest
as entry point.TransitiveIdeal(succ, seeds)
keeps the same behavior as before and is now the same asRecursivelyEnumeratedSet(seeds, succ, structure=None, enumeration='naive')
.TransitiveIdealGraded(succ, seeds, max_depth)
keeps the same behavior as before and is now the same asRecursivelyEnumeratedSet(seeds, succ, structure=None, enumeration='breadth', max_depth=max_depth)
.Remarks:
A. For now the code of
SearchForest
is still insage/combinat/backtrack.py
. It should be moved insage/sets/recursively_enumerated_set.pyx
. See #16351.B.
TransitiveIdeal
andTransitiveIealGraded
are used in the code ofsage/combinat
,sage/categories
andsage/groups
at least. These should be updated to useRecursivelyEnumeratedSet
for speed improvements and also to avoid issues explained in C below. See #16352.C. Note that there were some issues with
TransitiveIdeal
andTransitiveIdealGraded
, namely:TransitiveIdeal
is claimed to be depth first search in the top level filebacktrack.py
, but in fact, it is neither breadth first neither depth first. It is what I call a naive search.TransitiveIdealGraded
is indeed breadth first as claimed but it does not make use of the graded hypothesis at all because it remembers every generated elements.See my status report at SageDays57 for more info.
Depends on #14052
CC: @sagetrac-sage-combinat @hivert
Component: combinatorics
Keywords: backtrack, enumerated set, transitive closure, days57
Author: Sébastien Labbé
Branch:
3191690
Reviewer: Travis Scrimshaw
Issue created by migration from https://trac.sagemath.org/ticket/6637
The text was updated successfully, but these errors were encountered: