id summary reporter owner description type status priority milestone component resolution keywords cc merged author reviewer upstream work_issues branch commit dependencies stopgaps
29262 Combination unranking new algorithm gh-agenitrini "I propose to implement a new algorithm for the unranking of combinations in the lexicographic order, cf. sage.combinat.combination algorithm from_rank.
The actual implementation is related to McCaffrey's blog.
In a recent paper I have written, cf. https://hal.archives-ouvertes.fr/hal-02462764v1
I compare this method to other from the literature and a new one I have developed with my co-authors. The paper is actually under review.
If possible I would like to commit this new implementation. My function has the same signature from the previous one.
Regards.
Antoine
Example :
Actual implementation (on my laptop : core i7 32GiB Ubuntu Linux)
{{{
sage: n = 100
sage: k = 50
sage: set_random_seed(12345678987654321)
sage: r = randint(0, binomial(n,k)-1)
sage: %time A = combination.from_rank(r,n,k)
CPU times: user 1.55 ms, sys: 0 ns, total: 1.55 ms
Wall time: 1.06 ms
## With my algorithm
## (in the commit the function replace from_rank(.,.,.))
sage: %time B = unrank_combi_direct(r, n, k)
CPU times: user 297 µs, sys: 53 µs, total: 350 µs
Wall time: 296 µs
## Finally
sage: A==B
True
## A second example with greater values
sage: n = 10000
sage: k = 5000
sage: set_random_seed(12345678987654321)
sage: r = randint(0, binomial(n,k)-1)
sage: %time A = combination.from_rank(r,n,k)
CPU times: user 2.9 s, sys: 9.69 ms, total: 2.91 s
Wall time: 2.85 s
## With my algorithm (in the git branch I obviously reused the function name from_rank)
sage: %time B = unrank_combi_direct(r, n, k)
CPU times: user 22.4 ms, sys: 4.45 ms, total: 26.9 ms
Wall time: 21 ms
## Finally
sage: A==B
True
}}}
" enhancement closed major sage-9.1 combinatorics fixed combination unranking Antoine Genitrini Travis Scrimshaw N/A 845c21e3e4c1c2890aaa7cc06e8810d39a756ba0 845c21e3e4c1c2890aaa7cc06e8810d39a756ba0