-
-
Notifications
You must be signed in to change notification settings - Fork 478
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
Computing Partitions(...).cardinality()
with set min_length=
can be significantly improved by complementation and using max_length=
instead
#38897
Comments
Permutations(...).cardinality()
with set min_length=
can be significantly improved by complementation and using max_length=
insteadPartitions(...).cardinality()
with set min_length=
can be significantly improved by complementation and using max_length=
instead
If I made no mistake, We do have a dedicated cardinality function for partitions of given length, though.
|
PS: I appreciate your reports a lot! |
It's unfortunate that On a related note, I think Sage should issue a warning (at verbosity = 0 or 1 level) whenever it knowingly uses a non-efficient algorithm (such as enumeration via generation). I use to believe that whenever a certain functionality exists it implements the best available algorithm. Knowing when this is not the case will greatly help to find bottlenecks and avoid using slow algorithms when performance is an issue. |
Any combinations of any subset of
I think verbosity is hard to maintain. However, I use
|
Problem Description
Check this out:
Proposed Solution
As the code example shows, computing cardinality with
min_length=
appears to be much slower than that withmax_length=
. Hence, it'd be beneficial to convert one into the other by complementation (in the set of all partitions) as illustrated by the example.Alternatives Considered
I believe the cardinalities in both cases can be computed via dynamic programming, but I did not check if Sage uses it wisely and why in one case it's much slower than in the other.
Additional Information
No response
Is there an existing issue for this?
The text was updated successfully, but these errors were encountered: